teleren/devto huggingface dataset:
What are loops?
Tags: beginners, tutorial, learning, devtips
Published: 2019-05-31 09:52:45

---
title: What are loops?
published: true
tags: beginners, tutorial, learning, devtips
canonical_url: https://www.codetips.co.uk/beginner/what-are-loops/
---

> Perform a set task, or tasks, until a given condition is met.

 ![What are loops?](https://images.unsplash.com/photo-1465779171454-aa85ccf23be6?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjExNzczfQ)

If you've been following the articles from the beginning, you'll remember in the [variables](https://www.codetips.co.uk/beginner/what-is-a-variable/) article we were sending a letter to a number of people.

We made the process a lot easier by creating a variable at the top of our program, which would control who our letter was addressed to. The positives of this technique were discussed in that article, but what we didn't discuss were the negatives.

What if you decided to extend this letter to your friends and colleagues, totalling hundreds of people?

Using only the variable technique you'd have to repeat the process, of updating the variable and running the program, hundreds of times. If you found any mistakes, you'd have to do it all over again. This is far better than keeping hundreds of copies of the same letter, as we discussed in the [variables](https://codetips.co.uk/beginner/what-is-a-variable/) article, but isn't there an even easier way?

Yes. Loops. Below is a reminder of the code we were running in the [variables](https://codetips.co.uk/beginner/what-is-a-variable/) article.

<!--kg-card-begin: code-->
```
name = cfixe18918zt9o7g4nxl

Dear $name

.... body of text goes here that has a reference to the persons name 10 times ....
```
<!--kg-card-end: code-->

Let's make the process a bit easier, conceptually, by reducing the number of people we want to send this letter to, to 10 people and to reinstate their names instead of a random sequence of letters and numbers.

So let's define our list of people:

<!--kg-card-begin: code-->
```
recipients = James, John, Jimmy, Jane, Jake, Jemma, Joanne, Juliet, Jessica, Josh
```
<!--kg-card-end: code-->

Next, we can create a loop to go through this list one by one, generate the letter and print it like before:

<!--kg-card-begin: code-->
```
for $name in recipients {
    Dear $name

    .... body of letter ....
}
```
<!--kg-card-end: code-->

In this scenario we "loop" through the list, one by one, and we set our variable (`$name`) equal to the current person (first James, then John etc...) and we construct our letter using the `$name` variable, like we did before, but that variable will now be updated for each person and a letter generated for them.

Using this technique you only have to run your program once. If you find a mistake in your letter, you fix it once and you run the program again which will generate ALL of the letters for every person in your recipients' list.

You've now cut down on all of that repetition, making it much easier to maintain.
A Call For Talented Game Developers - TOMOCHAIN'S DAPPATHON
Tags: blockchain, gamedev, contest, tomochain
Published: 2019-03-21 07:19:52

---
title: A Call For Talented Game Developers - TOMOCHAIN'S DAPPATHON
published: true
description: Join us an earn yourself a chance to win a share of $20,000
tags: #blockchain #gamedev #contest #TomoChain
---
![alt text] (https://thepracticaldev.s3.amazonaws.com/i/jiwz267a6srcr7hin25s.png)
In 2018, the dapps market generated 6.7 billion in revenue. Over 30% of them were gaming dapps (source: dapp.com)

TomoChain is highly supportive of developers joining the blockchain movement, and introducing them to dapp development.

We are hosting our first international game focused dappathon, where anyone, from anywhere in the world can join.

##**What you should know about this competition:**

* Win a share of **20,000 USD** in cash prizes
* Have your game judged by gaming and blockchain industry leaders
* Be amongst the first to build a game on the TomoChain blockchain
* This contest is international, you can enter from anywhere in the world
* Three rounds of submissions, the first submission deadline is 15th April

##**Competition format**
The goal is simple: building a working game on the Tomochain Blockchain.

There will be three 3 rounds of submissions, applications are open from today and the deadline is one month away on April 15th. The second round runs from 15th of April to 15th of May, and the 3rd round is 17th of May to 15th of June.

Winners and prizes will be awarded for each round, and all winners will be invited to a showcase event in July.

![alt text](https://thepracticaldev.s3.amazonaws.com/i/4dndiz7ch9livxn89yn3.png)

You can visit the official competition page [here](https://tomochain.com/tomochain-game-contest/) for details, weekly updates, and to [register your interest](https://tomochain.com/tomochain-game-contest/).

##**Are you a Developer?**
Do you have questions about this competition?

Join our game contest channel on [Discord](https://discordapp.com/invite/2S6GdpJ) (#gamecontest), our team will support you in the next steps of building your first blockchain game

Interested in this event?
For media, sponsorship or other enquiries, you can reach me here:
Telegram: @jakepang
Email: [jake@tomochain.com](jake@tomochain.com)

*Prizes will be awarded in TOMO, as per the USD equivalent.
Debug React Native Android or iOS App Using Console log
Tags: reactnative, android, react, javascript
Published: 2019-03-21 04:34:58

---
title: Debug React Native Android or iOS App Using Console log
published: true
description: Debug React Native Android or iOS App Using Console log
tags: #reactnative #android #react #js
---

Post link : <a href="https://www.skptricks.com/2019/03/debug-react-native-android-or-ios-app.html" > Debug React Native Android or iOS App Using Console log </a>

This tutorial explains how to perform debugging using console.log() in react native application. Console.log() is a inbuilt and predefined function present in javascript. This function is created for both Android and iOS applications and used to maintain and debug errors in apps on run time. Console.log() helps us to detect errors in our code.

<img src="https://4.bp.blogspot.com/-GdZ7YwQPL_o/XJMRaqHkdfI/AAAAAAAACik/yi8NdDJL97MHLh_DfnNLRyZFoBCq76b8QCLcBGAs/s400/debug.png" />


In this example we are using console.log statement inside the function and that function mapped to the button as a click listener. When user perform click event on the button, then it will print console.log statement message in the console. Lets use the below complete source code for logging a message in console, that ultimately help you to debug the code.
[astuce] Utiliser les champs personnalisés par leurs noms simplement
Tags: tips, joomla, customfields, byname
Published: 2019-07-28 22:13:23

---
title: [astuce] Utiliser les champs personnalisés par leurs noms simplement
published: true
tags: tips,joomla,customfields,byname
canonical_url: 
---

Ami(e)s Joomlers,

Vous allez me dire qu'il y aura des conflits de noms si on utilise cette méthode et que les noms des champs personnalisés ne sont pas forcéments uniques. Mais si on s'y prend bien et qu'on utilise ce petit bout de code. On s'en sort beaucoup plus simplement qu'en essayant de vouloir retenir par coeur, même en ayant noté sur un document les id des différents champs personnalisés. Voici le bout de code:

<samp><span>$champs_par_nom = \Joomla\Utilities\ArrayHelper::pivot($liste_de_champs, 'name');</span></samp>

La partie $liste\_de\_champs correspond à la variable qui contient déjà les champs personnalisés de votre élément. Dans les cas communs (com\_content.article, com\_user.user, etc...)

Voilà, c'est tout pour cette fois

A tantôt les joomlers de l'extrême!
How to find open source projects as a new developer?
Tags: beginners, javascript, help, discuss
Published: 2019-03-21 00:25:10

Maybe I'm missing something, but it seems hard to find meaningful open-source projects that have something a new developer could tackle. Often looking up labels like "good-first-issue" on GitHub give an abundance of random tasks seemingly only made for things like Hacktoberfest.  

__So, anyone have any tips?__
How to Generate Contents of a New CSV Column Using JavaScript
Tags: javascript, sql
Published: 2019-03-21 00:09:15

---
title: How to Generate Contents of a New CSV Column Using JavaScript
published: true
description: How to Generate Contents of a New CSV Column Using JavaScript
tags: JavaScript, SQL
---

I had the need to populate data in a database table after a migration to update the production database schema. I thought of different means to achieve this. Manually populating the rows with data was not an option because the database contains thousands of records. 

I considered two approaches:

- Using a regex
- Writing code to achieve it

After a while, I settled for the second approach because of access restrictions on running the regex.

Here is how I achieved it:

- I exported the data, 
- Wrote the JavaScript code to generate the content of the new column
- Created a temporary table and imported the newly generated CSV data
- Imported the data to the actual table using an inner join

A sample data

```
"id", "label"
1,"Name"
2,"Age"
3,"Gender"
4,"Date of birth"
```

I assigned the data to a variable

```
var data = `"id", "label"
1, "Name"
2,"Age"
3,"Gender"
4,"Date of birth"`
```

Initially, I achieved the result using a nested `for loop`. Considering performance, I eventually refactored the code to use only one `for loop` 


The JavaScript code to generate the content of the new column

```
const dataAsArray = data.split('\n');

for(let datum of dataAsArray) {
  let currentRow = datum.split(',');
  let newColumn = currentRow[1].trim().toLowerCase().split(' ').join('_');
  currentRow += `,${newColumn}`;

  console.log(currentRow);   
}
```

The code above generated the data I needed. Which is, the content of the second column without spaces and separated by an underscore. I saved the result in a CSV file.

Then, I created a temporary table with the columns `"id","label","code"` and loaded the data using the command 

```
LOAD DATA LOCAL INFILE '/Users/Chiamaka/Desktop/query_result.csv'
INTO TABLE `testtable` 
CHARACTER SET 'utf8' FIELDS ESCAPED BY '\\' TERMINATED BY ',' ENCLOSED BY '"' LINES 
TERMINATED BY '\n'
IGNORE 1 LINES
```


To update the actual table with the newly generated data using backticks to ensure that reserved names are accepted as strings. 


```
UPDATE testtable tt
inner join actualtable actb on (tt.id = actb.id)
set actb.code = tt.`code`
where tt.id = actb.id;
```


This yielded the desired result

```
"id","label","code"
1,"Name","name"
2,"Age","age"
3,"Gender","gender"
4,"Date of birth","date_of_birth"
```
How to use Pug on Netlify?
Tags: netlify, pug, jade
Published: 2019-04-19 07:45:28

---
title: How to use Pug on Netlify?
published: true
tags: 
 - Netlify
 - Pug
 - Jade
canonical_url: https://peterthaleikis.com/posts/how-to-use-pug-on-netlify/
---

Netlify is a powerful, yet easy to use platform to host your website. Combine this with pug and it gives you a great starting point to build and host your own website.

## What is Pug?

Pug or PugJS, previously called Jade, is a JavaScript template engine. It assembles and combines your final HTML from different files and gives you a much cleaner development experience than plain HTML.

## How to configure pug on Netlify?

Netlify allows you to use a number of tools when building your site. Pug isn't support out of the box but can be added and configured easily with npm. The following command installs pug, runs the compile of all pug files in the folder `pug` and saves the result in the folder `public`:

```
npm install pug-cli; node node_modules/pug-cli/index.js pug/ --out ./public
```

You will have to adjust this command to your needs to match the folders and add it to the "Build command" on your Netlify site:

![Netlify configuration panel](https://peterthaleikis.com/static/images/How-to-use-Pug-on-Netlify/screenshot.png)

This approach should work for any library which can be installed npm and run directly on the command line. All it requires is to find the correct file to execute.
JavaScript notes I
Tags: javascript
Published: 2019-10-03 03:22:10

---
title: JavaScript notes I
published: true
date: 2019-03-21 00:00:00 UTC
tags: javascript
canonical_url: 
---

Let’s review some JavaScript features in a hurry!

## Iterables

Objects that can be used in `for..of` are called iterable.

Iterables must implement the method named `Symbol.iterator`. The result of `obj[Symbol.iterator]` is called an iterator. An iterator must have the method named `next()` that returns an object `{done: Boolean, value:
any}`, the value is the next value. The `Symbol.iterator` method is called automatically by `for..of`, but we also can do it directly.

`Array.from(obj[, mapFn, thisArg])` makes a real Array of an iterable or array-like obj, and we can then use array methods on it. The optional arguments mapFn and thisArg allow us to apply a function to each item.

## Destructuring

Map an object or array to variables.

Object syntax:

```javascript
let {prop : varName = default, ...} = object
```

Array syntax:

```javascript
let [item1 = default, item2, ...rest] = array
```

The first item goes to `item1`; the second goes into `item2`, all the rest makes the array rest.

## Map and Set

`Map`, is a collection of keyed values, it allows objects to be keys and provides a `size` property.

`Set`, is a collection of unique values, does not allow to reorder elements.

The following allow garbage-collection: There ara also `WeakMap` and `WeakSet` which provide garbage collection, I need to research more about these. Maybe the next post.
Upgrade to PHP 7.3 with Homebrew on Mac
Tags: php
Published: 2019-04-01 06:52:25

---
title: Upgrade to PHP 7.3 with Homebrew on Mac
published: true
tags: php
canonical_url: https://stitcher.io/blog/php-73-upgrade-mac
---

## Upgrading with Homebrew

Start by making sure brew is up-to-date:

```
brew update

```

Next, upgrade PHP:

```
brew upgrade php

```

Check the current version by running `php -v`:

```
php -v

# PHP 7.3.3 (cli) (built: Mar 8 2019 16:42:07) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.3.3, Copyright (c) 1999-2018, by Zend Technologies

```

Continue reading on [https://stitcher.io/blog/php-73-upgrade-mac](https://stitcher.io/blog/php-73-upgrade-mac)
What does a dev's personal website need to include?
Tags: discuss
Published: 2019-03-20 23:54:47

---
title: What does a dev's personal website need to include? 
published: true
description: 
tags: #discuss
---

I have a background in graphic design, but have semi-recently (over the past ~3 years) career shifted to a point where my current title is Front-end Dev & UI Designer.  

However, my personal website hasn't quite caught up with that change - funny how it doesn't update itself, right? It's long overdue for an update and I really want it to reflect my current skillset. I'm not looking to job hunt at the moment (if that affects your recommendations), but I do use my site a fair bit for networking and occasional freelance work. In the past, I used my site as a digital portfolio of stuff I designed + screenshots / gifs of static sites I coded on my own. However, now I'm doing web app development in React, building and maintaining a component library, sharing a codebase with a team of other devs, etc. - basically, not stuff I can screenshot and put in a gallery-view portfolio the same way I used to. 

I've done a bit of poking around on other folks' sites, but I'm curious: what content do you think is important to include on a front-end dev's personal site, and how do you present / communicate the work you've done?
Reducing spaghetti code on jquery application using model idea
Tags: javascript, jquery, mvc, framework
Published: 2019-03-20 23:19:24

---
title: Reducing spaghetti code on jquery application using model idea 
published: true
description: Using a jquery model to reduce complex code when dealing with object querys
tags: javascript, jquery, mvc, framework
---

Using jquery can be tricky sometimes, usually when code don't follow any concern separation. These cases are often related to a poor comprehension of javascript promises and callbacks.And is not rare to see a script file with tons of ajax calls passing the same parameters changing only the url.

As a possible workaround I would suggest making separated classes that holds ajax calls using M from MVC frameworks,  js models.

So lets start by encapsulating the ajax calls. I end up with this script, but you can change for something that works for you.


```javascript
class Api {
   static request(url, promise, formData, method) {
    if (promise)
      return $.ajax({
        url: url,
        dataType: 'json',
        method: method,
        data: formData
      })
    else
      $.ajax({
        url: url,
        dataType: 'json',
        method: 'POST',
        data: formData
      })
    }
}
```

Next, lets do some template to render ours items.

```javascript
var PostTemplates = {
    listItem:'<li><span>%(id)i</span><pre>%(title)s</pre></li>'
}

```

Using a model idea lets create a class that centralize ajax calls related to that object

```javascript
class Post {
    constructor(postInfo) {
        this.id = postInfo.id;
        this.title = postInfo.title;
    }

    static getList(){
    	const url = 'https://jsonplaceholder.typicode.com/posts';
    	let request = Api.request(url, true, {}, 'GET');
        return $.when(request); 
    }
    
    insert(){
   		 //...
    }
    
    remove(){
       //...
    }
    
    render(item){
        return sprintf(PostTemplates.listItem, this)
    }
}

```

And for last lets use the model by calling getList function

```javascript
Post.getList().then(function(posts){
    let rootElement = $("#banner-message");
    rootElement.empty();
    $.each(posts, function(index, postInfo){
         rootElement.append(new Post(postInfo).render());
    })
})
```
Building Something Fun - NSFW Detector
Tags: machinelearning, ai, kearas
Published: 2019-03-20 19:07:16

---
title: Building Something Fun - NSFW Detector
published: true
description: A story on making Machine Learning fun
tags: MachineLearning, AI, Kearas
---
![NSFW Model](https://thepracticaldev.s3.amazonaws.com/i/6grvorg8wen3ksu7x7a4.png)

Coming up with useful applications of Machine Learning can be an exciting and complicated problem.  Sure, I can do the same linear regression problem everyone does, with the same data, but if I'm not excited about what I'm creating, how can I expect anyone else to be interested?

Then I got the idea, what about NSFW detection for client and server!  This could cut down on work for teams, as well as provide a high-profile project for others.

Since creating the NSFW model, throngs of people have tweeted, and shown up to add pull requests.  I'll even be Keynoting in Italy, to review the project. 

One common request, a lot of people keep asking for the training data.  I'm both entertained and engaged in all the interactions in this project.  Never would I have assumed so many people would help me learn, challenge me to grow, and take interest in my project.

Because of this, I've documented the entire project here: https://medium.freecodecamp.org/how-to-set-up-nsfw-content-detection-with-machine-learning-229a9725829c

And released a JavaScript library here: https://shift.infinite.red/avoid-nightmares-nsfw-js-ab7b176978b1

### Make something awesome
So next time you're handed the same old projects and the dusty roadmap of projects you should follow, just reject it; spice it up.   Build something fun, crazy, and interesting.  You'll be surprised how rewarding it can be.
Hi, I'm Miracle Anyanwu (PolymathWhiz)
Tags: introductions
Published: 2019-03-20 22:37:13

---
title: Hi, I'm Miracle Anyanwu (PolymathWhiz)
published: true
description: Hi, I'm Miracle Anyanwu (PolymathWhiz)
tags: Introductions
---

You can find me on Twitter and GitHub, Instagram and the web as @polymathwhiz.

I love JavaScript but I've played with other exciting languages.

I'm so happy to meet you all!
What's your DJ name?
Tags: fun, devhumor, discuss, watercooler
Published: 2019-03-20 22:09:48

---
title: What's your DJ name?
published: true
description: Just having some fun building your DJ name
tags: fun,devhumor,discuss,watercooler
cover_image: https://thepracticaldev.s3.amazonaws.com/i/bar2l0tbbqvhu1u75hnz.jpeg
---

Just a fun thread I'm putting out here while on vacation.

{%twitter 1108488529926127620 %}

Your DJ name is **DJ** plus the **last method or function you used/wrote**.

{%twitter 1108056758692528128 %}

They call me **DJ describe**

Feel free to reply here and/or to the [Twitter thread](https://twitter.com/nickytonline/status/1108056758692528128).
Building a file sharing app with Node.js, Vue.js, Cloudinary, and MySQL - Part 2
Tags: node, vue, cloudinary, mysql
Published: 2019-03-20 21:29:58

---
title: Building a file sharing app with Node.js, Vue.js, Cloudinary, and MySQL - Part 2
published: true
description: Building a file sharing app with Node.js, Vue.js, Cloudinary, and MySQL - Part 2
tags: Node.js, Vue.js, Cloudinary, MySQL
---

In this tutorial, we will be creating an application that lets an individual upload an image. After uploading, the system generates a unique downloadable link that automatically disappears after 3 hours. 

# Getting Started

We will set up our Node.js API using [NPM](https://www.npmjs.com), and then install some packages that will enable us to complete some tasks without having to rebuild the wheels.

## Project Structure

Let's setup our Node app 
     ![alt text](https://thepracticaldev.s3.amazonaws.com/i/kmfe1l0qf8dawgu0nruo.png "Generating our node app")

## Application Folder
 
This is how our application folder will be like
 ![alt text]    (https://thepracticaldev.s3.amazonaws.com/i/vt8d5osms0qtrs1q2ded.png "Current folder structure")


## Application Packages 

You should have created the project folders at this point to house all the source code. This app depends on a couple of packages and we will use npm to install them. Navigate to the project directory you just created and you should have seen that the `npm init` command automagically created a package.json file with the content below.

![alt text]    (https://thepracticaldev.s3.amazonaws.com/i/wupkchdlf4pp442el0hm.png)

## Installing addition dependencies

We need to install the following dependencies to make our work easy to implement

1. `dotenv` - Loads environment variables from .env for nodejs projects.

2. `express` - Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.

3. `cloudinary` - Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline. 

4. `cors` - CORS is a node.js package for providing a Connect/Express middleware that can be used to enable CORS with various options.

5. `multer` - Multer is a node.js middleware for handling multipart/form-data, which is primarily used for uploading files. It is written on top of busboy for maximum efficiency.

6. `mysql2` - fast node-mysql compatible mysql driver for node.js

7. `nodemon` - Monitor for any changes in your node.js application and automatically restart the server - perfect for development

8. `request` - Simplified HTTP request client.

Now let's run the `npm install` command or `npm i` for short

 ![alt text](https://thepracticaldev.s3.amazonaws.com/i/0d5yml47b3md0rv1wq7n.png)

## Conclusion 

In this article, we went through generating our node app and downloading the necessary dependencies we need in our app. In the upcoming series, we will be putting the downloaded dependencies to good use and writing our custom functions. We will also be designing our database to handle our data.

See you in the next article!