teleren/devto huggingface dataset:
Understanding setImmediate()
Tags: node
Published: 2018-08-20 05:37:32

---
title: Understanding setImmediate()
published: true
tags: node
canonical_url: https://flaviocopes.com/node-setimmediate/
---

When you want to execute some piece of code asynchronously, but as soon as possible, one option is to use the `setImmediate()` function provided by Node.js:

```js
setImmediate(() => {
  //run something
})
```

Any function passed as the setImmediate() argument is a callback that's executed in the next iteration of the event loop.

How is `setImmediate()` different from `setTimeout(() => {}, 0)` (passing a 0ms timeout), and from `process.nextTick()`?

A function passed to `process.nextTick()` is going to be executed on the current iteration of the event loop, after the current operation ends. This means it will always execute before `setTimeout` and `setImmediate`.

A `setTimeout()` callback with a 0ms delay is very similar to `setImmediate()`. The execution order will depend on various factors, but they will be both run in the next iteration of the event loop.
What would you put in a Software Engineering Basics Workshop?
Tags: discuss, tutorial
Published: 2018-08-18 12:50:47

---
title: What would you put in a Software Engineering Basics Workshop?
published: true
description: Github
tags: discuss, tutorial
---

For a couple of years, I have been teaching a workshop/bootcamp for new software engineering students in a few courses. This is the material we try to cover on day 1, just to make sure everyone is up to speed.

This is the outline of materials and activities. Click links to see material.

What do you think? Anything to add/tweak/change?


# Software Engineering Basics

In this workshop, you will setup a local (or virtual environment) consisting of several tools, programming languages, and libraries, to support software engineering work.  You will also practice workflows needed to be productive in software engineering.

The primary goal of this workshop is for you have to have installed and learned a set of relevant tools (and processes in your head) for software development.

