teleren/devto huggingface dataset:
Day 12 – Creating own server - Learning Node JS In 30 Days [Mini series]
Tags: node, javascript, codenewbie
Published: 2019-12-15 18:21:53

Client make a request to the server and server provide the files using socket. So we are going to learn about how to make our own server using node today!

We are going to use `http module` for this. You can find the __official document__ here https://nodejs.org/dist/latest-v12.x/docs/api/http.html

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/gmgv6xm92bxdk997hlua.png)

First we are going to `require http` and store it to `http` variable using `const http = require('http')`

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/q0rkc1hyw3jlb1mnxc0w.png)

We are going to use http.createServer for creating the server

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/e13jmwmvshlzekkgbn8z.png)

We can just start our server using `const server = http.createServer()` but there are some more work to do.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/2nejstoiyqacu2g9o7y2.png)

We need to write a function inside the `createServer()` so that we can get the request and response according about it

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/u4euy60et7x57vcpm59y.png)


Now we can `send data` to request using `res.end('Hey everyone!')` and we need to give a port to listen. In my case I'm using `3000`.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/6ie3n8be1xxobq7dtt2m.png)

Now run the code using `node app.js`

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/cybmqtckmd72u9asohpe.png)

and finally go to localhost:3000 and you can see the result

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/pe64nu7cfks4uygh9z5x.png)

###So creating server is easy right ? 


You can see the graphical version here
{% instagram B6GbqvllwFl %}

Originally it published on [nerdjfpbblog](https://blog.nerdjfpb.com/day12-nodejsin30days/). You can connect with me in [twitter](https://twitter.com/nerdjfpb) or [linkedin](https://www.linkedin.com/in/nerdjfpb/) !


###__You can read the old posts from this series (below)__

{% post nerdjfpb/day-1-learning-node-js-in-30-days-mini-series-55e7 %}

{% post nerdjfpb/day-2-learning-node-js-in-30-days-mini-series-5023 %}

{% post nerdjfpb/day-3-learning-node-js-in-30-days-mini-series-24i4 %}

{% post nerdjfpb/day-4-learning-node-js-in-30-days-mini-series-1koc %}

{% post nerdjfpb/day-5-learning-node-js-in-30-days-mini-series-21jm %}

{% post nerdjfpb/day-6-learning-node-js-in-30-days-mini-series-758 %}

{% post nerdjfpb/day-7-learning-node-js-in-30-days-mini-series-3023 %}

{% post nerdjfpb/day-8-var-vs-let-vs-const-learning-node-js-in-30-days-mini-series-1i72 %}

{% post nerdjfpb/day-9-mastering-eventemitter-learning-node-js-in-30-days-mini-series-2dfe %}

{% post nerdjfpb/day-10-mastering-eventemitter-learning-node-js-in-30-days-mini-series-2802 %}

{% post nerdjfpb/day-11-creating-and-deleting-folders-learning-node-js-in-30-days-mini-series-3a2d %}
The Sound of Silence
Tags: stocisim, discuss, acceptance
Published: 2019-12-15 18:02:03

I lost my Airpods this morning. They may show up later, but for the time being, gone. 

As a father of a 1-year old, private/alone time is precious. There are four-hours of audio for two books I'm trying to finish, and I have a 90-minute run today. There's little I can do to occupy my mind on a long-run, so audiobooks and podcasts are essential (yes, essential.)

So, to my surprise, I found the loss of these little white wireless bastards a major hit to my positive state of mind.

Last night.

I'm training for a triathlon and, as I mentioned moments ago, having time alone is precious. Earlier in the week my bike tire got a flat. I'm new to fixing a flat, so they take me longer than a "trained professional." 

After an hour or so of YouTube and wrenching my fingers into a wheel frame, I fixed the flat! Because I used up 60-minutes of my 120-minute ride time, I had to combine a meeting with a ride on a bike-trainer (similar to a stationary bike, but with a real bike in a bike-mount).

00:12:36 minutes into the 2-hour ride the tire went flat again - damn! Let the mourning being.

From time to time, I pick up my copy of "The Daily Stoic" by Ryan Holiday. I don't consider myself a stoic (I'm not a thousand years old.) However, I like the short/concise nature of many stoic principles. Often, when I'm in a life-pinch, I pick it up and read the day's except. Without fail, it applies.

