teleren/devto huggingface dataset:
Henlo, Warld!
Tags: firstpost
Published: 2021-05-08 13:20:00

Greetings fellow humans! It is I, Alex (AKA olus2000), and I bring you freedom from professional, well documented and commented, enterprise-grade coding. On this blog I create the ugly, the useless, the overcomplicated and the bodged!

### A serious note
###### The only one
I'm a college student from Poland who prefers to watch youtube than learn. My experience with programming started with LOGO in primary school but I quickly switched to Python3 which is now my primary language of choice, both for work and quick projects. I'm currently studying computer science.

### My esoteric background
###### The interesting part starts here
I heard about brainfuck when I was 14, but it wasn't until high school that I found a fellow esolang enjoyer who has shown me the vast world of [esolang wiki](https://esolang.org) with all its glorious languages and concepts of self-interpreters, quines or using an esolang as machine code. I've been looking through the wiki ever since, though I'm still only fluent in brainfuck. I'm also a frequent user of an esoteric game engine - a fantasy console [PICO-8](https://www.lexaloffle.com/pico-8.php), and an esoteric human language - minimalistic conlang toki pona.

### What to expect
###### Basically nothing in particular
I make a choice of what to work on based on a very arbitrary notion of "fun". If I deem something "fun" I think about it and come up with dumb ideas using it. To this day "fun" things included: brainfuck, writing interpreters, making a microprocessor, minimalism, toki pona and balanced numbering systems among others.

There's no way to predict what's the next "fun" thing. I can only assure you it will be in no way useful whatsoever. Be warned though - not every post will be directly connected to IT. If I find a cool mathematical or linguistic concept I want to share I will not hesitate to do it.

### Previous notable work
###### See also: future posts
I have a couple of projects that I made this blog to share: an esoteric language based on toki pona grammar, two implementations of my custom brainfuck variant and a [timelapse tool for the game Neptune's Pride](https://olus2000.pl/nptimelapse). I will be posting about this for some time, and hopefully I will have another project in mind when I run out of stuff to say about these two. If you would like to support me you can donate on [Libera Pay](https://liberapay.com/olus2000/donate).

I also did a [speedrun of coding "Snake"](https://youtu.be/OuxudW1Nous). Can we make this a thing? Anyone?
Interview Quenstions Javscript
Published: 2021-05-08 13:17:42

JavaScript is a scripting language. It is different from Java language. It is object-based, lightweight, cross-platform translated language. It is widely used for client-side validation. The JavaScript Translator (embedded in the browser) is responsible for translating the JavaScript code for the web browser.




 List some of the advantages of JavaScript.

Some of the advantages of JavaScript are:

    Server interaction is less
    Feedback to the visitors is immediate
    Interactivity is high
    Interfaces are richer




List some of the disadvantages of JavaScript.

Some of the disadvantages of JavaScript are:

    No support for multithreading
    No support for multiprocessing
    Reading and writing of files is not allowed
    No support for networking applications.





 Define anonymous function

It is a function that has no name. These functions are declared dynamically at runtime using the function operator instead of the function declaration. The function operator is more flexible than a function declaration. It can be easily used in the place of an expression. For example:

    var display=function()  
    {  
      alert("Anonymous Function is invoked");  
    }  
    display();  





Define closure.

In JavaScript, we need closures when a variable which is defined outside the scope in reference is accessed from some inner scope.

    var num = 10;  
    function sum()   
    {  
    document.writeln(num+num);  
    }   
    sum();  





What is ES6 or ECMAScript 2015?

ES6 was released in June 2015, which is stated as the sixth edition of the language. Initially, it was named ES6 and later renamed to ECMAScript 2015. This edition includes several new features that are modules, iterators, class, arrow functions, for...of loop, promises, and many more. Brendan Eich developed it.





    Define Constants in ES6?

In ES6, a constant is affirmed by a const keyword. ES6 provides a const keyword, which a constant uses and declare a const.





    What do you mean by Babel?

Babel is a JS Transpiler, which let us write in ES6 and interpret the work done in ES6 into ES5 which is supported by browsers.




    Define undefined?

In Javascript, undefined means, changeable is affirmed but doesn’t hold value.







    Define promises in ES6?

In order to hold asynchronous encoding, promises transport a more precise way to apply async programming in JavaScript.





    Explain map?

The map can be distinct as elements that are stored as keys, or worth pairs. Objects or ancient values can be stored in the map as each key or value.





    Define Set?

Set is a compilation of sole values, in which photocopy values are ignored. All costs must be unique. Values can be thing references or primal types.
Deadlocks | MySQL
Tags: mysql
Published: 2021-05-08 13:07:04

{% youtube i2ltK4gplRg %}

**What is this article about?**

This post is about a certain type of database locks called "Deadlocks". I would like to show you how they occur using a simple example.

**How do the deadlocks happen?**

Essentially deadlocks happen when multiple sessions are attempting to get exclusive locks on the same resources(table records)

**What is the scenario?**

Imagine a busy e-commerce website. Two book sellers are trying to update certain attributes of the books they have listed on this e-commerce website.

When they make changes on the website, the underlying application will modify PRODUCTS table. In reality, the application might update more than one table. But to keep it simple, we will focus on PRODUCTS table only.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/izicu2lyuj7yw7opaqzt.png)

**What are the requirements?**

1. Disable autocommit in your MySQL database.

2. Set the transaction level to "READ COMMITTED"

You may run these commands first in all your database sessions.

set autocommit=0;

set session transaction isolation level read committed;

**How to simulate a deadlock?**

**Step 1:** Seller A updates the quantity of the book "The common path to uncommon success" (product_id = 1).

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38p4mk2w3dqxrqdbn09v.png)

**Step 2:** Seller B updates the price of the book "Tiny Habits" (product_id = 2) through a different session.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rwlbozomihccv401z6yr.png)