1. [Setup](https://github.com/chrisparnin/EngineeringBasics/blob/master/Setup.md#setup).  
   Getting started. Get some tools on your machine. 
   - [ ] Practice: Installed package manager for os.
   - [ ] Installed git, java, python2, nodejs
   - [ ] Optional: Make Windows Awesome
2. [Shells](https://github.com/chrisparnin/EngineeringBasics/blob/master/Shells.md#shells).  
   Basic overview of unix shells, shell programming, and windows shell tips.
   - [ ] Practice: Run commands to analyze data
   - [ ] Setup env variable.
   - [ ] Optional: Write a shell script.
3. [Version Control with Git](https://github.com/chrisparnin/EngineeringBasics/blob/master/Git.md#git).  
   Basic overview of git. Two interactive tutorials for learning commands.
   - [ ] Complete basic Git tutorial
   - [ ] Complete 4 levels in *Introduction to Git Commits*
   - [ ] Practice: Creating a repo
   - [ ] Optional: Solve all git branching levels
4. [Markdown and IDES](https://github.com/chrisparnin/EngineeringBasics/blob/master/MarkdownEditors.md#markdown).  
   Overview of markdown basics, lists, code, tables. Recommended editors for code. Creating Github Pages.
   - [ ] Install IDE(s)/Editors
   - [ ] Practice: Update markdown in README.md
   - [ ] Optional: Create a GitHub Pages (gh-pages branch) 
5. [Virtual Environments](https://github.com/chrisparnin/EngineeringBasics/blob/master/Environments.md#Environments).  
   Tools for creating and managing virtual computing environments.
   - [ ] Install VirtualBox and Baker
   - [ ] Create a simple virtual machine
   - [ ] Optional: Create your own environment
6. [Task Management](https://github.com/chrisparnin/EngineeringBasics/blob/master/OnlineTools.md#online-tools).  
   Using Github issues and Trello boards for task management.
   - [ ] Create issue on GitHub with this checklist (filled in) 
   - [ ] Try trello
Laravel Collections Higher Order Messages - Single Line Magic
Tags: php, laravel, collections, higherordermessages
Published: 2018-08-17 21:11:38

---
title: Laravel Collections Higher Order Messages - Single Line Magic
published: true
description: Cut crappy syntax down to one line using Higher Order Messages,
tags: PHP, Laravel, Collections, Higher Order Messages
---

Collections are wrappers around arrays in PHP. Collections provide fluent interfaces and **intuitive** APIs to access arrays. Laravel comes with collections out of the box, and Laravel's eloquent ORM returns the result set in the form of collections by default.

Collections come with many useful methods which allow us to easily manipulate arrays, and they are chainable as well. Compared to the built-in PHP array manipulation functions, collections offers much readable and consistent syntax. 

Here I will show you a little refactoring technique you can do while tinkering with collections using higher order messages.

>Collections provide support for "higher order messages", which are short-cuts for performing common actions on collections. [Documentation](https://laravel.com/docs/5.6/collections#higher-order-messages)

**Consider the scenario where you need to map over a collection and call method on the item**

```
<?php
User.php
--------- 

/** 
 * the method returns the full name of the user 
 * by joining first and last name 
**/

function fullName(){
   return $this->first_name . ' ' . $this->last_name;
}

SomeFile.php
------------
/** 
 * In some other file, we need full names of all users 
**/

$fullNames = User::all()->map(function ($user) {
    return $user->fullName()
});

```

the above code shows how we do it normally with `map()`, but functions with the simple body as in the above code, we can use higher-order functions to cut the explicit crap.

```
<?php
$fullNames = User::all()->map->fullName();
```
Boom ⚡ Single line Magic 🔥❤️

**Let's goto a little more complex scenario where we need to filter over a collection and then map over them again**

```
<?php

User.php
---------
/** 
 * the method returns the full name of the user by joining first and last name 
**/

public function fullName() {
   return $this->first_name . ' ' . $this->last_name;
}

/** 
 * the method returns the if the first_name starts with a given letter 
**/

public function isStartingWith($letter) {
    return starts_with($this->first_name, $letter)
}

OtherFile.php
-------------
/** 
 * In some file, we need full names of all users which starts with 'A'
**/

$fullNamesWithA = User::all()->filter(function($user){
    return $user->isStartingWith('A');
})->map(function ($user) {
    return $user->fullName()
});
```


Let's try to use Collection Higher-order functions here and cut explicit syntax crap.

```
<?php
$fullNamesWithA = User::all()->filter->isStartingWith('A')->map->fullName();
```

Boom ⚡ Single line Magic 🔥❤️ Again


**Adiós**
Introducing "Tips From a Build Farmer"
Tags: buildfarmertips
Published: 2018-08-28 20:20:43

---
title: Introducing "Tips From a Build Farmer"
published: true
tags: [buildfarmertips]
canonical_url: https://dmerej.info/blog/post/introducing-tips-from-a-build-farmer/
---


I’ve spent several years working on CI scripts and infrastructure. I’ve used many tools (Jenkins, Travis, GitLab CI, …). I’ve made a lot of mistakes, and I learned a few things I thought I might share here.

The topic of CI is _huge_, so as I did for _[Let’s Build Chuck Norris!](https://dmerej.info/blog/post/introducing-the-chuck-norris-project/)_ and _[Quantum of Ideas](https://dmerej.info/blog/post/introducing-quantom-of-ideas/)_, I’ll be writing several articles in the following weeks.

_Update: This series has been cancelled. I am [writing a book](https://dmerej.info/blog/post/im-writing-a-book/) instead!_
Devilbox is great for me like a dull developer
Published: 2018-08-18 08:01:07

---
title: Devilbox is great for me like a dull developer
published: true
description: 
tags: 
---

Yes, I am sure I am a dull developer.
Many months ago I wrote about a tool 'Devilbox' on unseen blog.

[Old post somewhere](https://gist.github.com/shtakai/c4df94003a7c24f2ed5706008ca6979b)

The motivation is
- I would not like to install the middleware natively.
- Because I am dull.
- And I want to develop on some laptops/nucs.
-- Mainly I use OSX, but with treason spirit I use linux.
-- Once a year, I use windows. 
(I used MSDOS, so I must love windows once a year.)
- Focusing on coding.
- Every 3 months I try to create box like this, but I break my heart and sleep.

So I found good stuff.  [Devilbox](https://devilbox.org/)

Written on website 'LAMP stack', it's okay to pass.
Just I want to implement is this.

It's easy to use. :) 

---

And I like to hear what is good stuff. :)
Flip Animation effect using CSS3
Tags: css, html, css3, design
Published: 2018-08-18 05:14:00

---
title: Flip Animation effect using CSS3
published: true
description: Flip Animation effect using CSS3
tags: #css #html #css3 #design
---

Post Link : <a href="https://www.skptricks.com/2018/01/flip-animation-effect-using-css3.html">Flip Animation effect using CSS3 </a>

This Post Explain <a href="https://www.skptricks.com/2018/01/flip-animation-effect-using-css3.html">how to create Flip Animation effect using CSS3</a>. Here we are using CSS keyframe attribute to perform flip animation effect horizontally and vertically to small square div box. All the animation effect is controlled by Keyframes Rule and it provides very smooth animation effect.

<img src="https://4.bp.blogspot.com/-rsk0wgF0mR8/Wlr9ZjCQ-ZI/AAAAAAAABLA/GlRDpP4JZyMFBWgin42e5hIjBT-RY7yLACLcBGAs/s1600/flip.gif" />

Keyframe Animation :
Here we are using below CSS Style to perform flip animation effect horizontally and vertically to small square div box.

@keyframes rotate-div {
  0% { 
    transform: perspective(120px) rotateX(0deg) rotateY(0deg);
    -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg); 
  } 50% { 
    transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
    -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg); 
  } 100% { 
    transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
    -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg); 
  background-color: #ec407a;
  }
}




Download code : https://github.com/skptricks/php-Tutorials/tree/master/Flip%20Animation%20effect%20using%20CSS3
Follow Me, Rubyists, Because...
Tags: testing, ruby, github, debugging
Published: 2018-08-18 01:44:09

---
title: Follow Me, Rubyists, Because...
published: true
description: 
tags: testing, ruby, github, debugging
---
I'm building gems for you:

[markdown_helper](https://rubygems.org/gems/markdown_helper):  supports file inclusion for GitHub Flavored Markdown, plus page table-of-contents.

[debug_helper](https://rubygems.org/gems/debug_helper):  shows analysis of an object, sometimes recursively.

[structured_log](https://rubygems.org/gems/structured_log):  supports nested sections, timestamp/duration, and exception rescue.

[test_values](https://rubygems.org/gems/test_values) (new):  supports named values to be used in testing.
On condescendence
Tags: career, beginners
Published: 2018-08-18 00:52:07

---
title: On condescendence
published: true
description: 
tags: #career #beginners
---

I recently came across a discussion on a web developer Facebook group. Someone had asked a somewhat simple question: Do you think there’s a need to use a CMS on every client projects?

My answer to that is relatively simple: In my web agencies days, countless times, a client would ask us to make *everything* editable. Making our dev work harder and longer, sometimes even with some design limitations. When the project was completed, usually two things would happen: either the client would call us to update the website because he didn’t have time to do it or he would just update a page once every 6 months.

It depends on the type of project or the type of client you are working with. That’s the key here: everyone has a different background and different previous experiences.

A guy, let's call him Max, was heart & soul defending the use of CMS and mainly Wordpress; how fast and easy it was for his clients to update their project. Everything should be editable by the client, bar none. Max couldn’t concede anyone was doing any *real* work without Wordpress (or a CMS). 

The problem here is the amount of condescendence he had when explaining his rationale. He was so disrespectful and ridiculed others for thinking differently than him. Telling to go back “Learn the web” before replying again. Calling people out by names. How you must be *stupid* for not using Wordpress [sic].

At one point, Max even said to another dev: Your replies make me want to punch you in the teeth. WHAT?

Don’t get me wrong: I love confidence. I love that you can have a strong opinion on a subject. You can talk about the ins-and-outs of Wordpress, that's great! I don’t think you can’t make it far in this industry if you have passion but communication is key. When I used to teach to young designers, one of the things I would tell them to remember is this: communication skills are as essential as your main craft. You can be the best designer in the world, but if you can’t explain yourself or sell your ideas, the best communicator will always win over you even if the work is less good.

What's even worse is that Max had good arguments, he was making sense. Wordpress is indeed great for many situations, especially in the advertising/marketing industry. And yes, it's a CMS used by many, yes it's easy to find resources online. Had he stayed respectful, others would have learned a thing or two. Others would have probably agreed with him.

Instead, he became irrelevant. No one wants to deal with such a character. His ego was so big that his arguments were lost in the wild. Everyone stopped listening. Only because he wasn't able to communicate well.

It’s essential for your career to master how to communicate and to stay open-minded. People will continually have different views than yours. Listen to them first. Make your point after. Help them understand your point of view. If they don’t; at least you tried. Stay humble. You will start getting people’s attention. There’s no place for condescendence. Ever.
What CDN do you use and why?
Tags: askdev, discuss
Published: 2018-08-18 00:11:38

---
title: What CDN do you use and why?
published: true
description: researching CDN and why!
tags: askdev, discuss
---

What CDN are you using and why? I’m actively working on something very similar to a CDN, so I’m curious to see what everyone uses and why?

My baseline requirements are always for a CDN:

- sub 30ms globally for “hot regions” (see list below)
- ability to push and persist content, not just pull and cache for short periods of time
- traffic and latency insights

**the hot country list:**

1. USA
2. Canada
3. United Kingdom
4. Brazil
5. Argentina
6. Australia
7. Germany
8. Spain
9. Israel
10. China

**ping requirements (per number):**

1. 15-30ms
2. 20-30ms
3. 15-30ms
4. 30ms
5. 30ms
6. 15-30ms
7. 20-30ms
8. 30ms
9. 20-40ms (exception made)
10. 20-40ms (exception made)
What is Declarative vs Imperative
Tags: tip, coding, learn
Published: 2018-08-17 23:41:17

---
title: What is Declarative vs Imperative
published: true
description: A brief overview of the difference between the two
tags: tip, coding, learn
---

So this is one that even to this day, I have to google every now and then. I'm making an effort to write a post from now on, any time I have to research something. The hope is it'll help me remember and also that it will help someone else in the same boat!

So here it goes. 

I just watched a great video on it that does a great job to explain the difference. You can find it [here](https://www.youtube.com/watch?v=M2e5sq1rnvc).

Chris Boesch says in the video, that it's simplest form is as follows.

* **Imperative:** How to do something
* **Declarative:** What to do

The example Chris gives further is that of when you get in a Taxi.

**Imperative** would be if you gave the Taxi driver a step by step instruction of how to get where you are going.

**Declarative** is like saying "take me to the white house"


If you want a code example, definitely watch the video linked above. 

One last way to remember, borrowed from zsoc on IRC `##javascript`, he stated declarative... as in 'declaring' something.. like "I'm going to do this thing" vs "this is how im going to do something"

anywho, hope that helps some of ya.


--DeChamp
It's obviously simple!
Tags: beginners, tips
Published: 2018-08-17 22:54:57

---
title: It's obviously simple!
published: true
description: The use of discouraging words
canonical_url: https://dev.to/david_ojeda/its-obviously-simple-2n8a
tags: beginners, tips
---


A couple of days ago I was going through some tutorials and guides on various software topics and got frustrated because I could not figure something out. But it was not that mere act that annoyed me, it was due to the way the instructions were stated: **JUST** need to change the configuration of your server.

You know, you **JUST** need to make this; you **JUST** need to modify that; the server will **OBVIOUSLY** crash.

<img src="https://thepracticaldev.s3.amazonaws.com/i/2p8j4ginx0mwl3k9ys53.jpeg" alt="Obviously a meme" style="display: block;margin-left: auto;margin-right: auto;width: 30%;">

Not because you find something obvious or simple means that everyone else will. Words like just, obviously and simply are generally discouraging- specially for beginners that are starting to piece different things together.

Moreover, I don't think those words add any value to your writing. Does it make your point clearer if you state that it should be obvious? **No**. On the contrary, your reader might feel like a fool because he/she didn't find it obvious at all.

While thinking about this I decided to do a little page where you can paste your text and it will highlight words like *obvious*, *simply*, *just*, etc. I decided to go with React/Redux, some deep learning algorithms and everything running serverless. **Just kidding**, it's an static website with inline CSS and JavaScript that uses a Regex 🙃 [Check it out here!](https://simply.davidojeda.mx/)

In my opinion, we should try to avoid those words as much as we can to stop discouraging others and to add more value to our ideas. Also, you use fewer words.


Thanks for reading me! ❤️
Choosing a Linux distro
Tags: linux
Published: 2018-08-17 22:21:25

---
title: Choosing a Linux distro
published: true
description: Linux, so many. BUT WHICH ONE?! 
tags: #linux
---
Recently I decided that I wanted to switch from Windows 10 to a Linux distro as my primary operating system. Mainly because I've always found that the dev environments are a lot better on Linux (personally) and that I have a lot more freedom to mess around with the OS. 

But the hardest decision was which do I chose? Linux is an
[Open source](https://github.com/torvalds/linx), meaning anyone is free to commit code and obviously create their own operating system. Personally I went with [Linux Mint (Cinnamon)](https://www.linuxmint.com/) for my new OS. But I still had other options in mind.

I made a table to showcase what I took into consideration, hopefully it may help you if you switch to Linux.

| OS            | Environment    |Purpose| Based on |Expertise required |
| ------------- |:-------------:| -----:|----------:|------------------:| 
| Mint      | Cinnamon, MATE, XFCE, KDE| General |Ubuntu, Debian | Low           | 
| Debian |GNOME, KDE, XFCE. LXDE (many more)|Community based, server, general use, other distros | N/A | Medium |
| Ubuntu | Unity | General | GNOME (Recent return) (Parts in Debian) | Low |
| Manjaro | Cinnamon, Enlightenment, XFCE, GNOME (+ others) | General | Arch | Medium |
| Arch | Cinnamon, GNOME, KDE | General use, server | N/A | High (pain to install) |
| Fedora | GNOME, KDE | General, testing sandbox | Red Hat | Medium |
| CentOS | GNOME, KDE | General, server | N/A | High |

I looked into quite a lot of Linux Distros before coming to my conclusion, these are the key factors I took into consideration before selecting. Before selecting I suggest you have a look at [This website](https://distrochooser.de/en) it allows choosing a distro based on your preferences and usage a lot easier.

In addition if you're dual booting it can be a pain in the ass to switch your OS every time in the BIOS. A friend of mine has shown me the [rEFInd project](http://www.rodsbooks.com/refind/linux.html) it presents a customizable interface on boot to allow you to select your chosen OS.

Happy deving!
Pointing A Domain to The Newest File In A Directory 
Tags: webdev, python, tutorial, process
Published: 2018-08-17 21:39:55

---
title: Pointing A Domain to The Newest File In A Directory 
published: true
description: A look into the thought process of solving a problem with python and Apache Virtual Hosts.
tags: webdev, python, tutorial, process
canonical_url: https://harnerdesigns.com/blog/pointing-a-domain-to-the-newest-file-in-a-directory/
cover_image: https://harnerdesigns.com/wp-content/uploads/2018/08/fancycrave-277756-unsplash.jpg
---
_This might not be any where near the best solution, but it worked for me in this one instance. More of a description of my thought process than an actual tutorial._ 

I wrote a python script for Shoolu.com to use the BigCommerce API to pull the latest added products and generate an XML RSS file.  BigCommerce did have the functionality to automatically generate these RSS feeds but they have moonlighted support and have removed it for new merchants so it didn't seem like something to rely on. 

## PYTHON To The Rescue
I found the BigCommerce Python API and used that to fetch all the products with a created date of at most 7 days ago. I then looped through all those products to create the necessary items in the RSS File. 

This worked well and good but I was basically just overwriting the one file and losing any previous weeks worth of New Products. I knew it would be easy enough to just write to a different file with the current date in the file name so it'd be new every time. 

## Trouble In Paradise
The plan was to use this RSS feed to generate a "What's new at Shoolu" email every week through MailChimp and their ability to work with RSS Feeds. The problem with the current approach of dating the files was that I was pointing Mailchimp at the one direct file so I'd have to update it every week which kind of defeats the purpose of all of this. 

## An Unexpected Solution
I tried digging around for a way to have a root domain ([rss.shoolu.com](https://rss.shoolu.com)) point to the latest file in the directory. There were several suggestions including using php to fetch the latest file and redirecting and some other less than elegant solutions. 

None of them really tickled me the way a good solution does. 

I finally decided to just update the python script to just output `index.xml` as well as `latestProducts-[date].xml`. That way `index.xml` would get overwritten with the currently accurate info and we'd also get the dated backups to log. 

Then for simplicity's sake I just updated the Apache Virtual Host file for the domain:
```
<directory /var/www/rss/public/>
	...
	DirectoryIndex index.xml
</directory>
```
So the root domain would point directly to the file. Might not be the most elegant solution, but it works in this specific case so I'd figured I'd document it.

_Originally Posted on my blog: [Pointing A Domain to The Newest File In A Directory](https://harnerdesigns.com/blog/pointing-a-domain-to-the-newest-file-in-a-directory/)_