teleren/devto huggingface dataset:
Deploy a REST API using Serverless, Django and Python
Tags: serverless, django, python, restapi
Published: 2018-08-13 05:18:01

---
title: Deploy a REST API using Serverless, Django and Python
published: true
description: 
tags: serverless, django, Python, rest-api
---

[Deploy a REST API using Serverless, Django and Python](https://serverless.com/blog/django-serverless-framework-a-match-made-in-heaven/)
Add Rounded Corner Borders to TextInput Component in React Native
Tags: react, reactnative, android, mobileapp
Published: 2018-08-13 04:20:19

---
title: Add Rounded Corner Borders to TextInput Component in React Native
published: true
description: Add Rounded Corner Borders to TextInput Component in React Native
tags: #react #reactnative #android #mobileapp
---

Post Link : <a href="https://www.skptricks.com/2018/08/add-rounded-corner-borders-to-textinput-component.html" >Add Rounded Corner Borders to TextInput Component in React Native </a>

This post explains How to display rounded corner border around EditText TextInput component in React Native application. We need to specify borderRadius style-sheet property in TextInput  layout component.

<img src="https://4.bp.blogspot.com/-NgagxHEgmfM/W3EDy_1cVXI/AAAAAAAAByQ/CJ9ccry80aE3VFapZzVK8r3RPeeJvPbWwCLcBGAs/s400/rb.jpg" />

code snippet to set rounded corner border to TextInput Component :
<TextInput
  style={{ height: 40, width: "95%", borderColor: 'gray', borderWidth: 2, borderRadius: 20,  marginBottom: 20, fontSize: 18 }}
  // Adding hint in TextInput using Placeholder option.
  placeholder=" Enter Your First Name"
  // Making the Under line Transparent.
  underlineColorAndroid="transparent"
/>

{% youtube AGT_sv3QrgA %}
I'm Nodejs Backend developer and love it, Ask Me Anything!
Tags: ama
Published: 2018-08-13 03:01:17

---
title: I'm Nodejs Backend developer and love it, Ask Me Anything!
published: true
tags: ama
---


tags: `pinus`, `nestjs` , `pomelo`,`socket.io`.

skills: `mysql`,`redis`,`mongodb`,`win32`,`asm32`,`mfc`,.

languages: `cpp/c`,`lua`,`javascript`,`typescript`.
How i went from making php codes for fun to senior dev
Tags: career
Published: 2018-08-13 02:03:47

---
title: How i went from making php codes for fun to senior dev
published: true
description: this the story of my own career.
tags: career
---

It all started with 'minecraft: pocket edition', yes the mobile version of minecraft. 5 years ago i was playing alot on servers and was wondering how they make all the cool stuff, first i thought we had to do a ton of codes to check even a simple thing but then when i started looking into tutorials it seemed way easier than i thought. In fact, i remember the first ide i downloaded was NetBeans IDE, i was really confused with all the '{}' and ';' stuff because i was basically copying the examples and not learning it. But then after a few tries (actually alot), i found out alone how to write codes just by looking at open source examples on github. After 3 years i got bored of it and i even started making console apps using php (i'd never recommend it to anyone). And then while scrolling thought some facebook group, i found an article talking about how "Go is 1000 times faster than php 5" and that alone was enough to motivate me, the first thing i did was try to find a good book, the best one i could find was "the way to go", i recommend it! it took me a few weeks to finish it because i had school exams but i did finish it, and as soon as i did, i downloaded Jetbrains's IDE for Golang "Goland" and made a complicated program with ui and proxy and it worked just how i expected it, then the second thing i've done was getting hired into a site to re-write the back-end codes from NodeJS to Go (i actually didn't even look at the NodeJS app codes and did just what they told me) and it ended up being super good :D! and then learning Go opened alot of doors for me, i've now learned python, rust, C/C++ and Kotlin.

Also in my opinion, Kotlin, Rust and Go are the languages that anyone must learn because they are the future of programming. (The community say Elixir, Crystal and Nim too but i've not tested them so i can't recommend them).
Contravariance in the real world
Tags: scala, variance, types
Published: 2018-08-12 14:48:54

---
title: "Contravariance in the real world"
published: true
description: "Using simple examples to understand contravariance"
tags: scala, variance, types
---

*Contravariance* hurts the brain! The [definition](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)#Formal_definition) is straightforward, but applying it to the real world doesn’t make much sense. How come `Container[Waste]` be a subtype of `Container[Paper]` when `Paper` is a more specialized type of `Waste`?

The key to understanding *contravariance* is to stop thinking of types in terms of *"is a more specialized type"* and switch the focus to the idea of **acceptance**.

Visualize the following scenario in Scala:

```scala
class Waste
class Paper extends Waste
class Glass extends Waste

class Container[T] {
  //...
}

object Office {
    def setPaperContainer(container: Container[Paper]): Unit = ???

    def setGlassContainer(container: Container[Glass]): Unit = ???
}
```

The `Office` only **accepts** specific types of containers:`Container[Paper]` and `Container[Glass]`. But that’s not practical! What happens, in reality, is to have the same type of container with different colors:

![Waste containers](https://thepracticaldev.s3.amazonaws.com/i/kbgqpvdt51a17433hmj7.jpg)

They are not specialized as the example suggests.

The following expresses better what happens in reality:

```scala
object Office {
  def setPaperContainer(container: Container[Waste]): Unit = ???

  def setGlassContainer(container: Container[Waste]): Unit = ???
}
```

But, what if policies in the office require a particular container for `Paper` that shreds everything? Would it make sense to let `Container` be *covariant*? Could the `Office` **accept** `Container[Waste]`, or any other more specialized type for both `Paper` and `Glass`?

```scala
class Container[+T] { //<---- Covariant
  //...
}

object Office {
  def setPaperContainer(container: Container[Waste]): Unit = ???

  def setGlassContainer(container: Container[Waste]): Unit = ???
}
```

The answer is NO. Otherwise, the `Office` would **accept** a shredder as a `Container[Glass]` and the result would be messy!

So, how to express that a `Container` can be either the basic type or only specialized for a given type? In other words, how to **accept** a `Container[Waste]` and a `Container[Paper]` for `Paper`, and just **accept** a `Container[Waste]` and `Container[Glass]` for `Glass`?

Using *contravariance*!

```scala
class Container[-T] {//<---- Contravariant
  //...
}

object Office {
  def setPaperContainer(container: Container[Paper]): Unit = ???

  def setGlassContainer(container: Container[Glass]): Unit = ???
}
```

By making `Container` *contravariant*, the `Office` **accepts** a `Container[Waste]` for both `Paper` and `Glass`, or a specialized type for each one. And it doesn't **accept** a shredder for `Glass`, or a specialized `Glass` container for `Paper`.

Don't crush glasses in a paper shredder. Use *contravariance*!
Munin plugins for Beanstalkd in PHP are now 1.0.0
Tags: php, munin, observability, beanstalkd
Published: 2020-03-27 10:02:57

---
title: Munin plugins for Beanstalkd in PHP are now 1.0.0
published: true
date: 2018-08-12 19:16:07 UTC
tags: ["php", "munin", "observability", "beanstalkd"]
canonical_url: https://blog.riff.org/2018_08_12_munin_plugins_for_beanstalkd_in_php_are_now_100
---

In 2014, I created a PHP version of the [Munin plugins for Beanstalkd](https://github.com/fgm/beanstalk-munin-php) introduced by AirBnB, but originally created in Python.

Fast forward four years, and after being adapted for compliance with the PHP-FIG PSR1, PSR2 and PSR12 standards, as well as the Zend coding standards, and with extra documentation, I published the first "stable" version 1.0.0 of the package today under the Apache APL-2.0 license.

To use it and ensure observability of your [favorite job queue](http://kr.github.io/beanstalkd/), follow the instructions in the INSTALL.md file. In short, it's just 3 steps:

1. clone the repository
2. install its dependencies with `composer install`
3. symlink the plugins to `/etc/munin/plugins`

That's it, you can now plot command rate, connections, jobs rate, age in queue, queue size by type, and timeouts frequency.

Blog tags:
- [PHP](https://blog.riff.org/topic/computing/php_0) 
- [munin](https://blog.riff.org/taxonomy/term/238)
- [observability](https://blog.riff.org/taxonomy/term/239)
- [php-fig](https://blog.riff.org/tags/phpfig)
Anyone help a young Dev ?
Tags: discuss
Published: 2018-08-12 16:56:37

---
title: Anyone help a young Dev ?
published: true
tags: discuss
---

Hi devs, recently my laptop got spoilt due to a power surge. Anyone has an unused laptop / old laptop to send to me ?. I'm shamelessly asking. Here's my GitHub repo to be sure I'm a developer,
https://GitHub.com/Youngestdev
Ask for feedback: Tech consulting companies
Tags: consulting, career, tech, discuss
Published: 2018-08-12 16:41:43

---
title: Ask for feedback: Tech consulting companies
published: true
description: 
tags: #Consulting #career #Tech #discuss
---

I'm making some research about consulting companies (Tech consulting).

This industry is known to have a very bad reputation for lots of reasons.
Among others:
- The way they treat consultants
- Low salaries
- Type of projects consultants are working on (not interesting missions)
- Not much/No training
- Bad relationship with the manager (who is often a sales person with no tech background at all)

What would be, in your opinion, the perks/processes/code of conduct that a consulting firm should have in order to attract (and keep) good developers ?
Cycles while and for in JS, help me!
Tags: javascript, beginners, help
Published: 2018-08-12 16:34:26

---
title: Cycles while and for in JS, help me!
published: true
description:  I'm learning JS but I have a problem with my code
tags: javascript, beginners, help, 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/aod6ry8kk6z2jdpwa00d.jpg
---

Hi! I'm trying to learn how to draw in Canvas, as an exercise to learn about cycles in JS, the exercise is that we have to use **while** to create a cycle and draw this: 

![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/vzeeu3li0wh73tnwashm.png)

Everything was okay, my code is like this:

```javascript
**var d= document.getElementById("dibujito");**
**var lienzo= d.getContext("2d");**
**var lineas = 30;**
**var l = 0;**
**var yi, xf;**
**var colorcito = "pink";**


**while(l < lineas)**
**{**
 ** yi = 10 * l;**
  **xf = 10 * (l+1);**
  **dibujarLinea(colorcito, 0,yi,xf,300);**
  **console.log("Linea " + l)**
  **l = l + 1;**
**}**


**dibujarLinea(colorcito,299,1,299,299);**
**dibujarLinea(colorcito,1,1,299,1);**
**dibujarLinea(colorcito,1,1,1,299);**
**dibujarLinea(colorcito,1,299,299,299);**

**function dibujarLinea(color,xinicial,yinicial,xfinal,yfinal)**
**{**
  **lienzo.beginPath();**
  **lienzo.strokeStyle = color;**
  **lienzo.moveTo(xinicial,yinicial);**
  **lienzo.lineTo(xfinal,yfinal);**
  **lienzo.stroke();**
  **lienzo.closePath();**
**}**
```

But the problem comes when I have to turn the draw like this with **for**

![Alt text of image](https://thepracticaldev.s3.amazonaws.com/i/ljnikv3f7od044u017uu.png)

I just don't understand how to use **for**, I've already tried to make the code work but I can't, can you explain to me how to make it work? Thanks!

Hugs & Husky love!🐶👩🏻‍💻
BxJS Weekly Episode 23 - javascript news podcast
Tags: javascript, node, podcast, news
Published: 2018-08-12 16:16:27

---
title: BxJS Weekly Episode 23 - javascript news podcast
published: true
description: Listen to the best javascript news of the week in a podcast form
tags: javascript, node, podcast, news
---

Hey dev.to community!

BxJS Weekly Episode 23 is now out! 🚀
Listen to the best javascript news of the week in a podcast form right here.
You can find all the mentioned links [here on github](https://github.com/BuildingXwithJS/bxjs-weekly/blob/master/episodes/Episode-23-2018-08-11.md).

You can also watch or listen to this episode on:
- [YouTube](https://www.youtube.com/watch?v=uysfPwNcTVo)
- [Soundcloud](https://soundcloud.com/bxjsweekly/episode-23-aug-11-2018-javascript-news-podcast)
- [Castbox](https://castbox.fm/episode/BxJS-Weekly-Ep.-23-Aug-11%2C-2018-(javascript-news-podcast)-id1378315-id88422871?country=us)

Any feedback is appreciated 😁

Additional stuff:
- [Twitch channel](https://www.twitch.tv/yamalight)
- [Discord server](https://discord.gg/hnKCXqQ)
- [BxJS Weekly github repo](https://github.com/BuildingXwithJS/bxjs-weekly)

Social media links:
- [Twitter](http://twitter.com/yamalight)
- [Medium](https://medium.com/@yamalight)
- [Github](http://github.com/yamalight)

If you enjoy my content, please consider [supporting me](https://codezen.net/support.html) 😉
How do you write your PHP validator?
Tags: validator, php, programming
Published: 2018-08-12 15:53:47

---
title: How do you write your PHP validator?
published: true
description: 
tags: validator, PHP, programming 
---
I recently started to write an MVC framework in PHP for the better understanding of object-oriented design and how the framework works. Today I was writing a validator for the MVC. I was wondering if there is are better ways to do than what I did. 

Here is my validator class

```php
class Validator{

    private $_errors = [];

    
    public function validate($src, $rules = [] ){

        foreach($src as $item => $item_value){
            if(key_exists($item, $rules)){
                foreach($rules[$item] as $rule => $rule_value){
                   
                    if(is_int($rule))
                         $rule = $rule_value;
                    
                    switch ($rule){
                        case 'required':
                        if(empty($item_value) && $rule_value){
                            $this->addError($item,ucwords($item). ' required');
                        }
                        break;

                        case 'minLen':
                        if(strlen($item_value) < $rule_value){
                            $this->addError($item, ucwords($item). ' should be minimum '.$rule_value. ' characters');
                        }       
                        break;

                        case 'maxLen':
                        if(strlen($item_value) > $rule_value){
                            $this->addError($item, ucwords($item). ' should be maximum '.$rule_value. ' characters');
                        }
                        break;

                        case 'numeric':
                        if(!ctype_digit($item_value) && $rule_value){
                            $this->addError($item, ucwords($item). ' should be numeric');
                        }
                        break;
                        case 'alpha':
                        if(!ctype_alpha($item_value) && $rule_value){
                            $this->addError($item, ucwords($item). ' should be alphabetic characters');
                        }
                    }
                }
            }
        }    
    }

    private function addError($item, $error){
        $this->_errors[$item][] = $error;
    }


    public function error(){
        if(empty($this->_errors)) return false;
        return $this->_errors;
    }
}
```

Now testing the validator. 

```php
$data = ['username' => '', 'password' => 'pass'];
$rules = [
    'username' => ['required', 'minLen' => 6,'maxLen' => 150, 'alpha'],
    'password' => ['required', 'minLen' => 8]
];
$v = new Validator();
$v->validate($data, $rules);
if($v->error()){
    print_r($v->error());
} else{
    echo 'Ok';
}
``` 

Result

```
Array
(
    [username] => Array
        (
            [0] => Username required
            [1] => Username should be minimum 6 characters
            [2] => Username should be alphabetic characters
        )

    [password] => Array
        (
            [0] => Password should be minimum 8 characters
        )

)
```
University site for beginners
Tags: beginners, coding, nu
Published: 2018-08-12 14:55:14

---
title: University site for beginners
published: true
description: NU's site for learning coding
tags: beginner, coding, NU
---

Hello everyone! If you are a beginner, you could use site of Nazarbayev University (NU) to learn C language ---> **http://sst-csci.com/csci151/** 
Everyone can register in this site and start to learn C language. There are training materials, quizzes, and other interesting things.

As I've mentioned in previous post, I am a beginner and in the 1st course. So our curriculum includes studying C, C++, Java, and Python languages. Now I will learn C language. 

Some sites were suggested to learning C++ languages:
**https://acmp.ru** 
**https://informatics.mccme.ru** 
**https://www.hackerrank.com** 
**https://leetcode.com** 

You can also suggest sources of learning C nor C++, nor Java, or Python. It would be great help for me and other people, who study these languages)))

Thank you very much for attention! I hope this information will help you ^_^
I'm 18 and I do systems security, Ask Me Anything!
Tags: ama, security, infosec
Published: 2018-08-12 14:30:46

---
title: I'm 18 and I do systems security, Ask Me Anything!
published: true
tags: ama, security, infosec
---

Hey guys, I'm a systems security engineer at a local startup. I've been into infosec since 8th grade. I'm (obviously) still learning, and gearing towards an OSCP. Ask me anything!
increasing test timeout in jest while debugging
Tags: jesttesting
Published: 2018-08-12 14:12:11

---
title: increasing test timeout in jest while debugging
published: true
description: 
tags: jest testing
---

When debugging code, the script execution takes substantially more time which sometimes leads to very strange errors when an asyc test is failed due to exceeding the time specified in `jest.setTimeout` which causes the next test to execute while the previous test is still running in the background.

Fortunately, we can change the default time using `--setupTestFrameworkScriptFile` option that should point to a file in which we change the timeout:

```js
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 60 * 1000;
```

We can put this file in the home directory and run jest with changed timeouts from anywhere with a little bit of command line magic:

```bash
node --inspect-brk node_modules/.bin/jest --runInBand --setupTestFrameworkScriptFile="${HOME}/test-setup.js"
```

Another cool thing is that if we also have a setup file in our project, both files are used (but values from file given through command line option take precedence).
Have you tried switching it off and on again?
Tags: fun
Published: 2018-08-12 13:54:31

---
title: Have you tried switching it off and on again?
published: true
description: JavaScript dev equivalent of "Have you tried switching it off and on again?"
tags: fun
cover_image: https://thepracticaldev.s3.amazonaws.com/i/wclw4funwpo3zkxtcd75.png
---

I just wanted to share this _insightful_ [comment](https://www.reddit.com/r/reactjs/comments/95e9cc/how_can_i_use_js_instead_of_jsx/e3s41xo) on Reddit.

![reddit comment](https://thepracticaldev.s3.amazonaws.com/i/179aqbvbkpa3rtcs5hcq.png)

I've seen HelpDesk technicians at work asking,  
> "Have you tried switching it off and on again?"

several times a day, thus I bursted into laugher.


Please feel free to share if you think of any others 😉
Setting Border Color of TextInput Component In React Native
Tags: reactnative, android, javascript, react
Published: 2018-08-12 12:15:39

---
title: Setting Border Color of TextInput Component In React Native
published: true
description: Setting Border Color of TextInput Component In React Native
tags: #reactnative #android #javascript #react
---

Post Link : https://www.skptricks.com/2018/08/setting-border-color-of-textinput-component.html

This tutorial explains how to change border color of TextInput Component in react native application. In this demo we have added few style-sheet design property to TextInput layout component, that helps to change border color of text input field.
Here we have specified borderWidth, borderColor property of CSS Stylesheet in TextInput Component.

<img src="https://4.bp.blogspot.com/-VLMhXopVvfs/W3AfDAA0O-I/AAAAAAAABx8/0rwJummWWxYF529vNXFSDMe_kNhPTAz4QCLcBGAs/s400/bc.jpg" />


Code Snippet to change border color of TextInput layout  :
 <TextInput
     style={{ height: 40, width: "95%", borderColor: 'gray', borderWidth: 1,  marginBottom: 20 }}
     // Adding hint in TextInput using Placeholder option.
     placeholder="Enter Your First Name"
    // Making the Under line Transparent.
    underlineColorAndroid="transparent"
 />

<a href="https://www.skptricks.com/2018/08/setting-border-color-of-textinput-component.html" > Download source code </a>
Remove TextInput Component Bottom Underline in React Native
Tags: reactnative, android, javascript, react
Published: 2018-08-12 12:12:40

---
title: Remove TextInput Component Bottom Underline in React Native
published: true
description: Remove TextInput Component Bottom Underline in React Native
tags: #reactnative #android #javascript #react
---

Post Link : https://www.skptricks.com/2018/08/remove-textinput-component-bottom-uderline-in-react-native.html

This tutorial explains How to hide bottom border underline present on TextInput layout component in React Native application.
Text Input component by default comes with base bottom underline, shows just below the Text Input. Sometimes developer needs to remove this line to use custom border. So here we are going to provide complete guide to hide bottom underline of TextInput component.
 underlineColorAndroid Prop would make the under line color as transparent so automatically the underline will be hidden.
underlineColorAndroid="transparent"

<img src="https://2.bp.blogspot.com/-eJ2Lih17rv4/W2_ugA0ZJnI/AAAAAAAABxU/i_0gfvl5Msoi-tX-KVxigqX4v8k4s7qBwCLcBGAs/s400/uder.jpg" />

<a href="https://www.skptricks.com/2018/08/remove-textinput-component-bottom-uderline-in-react-native.html" >Remove underline in inputText in React Native  </a>
Lets follow the below steps to remove bottom underline in TextInput Component in react native application :

Step-1 :  Create a new React Native project.

Step-2 :  Add Platform, StyleSheet, Text, View, TextInput Component in import block.
import { Platform, StyleSheet, Text, View, TextInput } from "react-native";

Step-3 : 
Create TextInput component inside the render block and specify the underlineColorAndroid="transparent" prop inside the TextInput layout, this helps you to hide bottom underline.
{/* TextInput Component helps to accept user inputs via keyboard...*/}
        <TextInput
          style={{ height: 40, width: "95%" }}
          // Adding hint in TextInput using Placeholder option.
          placeholder="Enter Your First Name"
          // Making the Under line Transparent.
          underlineColorAndroid="transparent"
        />