**Step 3:** Seller B also attempts to update the price of the book "Tiny Habits" (product_id = 1) in the same session as above.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rrnka0qqmbihtxcve6mo.png)

This command will hang because Seller A still hasn't executed a "commit" operation.

**Step 4:** Seller A attempts to update the quantity of the book "The common path to uncommon success" (product_id = 1).

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5r5rjnlclj09yns2s20.png)

**MySQL decided to rollback Seller A's transaction to avoid two sessions waiting on each other endlessly.**
precision agriculture
Published: 2021-05-08 12:51:31

Precision agriculture refers to the precise application of agricultural inputs with respect to soil, weather and crop need in order to improve productivity, quality, and profitability in agriculture.
It is a modern agriculture practice involving the use of technology in agriculture like remote sensing, GPS and Geographical Information System (GIS) for improving productivity and profitability.
It enables farmers to use crop inputs more efficiently including pesticides, fertilizers, tillage and irrigation water.
More effective utilization of inputs will bring in more crop yield and quality without polluting the environment and will result in sustainable agriculture and sustainable development.
Hence precision agriculture is about doing the right thing, in the right place, in the right way, at the right time.
OOP in Batch
Published: 2021-05-08 12:47:48

Hi, I'm Nguyen Phu Minh, creator and lead developer of the [FreakC Programming Language](https://github.com/FreakC-Foundation/FreakC). Since Batch does not have object-oriented programming, so today I'm sharing my attempt in "faking" OOP in Batch.

# Creating a structure
First, I will create a file called "Dog.bat":

```bat
:: Creating properties
set %~1.age=%~2
set %~2.weight=%~3
:: Creating a child method
(
echo echo %%~1!
)>%~1.say.bat
```

Then, I will create a main file which we run our code on:

```bat
:: Create an object
call Dog "Mary" "3" "4kg"
:: Prints out "age" property of "Mary", which is "3"
echo Age: %Mary.age%
:: Call "Mary.say" with argument "Woof", which prints out "Woof"
call Mary.say "Woof"
```

That's it! Simple, right? Please comment if you've a better solution.
A Verbose Log Snippet for Easier Debugging
Tags: webdev, codenewbie, javascript, beginners
Published: 2021-05-08 12:32:19