Now, it might be divine intervention; or it might be that, like a good palm reading, I will find a way to make any generalizable advice, applicable. Regardless, today's except was spot on.

_"This is the mark of perfection of character - to spend each day as if it were your last, without frenzy, laziness, or any pretending." - Marcus Aurelius, Meditations, 7.69_

As Ryan puts it in the book:

_"...Can you actually live today like it is your last day? Is it even possible to embody completeness or perfection in our ethos (character)... Maybe not. But if trying was enough for the Stoics, it should be enough for us too._

Today, I will commit to trying. Today, I will be okay with almost. Today, I will accept the sound of silence as the sound of acceptance: of being human.
What's better than Give-A-Ways and Merch?
Tags: hiring, career, womenintech, news
Published: 2019-12-15 17:50:04

It's the Holiday Season!
And I want to give YOU something! 

6 months ago I fell in love.  ❤️

For 10 years I was confused as to why I was always bored, no matter what position I held. I was tired, passionless, and annoyed. I wanted a change, I NEEDED a change...so I quit...with no backup plan. I came across blogs about coding and began to learn things about software, sites, tools, and languages and I couldn't stop soaking in the information and earned certificates from SoLo Learn and Flatiron.

After a couple of months, I took an internship to learn all about how to recruit for technical positions. I not only learned how to be a top recruiter...but I found who I am, and what I was passionate about. I now work for Talent Solutions Group, a company that focuses on not only the clients' needs but also the candidates. I am also able to be who I am with no boundaries - a helper, a researcher, a giver, a friend...and your door to your next career move.

Or maybe you're a company growing fast and needing to fill positions fast, reach to Ken, Rick or Adam for immediate team expansion!

Bloggers have Give-A-Ways, Youtubers have Merch, but TSG has open positions that bring passion and growth back in your career. 
The Holidays are here, let us open your new door for 2020!

-Erica Austin (Sr. Tech Recruiter @ TSG)
How To Become More Productive and Consistent: Life Log #1
Tags: productivity, beginners
Published: 2019-12-15 17:05:52

It’s Sunday, 15th Dec’19. You must be thinking about what special about this day.

From the last couple of weeks, I have started to review my progress in `work` and `personal life` every Sunday. And, that's why it’s special for me because I get to know where I am lacking and how can I improve myself.

A couple of weeks back, I joined FluxAuto, a company that works on Autonomous Vehicles, as a Full-Time Software Development Engineer in Bangalore, India. 

Last week at the new office was exciting, however, I still feel that I was not much productive.

There are sets of questions, I ask myself every Sunday.

- **What did you learn**?

- **What did you do**?

- **What are you most proud of**?

- **How can you improve**?

The answer was negative for most of these questions. So, I know it’s time to change something.

It’s not that I didn’t learn anything new this week or I wasted my time watching NetFlix.

But, I feel I didn’t document anything. Whatever I had learned, I could have shared a simple blog or a youtube video or a Github repo.

I feel you can only track your progress when you have something to show. Do you things its possible to track progress in mind, without creating new things?

Next week's goal would be to share what I learn, be more productive in the office hours and consistent in what I do.

That’s all for this week.

