teleren/devto huggingface dataset:
Sort Python Dictionaries by Key or Value
Tags: python, beginners
Published: 2020-01-30 17:03:48

In <a href="https://python.org">Python</a> a dictionary is a <a href="https://pythonbasics.org/dictionary/">key-value mapping</a>. Its a set of key-value pairs, every key has a value.

You can use this to <a href="https://pythonspot.com/python-dictionaries/">receive values using keys</a>. Values in a dictionary can be of any data type. The data in a dictionary is not in any specific order.

This means you can define a dict with key-value pairs like this:

```python
>>> di = { 'five': 5, 'two': 2, 'one': 1 }
>>> di
{'five': 5, 'two': 2, 'one': 1}
>>> 
```

You can call the list method with the dictionary as parameter. This outputs all the keys:

```python
>>> list(di)
['five', 'two', 'one']
```

## Sort dictionary by values

Each pair in a dictionary is a key-value pair. For the dictionary above 'five','two' and 'one' are keys. The values are 1,2,5 and each are mapped. 

To sort a dictionary by values you can use:

```python
>>> sorted(di.values())
[1, 2, 5]
```

## Sort dict by keys

You can sort by keys too:

```python
>>> sorted(di)
['five', 'one', 'two']
```

This is in alphabetic order, 'f' before 'o' and 't'.

## Real world example

You can define a dictionary with months like this:

```python
>>> month = { 'January':1, 'February':2, 'March':3, 'April':4, 'May':5, 'June':6 }
```

Then you can sort by keys or values:

```python
>>> sorted(month)
['April', 'February', 'January', 'June', 'March', 'May']
>>> sorted(month.values())
[1, 2, 3, 4, 5, 6]

```

You can sort in reverse order too:

```python
>>> sorted(month, reverse=True)
['May', 'March', 'June', 'January', 'February', 'April']
```

**Related links:**
* <a href="https://pythonbasics.org/dictionary/">Python dictionary</a>
* <a href="https://wiki.python.org/moin/HowTo/Sorting">More on sorting in Python</a>
* <a href="https://pythonbasics.org">Learn Python</a>
Understanding Constructor and Method Dependency Injection in Laravel
Tags: laravel
Published: 2020-01-30 17:02:07

Hey Artisan , in this tutorial we are going to learn about laravel dependency injection. Dependency injection in laravel 6 example tutorial is going to be discussed briefly in this tutorial.

Dependency injection is commonly used in Laravel. Even access to Request we mostly inject it.When you try to inject an object into your class, Container uses Reflection API to inspect your constructor method and retrieves what you have defined as a dependency.

https://www.codechief.org/article/understanding-constructor-and-method-dependency-injection-in-laravel
Why WordPress is an absolute Gem for Website owners?
Tags: wordpress, webdev
Published: 2020-01-30 16:51:18

"Almost 20% of the site on the Internet is powered by WordPress" Yes, you heard it right, it's such a big number. There are more than 1.74 billion+ website on the Internet and 20% of it is just insane, that sums up like 3480000000+ websites use WordPress as their CMS.

If you are someone who is into Web development then you might be already aware of WordPress. If not, WordPress is one of the best CMS or Content Management System that is available on the planet. The flexibility and customization options are what that makes it different from all other leading CMS like Magneto, Drupal, Joomla, etc



Talking about WordPress, there are two types of WordPress sites, the first one is Wordpress.com websites and the other one is self-hosted WordPress with maximum features and customization options. Both Wordpress.com and self-hosted WordPress is 100% free but if you want more control over your website, I prefer using self-hosted WordPress.

Having said that WordPress is Free, but you need to pay for Hosting and Domain. I believe you are all aware of it already.

Coming to our main topic, Why so many websites are using WordPress and what's special in them. Well, let's check it out.

 - The first reason why a good number of web developers opt to go with WordPress is the insane customization options available. You can customize your website in every nook and corner without any restrictions and further increase the features by using WordPress plugins to extend the functionalities.

 - Easy to set up and maintenance is also simple as a cake piece. Installation is really simple and if your web host supports a Softaculous web installer then you can get WP installed in a single click.

 - Extend functionalities with the help of WordPress Plugins. The official repo of WordPress contains thousands of quality plugins that you can use for different purposes like showing ads, caching, SEO, Page builders and what not.

Even my website <a href="https://ipeeworld.com">IPEE World</a> and famous sites like <a href="https://techcrunch.com">TechCrunch</a> are made with WordPress and it's such a great platform with great capabilities for all website owners out there. Whether you need a simple blog or a complex website for your business, WordPress got you covered!
5 Books About Programming You Should Read
Tags: books, webdev, javascript
Published: 2020-01-30 16:47:55

