teleren/devto huggingface dataset:
Cookie, localStorage, or sessionStorage?
Tags: cookie, localstorage, sessionstorage, javascript
Published: 2018-10-28 06:07:58

---
title: Cookie, localStorage, or sessionStorage?
published: true
description: difference between cookie, localStorage and sessionStorage
tags: #cookie, #localStorage, #sessionStorage, #javaScript
---


Cookie, localStorage, and sessionStorage are all the simple data storage ways for client-side storage. Cookie is more like an old school way to handle the simple data stored on the client-side. In HTML5, web storage, such as localStorage or sessionStorage is introduced and it’s also easier to use.

###Cookies
1. Persistence: user can set expiration time for each cookies.
2. Storage: there’s only about 4KB space for entire cookie data.
3. Traffic: data needs to be sent back to the server for all the HTTP requests, which increases the traffic between client and server.
4. Works for old browsers.


###localStorage
1. Persistence: data exist until it’s deleted
2. Storage: available space increase to around 5 MB
3. Traffic: less traffic because not all of the HTTP requests need to send data back to the server
4. Domain: data only stays in the same domain, which means if data is stored on website A, next time it can only be accessed on website A. To be clear of the domain used here, it means the same website field. For example, whichever  different posts or different personal pages in Facebook that you are browsing are all under facebook.com. As a result, those pages are all under the same domain. 

###sessionStorage
sessionStorage is similar to localStorage. The only difference will be the persistence of the data. For sessionStorage, once user leaves the domain, such as closing the tabs or windows, the sessionStorage is emptied. 

###How to use localStorage and sessionStorage?
Both localStorage and sessionStorage use key-value pair and their syntax are similar. Followings are the examples.

###Syntax

```javascript
//To store the data:
localStorage.setItem(“key”,”value”);

//To retrieve the data:
localStorage.getItem(“key”);

//To update the data (the same as to store the data):
localStorage.setItem(“key”,”value”);

//To remove one entry:
localStorage.removeItem(“key”);

//To clear all the data:
localStorage.clear();
```
Rounding Numbers in PHP with round()
Tags: php, beginners
Published: 2018-10-28 04:14:54