If you like to see more about my journey and daily routines, please follow me on [Instagram](https://instagram.com/dipakkr.co)!

[Subscribe to my email newsletter and stay updated!](https://dipakkr.substack.com/)
Kubernetes' 2k+ TODO Comments
Tags: kubernetes, git, go
Published: 2019-12-15 16:24:24

This Medium story takes a look at the 2,000 TODO comments in the Kubernetes' source code; where the average age of a TODO comment is 2.3 years. Check it out if you're interested!

https://medium.com/@augmentable/looking-at-kubernetes-2k-todo-comments-b2db42dc7fdb
Algorithm is...
Tags: cs, algorithms, mindmap
Published: 2019-12-15 19:04:48

---
title: Algorithm is...
published: true
date: 2019-12-15 15:58:11 UTC
tags: cs, algorithm, mindmap
canonical_url: https://vorakl.com/articles/algorithm/
cover_image: https://vorakl.com/files/algorithm/algorithm-properties.png
---

Despite the obvious expectation to find some sort of a definition of the term "Algorithm" here, I have to disappoint you, as there isn't any general or well-accepted definition. But, it's not a unique situation! Take mathematics, for example. Although there are plenty of different "definitions" that can be found in the literature, they all are just oversimplified attempts to explain what an algorithm really means.

  

In general, an algorithm is a way of describing the logic. And that's why it's so hard to cover all possible forms of it in terms of common rules or definitions. Most prominent mathematicians began seriously thinking about computability and what can be computed at the beginning of the 20th century. But it was so hard to generalize all the cases that eventually they had to limit the consideration by functions defined only on the set of [Natural numbers](https://dev.to/vorakl/number-classification-im6).

  

The most famous works were done by [Alan Turing](https://en.wikipedia.org/wiki/Church%E2%80%93Turing_thesis) (related to algorithms) and[Alonzo Church](https://en.wikipedia.org/wiki/Church%E2%80%93Turing_thesis) (related to computable functions). Alan Turing came up with the thesis which basically says, that if a function is computable then it has an algorithm, and if so, then it can be implemented on the Turing machine (TM).In other words, Turing's thesis makes it clear what can be computed and what is needed to get computed.

  

[Turing machine](https://www.youtube.com/watch?v=dNRDvLACg5Q) is an abstract system that has a finite set of states and symbols, a few certain operations, and an endless tape (consisted of cells). The behavior of a TM is controlled by a program that defines a state transition and a next tape movement depending on a symbol that was read. Although, there is no real-world analog of the TM as it is unlikely possible to have infinite memory. So, to get it more realistic, for a real analog of TM, it means two things:

1. to have enough memory, at least, as much as needed (analog of the tape)
2. to have a conditional branching, some sort of if/else and goto statements(analog of state transitions)

  

All algorithms share the same properties:

- deterministic (produces the same result for the same input)
- discrete (works with discrete data, like texts, integers, rational numbers)
- finite (represented by a finite text)

  

[![Turing completeness](https://vorakl.com/files/algorithm/algorithm-properties.png)](https://vorakl.com/files/algorithm/algorithm-properties.png)
Reading Snippets [12]
Tags: beginners, javascript, todayilearned
Published: 2019-12-15 15:53:18

How does Array.prototype.slice.call() work?

It can be used to make arguments object into an Array instance. Under the hood, this is an array and is iterated over. 

New arrays are created using the Array. The arrays are passed through slice which is stored in the prototype object.
CORE as Code Once and Run Everywhere
Tags: dotnetframework, dotnetcore, core
Published: 2019-12-15 15:39:08

The framework .Net is one of the most known and efficient frameworks. Nowadays, being efficient or known is not sufficient, because the user environment is our final target. Let imagine that our user is using Windows, Mac OS, Linux or mobile systems then our most new efforts have to bring us closer to multiplatform. These efforts will make users and developers happy by coding once and run everywhere. For me, this word "CORE" is the first keyword which gives consideration to developers and users at once.  

<h2>Developers like CO feature</h2>
![CODING ONCE](https://thepracticaldev.s3.amazonaws.com/i/u87lgkri3piq17nstto5.gif)



<h2>Users like RE feature</h2>
![RUN EVERYWHERE](https://thepracticaldev.s3.amazonaws.com/i/02s8xx4dge8q69i3oqhc.gif)


I am a user and a developer and I wish to use other frameworks CORE like DotNet Core in the future.
PHP Javascript form formData 55: input text textarea checkbox-multiple using ajax (XMLHttpRequest)
Tags: php, javascript, form, xmlhttprequest
Published: 2019-12-15 14:58:07

<hr />

<center>Happy Coding</center>

<hr />

index.php

		<form method="post" action="process.php" >

			Firstname: <input type="text" name="firstname" />
			<br />

			Lastname: <input type="text" name="lastname" />
			<br />

			Description: <textarea name="description" rows="10" cols="50" ></textarea>
			<br />

			Hobbies (multiple):
			<input type="checkbox" name="hobbies[]" value="studying" /> Studying
			<input type="checkbox" name="hobbies[]" value="reading" checked /> Reading
			<input type="checkbox" name="hobbies[]" value="writing" /> Writing
			<input type="checkbox" name="hobbies[]" value="sleeping" checked /> Sleeping
			<br />

			<hr />

			<input type="submit" value="Submit" />

		</form>

		<hr />


display result form server

		<div id="output"></div>

get formHTML element and add onsubmit event, and create formData, then call ajax function with arguments formHTML, formData and output display ("#output") 

		<script>

			/* submit form */
			document.querySelector( "form" ).addEventListener( "submit", function (event) {

				event.preventDefault(); // return false


				var formHTML = event.target; // this

				console.log( formHTML ); // formHTML element


				// https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects
				var formData = new FormData( formHTML );

				console.log( formData );


				// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
				// https://www.w3schools.com/xml/xml_http.asp
				// https://www.w3schools.com/js/js_ajax_http.asp

				/* AJAX request */
				ajax( formHTML, formData, "#output" ); // ajax( form, data destination )

			});

		</script>

ajax function

		<script>

			function ajax( form, data, destination )
			{

				if (window.XMLHttpRequest)
				{
					var xhr = new XMLHttpRequest(); /* code for modern browsers */
				}
				else
				{
					var xhr = new ActiveXObject("Microsoft.XMLHTTP"); /* code for old IE browsers */
				}

				xhr.open( form.method, form.action, true ); // ( "post", "process.php", true )
				xhr.send( data );

				xhr.onreadystatechange = function () {
					if ( this.readyState == 4 && this.status == 200 )
					{
						document.querySelector( destination ).innerHTML = this.responseText;
					}
				};

			}

		</script>

<hr />

process.php

    echo "<pre>";

    var_dump($_POST);

    echo "</pre>";

<hr />

Demo <a href="https://repl.it" >repl.it</a>

<ul>
  <li><a href="https://repl.it/@antelove19/Javascript-form-formData-55" >Editor</a></li>
  <li><a href="https://Javascript-form-formData-55.antelove19.repl.co" >Live</a></li>
</ul>

<hr/>

<center>Thank for reading :)</center>

<hr/>
PHP Javascript form formData 50: input text textarea checkbox using ajax (XMLHttpRequest)
Tags: php, javascript, form, xmlhttprequest
Published: 2019-12-15 14:51:46

<hr />

<center>Happy Coding</center>

<hr />

index.php

		<form method="post" action="process.php" >

			Firstname: <input type="text" name="firstname" />
			<br />

			Lastname: <input type="text" name="lastname" />
			<br />

			Description: <textarea name="description" rows="10" cols="50" ></textarea>
			<br />

			Hobby (single): <input type="checkbox" name="hobby" value="studying" /> Studying
			<br />

			<hr />

			<input type="submit" value="Submit" />

		</form>

		<hr />


display result form server

		<div id="output"></div>

get formHTML element and add onsubmit event, and create formData, then call ajax function with arguments formHTML, formData and output display ("#output") 

		<script>

			/* submit form */
			document.querySelector( "form" ).addEventListener( "submit", function (event) {

				event.preventDefault(); // return false


				var formHTML = event.target; // this

				console.log( formHTML ); // formHTML element


				// https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects
				var formData = new FormData( formHTML );

				console.log( formData );


				// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
				// https://www.w3schools.com/xml/xml_http.asp
				// https://www.w3schools.com/js/js_ajax_http.asp

				/* AJAX request */
				ajax( formHTML, formData, "#output" ); // ajax( form, data destination )

			});

		</script>

ajax function

		<script>

			function ajax( form, data, destination )
			{

				if (window.XMLHttpRequest)
				{
					var xhr = new XMLHttpRequest(); /* code for modern browsers */
				}
				else
				{
					var xhr = new ActiveXObject("Microsoft.XMLHTTP"); /* code for old IE browsers */
				}

				xhr.open( form.method, form.action, true ); // ( "post", "process.php", true )
				xhr.send( data );

				xhr.onreadystatechange = function () {
					if ( this.readyState == 4 && this.status == 200 )
					{
						document.querySelector( destination ).innerHTML = this.responseText;
					}
				};

			}

		</script>

<hr />

process.php

    echo "<pre>";

    var_dump($_POST);

    echo "</pre>";

<hr />

Demo <a href="https://repl.it" >repl.it</a>

<ul>
  <li><a href="https://repl.it/@antelove19/Javascript-form-formData-50" >Editor</a></li>
  <li><a href="https://Javascript-form-formData-50.antelove19.repl.co" >Live</a></li>
</ul>

<hr/>

<center>Thank for reading :)</center>

<hr/>
Why I started using dual-licensing for Vue tables 2 
Tags: vue, opensource
Published: 2019-12-15 14:50:46

I've been working on Vue Tables 2 for almost 3 years now. I probably spent more than 1,000 hours of work on it. I love this project. I got a lot of positive feedback and it seems like many devs found it useful, which is exactly why I started it. But recently, it became a bit too much to handle. So many emails with feature requests, so much work on new features, writing documentation, fixing bugs, not to mention working on the soon to be released Vue 3 version. Like many of you guys, I also have a day job, and I just can't afford to spend so much time at the expense of my paid work hours. Got rent to pay and mouths to feed.

I tried asking for donations. It didn't work. So, I've decided to start monetizing it with dual licensing. As of version 1.6.0 vue-tables-2 is available on Github under GPLv3 license, while offering an MIT version as a paid subscription. The previous versions prior to the license change are still available as MIT, so no one should get hurt if they're currently using it in their projects - but future releases will be GPLv3.

I know this seems drastic, but the next version - which includes a huge improvement in building custom templates, by allowing the user to swap any table component with his own implementation  - takes an enormous amount of work, and I've decided that in order to take this project to the next level, I will need stable financial support from the companies that use it commercially. Charging a few dollars a month for a license to use it commercially seems reasonable to me. 

I intend to continue building Vue tables 2 (and 3!), and make it a better open source project for all of us.

I will keep you guys posted on how this goes.

https://github.com/matfish2/vue-tables-2
12v fan to 220v fan
Tags: hardware, pcbuilding, spanish
Published: 2019-12-15 07:44:51

---
title: 12v fan to 220v fan
published: true
description: Replacing 12 volts DC cooling fans with 220 volts AC cooling fans
tags: hardware, pcbuilding, spanish
---

**Spanish only post, sorry.**

Desde hace tiempo tenia ganas de reemplazar los ventiladores "gamer" originales de 12 volts DC de la PC Desktop,
pero pense en probar reemplazarlos con ventiladores nuevos pero de 220 volts AC,
para liberar un poco de capacidad y conectores de la fuente,
por que los originales hacen ruido y giran lento o recalientan en verano.

Yo desarme ventiladores "gamer" caros y baratos de CPU/GPU,
note que realmente el motor es el mismo, no es mas grande ni nada,
solo que el ventilador caro tiene mejor plastico y terminacion,
es trasparente y con leds de colores, pero basicamente el motor es el mismo,
estas pagando extra por decoracion, lo unico que mueve aire es el motor.

Compre 2 fan de 220 volts nuevos en una casa de electronica de Buenos Aires,
son mas baratos que los "gamer", son de aluminio en lugar de plastico,
son mas feos pues solo vienen color negro los de plastico vienen con leds,
usa rulemanes en lugar de bujes, los cables son mucho mas finos (1mm),
consumen menos electricidad (mas voltage necesita menos amperaje),
vienen en medida similar a los originales, inclusive use los mismos tornillos, 1 de 120mm para GPU (nVidia), 1 de 60mm para CPU (AMD).
Lo que mas calienta hoy dia es la placa de video igualmente.

La parte electrica simplemente la conecte a la ficha de 220 volts de la fuente directamente,
con el cable finito que vino con el ventilador, la fuente tiene una  tecla de apagado igualmente.

Realmente no llevaron muchas mas adaptaciones que eso, 
son practicamente iguales a los ventiladores anteriores originales.

El centro donde esta el motor del ventilador es mas gordito,
pero las aspas del ventilador son mas anchas y mueven **mucho** mas aire.

El motor esta electricamente aislado del cuerpo de aluminio del ventilador.
Guarde los ventiladores originales en una cajita.

La temperatura es igual o 6 grados mas que la temperatura ambiente.
Considero la adaptacion exitosa y relativamente sencilla, 
me gusta hacer *hardware experimental DIY*.
Dont do this at home, blah, blah, blah.  :)
Les dejo unas fotos que tome con el movil.


![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/b2ma5a9cudubuh3cssjg.jpg)


![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/rvsa493t3rd85v4c06xd.jpg)


![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/9i0pmxptwatpu2h4binm.jpg)


## Resultado final

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/2xgsgg15km35f2n7l0ws.jpg)