Initially posted at [efficientuser.com] (https://efficientuser.com/2019/10/15/top-5-books-every-web-developer-should-read/) with ❤️

>So many books, so little time.

One of my mentors said to me, to read a complete book every month. He suggested me to read at least 2 books each month.

One book for technical stuff
One book for non technical stuff
Thanks Uday. It’s a good guidance at the right time in the start of my career.

I took that guidance seriously and started to read books.

I used to track the books I read in good reads website. You can find the list of books in my [goodreads profile.](https://www.goodreads.com/user/show/67612430-pandiyan)

Coming back to the theme of this post.

Here is the list of my favorite books related to web development as well as General professional development.

##The Clean Coder: A Code of Conduct for Professional Programmers
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8fsnslth5o8n3v8bgdom.jpg)
Author: Robert C. Martin

## The Art of Readable Code
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/v4l7i5wrsmq446y6c0cf.jpg)
Author: Dustin Boswell, Trevor Foucher

## Don’t Make Me Think, Revisited: A Common Sense Approach to Web Usability
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/iqvhchaqm9n2kakk6c9j.jpg)
Author: Steve Krug 

## JavaScript: The Good Parts
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/nykas0r30pipinfuuh3h.jpg)
Douglas Crockford

## Even Faster Web Sites
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bozr1l6v4n5vziw36xai.jpg)
Author: Steve Souders

**Disclaimer**: The ordering doesn’t related to quality of book. Its purely sorted based my personal favorite. (Web developer) 

You can start with any of the book. 

Photo by Eliabe Costa on Unsplash

Follow 🍉 the profile for more interesting content in future & Comment 🥑 your favorite book in the comment section below.
Basic Programming Concepts In Desi Way  (Urdu/Hindi)— Part 4 (Data Types)
Tags: codenewbie, beginners, programming, coding
Published: 2020-01-30 16:07:59

---
title: Basic Programming Concepts In Desi Way  (Urdu/Hindi)— Part 4 (Data Types)
published: true
series: Basic Programming Concepts In Desi Way (Urdu/Hindi)
description: Learn the data types with a desi touch
tags: codenewbie, beginners, programming, coding
---

Data Types:
===========