Here's a VSCode snippet that populates a `console.log` call with more information to help you interpret your output. Typing `llog` then Tab will get you something like:

```js
console.log(`❗ data.js line:78 'reservations' <type: ${typeof reservations}>`,reservations);
```

Instead of just printing the value of your `console.log` argument, you get the file name, the line number, the name of the argument, its type, and *then* its output. There is also a red emoji to mark this as your own note and to easily spot the beginning of the log.

### The actual snippet
```json
"Labeled log to console": {
		"prefix": "llog",
		"body": [
			"console.log(`❗ $TM_FILENAME line:$TM_LINE_NUMBER '${2:expression}' <type: \\${typeof ${2:expression}\\}>`,${2:expression});"
		],
		"description": "Logs filename, rough line called, name, type, and value of expression "
	},
```
Here's a shorter version of the same info:
```json
 "Labeled log to console": {
		"prefix": "llog",
		"body": [
			"console.log(`❗ $TM_FILENAME:$TM_LINE_NUMBER '${2:expression}' <\\${typeof ${2:expression}\\}>`,${2:expression});"
		],
		"description": "Logs filename, rough line called, name, type, and value of expression "
	},
```
And an even shorter version with no `typeof` - use with `slog` then tab:
```json
  "Short log to console": {
		"prefix": "slog",
		"body": [
			"console.log(`❗ $TM_FILENAME:$TM_LINE_NUMBER '${2:expression}'`,${2:expression});"
		],
		"description": "Logs filename, rough line called, name, and value of expression "
	},
```