I don’t know about you, but to me, these converted temperatures from my [last post](https://dev.to/morinoko/for-loops-in-php-converting-oven-temperatures-414c) are a bit hard to read. Converting 400 degrees Fahrenheit shows up as 204 degrees Celsius and converting 200 degrees Celsius shows up as 392 degrees Fahrenheit. These numbers aren’t really easy to set on an oven and a bit hard for the mind to process at first glance. Let's fix this problem by rounding to the nearest five degrees using PHP’s `round()` function!

## Rounding to the Nearest 5 degrees
PHP’s `round()` function takes a decimal number (a.k.a. floating point number) and rounds up or down. In its most simple and default form, it will round the decimal to the nearest whole number. For example, `round(3.457)` will give you the result `3`.

If you want to keep some of those decimal points, you can add in a precision argument. The default is 0, so without a precision value, `round()` will simply round to the nearest whole number as mentioned above. If you wanted to round the previous example to a precision of 2 decimal points, you would write `round(3.457, 2)` instead, resulting in `3.46`.

So the basic usage goes like this:

```php
round(<number you want to round>, <precision/number of decimal points to round to>)
```

There is also a third argument you can use called the “mode” which will let you control the way the rounding works. For example, do you want the rounding to go towards or away from zero, or to the next even or odd number? Learn more about that in the [PHP Manual](http://php.net/manual/en/function.round.php).

## Rounding to the Nearest 5 degrees

When it comes to oven temperatures, however, we don’t just want to round to the nearest whole number, we want to round to the nearest 5 degrees because these are more likely to be actual temperatures you can set your oven to and are much easier to read. But, if we just do something like `round(204)`, the result is just going to be `204`. How can we get this to round to the nearest 5 degrees?

Here’s the trick: First, divide the number you want to round by 5. Then round it. Last, multiply it by 5 again. This will give you the original number rounded to the nearest multiple of 5.

```php
$celsius = round(204/5) * 5;
print $celsius;

// This will print "205"
```

If you wanted multiples of 10 instead, just take your number and divide by 10, round, and multiply by 10 again.

```php
$celsius = round(204/10) * 10;
print $celsius;

// This will print "200"
```

Let’s see it in action with the temperature conversion list from my [last post](https://dev.to/morinoko/for-loops-in-php-converting-oven-temperatures-414c).

### Converting Celsius to Fahrenheit and Rounding Results
{% replit @morinoko_/RoundingOvenTemperaturesCtoF %}

### Converting Fahrenheit to Celsius and Rounding Results
{% replit @morinoko_/RoundingOvenTemperaturesFtoC %}

There we go! Pretty temperatures that you can actually input into your oven :)
Introducing the system-wide performance analysis tool based on linux!
Tags: linux, kernel, python, perf
Published: 2018-10-28 03:51:13

---
title: Introducing the system-wide performance analysis tool based on linux!
published: true
description: 
tags: #linux #kernel #python #perf
---

Guider is a system-wide performance analysis tool written in python and open-source released to https://github.com/iipeace/guider.
you can analysis your system with it!
if you are interested in Guider then give me your feedback after using it!
I share simple commands for you.
------------------------------------------------------------------------
1. download source as below.
 1. $ git clone https://github.com/iipeace/guider
2. move guider directory
 1. $ cd guider/guider
3. show guider commands as below.
 1. $ ./guider.py -h
 2. $ ./guider.py top -h
 3. $ ./guider.py bgtop -h
 4. $ ./guider.py list -h
4. run guider commands.
 1. $ ./guider.py top
 2. $ ./guider.py bgtop
 3. $ ./guider.py list
 4. $ ./guider.py stop
 5. $ cat /tmp/guider.out OR /var/log/guider.out
 6. $ ./guider.py draw guider.out
5. check graph and chart files. e.g.  https://cloud.githubusercontent.com/assets/15862689/23285445/a03e0bf0-fa74-11e6-9f5a-872a3f10fe48.png
------------------------------------------------------------------------
RESTPie3 - Python REST API Server Starter Kit
Tags: python, rest, flask, postgres
Published: 2018-10-26 19:56:40

---
title: RESTPie3 - Python REST API Server Starter Kit
published: true
description: lightweight api server with the essentials baked in
tags: python, rest, flask, postgresql
---

Hello DEV community! My first post here.

I'm a python veteran and have built many web services with various python frameworks for a long time. In recent years the codebase that I usually start with has stabilized into a coherent set of source files and components that I recently open-sourced.

RESTPie3 is a practical and flexible starter codebase that provides the essential REST service features in a nice package: a master daemon, database, sessions, cache, queues, background workers, authentication, authorization, cron, logging. You can dockerize the service into cloud or simply deploy via rsync into vps. 

RESTPie3 relies on a few solid components such as Flask, uWSGI, PostgreSQL and Redis that have served me well over the years. Nothing that extraordinary in this starter, just a simple and sane way to build a REST service as I see it.

Also there is no front-end in this starter, as it is intended to function as a pure REST server. However, I have also authored sample SPA front-ends in both Vue and React that talk to a REST server. 

Full documentation at Github README. Go and fork.

{% github tomimick/restpie3 %}
How to use git version control
Tags: git, vcs, development, github
Published: 2020-09-12 10:17:26

---
title: How to use git version control
published: true
date: 2018-10-28 00:00:00 UTC
tags: [git, vcs, development, github]
canonical_url: https://mrpowerscripts.com/learn-git/
---

When I first started scripting, my development flow went something like this: Create a script and save it as a file. Make some adjustments I want to test and save it in a new file. Make more adjustments and save it as a new file. Rinse, repeat. I would end up with a folder full of different file versions with different names that all were effectively the same script. 

[How to use git tutorial video](https://www.youtube.com/watch?v=NwQ0M-pyeHQ)

If you’re doing things this way then STOP. Watch the video above and save yourself. After learning to use git I was vastly more effective in terms of speed and organization of my code.

I first encountered git when I join a remote development team. Many people were working on the same code base and my existing practices definitely weren’t viable. They taught me how to use git in my first few weeks. It was a huge challenge. There are so many commands and weird words I’d never used in the process of developing. What is a branch? What the heck does master mean? What’s the point of a SHA? It all seemed really daunting for me.

I realized after some time that git is one of those tools where 99% of the time you’ll use 1% of the features it offers. Even that small portion is enough to completely revamp the way you manage your code. Once you have the basics down you can really appreciate some of the more advanced toolings that are available.

`git bisect` is a great example of this. By breaking all of your code changes into individual orderly commits it helps maintain a clear stream of changes to your code. If many people are working on the same codebase and making lots of changes it can be difficult to figure out when a change was introduced that broke something. `git bisect` is a command that helps you traverse all of the changes to the code very efficiently to identify the precise commit that introduced the change. Even if you’re not familiar with the code or someone else introduced the breaking change.

Modern development is possible because of version control systems, and I think git is a really great place to start for anyone who wants to become a modern developer.
Navigating Between Screens or Activities Using React Navigation Library - Android 
Tags: react, reactnative, android, javascript
Published: 2018-10-27 16:12:55

---
title: Navigating Between Screens or Activities Using React Navigation Library - Android 
published: true
description: Navigating Between Screens or Activities Using React Navigation Library - Android
tags: #react #reactnative #android #javascript
---

Post Link : <a href="https://www.skptricks.com/2018/10/navigating-between-screens-or-activity-in-react-navigation.html"> Navigating Between Screens or Activities Using React Navigation Library - Android </a>

This tutorial explains how to move or navigate from one screen to another using React Navigation Library in react native application. In a web browser, you can link to different pages using an anchor (a) tag. When the user clicks on a link, the URL is pushed to the browser history stack. When the user presses the back button, the browser pops the item from the top of the history stack.
Similarly, React Navigation's stack navigator provides a way for your app to transition between screens and manage navigation history.React Navigation is that React Navigation's stack navigator provides the gestures and animations that you would expect on Android and iOS when navigating between routes in the stack.

<a href="https://www.skptricks.com/2018/10/navigating-between-screens-or-activity-in-react-navigation.html"> Navigating Between Screens or Activities Using React Navigation Library - Android </a>


<img src="https://4.bp.blogspot.com/-B9MF3Fh4MLk/W9SGCQfXp6I/AAAAAAAACEE/8RVlcQsDkoAmLiy1PYhd74zoWHENGI_iACLcBGAs/s640/na.png" />
Why you should reinvent the wheel
Tags: productivity, career, beginners
Published: 2018-10-27 23:27:23

---
title: Why you should reinvent the wheel
published: true
description: Improve yourself by not thinking about new revolutionary ideas
cover_image: https://thepracticaldev.s3.amazonaws.com/i/1kzsc7ag1v0fivg5ui5l.png
tags: meta, productivity, career, beginners
---
Sometimes some people tell to not "reinvent the wheel" by creating things that already exists. It's been time to clarify why we should reinvent the wheel and why they are wrong!

# Learning
The best argument you can say in this situation is that you want to learn. Revolutionary ideas don't come that easy, if you want to learn just do something you would like to do, don't focus on creating new things especially.

You need skills to create your ideas. Get those skills by doing anything that comes in your mind!

# Understanding how something works
Doing something that already exists can make yourself understand how it works and how can it be improved. Things are not perfects but are perfectibles, let's see the smartphone industry for instance.

# You want to do it
You reinvent the wheel? So what? Peoples should not lead you in unwanted situations. Just have fun making things. Doesn't matter if those already exists, at least you'll be happy and that's what matters the most.

# The "wheel" has been improved
The metaphor "don't reinvent the wheel" is so wrong! The wheel, strictly speaking, has been reinvented tons of times. We didn't come with a full rubber wheel in high technology cars in the first try. Things evolves because peoples "reinvent the wheel", and it should continue like that.

![Reinventing the wheel](https://thepracticaldev.s3.amazonaws.com/i/dhedtiyp62p692m59ojy.jpg)



In conclusion, just improve yourself without thinking about making a brand new idea. It's ain't easy to find something that haven't been created yet so don't think too much about it if your only goal is to discover and explore new things.

Ideas comes with discovery. 
Discoveries comes with time.
Why Hacktoberfest is an amazing event!
Tags: hacktoberfest, opensource, beginners
Published: 2018-10-27 22:48:48

---
title: Why Hacktoberfest is an amazing event!
published: true
description: 
tags: #hacktoberfest,#opensource,#beginner
cover_image: https://user-images.githubusercontent.com/121322/45653341-78d1c000-ba8c-11e8-9497-2855130c0634.png
---


I really fancy the idea of contributing to open source projects. But like every year on the non-October months, I am really great at avoiding sitting down and coding a feature for a lib I love. (wondering if that's just me ¯\\_(ツ)_/¯  ) It's not something that I am proud of, but the GitHub contribution grid is great at confirming it.

![contribution grid](https://i.imgur.com/n7z2WpX.png)


Because of that, I am really grateful for the Hacktoberfest event. It's been the third time that it has given me a long needed push to do something for the community. It helped me finally make a pull request for an issue that was months old. Finally, I could create a feature that I could use in my project, feel the thrill of an issue hunt, raise issues that could improve projects. I'm happy that I did it.

 And I am happy that I did it. 

![digital ocean congratulation letter](https://i.imgur.com/BB32XVQ.png)


Big props to DigitalOcean who started it five years ago, and to the many other companies who joined it for the greater good. 
You can look into https://devswag.io/ with tag Hacktoberfest for more companies that have joined this year.



P.s It's is my first post, how did I do?
CTO, Technical Co-Founder
Tags: cto, machinelearning, deeplearning, blockchain
Published: 2018-10-27 21:20:11

---
title: 'CTO, Technical Co-Founder'
published: true
description: 'REKTRA Network searching for Technical Co-Founder with rich technical skills, and vision of REKTRA Project in future.
We searching for CTO who: 
- Manages and monitor the progress of code development and continuously checking it (mostly Golang), 
- Manages projects and cooperate on developing (Blockchain, Machine Learning, Software, and Web Applications). 
- Have a experience with algorithms and models of machine learning (optionally deep learning), 
- Have a experience in Blockchain technology and blockchain architecting, 
- Have a experience with Data Science, 
- Have a experience in algorithmic trading and strategy trading.
REKTRA Network offers a 5-10% of equity (tokens). 
We are open to a remote job.
Apply on [Angel.co](https://angel.co/rektra-network/jobs/444584-cto-technical-co-founder)'

tags: CTO, Machine learning, Deep Learning, Blockchain
---
How a conference can be so rewarding
Tags: beginners, career
Published: 2018-10-27 18:36:33

TL;DR. If you have to travel to go to conferences, try it! At least one time. Save money, if you can, and try it! I think you won't be disappointed. And it's OK to go alone (maybe better: it's easier to talk to strangers.)

Last weekend I went to my first big conferece: NodeConfArg at Buenos Aires. I'm from a city from the north Patagonia where are no meetups and no one is organizing anything, which makes it difficult to find people with the same technical profile.

I went alone. My actual work allowed me to take those days off, but it didn't help me economically in any way. This made imposible to some of my teammates to go, since they have more responsabilities than me, like their house or family. This experience costed me half of my monthly salary.

Please, please, if you have a job like this, update your CV and send it to other places, even if you don't think your expertise/experience is sufficient. I'm doing this right now because I don't want to spend my time in a place that doesn't care about the improvement of their human resources.

Ok, enough ranting. At the NodeConfArg, I could talk to people from other countries like Bolivia, Perú or USA. I could also meet and exchange some words with some speakers (by the way, everyone was super cool). I could also meet an online friend of mine and their teammates from the other extreme of my country. I felt multiple emotions at the same time.

The first day had workshops. I register to two: the first one was about the [dat project](https://datproject.org/), a p2p protocol for the web. It was really _really_ amazing. Both teachers had good charisma and passion about what they were teaching. By the way, here's the repo: https://github.com/geut/dat-workshop

The second and third day had talks only (and an amazing panel). Every talk was fabulous. In total where 20 incredible talks which blown my mind. Mostly everything was new to me. Since I'm not working at scale, and since most of the talks were about optimization, I could learn _a lot_. By the way, it's *OK* to _not_ know about the topics (and maybe even better).

There were talks about iot, communication through sounds (using https://chirp.io/), the use of monorepos, ia and art, inclussion, standards, optimization (a looot), native extensions, tracing and metrics, serverless, p2p and about the state of node+js as a community. A lot of topics.

I'm conscient that I'll implement near nothing about everything I learned right now. But! I can say that _now_ I have curiosity about those topics (so I will start reading about them).

Thank you for reading this!

See you next time!
Bubble Sort in Python
Tags: algorithms, sorting, easy, elim5
Published: 2018-10-27 17:45:38

---
title: Bubble Sort in Python
published: true
description: Easy 
tags: 
- algorithms
- sorting
- easy
- elim5
---


Become a Software Engineer -> Pass Technical Interview -> Be darn good at Data Structure and Algorithms -> Starting with Sorting Algorithms -> 1. Bubble Sort

{% youtube SsJ7_aZjZ2Q %}


Bubble Sort (Decreasing Order)


``` python
def bubblesort(array):
    # we minus 1 because we are always comparing the current value with the next value
    lengthOfArray = len(array) - 1
    # numbe of rounds will be the total length - 1, for array with length 5, we will do 4 rounds: 0 and 1, 1 and 2, 2 and 3, 3 and 4.
    for i in range(lengthOfArray):
        # at each round, we compare the current j with the next value
        for j in range(lengthOfArray - i):
            # only swap their positions if left value < right value as we aim to move all the small values to the back
            if array[j] < array[j + 1]:
                array[j], array[j + 1] = array[j + 1], array[j]

    return array


array = [2, 1, 5, 4, 3]
print bubblesort(array)
```
How to show var_dumps in phpunit or codeception
Tags: php, phpunit, codeception
Published: 2018-10-27 14:56:20

---
title: How to show var_dumps in phpunit or codeception
published: true
description: How to show the output of var_dump from classes used in tests from phpunit or codeception
tags: #php, #phpunit, #codeception
cover_image: https://thepracticaldev.s3.amazonaws.com/i/1513rzz8uy395tdweqbl.jpg
---
if you use [phpunit][1] or [codeception][2] (which uses phpunit under the hood), you sometimes want to see the output of the `vardump()`'s of the class you are testing. per default the output of vardump is supressed.


`MyClassToTest.php`
```
...
public function doSomething()
{
    ...
    var_dump('my var dump');
    ...
}

...

```

`Test.php`
```
public function test()
{
    $myClassToTest = Stub::make('\App\MyClassToTest', ['name' => 'myname']);

    $this->assertEquals('name', $myClassToTest->doSomething());
}
```

```
codecept run unit -vvv
```
does not show the `var_dump` calls


if you add a `ob_flush();` after your var_dump call, the output is shown
```
...
public function doSomething()
{
    ...
    var_dump('my var dump');
    ob_flush();
    ...
}

...
```
alternatively you can use the [symfony var dumper component][3] which output is shown without a `ob_flush()`;

```
...
public function doSomething()
{
    ...
    dump('my var dump');
    ...
}

...
```

you don't need the `-vvv` parameter, the output is still shown.
```
codecept run unit
```

links:
- cover image by Anja Osenberg https://pixabay.com/en/cat-animal-cat-s-eyes-eyes-pet-1285634/

[1]: https://phpunit.de/
[2]: https://codeception.com/
[3]: https://symfony.com/doc/current/components/var_dumper.html