Data Types ko samajhne se pehle apko Variables ka samajhna zarori hai. Behtar hai aap iss series ka [Part 3](https://medium.com/@imfarjad/basic-programming-concepts-in-desi-way-part-3-variables-ba54cad14664) pehle parh lain.

Hum samajhne ke liye Variables ko kapray dhonay ki baltiyaan soch sakte hain. In baltiyon mein hum kapray(data) store karte hain processing ke liye.

Jaisay ke humare kapre mukhtalif kisam ke hota hain issi tarah data bhi mukhtalif kisam ka hota hai. Data ki inn mukhtalif kismo ko hum Data Types kehte hain.

Ab mere jaisa zara bewakoof banda pochay ga ke "Mukhtalif data types ki akhir zarorat kiya hai?"

Iss sawal ka jawab balti ke kapron mein chupa hai. Imagine karein, apke paas mukhtalif tarah ke kapray hain. For example, sweaters, fancy kapray aur cotton (kalaf walay) kapray.

Inn sab mukhtalif kapron ko dhonay ke tarikay bhi aik dosre se farq hain. Iss liye humein chahiye aik balti mein aik hi kisam ke kapray daalain. Matlab, aik balti mein sirf sweaters, aik mein fancy kapray aur aik balti mein cotton walay kapray.

Bilkul issi tarah aik Variable mein aik kisam(Data Type) ka data store karna hota hai.

For example,

Integer number = 123
String name = "abcd"

Upar diye huwe Variable "number" mein hum sirf Integer data type ka data store kar sakte hain. Issi tarah String data type sirf jumlay (Text or Words) store karne ke liye use ho sakti hai.

Kuch common Data Types yeh hain:

-   Boolean (e.g., True or False)
-   Character (e.g., a)
-   Double (e.g., 1.79769313486232E308)
-   Floating-point number (e.g., 1.234)
-   Integer (e.g., 1234)
-   String (e.g., abcd)
Diff Two Array
Tags: replit, node
Published: 2020-01-30 16:35:26

---
title: Diff Two Array
published: true
tags: replit, nodejs
---

Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. In other words, return the symmetric difference of the two arrays.
function diffArray(arr1, arr2) {
  var odd =  arr1.concat(arr2)
 
  var newArr = odd.filter(function(item){
              return  arr2.indexOf(item) ===-1 || arr1.indexOf(item) ===-1  ;
  });
  
 
  console.log(newArr)
  return newArr;
  // Same, same; but different.
  
 
}

diffArray(["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]);
iffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]) should return an array.
Passed
["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"] should return ["pink wool"].
Passed
["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"] should return an array with one item.
Passed
["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"] should return ["diorite", "pink wool"].
Passed
["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"] should return an array with two items.
Passed
["andesite", "grass", "dirt", "dead shrub"], ["andesite", "grass", "dirt", "dead shrub"] should return [].
Passed
["andesite", "grass", "dirt", "dead shrub"], ["andesite", "grass", "dirt", "dead shrub"] should return an empty array.
Passed
[1, 2, 3, 5], [1, 2, 3, 4, 5] should return [4].
Passed
[1, 2, 3, 5], [1, 2, 3, 4, 5] should return an array with one item.
Passed
[1, "calf", 3, "piglet"], [1, "calf", 3, 4] should return ["piglet", 4].
Passed
[1, "calf", 3, "piglet"], [1, "calf", 3, 4] should return an array with two items.
Passed
[], ["snuffleupagus", "cookie monster", "elmo"] should return ["snuffleupagus", "cookie monster", "elmo"].
Passed
[], ["snuffleupagus", "cookie monster", "elmo"] should return an array with three items.
Passed
[1, "calf", 3, "piglet"], [7, "filly"] should return [1, "calf", 3, "piglet", 7, "filly"].
Passed
[1, "calf", 3, "piglet"], [7, "filly"] should return an array with six items.



{% replit @oscarhernandez6/Diff-Two-Arrays %}
Hide the exported ENV variables from the history
Tags: linux, bash, ubuntu, webdev
Published: 2020-01-30 16:33:44

Hi, happy to join your community. This is my first post, so I start from the simple one, but useful. Maybe you don't know about it yet.

When you work with the Linux server, sometimes you export some environment variables. Some envs can be neutral like *NODE_ENV=production* or something else, but sometimes it must be safe like *GITHUB_API_KEY* or *MYSQL_PASSWORD*.

The problem is if anyone accesses the server bash and enters the **history** command it will see the secrets:

```bash
...
1989  export MYSQL_PASSWORD=my_secret_mysql_password
...
2000  history
```

To be safe, before working with the bash, export Linux history control environment variable which is called *HISTCONTROL*.

```bash
$ export HISTCONTROL=ignorespace
```

**ignorespace** means that if you leave the space before any bash command, it will be ignored in history.

So while exporting the secret environment variable, enter the space before *export*

```bash
$ export HISTCONTROL=ignorespace
# keep in mind space before export
$  export MYSQL_PASSWORD=my_secret_mysql_password
$ history
```

So now, the Mysql password will be ignored in history

```bash
...
1999  export HISTCONTROL=ignorespace
2000  history
```

This method is not only for environment variables, but it can also hide any bash command, even *export HISTCONTROL=ignorespace* itself.


Good luck and be safe! :)
Save yourself from burnouts in DevRel
Tags: devrel, marketing, podcast, mentalhealth
Published: 2020-01-30 16:26:21

Trick question of the week:
_How can you lead a healthy community when you are not feeling healthy?_

Burnouts are -unfortunately- a common theme in the Tech industry and in DevRel.
Why?
Because of our empathy. According to Anjuan and Aneika Simmons who join us for this episode, burnout is the result of chronic stress.  As Anjuan puts it: "in DevRel you work with many developers that are under stress and because you care, this stress is projected back at you.".

In this episode, we discuss stress and burnouts in developer marketing and:

* Early signs of burnout
* How to recover from a burnout
* How to make yourself, and your community and team, more burnout-resistant

**A hot episode about saying healthy and helping your community grow without burning out.**