Shoutout to Neophius and alexdima for showing me [the escape characters](https://github.com/microsoft/vscode/issues/1670#issuecomment-277265737)

### How to use VSCode snippets
It's easier if I just show you:

<img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6a8snlldfkbbqwfz824q.gif" alt="A gif demonstration of what the snippet does and how to use VSCode snippets">


### Notes

* The line number doesn't update if the call moves to another line in the file. It doesn't matter very much in practice.
* Maybe you have more than one `index.js`? Replace `TM_FILENAME` in the snippet with `TM_FILEPATH` for the full path to the file. 

[Learn more about user snippets] (https://code.visualstudio.com/docs/editor/userdefinedsnippets)
Truthy and Falsy values in Javascript 
Published: 2021-05-08 12:19:39

We are going to discuss an important javascript topic for interviews that can help you also understand a basic of Javascript. 

**Truthy and Falsy values**

In javascript when you declare a variable with some value except 0 Javascript should consider this as a true value and if the value is 0 Javascript will consider this as false.

```
const score = 20;

if(score){
console.log("It is true")
}
else{
console.log("It is false")
}
// Output : It is true
const duck = 0;

if(duck){
console.log("It is true")
}
else{
console.log("It is false")
}
// Output : It is false
```

So Javascript will consider 0 as false and other values as true.

If you declare a string with its length < 0 then javascript will consider this as true, otherwise if you declare an empty string it will be considered as false.

```
const name1 = "Alvee";

if(name1){
console.log("It is true")
}
else{
console.log("It is false")
}
// Output : It is true
const name2 = "";

if(name2){
console.log("It is true")
}
else{
console.log("It is false")
}
// Output : It is false
```

If you don't define a variable Javascript will consider it as false.
 
```
let name;

if(name){
console.log("It is true")
}
else{
console.log("It is false")
}
// Output : It is false
```

If you define a variable as Null Javascript will consider it as false.
 
```
let name = null;

if(name){
console.log("It is true")
}
else{
console.log("It is false")
}
// Output : It is false
```

If you also define a variable with NaN Javascript will consider it as false.
 
```
let value = NaN ;

if(value){
console.log("It is true")
}
else{
console.log("It is false")
}
// Output : It is false
```

We saw that the empty string was false, but if you declare an empty array or object it will be considered as true value.



```
const array = [];

if(array){
console.log("It is true")
}
else{
console.log("It is false")
}
// Output : It is true

const object = {};

if(object){
console.log("It is true")
}
else{
console.log("It is false")
}
// Output : It is true
```

Besides all these, if you declare a value as false, there what can Javascript do!

```
const value = false;

if(value){
console.log("It is true")
}
else{
console.log("It is false")
}
// Output : It is false
```

So we can say that if you declare a variable with the value of undefined, null, NaN, 0, "" the output will be false.

The following values are always falsy:

* false
* 0 (zero)
* '' or "" (empty string)
* null
* undefined
* NaN

Everything else is truthy. That includes:

* '0' (a string containing a single zero)
* 'false' (a string containing the text “false”)
* [] (an empty array)
* {} (an empty object)
* function(){} (an “empty” function)

you can also check out this [article](https://www.sitepoint.com/javascript-truthy-falsy/) I found informative
Daily Developer Jokes - Saturday, May 8, 2021
Tags: jokes, dailydeveloperjokes
Published: 2021-05-08 12:00:02

---
title: "Daily Developer Jokes - Saturday, May 8, 2021"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Saturday%2C%20May%208%2C%202021"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e125988c2636.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ Why did the web developer always go to the wrong hotel room?

___A:___ They were in room 301.
 -->
Dynamically Generate GitHub Stats SVG like Terminal for your Readme
Tags: python, github, javascript, webdev
Published: 2021-05-08 11:48:50

<h1 align='center'>GitHub Stats Terminal Style</h1>
<p align='center'>Dynamically Generate GitHub Stats as like Terminal Interface </p>

<p align='center'>
  <img align="center" src="https://raw.githubusercontent.com/yogeshwaran01/github-stats-terminal-style/master/github_stats.svg">
</p>

## Usage

1. Create a New Repository using by click [here](https://github.com/yogeshwaran01/github-stats-terminal-style/generate) to create.
2. Create the personal Access token. Check this [link](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) to create personal access token.
3. Add a New Repository secret to your repo. Name of the secret is must be `GHT` and valve is your personal access token. Checkout this [link](https://docs.github.com/en/actions/reference/encrypted-secrets) to add new repository secret.

The File `github_stats.svg` is svg image of your github stats. you can copy the link of the image and use it any where. By default it update daily at `2:47 UTC` you can also can this by change the cron in `/.github/workflows/main.yml` by using [Cron Generator](https://crontab.guru/).

## Themes

Now only Nine themes are only available.

By default it ubuntu theme.

you can change the theme by change the command in file `/.github/workflows/main.yml`

change

```bash
node updater.js ${{ github.repository_owner }}
```

to this

```bash
node updater.js ${{ github.repository_owner }} <themeName>
```

[Github Link](https://github.com/yogeshwaran01/github-stats-terminal-style)

Contributions, issue and pull requests are welcome

<h3 align='center'>Made With Javascript :heart:</h3>
Top 5 Awesome Web User Experience You have never seen before
Tags: uiweekly, ux, css, webdev
Published: 2021-05-08 11:42:01

#1 Smooth transition to header

###Video tutorial
{% youtube N8Y7OeqLeXU %}

#2 Theme change with range Slider

###Video tutorial
{% youtube 7ClyFMsGKK8 %}

#3 Product Card

###Demo

{% codesandbox  vigorous-varahamihira-0t85z %}

>I suggest you to view demo in full new window. click on the top right most button to view in full window.

###Video tutorial

{% youtube 2MtU84rS2GA %}

#4 Tile Navbar

###Demo

{% codesandbox divine-leftpad-miow4 %}

>Its not responsive So view this demo in full view window. Click on the top right most button.

###Video tutorial

{% youtube EsD3QY_wFm8 %}

#5 Thanos Snap Effect Image Slider
###Demo

{% codesandbox xenodochial-cache-gyjy7 %}

###Video tutorial

{% youtube iEYYT-okGgY %}

>I agree my designs are not responsive but my design are awesome. If you like it follow me.

>If you found Video tutorials helpful please consider subscribing my youtube channel.
Docker vs Virtual Machine
Tags: docker, devops
Published: 2021-05-08 11:38:27

### What is Docker?
Docker is a tool that uses containers to make the creation, deployment, and running of applications a lot easier. It binds the application and its dependencies inside a container.
Container 

![Docker](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yiv4vlwmk94kjqdo1jrf.png)

* OS level process isolation
* Each container can share OS
* Boots in seconds
* Containers are lightweight
* Pre-built docker containers are easily available
* Containers are destroyed and re-created rather than moving
* Containers can be created in seconds
* Less resource usage

### What is Virtual Machine?
A virtual machine is a system that acts exactly like a computer.

In simple terms, it makes it possible to run what appears to be on many separate computers on hardware, that is one computer. Each virtual machine requires its underlying operating system, and then the hardware is virtualized.

![Virtual Machine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9mhnnjcmiu9qnz8ee8w.png)

* Hardware-level process isolation
* Each VM has a separate OS
* Boots in minutes
* VMs are of few GBs
* Ready-made VMs are difficult to find
* VMs can move to new host easily
* Creating VM takes a relatively longer time
* More resource usage

---
### Watch this YouTube video for more details
[![Docker vs Virtual Machine](https://i.ytimg.com/vi/5GanJdbHlAA/hq720.jpg?sqp=-oaymwEcCNAFEJQDSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLC6tTpZ3Fy-TYuboctBQqrCBXxwaQ)](https://youtu.be/5GanJdbHlAA)
How to Grow as a Developer
Tags: programming, codenewbie
Published: 2021-05-08 11:35:28



Growth is a paramount aspect of our lives, and as developers, we desire to grow in our code journey.

In this article, I will share various tips that have helped me grow as a developer and I hope you find it resourceful as well.


> "Do the best you can until you know better. Then when you know better, do better." - Maya Angelou

1. **Coding project**: taking up a coding project is very important, why? because you get to learn a lot. You get to make research, debug and most importantly understand code structure and technique.

2. **Read books**: not everybody loves reading, but I encourage you to cultivate the habit of reading. Books contain useful information that can enable you to improve more on your skill as a developer.

3. **Documentation**: documentation is a very important tool and I cannot over-emphasize it. Most tools or plugin we use in our project is backed with well-written documentation that contains: _installation guide_, _usage_ etc. 
Knowing how to read documentation can also help you grow as a developer.

4. **Articles**: another tip is articles, there are lots of articles out there, that explains whatever challenge you may have.

5. **Stay updated**: keeping up with the latest news and trend with your related programming tools is another tip, why? because it helps you know the latest changes, security fix, tools that are deprecated etc.

I hope you are able to get a thing or two from the above tips, if you have any tip that is also beneficial, feel free to leave it as a comment.

Original post on my [blog](https://judithoiku.tech/2021-how-to-grow-as-a-developer/)
WordPress: modify user roles dynamically with functions.php
Tags: wordpress, authorization, php, security
Published: 2021-05-08 11:33:46

[WordPress](https://wordpress.org/) provides variety of user [roles and capabilities](https://wordpress.org/support/article/roles-and-capabilities).

It is able to modify user roles with `functions.php` dynamically as well as capabilities.

{% post nabbisen/wordpress-modify-user-capabilities-dynamically-with-functions-php-383n %}

In other words, in terms of security, it is able to act as `administrator` when there is a way to edit [`functions.php`](https://developer.wordpress.org/themes/basics/theme-functions) such as [FTP](https://en.wikipedia.org/wiki/File_Transfer_Protocol).

Here is a code example.

```php
# functions.php
function custom_user_role() {
	// get user
	$user = new WP_User( <user-ID> );
	//$user = new WP_User( '<user-login-name>' );
	//$user = wp_get_current_user();

	// modify roles	
	// for example, set/unset them as administrator
	$user->add_role( 'administrator' );
	//$user->remove_role( 'administrator' );
}
// register action
add_action( 'admin_init', 'custom_user_role' );
```

Adding it to `functions.php` gives the user, which is got by ID, login name or login information, the role as `editor` even if they is just a `reader` or a `editor`.

Wordpress user roles list is [here](https://wordpress.org/support/article/roles-and-capabilities/#roles).