teleren/devto huggingface dataset:
Step by step guide for hosting static site in github.
Tags: github
Published: 2019-09-19 15:48:45

---
title: Step by step guide for hosting static site in github.
published: true
tags: github
canonical_url: https://thecodersblog.com/simple-step-by-step-guide-guthub-hosting/
---

Github allow us to host static site in github for free. It also support static site builder like `jekyll`. But let’s limit this article on hosting plain static site.

##### Simple steps for hosting static sites.

- Create a github account if you already don’t have one [here”](https://github.com). 

> Advance user can use git & terminal to sync and push it to github

- Download either GitHub for Mac or GitHub for Windows, depending on your operating system. Open the app and log in using the account you just created. [For the advance user, you can use terminal and ssh to clone repository].
- [For Mac:]After you login, click advanced and make sure that your name and email are correct. Then, click “Install Command Line Tools”, just in case you want to start using the command line later in life.
- Create a new repository in your GitHub application. Name it your-username.github.io. The name is very important. Note the folder that GitHub is saving the repository to. Make sure the “Push to GitHub?” box is checked.
- Move your website’s files into the folder that GitHub just created when you made the repository. IMPORTANT: Your homepage HTML file must be called “index.html”, and it must exist in the top-level directory.
- Back in the GitHub application, you should see your files in the left column. Make sure they are all checked. If so, enter a message in the text box called “commit summary”, something like “initial commit.” Then, click the commit button.
- Click the “Publish repo” button in the top right corner.
- Give it about 10 minutes, then check your-username.github.io. Your website should be there!

#### Using a custom domain name

You can just leave your website at that address (it’ll give you some serious street cred in the developer world), but if you have a custom domain you would like to use, it is very simple to make GitHub redirect your page.

1. Log in to your domain registrar and find where to change your host records. If you don’t know, you can usually Google “(domain registrar) change host records”, and your registrar will have an explainer telling you how to do it.
2. Change your domain’s A Record to 185.199.108.153. This is GitHub’s IP address, which allows GitHub to resolve your URL and serve the correct files.
3. In your website’s directory folder on your computer, create a file called “CNAME”. On the first line, type your domain name. Save the file.
4. In your GitHub application, you should see the file in the left column. Make sure it is checked and enter your commit message. Have it say something like “Adding CNAME file.”
5. Click “Sync branches.”

It can take as long as 48 hours for your domain to resolve to your GitHub page. However, it is usually pretty quick, so check back in an hour or so.
Managing error and loading state using useReducer
Tags: javascript, react, webdev, tutorial
Published: 2019-09-16 14:39:15

---
title: Managing error and loading state using useReducer
published: true
tags: ['javascript', 'react', 'webdev', 'tutorial']
canonical_url: https://learnwithparam.com/videos/react-usereducer-to-manage-object-state/
description: In this tutorial, we will learn when to use useState and when to use useReducer. Also how to manage error and loading state while fetching an API using useEffect
series: Small steps on React
---

{% youtube 0man5ImAulg %}
How to enable swap in ubuntu and debian?
Tags: linux
Published: 2019-09-19 15:50:58

---
title: How to enable swap in ubuntu and debian?
published: true
tags: linux
canonical_url: https://thecodersblog.com/how-to-enable-swap-in-ubuntu-and-debian/
---

##### What is swap space?

Swap space in any operating system is amount of disk space reserve for moving inactive pages from RAM. Swap space are of two type dedicate swap or of swap files in linux OS. Here we will create a swap file for the linux system.

> We assume that the system does have not swap partition for this guide.

##### Check if your system already exist swap partition.

Open the terminal, and enter the following command to check.

```
swapon --show
```

##### Check free memory and disk.

```
free h
 //or
 df -h
```

If you have sufficient space in you hard-disk then lets continue.

##### Step:1 Make swap off

```
swapoff /var/swapfile
```

##### Step 2: Resize the swapfile

Here let us increase to 2GB (assuming existing one has 1GB space as given in the article)

```
dd if=/dev/zero of=/var/swapfile bs=1024k count=2000
```

##### Step 3: Make swapfile usable

```
mkswap /var/swapfile
```

##### Step 4: Make swapon

```
swapon /var/swapfile
```

##### Step 5: Change permission to 0600

```
chmod 0600 /var/swapfile
```

##### Step 6: Verify the swapfile

```
swapon -show
```

##### Step 7: Make swap file permanent

```
echo '/var/swapfile none swap sw 0 0' | tee -a /etc/fstab
```
Happy programmer's day!
Tags: happyday, programming, discuss
Published: 2019-09-13 23:06:19

---
title: Happy programmer's day!
published: true
description: what's the best part of being a programmer?
tags: happyday, programming, discussion
---

Happy programmer's day to everybody! What's the best part of being a programmer for you? Share with the community! Get a cup of your favorite drink and celebrate with all of us!

The best part for me is that I always find surprises about what can I do with my code, and all the awesome things I can learn, is a whole world waiting to be discovered, and I really enjoy that.

Hugs&Husky love 🐶
![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/2ddzzcgunzlbw0gsoi1b.gif)
What's your first experience with programming/coding?
Tags: watercooler, discuss, developer
Published: 2019-09-13 23:04:39

Happy programmers' day 2019 everyone! What was the first time you remember programming? The first time I actually formally programmed anything was at 13. I took a Python beginners class over the summer at Portland State University. From that day, programming and software development has been a part of my life.
Raw SQL Migrations Library
Tags: php, sql, database
Published: 2019-09-13 21:38:14

Where I currently work, we operate on a stack of mostly PHP and PostgreSQL. Our framework was written in ZF1 (it's legacy), and our deployment process for keeping our database changes version-controlled is quite tedious and complex.

Outside of work, I love using frameworks like Laravel and Rails and one of the features I really love from both of these is migrations. Since our legacy application at work doesn't have this concept, I started thinking of ways to take this modern approach and apply it to our legacy app.

Since we cannot convert our entire application over to one of these frameworks (it would be a major overhaul), I looked into some options like Phinx and Flyway for possible integration, but these options were not really compatible with our app (for various reasons that would deserve their own post).

At our company, we make very heavy use of PostgreSQL: complex procedures, triggers, views, multiple schemas, data warehousing, etc... we power everything on it. Many migration-type libraries usually have some abstraction layer that doesn't really support the full range of these database features. For example, Rails migrations are written in Ruby and then converted down to SQL before execution; same with Laravel and PHP. This isn't a bad thing, but these types of abstractions don't truly support the wide range of database features (particularly procedures) and are typically limited to just creating tables, indexes, and constraints.

So, I decided to task myself (for fun mostly) with trying to build a migrations library that would run on raw SQL, and lo and behold, I actually got a simple concept going! The underlying CLI is written in PHP, but you write and execute migrations in raw SQL.

I figured that maybe a lot of other people could get some use from such a library, and so I put it up on GitHub a while back but never really shared its existence with anyone. So today, that is what I am doing.

I am really looking for people who would like to help make it better. I think it's a good start, but I know a truly great tool isn't built by one person alone. Feel free to criticize, praise, or contribute!

Exodus Migrations Library: https://github.com/grahamsutton/exodus
Create and Test a JavaScript Node.js Serverless Function on Azure
Tags: javascript, aws, azure, serverless
Published: 2019-09-13 21:25:07

---
title: Create and Test a JavaScript Node.js Serverless Function on Azure
published: true
description: This second article in the series about migrating from AWS Lambda to Azure Functions demonstrates how to implement serverless JavaScript Node.js using Azure Functions.
tags: javascript, aws, azure, serverless
canonical_url: https://medium.com/microsoftazure/moving-from-lambda-%C6%9B-to-azure-functions-b6d5ed5ca007?part=2
series: Moving from Lambda to Azure Functions
---
> This article is part of [#ServerlessSeptember](https://dev.to/azure/serverless-september-content-collection-2fhb). You'll find other helpful articles, detailed tutorials, and videos in this all-things-Serverless content collection. New articles are published every day — that's right, every day — from community members and cloud advocates in the month of September.

> Find out more about how Microsoft Azure enables your Serverless functions at [https://docs.microsoft.com/azure/azure-functions/](https://docs.microsoft.com/azure/azure-functions/?WT.mc_id=devto-blog-jeliknes).

The Azure Functions app serves as the host for serverless functions. It is a unit of deployment and scale that defines features for your app such as your language and runtime, security settings, and root URL endpoint. 

# Create an Azure Functions App

This video is designed for anyone new to Azure Functions, even if you're not migrating from AWS Lambda. It walks through how to create the host, write simple code using JavaScript and Node.js, and test the function from your browser and the command line.

{% youtube YgcUqPzk63c %}

You can view the source code for the sample app and deploy the migrated code directly to Azure with a single-click in the “AWSMigration” GitHub repository.

{% github JeremyLikness/AWSMigration %}

In the next article, we'll explore how to integrate the [primes code](https://github.com/JeremyLikness/AWSMigration/blob/master/azure/portal/isItAPrime/index.js) from our AWS Lambda function, including setting up a cache using [Azure Table Storage](https://docs.microsoft.com/azure/cosmos-db/table-storage-overview?WT.mc_id=devto-blog-jeliknes).

## Resources

1. [Create your free Azure account](https://azure.com/free?WT.mc_id=devto-blog-jeliknes)
2. [JavaScript Developer Reference for Azure Functions](https://docs.microsoft.com/azure/azure-functions/functions-reference-node?WT.mc_id=devto-blog-jeliknes)
3. [How to Use Azure Table Storage from Node.js](https://docs.microsoft.com/azure/cosmos-db/table-storage-how-to-use-nodejs?WT.mc_id=devto-blog-jeliknes)
Calif Coder - Youtube Channel Intro 
Tags: java, beginners, codinginterview, preparation
Published: 2019-09-13 21:19:52

---
title: Calif Coder - Youtube Channel Intro 
published: true
description: Intro video about the coding interview problems.
tags: #Java #Beginner #CodingInterview #Preparation
---

Please look at the [Youtube Video](https://youtu.be/hTua-UBowGQ)

All i want to know that how is my explanation skills. 
(think of this as a interview).

Please share your thoughts and feed back.

I would like to improve myself in cracking the interviews. So i started this channel to share my experience and gain the knowledge.
Ruby driven Raspberry Pi buttons
Tags: raspberrypi, ruby, tutorial
Published: 2019-09-14 12:54:08

---
title: Ruby driven Raspberry Pi buttons
published: true
tags: RaspberryPi, ruby, tutorial
canonical_url: https://blog.codenamev.com/ruby-driven-raspberry-pi-buttons/
series: Sunfounder Superkit
---

> This is part 2 in my [Sunfounder Superkit series](https://blog.codenamev.com/tag/sunfounder-super-kit/).

Blinking an LED was too easy!  Let's make this piece interactive.  Buttons are exactly the magic I'm looking for.  Push it, and do _something.  ANYTHING_!  Let's keep it simple and build off of our first simple LED hookup.

![Ruby driven Raspberry Pi buttons](https://blog.codenamev.com/content/images/2019/09/raspberry-pi-button-led-1.jpg)<figcaption>Wiring a button to an LED on a Raspberry Pi B+</figcaption>

With that in place, and a little Ruby script, we can loop in the button to join the LED blinking fun.

{% gist https://gist.github.com/codenamev/b19d7f57c3efca3dfdf2090c6dfe73bd %}

## The Great Ruby Takeaways

Ok, so maybe the circuit is not _that_ exciting, but this is just the start!  With this we've gained some exposure to both listening in on and controlling the state of GPIO pins.  Writing this script also introduces us to some great aspects of working with Ruby programs from a lower level.

### IO#flush and IO#sync

Firstly, [`STDOUT.flush`](https://ruby-doc.org/core-2.6.4/IO.html#method-i-flush).  This will clear any buffered data to standard out allowing future calls to `puts` to replace what was there.  Little did I know there is [a flag you can set on an IO instance](https://ruby-doc.org/core-2.6.4/IO.html#method-i-sync) to immediately flush the output after every call with: `STDOUT.sync = true`

### Kernel#at\_exit

Ruby's Kernel comes with some great stuff for working with the command line.  The fine folks over at HoneyBadger have [a great writeup on different ways to exit a Ruby program](https://www.honeybadger.io/blog/how-to-exit-a-ruby-program/), and some best practices.  In this specific case, we can use the special [`at_exit`](https://ruby-doc.org/core-2.6.4/Kernel.html#method-i-at_exit) callback to perform some code to reset the state of our GPIO pins (so we make sure not to set any fires).

### Interrupt and SignalException

Lastly, because we want to ensure that our circuit resets itself whenever the program stops running, we need a way to catch both user-initiated interrupts (a.k.a [`Interrupt`](https://ruby-doc.org/core-2.6.4/Interrupt.html) caused by a ctrl+c) and system-initiated interrupts (a.k.a. [`SignalException`](https://ruby-doc.org/core-2.6.4/SignalException.html)).  While it may be more beneficial to [trap unix signals](https://www.sitepoint.com/license-to-sigkill/), I went with the quick and dirty.

Hopefully you learned something today.  I know I did!  Tune in next time when I get serious with the breadboard and jam as many LEDs in it as I can (or have patience for).
Variables in kotlin
Tags: android, kotlin
Published: 2019-09-13 19:33:38

Welcome back everyone to another brief learning of kotlin and today we will be talking about variables.

TADA!!!!

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


Now let's start, first i wanna believe you aren't a newbie in programming but if you are, no problemo.

Alright you'll need Inteli J Idea installed on your computer for starts, don't forget java jdk as well. Here are the respective links to get them.

https://www.jetbrains.com/idea/download/index.html#section=linux

https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html

If you already had them, great let's begin right away.

So kotlin has data types, what are data types you ask?
consider them as containers carrying different information/data.

How exactly?

Say we different cups lined up, those cups are the containers but what they have inside is what makes them different. We use these different data in building cool stuffs and passing information to our computer.

Examples of data types are:

1.Int = Integers 
2. String = Bunch of characters such as texts or words.
3. Double = Decimal digits
4. Float = Decimal digits too but smaller than double

 As the name implies, a double has 2x the precision of float[1]. In general a double has 15 decimal digits of precision, while float has 7.

Here's how the number of digits are calculated:

double has 52 mantissa bits + 1 hidden bit: log(253)÷log(10) = 15.95 digits

float has 23 mantissa bits + 1 hidden bit: log(224)÷log(10) = 7.22 digits 

This precision loss could lead to truncation errors much easier to float up

5. Char = characters of the 26 alphabets
6. Boolean = True or false



Next: How to define variables in kotlin

![Alt Text](https://i.ytimg.com/vi/GidIn50ZOgg/maxresdefault.jpg)


So open your Inteli J idea and create your kotlin project.

You declare variables in two ways in kotlin.

Using "var" or "val"

Difference:
var means you can assign a different value different from the initial value to the variable whenever you want.

example:

//initial value
var kot:Int = 8 

//new value 

kot = 10

println(kot)

Output = 10


Using val

val kot:Int = 8

kot = 6


(Editor throws error "kot cannot be assigned a value").

That's for today. I'm sorry guys but i promise more posts. 
Feel free to ask your questions as well.


Here's how you'd define variables of different data types

val a:Double = 4.8d
val b:Float = 5.0
val c:Char = 'g'
val d:Strinfg = "Hello"
val e:Boolean = true

Thank you
Sending Realtime Events To The Client From Node child process
Tags: rabbitmq, redis, node, socketio
Published: 2019-09-13 16:10:29

---
title: Sending Realtime Events To The Client From Node child process
published: true
description: Executing jobs in child processes using and getting realtime progress using RabbitMq, Redis, SocketIo and Node
tags: RabbitMq, Redis, NodeJs, Socketio
---

So I recently had to add a new feature to an existing app. The new feature did some data heavy stuff like processing large documents of which the content was to be saved into a database.

Naturally, I queued the data from the file and consumed the queue in a forked child process then saved the info to the database in the child process. To send a progress report on the status of the processing, I decided to use socketio to fire events to the client. This approach presented me with several problems because for one the processing was fast and the socketio instance didn't capture most of the events another problem was how to use the same socketio Instance between parent and child.

The approach I later settled for was to use Redis Pub/Sub to fire events from the child processes, listen on the main process and send said events to the client. The approach works, scales well and gives a really good performance.

# Now for Some code

I will assume you have an existing nodejs app and the data has been queued already. We need to install the following

* Redis Nodejs Client (I use https://www.npmjs.com/package/redis)
* SocketIo

Both can be installed using npm. `npm i -S socket.io redis`

# RabbitMqHelper

Though this is out of scope for this article, I wrote a RabbitMq Helper which I use in my apps.

{% gist https://gist.github.com/gate3/9ba272aa9557be1d87911746299b7da7 %}


# The Child Process

The feature required processing different queues that had different types of information but they both required the same underlying action; Saving into the database. So, I wrote a base child process and the specifics of each child process extended this

## Base Worker

{% gist https://gist.github.com/gate3/7d2fb107126cf16ae5a6e58c258d19f4 %}


## User Worker

{% gist https://gist.github.com/gate3/581cb39267742b9e5f7792de9a7163dd %}

# The Main Process

The main or parent process will fork the child processes anytime it starts. Starting a few child processes isn’t very difficult, but imagine having several child processes, it can be stressful getting the path to each and running them one after the other. So for that, I like to use a glob to find all child processes.

For that, I will use a npm module called `glob`.

`npm i -S glob`

The code for the main process looks like this.

{% gist https://gist.github.com/gate3/f2da2986aef2bd740da72627ad89bae6 %}

And that is it. Please leave your comments and opinions. Enjoy!
TIL
Tags: python, pydoc, documentation
Published: 2019-09-13 19:14:08

---
title: TIL 
published: true
description: 
tags: python,pydoc,documentation
---

Today I learned that you can view python's documetation in browser using
pydoc 
if you run this command `python3 -m pydoc -p <specify_port>`
Is there a solid fork of .NET Core CLI without data collection?
Tags: dotnetcore, help, discuss
Published: 2019-09-13 18:43:07

Just curious if anyone knows of one that is commonly accepted. My brief searches didn't turn up anything.

Currently we set the environment variable on all our machines to turn off dotnet core CLI data collection. (Even though this does not appear to stop it in some cases.) I have always hated data collection schemes, but given recent headlines, it seems only prudent to start taking more proactive measures.

**Edit**: It occurs to me that some might be unfamiliar with data collection in .NET Core CLI. So I will repost an explanation below.

----

Microsoft calls their data collection "telemetry", and it is in the dotnet core command-line tools. It is enabled by default, but you can opt out by setting an environment variable. It is not well-liked.

{% github https://github.com/dotnet/cli/issues/3093 %}

It was [announced](https://devblogs.microsoft.com/dotnet/announcing-net-core-rc2/#user-content-eula) as sortof a footnote of a release candidate build back in 2016.

The MSDN page about it -- as well as opt-out instructions -- can be found [here](https://docs.microsoft.com/en-us/dotnet/core/tools/telemetry). Although some of the wording there is understated.

{% github https://github.com/dotnet/cli/issues/11311 %}

Note: It does not _currently_ collect runtime data. Meaning, when you invoke a built app with `dotnet MyApp.dll`, it does not collect anything at this moment. It does record and report some data points as you use it for dev purposes (e.g. `dotnet run`) unless you opt out by setting an environment variable. It has been reported that some post-install scripts send off telemetry data even if you opted out. But afterwards, it should not.