[Listen to the episode here.] (https://www.developermarketingpodcast.com/) 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jrtx8q9nsyre4n6dpf23.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/oynqtfognh97pdeuanf2.png)


**Anjuan Simmons** is a technologist with a successful track record of delivering technology solutions from the user interface to the database. He combines his experiences working at Big 4 management consulting companies as well as small technology startups to implement practical solutions that can be understood and scaled across organizations.

**Aneika Simmons** is a Full Professor of Management at Sam Houston State University who specializes in organizational behavior, human resources, leadership development, team dynamics, interpersonal relationships, and principles of management.
The last functional programming post
Tags: functional, career
Published: 2020-01-30 13:32:52

In the last few years, we have seen lots of buzz around functional programming.
There is a new post every day, each reminding us of the same old stuff, functions, purity, no side effects, referential transparency...
By now I hope that everyone with at least a little experience in the business knows the basics of functional programming.

####**So where is the magic?**

Functional programming is more than a few snippets of code, like every other paradigm it is based on concepts, and usually, mastering the concepts gives us transferable skills, and that's what we should be aiming for.
So, instead of showing you how you can use map, filter or reduce to achieve something, I'll explain to you why.
Functional programming has a few unique concepts that we all know, like the ones stated above (functions, purity, no side effects, referential transparency).

####**Why use functional programming?**

Short answer, multi-threading.
Our computers have become very fast in the last few years and we cannot increase their speed a lot. This gives us one answer, increase the cores so we can have more working force.

####**How does functional programming solve this?**

It doesn't, it helps the programmer deal with this, because if we had a functional project running on 1 thread it would be the same as running on 10, remember no side effects, referential transparency, so it's safe.
On the other hand, the majority of the codebases have a lot of side effects which causes programmers a lot of trouble to use multi-threading.

####**How do we work with a world of pure programming?**

We don't.
We need I/O and we need to have different states.
If we have none of that, then we get a heating machine instead of a computer.
The question instead should be how do we approach I/O and state?
Regarding I/O we must encapsulate it in functions with good names that explicitly shows us that we are dealing with impurity.
Regarding state, all of us should be using event sourcing so we never lose data and always can retrieve a state at any point in time.

####**Bonus**

Our brain processes everything sequentially making functional programming and declarative syntax anti-natural.
We must approach declarative syntax by shifting our mindset to one where we try to understand how do we accomplish our goals.

Example: map transforms a sequence. 
In imperative syntax, we should see a for loop iterating and transforming the sequence. 
In declarative syntax, we have a map, a function we know will transform a sequence, so we give it a sequence and a function that tells it how to transform each element.

###**Conclusion**

Functional programming is a lot more than most of the posts about it, I am still and will always be learning it.
But remember that the best learning approach is by investing in transferrable skills instead of a language or framework.
Basic Programming Concepts In Desi Way (Urdu/Hindi) — Part 6 (Operators)
Tags: codenewbie, beginners, programming, coding
Published: 2020-01-30 16:19:02

---
title: Basic Programming Concepts In Desi Way (Urdu/Hindi) — Part 6 (Operators)
published: true
series: Basic Programming Concepts In Desi Way (Urdu/Hindi)
description: Try to understand Operators in desi way
tags: codenewbie, beginners, programming, coding
---

Jis tarah hum mathematics mein plus(+) aur minus(-) ke signs istemal karte takay humein pata chal sakey ke hum do values ko add karna hai ya subtract. Same issi tarah hum programming mein bhi signs istemal karte hain different processes ko identify karne ke liye, inn signs ko "Operators" kaha jata hai.

Mostly, basic operators sab programming languages mein common hain.

![](https://miro.medium.com/max/1303/1*ZdeSPnYCcGzyFQPVpEsbQw.png)
Basic Programming Concepts In Desi Way (Urdu/Hindi) — Part 5 (Keywords)
Tags: codenewbie, beginners, programming, coding
Published: 2020-01-30 16:16:09

---
title: Basic Programming Concepts In Desi Way (Urdu/Hindi) — Part 5 (Keywords)
published: true
series: Basic Programming Concepts In Desi Way (Urdu/Hindi)
description: Lets meet the keywords in a desi way
tags: codenewbie, beginners, programming, coding
---

Keywords:
=========

Keywords ka topic iss programming series ka sabse asaan topic hai. Keywords kafi hadd tak [Syntax](https://medium.com/@imfarjad/basic-programming-concepts-in-desi-way-part-2-syntax-1a208a1a55a) ke blog mein cover ho gaye hain. Lekin kuch important points reh gaye thay jinka batana zarori hai.

Sabse pehle dekhte hain ke akhir Keyword hai kya cheez. Har programming language mein kuch special lafz hain jo uske different processes or functionality ko identify karte hain.

For example:

if ( $age >= 18 )
{
echo "You can vote";
}

Iss example mein "if" aik keyword hain. Jab bhi hum kisi program mein "if" istemal karein gay, toh computer expect kare ga ke iske baad aik condition aaye gi jisko calculate karke faisla karna hai ke woh Sahi(True) hai ya Nahi(False).

Keywords ko hum [Variable](https://imfarjad.blogspot.com/2019/06/basic-programming-concepts-desi-way-part-3.html) names mein use nahi kar sakte, kyunke iske computer confuse ho jata hai ke aap asal mein kaunsa kaam perform karna chahte hain.

Sab programming languages ke kuch Keywords same hain aur kuch different.

C Programming Language Keywords:
--------------------------------

if, int, double, float, else, long, switch, static, while, for.

Java Programming Language Keywords:
-----------------------------------

> if, int, new, abstract, else, this, super, static, while, for.

Umeed hai ke Keywords ke baray mein apka concept clear ho gaya hoga. Agar koi confusion hai ya aur explanation chahiye, toh aap mujhe apne sawal send kar sakte hain.
New getting started with React Native docs!
Tags: gettingstarted, reactnative, react, documentation
Published: 2020-01-30 16:05:46

---
title: New getting started with React Native docs!
published: true
description: React Native team just launched some new docs for folks getting started on their journey to mobile development with React
tags: getting started, react native, react, documentation
---

I'm pleased to announce my first major contribution to React Native—new introductory docs to help folks start their mobile development journey with React!

- How to use the docs: https://facebook.github.io/react-native/docs/next/getting-started
- Native & Core Components (with illustrations): https://facebook.github.io/react-native/docs/next/intro-react-native-components
- And a handy intro to React core concepts: https://facebook.github.io/react-native/docs/next/intro-react

Any feedback? I'm all ears!

---

Special thanks to Eli White, Dan Abramov, Christoph Nakazawa, Nader Dabit, Lorenzo, and Brent Vatne for their feedback and editorial assistance along the way and Kirsty Simmonds and Aasmund Eldhuset for proofreading and playtesting. And thanks of course to the countless contributors and community organizers who make React Native what it is today!
Basic Programming Concepts In Desi Way  (Urdu/Hindi)— Part 2 (Syntax)
Tags: codenewbie, beginners, programming, coding
Published: 2020-01-30 15:48:50

---
title: Basic Programming Concepts In Desi Way  (Urdu/Hindi)— Part 2 (Syntax)
published: true
description: Lets learn about basic programming syntax
series: Basic Programming Concepts In Desi Way (Urdu/Hindi)
tags: codenewbie, beginners, programming, coding
---

### Basic Syntax:

Programmers kuch lafz buhat istemal karte hain. Un mein se aik lafz **"Syntax"** hai. Asan lafzon mein woh basic zahiri tarteeb jo program likhne ke liye zarori hai.

Dunya ki har zuban ka koi syntax zaror hota hai. Jaisay ke Urdu mein koi jumla bananay ke liye lafzon ko aik khaas tarteeb mein likhna hota hai takay unka koi matlab nikle. Aap **Syntax** ko aik kisam grammer keh sakte hain.

**Example 1:**

***"Babar aik acha aur zaheen larka hai."***
Upar diye gaye jumlay ko ap asani se samajh sakte hain aur iska matlab bhi bilkul saaf hai.

Agar issi jumlay ki tarteeb hum change kar dain toh iska matlab hi samajhna mushkil ho jaye ga.
***"Acha Babar aik hai aur larka zaheen."***

Chalain aik aur Urdu ki misaal laitay hain, hum har jumla khatam karne ke liye nukta(full stop) lagate hain. Issay yeh faida hota hai ke jo koi bhi yeh jumla parhay aur Urdu jaanta ho woh samajh jaye ke kahan jumla khatam ho raha hai.

Bilkul issi tarah Programming mein bhi mukhtalif asool or tareekay hain jo follow karne parhtay hain, aur yeh sab mil kar Syntax kehlatay hain.

**Example 2:**

PHP Programming Language mein line(jumla) khatam karne ke liye **semi-colon (;)** lagana parhta hai. Kyunke humara code computer ne samajhna hota hai aur computer mein pehle se Syntax save hota hai. Woh hamesha line ke end pe **semi-colon (;)** expect kare ga. Aur agar woh miss howa toh error (means, apne koi ghabla kiya hai), dikhaye ga. Asay errors ko hum **Syntax Errors** kehte hain.

Main ab Urdu ka wohi jumla Programming mein likhta hon.

**echo *"Babar aik acha aur zaheen larka hai.";***
Upar wali line mein koi Syntax error nahi.*
***echo *"Babar aik acha aur zaheen larka hai."***
Upar wali line ke end mein semi-colon(;) missing hai, iss liye Syntax error hai.

***Trick Question:***

**echo "Acha Babar aik hai aur larka zaheen.";**

kya upar walay jumlay mein koi syntax error hai ya nahi?

Mujhe pata hai start zara boring huwa hai, lekin agay ke topics interesting hain aur phir real programming bhi shuru hogi toh asal maza aaye ga.

*Picture abhi baki hai mere dost!!*