teleren/devto huggingface dataset:
Charming the Python: List Comprehension
Tags: python, beginners
Published: 2019-12-12 14:44:28

*If coding tutorials with math examples are the bane of your existence, keep reading. This series uses relatable examples like dogs and cats.*

---
## List Comprehension
List comprehensions are shorthand ways to make lists from sequences. This is much faster than processing a list via a `for loop`.

List comprehensions alow you to make a list and define it's contents. This quicker than creating an empt list, then populating it.

```python
# syntax
list = [i for i in iterable if expression]
```
```python
dog_letters = [ letter for letter in 'dog' ]
print( dog_letters)
>>> ['d', 'o', 'g']
```

Math example
```python
squares = [number * number for number in range(10)]  # multiplies 0*0, then 1*1, then 2*2, then 3*3...
print(squares)
>>> 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 
```

---
Series based on {% post https://dev.to/asabeneh/30daysofpyton-challenge-43ii %}
Daily Challenge #136 - The Deaf Rats of Hamelin
Tags: challenge
Published: 2019-12-12 14:31:58

---
title: Daily Challenge #136 - The Deaf Rats of Hamelin
published: true
series: Daily Challenge
description: How many deaf rats are there?
tags: challenge
---

*Story*

The Pied Piper has been enlisted to play his magical tune and coax all the rats out of town.

But some of the rats are deaf and are going the wrong way!

How many deaf rats are there?

*Legend*
- `P` = The Pied Piper
- `O~` = Rat going left
- `~O` = Rat going right

*Example*
- ex1 `~O~O~O~O P` has 0 deaf rats
- ex2 `P O~ O~ ~O O~` has 1 deaf rat
- ex3 `~O~O~O~OP~O~OO~` has 2 deaf rats

***
_This challenge comes from dinglemouse on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
day 0
Tags: 100daysofcode
Published: 2019-12-12 14:28:01

bismillahirrahmanirrahim

On 2020/03/21 I hope I will get following certificates of freecodecamp.org

1- Responsive Web Design Certification (300 hours)
2- JavaScript Algorithms and Data Structures Certification (300 hours)
3- Front End Libraries Certification (300 hours)

I have already passed basic html and css in less then two hours.
Creating React Components - different syntaxes
Tags: react, components, syntax
Published: 2019-12-12 14:04:42

# Intro

I would like to show the different ways we can create React Components. I like the `arrow function statement` style the most.

## 1 - Function declaration

```jsx
// Different ways of creating react Components

// 1 - function declaration
import React from 'react'

function Component() {
  return <h1>Hello World</h1>
}

export default Component

```

## 2 - Anonymous function statement
```jsx
// Different ways of creating react Components

// 2 - anonymous function statement
import React from 'react'

const Component = function() {
  return <h1>Hello World</h1>
}

export default Component

```

## 3 - Arrow function statement
```jsx
// Different ways of creating react Components

// 3 - arrow function statement
import React from 'react'

const Component = () => {
  return <h1>Hello World</h1>
}

export default Component

```

## 4 - default export function

```jsx
// Different ways of creating react Components

// 4 - export default function
import React from 'react'

export default () => {
  return <h1>Hello World</h1>
}

```

## 5 - classic component syntax
```jsx
// Different ways of creating react Components

// 5 - classic component syntax
import React from 'react'

class Component extends React.Component {
  render() {
  	return <h1>Hello World</h1>
  }
}

export default Component
```

What is your favorite one, is there a better one than the ones I mentioned here?
Who am I? Me, the name of the currently executing method in C#
Tags: csharp, javascript
Published: 2019-12-12 14:01:48

I have a function in my JavaScript collection which gives me the name of the currently executing function.
```javascript
function CalleeName(a) {
  return a.callee.toString().split(" ")[1].split("(")[0].trim();
}
```
To make it work I have to provide the `arguments` object as the parameter, viz
```javascript
function foo() {
  var me = CalleeName(arguments);
  // ..
}
```
Today I found out how to do the same thing in C#. I find this helpful for logs and status messages.
```csharp
// method version
private static string Me() => new StackTrace().GetFrame(1).GetMethod().Name;

// or property version
private static string Me => new StackTrace().GetFrame(1).GetMethod().Name;
```
That gives the name of the parent of the currently executing method. You may wonder how that helps, but in the context of a C# program, evaluating `Me` returns the name of the method that *called* `Me` which in this case turns out to be the current method.

So running this
```csharp
using System;
using System.Diagnostics;

namespace dotnets
{
    class Program
    {
        private static string Me => new StackTrace().GetFrame(1).GetMethod().Name;

        static void Main(string[] args)
        {
            Console.WriteLine(Me);
            foo();
        }

        static void foo()
        {
            Console.WriteLine(Me);
        }

    }
}
```
displays `Main` then `foo`.
wordpress api with JWT Authentication for WP-API
Tags: wordpress
Published: 2019-12-12 13:10:17

Hello i want implementing wordpress rest api in my nodejs express app.i am using JWT Authentication for WP-API plug in .but i cant not get all users from myapi call. following error i am facing when a call the route:

{code:"rest_no_route"data:Object {status: 404}message:"No route was found matching the URL and request method",}

Code for my rest wp route is following:

var WPAPI = require('wpapi');  var wp = new WPAPI({ endpoint: 'domain.com/wp-json' }); wp.myCustomResource = wp.registerRoute('jwt-auth/v1', '/token',
    { methods: 'POST', params: ['username', 'password'] })
wp.myCustomResource()
    .username('myUserName').password('myPassword')
    .then(res => console.log(res))
    .catch(err => console.error(err))
});

i have already generate token and validate it from postman. i code it from this site "http://wp-api.org/node-wpapi/custom-routes/"

i already edit my .htaccess file and my plugin file( jwt-authentication-for-wp-rest-api/public/class-jwt-auth-public.php) but it does not helped me.

if some one resolve this error kindly help us
Broken Windows
Tags: beginners, codequality, programming
Published: 2019-12-12 13:44:05

---
title: Broken Windows
published: true
description: How the “Broken Window Theory” can relate to our codebases?
tags: beginner, codequality, programming
cover_image: https://res.cloudinary.com/drzgzthur/image/upload/v1576073474/Blog/broken-window.png
---

I recently started reading "The Pragmatic Programmer" by [Andrew Hunt](https://twitter.com/PragmaticAndy) and [David Thomas](https://twitter.com/pragdave). Written 20 years ago, this book surprisingly stays current with its use of analogies and short stories to help the reader develop into a productive programmer. Think of it as the "How to Win Friends & Influence People" for programmers.

One story that stuck with me describes how quickly great code can go rotten.

### Broken Windows

Anyone who has been to a city knows that they are filled with beautiful timeless buildings. But there are also buildings that look like they were left and forgotten, decaying in plain sight.

How do these buildings go from something beautiful to something so ugly? In short, it can stem from a single broken window.

I'll let Andrew and David explain:

> One broken window, left unrepaired for any substantial length of time, instills in the inhabitants of the building a sense of abandonment — a sense that the powers that be don’t care about the building. So another window gets broken. People start littering. Graffiti appears. Serious structural damage begins. In a relatively short space of time, the building becomes damaged beyond the owner’s desire to fix it, and the sense of abandonment becomes reality.

This phenomenon has been studied and coined as "[The Broken Window Theory](https://en.wikipedia.org/wiki/Broken_windows_theory)".

Can you recognize how this "Broken Window Theory" can relate to our codebases?

When we make bad design decisions in our code or notice a function is written incorrectly, do not leave it with the intention to come back later and fix it. Fix it now, or else you'll find yourself looking at a codebase full of broken windows.

Other code maintainers will begin to adhere to the same standard, ignoring code that should be fixed, and they will continue to implement additional sloppy commits. Over time, the general sentiment towards this codebase can best be described as carelessness. There will be no concern about the quality or maintainability. Then, finally your codebase will be unmaintainable and eventually abandoned.

**So fix any broken windows you may come across**. This will cultivate a mindset that the codebase is handled with care and responsibility.

_This post originally appeared on my [personal blog](https://mikeymurph.com/Broken-Windows/). Though there's not much there at the moment, I plan to contribute more to it and back post to dev.to. Thanks for reading!_
Get alphabet position value of a letter [JavaScript]
Tags: javascript, tutorial, beginners
Published: 2019-12-12 13:34:59

a = 1, b = 2 ... z = 26 if we need these decimal values (alphabet position) of a letter. One of the solutions is to use UTF (ASCII) Table.

ASCII table contains the decimal/hex/binary representation of each character (letter, number, symbol ...) of your keyboard.

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

If you see this table 'a' represents 97 number and z represents 122, so alphabet starts at 97 number but we need 1 instead of 97, it's easy, the only thing we need to do is to subtract '96' for each letter representation.

## JavaScript code
In order to get UTF code of a character, we use charCodeAt string function.

chatCodeAt returns UTF 16 decimal representation of one character into a string.

```javascript

'hello'.charCodeAt(1) - 96 // output 5

//This takes only 1 parameter, index of the character we want.
//remember index starts at 0 (first letter = 0, second = 1)
//here we  get 'e' decimal so it returns number 5.
```

## Use case


This is an example of algorithm problem

```javascript
/**
Each letter of a word scores points according to its 
position in the alphabet: a = 1, b = 2, c = 3 etc.

We need the highest scoring word as a string.
If two words score the same, return the word that
appears earliest in the original string.
All letters will be lowercase and all inputs will be valid.

Write a high function which takes a string and returns 
the highest score word

tests:
**/

 assert.equal(high('man i need a taxi up to ubud'), 'taxi');
 assert.equal(high('what time are we climbing up the volcano'), 'volcano'); 
 assert.equal(high('take me to semynak'), 'semynak');  
```
Finally completed #25DaysOfServerless challenge six w/ @GCPcloud Scheduler API. 
Tags: serverless, 25daysofserverless, webdev, node
Published: 2019-12-12 13:30:24

Completed challenge six with **Google Cloud Scheduler API** and **Google Cloud Functions for Firebase**. 
Check out: https://t.co/hRRN2hKy5g

Ps: It would've been nice if GCP provided _Stateful Serverless_ and _Durable Functions_ as part of their services.
My Gift To Dev.to :) 
Tags: gift
Published: 2019-12-12 13:29:32

I've Been using Dev For Some Time And i Absolutely Love It! Starting from just a random search "DEVTO" to an amazing platform. I would like to give dev a gift for all the happiness it gave me. So In a few days im making Dev FA! Dev FA is like dev but a little bit different. See You Would Send An email to TGDevSuport@gmail.com and link one of your dev posts. If its good it will be featured! We're building it up using WordPress. 

Some Other Posts That I find Nice Will also be featured! 

So heres how it works. There will be a tab called Featured There Will Be All The Amazing Posts that you make! Including some of my own. also with 15 posts in total. More people who get accepted more posts will be taken out. Easy right?

Sadly It will have a .WordPress in the end. And if you get the https wrong it might show a danger symbol. 

What does Dev FA even mean? Dev FA means Dev Featured Articles.  

If we're lucky we might embed your post. But Thats another story. 

The website is gonna be released soon

Ibrahim From TGD Dev ™
Where do these wires intersect?? Advent of Code 2019 - Day 3
Tags: challenge, adventofcode, javascript, video
Published: 2019-12-12 13:27:42

---
title: Where do these wires intersect?? Advent of Code 2019 - Day 3
published: true
description: JavaScript walkthrough of Advent of Code 2019 (day 3)
tags: challenge, AdventOfCode, javascript, video
series: Advent of Code 2019 in Javascript
---

{% youtube wQveGvjNciA %}
Launching - Tech Podcast 🎤 🎧 📹 for the World! Made with ❤️ in Berlin, Germany 🇩🇪
Tags: javascript, react, csharp, podcast
Published: 2019-12-12 13:19:15

Hello world and Hello Everyone :wave:

<h4>Wow, I am super excited to announce this 😱 </h4>

Winter has come with Darkness and sadness 😰

And in this Winter, I am planning to start a Podcast 🎤 to make the Winter a bit better :heart:

We will go LIVE on Youtube so that every one of you can interact in realtime and ask questions on the go.

[<h3>:point_right: Please SUBSCRIBE to the Youtube Channel here </h3>](https://www.youtube.com/channel/UCy5EgfydCQlVv_AM-FZyYcg)


{% youtube PtaziLK3xZE %}


[<h3> :point_right:Please also LIKE the Facebook Page here</h3>](https://www.facebook.com/the.destro.dev.show/)
Speed vs quality; lessons from functional languages; & advice for new devs
Tags: todayilearned, beginners, programming, codenewbie
Published: 2019-12-12 13:00:14

*TL;DR notes from articles I read today.*

### [Software development speed vs. quality: a tech shop conundrum](http://bit.ly/36mIs7H)

- Achieving both speed and quality together is nearly impossible. A tech shop can operate in speed mode, or quality mode, or somewhere in the middle. 
- Developers, quality engineers, and quality assurance folks, who define their success in terms of quality, are the advocates for it. 
- Executives, product managers, sales & marketing people who are driven by deadlines that impact growth and revenues push for speed.
- Startups and smaller companies often lean towards speed, since they need to be disruptive to succeed.
- Within a single product release schedule, there can be a shift from quality mode early on in development to speed as there is more pressure to deliver. 
- Towards the end of the release cycle, you may need to sacrifice scope to hot deadlines while maintaining quality. 

*[Full post here](http://bit.ly/36mIs7H), 5 mins read*

---

### [Functional lessons learnt](http://bit.ly/358Uj9g)

- Respect the purity of the functions. Keeping your code pure makes it easier to test and overall more predictable. A function is pure when it doesn’t create side effects and only affect the context within the function itself, not outside. 
- Focus on the order of parameters to increase the readability of your code. Go with either horizontal or vertical functions. Avoid mixing them as much as possible. Start by keeping the function heads consistent in the order of parameters.  
- Applying transformations to your data structures and always making sure you return that same data structure can help endlessly pipe your reducers, and achieve vertical functions.
- Keep your data private and your behaviour public. That way, modifying the underlying implementation of your behaviour will never affect the users of your API.

*[Full post here](http://bit.ly/358Uj9g), 11 mins read*

---

### [Practical advice for new software engineers](http://bit.ly/2LEKqbA)

- Get feedback early. While working on a pull request, start with a trivial change just to open it up for discussion. Or offer mockups, whiteboard wireframes or sketches, before you start writing code.
- Thinking out loud can lend enough clarity for the solution to emerge readily.
- Automate your most tedious or more frequently run processes.
- Don’t let writing the perfect abstraction slow you down. 
- Read ahead to get more context when struggling to comprehend code, documentation or technical articles.
- Keep detailed daily/weekly notes of what you worked on, problems you encountered, and how you solved them. 

*[Full post here](http://bit.ly/2LEKqbA), 6 mins read*

---

*[Get these notes directly in your inbox every weekday by signing up for my newsletter, in.snippets().](https://mailchi.mp/appsmith/insnippets?utm_source=devto&utm_medium=post08&utm_campaign=is)*
DevTips: Use early returns to avoid nested conditions
Tags: beginners, tutorial, codenewbie, javascript
Published: 2019-12-12 12:41:10

As a developper, you will encounter some patterns you should identify as [code smells](https://martinfowler.com/bliki/CodeSmell.html). Most of them have well known solutions. Today I want to talk about using early returns to avoid else statements and nested conditions.

Let's take a example. I need to call a server to know if a person already exists in my database. The function that makes the call also return a loading indicator so I can inform the user.

```js
render() {
  const personToLookFor = 'Thierry'
  const [result, loading] = doesPersonExists(personToLookFor)

  if (!loading) {
    let message
    if (result) {
      message = `${personToLookFor} already exists.` 
    } else {
      message = `${personToLookFor} doesn't exist.`
    }
    return message
  } else {
    return 'Loading...'
  }
}
```

As you can see the nested conditions and if/else statements are hard to read. You don't really understand what does this piece of code at first glance. I bet you already run into this pattern before. Let's refactor this a bit to make it more maintainable!

If the call is still pending we can directly quit the function and display the loading indicator.

```js
render() {
  const personToLookFor = 'Thierry'
  const [result, loading] = doesPersonExists(personToLookFor)

  if (loading) return 'Loading...'

  let message
  if (result) {
    message = `${personToLookFor} already exists.` 
  } else {
    message = `${personToLookFor} doesn't exist.`
  }
  return message
}
```

Isn't it a bit clearer? We can also get rid of the else statement by returning directly the message in the if statement.

```js
render() {
  const personToLookFor = 'Thierry'
  const [result, loading] = doesPersonExists(personToLookFor)

  if (loading) return 'Loading...'

  if (result) {
    return `${personToLookFor} already exists.` 
  }
  return `${personToLookFor} doesn't exist.`
}
```

It also removes the necessity to have a message variable. You're set 🙌

Hope it will help you!

<hr />

Feedback is appreciated 🙏 Please tweet me if you have any questions [@YvonnickFrin](https://twitter.com/YvonnickFrin)!
Animated card component in HTML and CSS
Tags: tutorial, beginners, css, webdev
Published: 2019-12-12 12:38:13

In this tutorial, we'll design an animated card using CodyFrame.

Final result:
{% codepen https://codepen.io/codyhouse/pen/OJPNaMR %}

To follow along the tutorial, fork this pen on Codepen:
🕹 [codepen.io/codyhouse/pen/Wqvpmm](https://codepen.io/codyhouse/pen/Wqvpmm)

or download CodyFrame on Github:
- 📦 Framework [github.com/CodyHouse/codyhouse-framework](https://github.com/CodyHouse/codyhouse-framework)
- 🎨 A1 Theme [github.com/CodyHouse/a1-codyframe-theme](https://github.com/CodyHouse/a1-codyframe-theme)

Here's the video tutorial:
{% youtube oewQd6IPajM %}

Originally published at [CodyHouse.co](https://codyhouse.co/tutorials/card)
Finally, Ctrl-Tab in Chrome
Tags: chrome, productivity
Published: 2019-12-12 11:33:24

OK, maybe it's "Finally for me".  But, one of the things I absolutely HATE about Chrome is the `Ctrl-Tab` key behavior.  `Ctrl-Tab` means previous tab/window.  Why doesn't Chrome get this?

Every so often, I abandon Chrome to try and find a better browser.  

* Firefox, great -- but I need certain Chrome extensions and Chrome Store Foxified just doesn't seem to cut it
* Opera -- I was totally converted til it started having issues with a site that Chrome handled fine
* [Brave](https://brave.com/) (the one I'm actually using now) -- looks promising!

But, need that MRU with `Ctrl-Tab`.  Here's how to get it.

`NOTE`: I totally get the dangers of pasting unknown code into your console.  However, I've included the code below.  Review it for yourself


## Step 1:  Install QuicKey

[QuicKey](https://chrome.google.com/webstore/search/quickey?hl=en-US) in the Chrome Webstore

## Step 2: Follow Instructions

Follow [these detailed instructions](https://fwextensions.github.io/QuicKey/ctrl-tab/).  I prefer Option 1 to instantly switch between tabs.

## Enjoy

For reference, here is the code you paste after installing the extension:

```js
chrome.developerPrivate.updateExtensionCommand({
    extensionId: "ldlghkoiihaelfnggonhjnfiabmaficg",
    commandName: "30-toggle-recent-tabs",
    keybinding: "Ctrl+Tab"
});
```

## Bonus

For those who want to key your bookmarks sync'd between browsers, check out [xBrowserSync](https://chrome.google.com/webstore/detail/xbrowsersync/lcbjdhceifofjlpecfpeimnnphbcjgnc?hl=en-US).  So far, I'm impressed...
Unofficial LineageOS 17 brings Android 10 to the Moto G 2013 and Moto G 2014
Tags: xda, news, lineageos, android
Published: 2019-12-12 14:26:58

---
title: Unofficial LineageOS 17 brings Android 10 to the Moto G 2013 and Moto G 2014
published: true
date: 2019-12-12 12:34:58 UTC
tags: XDA,News,LineageOS,Android
canonical_url: https://www.xda-developers.com/unofficial-lineageos-17-brings-android-10-moto-g-2013-moto-g-2014/
---

With the launch of the [Moto G](https://forum.xda-developers.com/moto-g) series back in 2013, Motorola revolutionized the budget smartphone marketplace. While the original Moto G might not seem like much today, back then it was one of the go-to choices for anyone looking for a well-built budget smartphone offering a near-stock Android experience. Even though the Moto G 2013 and its successor, the [Moto G 2014](https://forum.xda-developers.com/moto-g-2014), haven’t aged well over the last few years the devices still have a solid fan following and our forums are filled with constant discussions and third-party development updates for both the devices. In case you have either of the two devices lying around and want to breathe new life into them, then you’d be glad to know that developers have managed to port an unofficial build of [LineageOS](https://www.xda-developers.com/tag/lineageos/) 17 for the devices.

**[Moto G (2013) XDA Forums](https://forum.xda-developers.com/moto-g) || [Moto G (2014) XDA Forums](https://forum.xda-developers.com/moto-g-2014)**

For the unaware, LineageOS is one of the most popular, community-built third-party ROM for Andriod devices and its latest version — LineageOS 17 — is based on Android 10. We’ve previously seen unofficial LineageOS 17 builds for several older [devices like the LG G2](https://www.xda-developers.com/asus-zenfone-6-asus-zenfone-5z-oneplus-6-oneplus-6t-lg-g2-android-10-custom-rom/), [Realme 3 Pro, Lenovo ZUK Z1](https://www.xda-developers.com/android-10-ports-realme-3-pro-galaxy-s7-mi-a2-lite-zuk-z1-sony-xperia-xa2/), and more. But the Moto G 2013 and Moto G 2014 are among the oldest devices to be upgraded to Android 10 with an unofficial LineageOS port. You can download the LineageOS 17 ports for these devices from the links below and enjoy all the new features Google released in Android 10 on your phone.

**[Download Unofficial LineageOS 17 for the Moto G (2013)](https://forum.xda-developers.com/moto-g/development/rom-lineageos-17-0-t4018259)**

**[Download Unofficial LineageOS 17 for the Moto G (2014)](https://forum.xda-developers.com/moto-g-2014/orig-development/rom-lineageos-17-0-t3997639)**

The post [Unofficial LineageOS 17 brings Android 10 to the Moto G 2013 and Moto G 2014](https://www.xda-developers.com/unofficial-lineageos-17-brings-android-10-moto-g-2013-moto-g-2014/) appeared first on [xda-developers](https://www.xda-developers.com).