teleren/devto huggingface dataset:
Map, reduce and all these stuff
Tags: python, lists, operations, introduction
Published: 2018-12-31 09:16:08

---
title: Map, reduce and all these stuff
published: true 
description: A couple of examples of Map, reduce, filter operations
tags: python, lists, operations, introduction
---

Continuing with a functional approach of python we take a look to the List functions. we will provide a little example for each one of this functions. This functions  are map, reduce and filter.
## Map

Map applies a function to each one of the elements of a sequence

```python
secuence = list(range(0,10))
# secuence = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
f = lambda x: x + 1
map(f, secuence)
# result [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
```

 
## Filter
Filter reduces a secuence depending of a boolean function

```python
secuence = list(range(0, 10))
# secuence = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
f = lambda x: x % 2 == 0
filter(f, secuence)
#result = [0, 2, 4, 6, 8]
```

##Reduce
Reduce,  is a operation that "reduces a list"  apliying an operator

```python
from functools import reduce
secuence = list(range(0, 10))
# secuence = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
f = lambda x, y: x + y
reduce(f,secuence)
# result = 45
# Using initial value, thanks to @magicleon94
reduce(f,secuence, 10)
# result = 55

```
Building a data structure with nothing but functions
Tags: python, fp, datastructures
Published: 2019-01-01 02:00:31

---
title: Building a data structure with nothing but functions
published: true
tags: python, fp, data structures
canonical_url: https://scotchka.github.io/blog/html/2018/12/31/building_a_data_structure_with_nothing_but_functions.html
---

A simple but far reaching consequence of being able to nest functions is that data can be stored in the enclosing scope - or closure - of the inner function. Consider the following function:

```python
def make_node(value, next_node):
    return lambda func: func(value, next_node)
```

When `make_node` is called with two arguments, they are attached to the closure of the returned function. Subsequently, we can access the two arguments via

```python
def value(node):
    return node(lambda value, next_node: value)
```

and

```python
def next_node(node):
    return node(lambda value, next_node: next_node)
```

For example,

```python
>>> node = make_node("head", "tail")
>>> value(node)
'head'
>>> next_node(node)
'tail'
```

With these functions in hand, it is easy to implement a stack as a linked list. We define the usual stack operations

```python
def push(value, stack):
    return make_node(value, stack)
```

and

```python
def pop(stack):
    return value(stack), next_node(stack)
```

The behavior is as expected:

```python
>>> stack = None
>>> stack = push(1, stack)
>>> stack = push(2, stack)
>>> stack = push(3, stack)
>>> val, stack = pop(stack)
>>> val
3
>>> val, stack = pop(stack)
>>> val
2
>>> val, stack = pop(stack)
>>> val
1
```

It is remarkable that this stack does not use any built-in data structure such as an array, nor does it build the linked list by instantiating node objects. Rather, there is a chain of functions wherein each function’s closure contains a value and a reference to the next function.

This discussion was inspired by the classic [Structure and Interpretation of Computer Programs](https://mitpress.mit.edu/sites/default/files/sicp/index.html). In particular, section 2.1 introduces the notion of using closures to build data structures.
You may have missed these hidden DEV gems
Tags: bestofdev, meta
Published: 2018-12-31 07:42:57

---
description: Three awesome posts that may have slipped past your radar
---

There's so much amazing content here at dev.to that sometimes I see a great post get buried by all the _other_ great posts before it has a chance to take off and collect all the unicorn emojis it truly deserves. So, I thought I'd take a minute and boost three awesome, under-emojied articles you may have missed:

## 1) The idea spawner

{% link https://dev.to/thejessleigh/how-to-get-the-most-out-of-dev-4oc1 %}

[Jess Unrein](https://dev.to/thejessleigh) shared some interesting thoughts about what the community might find engaging, which spawned a great discussion. One of [Ben Halpern](https://dev.to/ben)'s comments suggested boosting with the [#bestofdev](https://dev.to/t/bestofdev/) tag, and well... here we are!

## 2) Notably quotable, and quotably notable

{% link https://dev.to/carlymho/the-hardest-thing-is-to-keep-going--27ee %}

I've kept a quote list for many years, organized by author. After reading this article about carrying on, my list officially has a page for [Carly Ho](https://dev.to/carlymho).

> "Keep learning, and try not to lock yourself into the futures you can see yourself in now."

And...

> "[L]ike all hard things, carrying on gets easier with practice."

The whole post is just beautiful.

## 3) +12 for productivity tips

{% link https://dev.to/anaulin/tactics-to-keep-up-your-motivation-42cc %}

As a novelist, I'm always intrigued by the overlap between writing and software development. I'm also a fan of anything that uses RPG modifiers to really drive home a point. [Ana Ulin](https://dev.to/anaulin) wrote a great piece about staying motivated during [National Novel Writing Month](https://nanowrimo.org/), and her advice applies to any long-term project.

---

What about you? Know a hidden dev.to gem? Boost it in the comments below!

---

Was this helpful? Did I save you some time?

## {% cta https://www.adamlombard.com/support-me %} 🫖 Buy Me A Tea! ☕️ {% endcta %}

---
Integrating Pytest Results with GitHub
Tags: python, pytest, github
Published: 2019-07-05 03:36:50

---
title: Integrating Pytest Results with GitHub
published: true
tags: python, pytest, github
canonical_url: https://tryexceptpass.org/article/pytest-github-integration/
cover_image: https://tryexceptpass.org/images/pytest-github-integration/pytest-github-integration.jpg
---

When joining a new engineering team, one of the first things I do is familiarize myself with the dev and test processes. Especially the tools used to enforce them. In the past 5 years or so, I’ve noticed that a lot of organizations still use older tools that haven’t yet evolved to support modern practices. Even teams that purely develop software can find themselves working around cumbersome systems that hinder instead of enable.

What do I mean by that? Very few of these tools include useful interfaces to leverage integrations with other systems (like REST APIs). Most have no concept of modern dev practices like continuous integration or containerization. Almost all of them want to record pass / fail at a step by step basis as if you’re executing manually. The vast majority are built around a separation between test and dev (some even emphasize it). And a lot of them require the organization to hire “specialists” for the purpose of “customizing” the tool to the team. In my opinion, these types of systems coerce the organization to emphasize blame over quality and team boundaries over productivity.

I’ve been very successful at building long-lived alternatives to these systems in several organizations. I’ve done it enough to know which features are worth including, and which to leave to the test / dev engineers, especially after the advent of continuous integration and delivery.

[Read on ...](https://tryexceptpass.org/article/pytest-github-integration/)
Using Multi-stage Dockerfiles
Tags: docker, ruby, systemadministration, containers
Published: 2018-12-31 04:24:36

---
title: Using Multi-stage Dockerfiles
published: true
description: 
tags: docker, ruby, system-administration, containers
---

Docker supports the capability to use the Dockerfile declaration to perform an image build in [multiple steps](https://docs.docker.com/develop/develop-images/multistage-build) called a multi-stage build.

A while ago, I built [a Ruby application](https://vpn-deployer.arcology.io) that provisions and deploys a Docker-based VPN server on DigitalOcean that, itself, runs in a Docker container. Before it ran on Kubernetes, however, I ran it on pre-imaged hosts that had dependencies baked into it, which make spinning up new instances very quick. 

I had the same capability in Docker, to build a base image in an earlier stage (incidentally, using the same CI/CD tooling I used for my base instance images), so when I went to deploy it, I would have those available and not have to perform the entire build at deploy-time. However, initially, I didn't know this, and had a Dockerfile that looked like this:

```dockerfile
FROM ruby:2.2.4

ADD app.rb /app/app.rb
ADD Gemfile /app/Gemfile
ADD views/index.erb /app/views/index.erb
ADD views/confirmation.erb /app/views/confirmation.erb
ADD environment.rb /app/environment.rb
WORKDIR /app
RUN bundle install

ENTRYPOINT ["ruby","app.rb","-o","0.0.0.0"]
```
It got the job done, but took a long time each time I deployed the rebuilt image because of the added steps further down my pipeline each time the image was touched. 

So, I created a base image that only handled installing the Gem dependencies first, as its own step:

```dockerfile
FROM ruby:2.2.4 as rb-base

ADD Gemfile /root/Gemfile
WORKDIR /root
RUN bundle install
```

I will reference resources from this image through the alias I gave it above, `rb-base`, and move on to the image I will end up pushing, so I'll append the following to the Dockerfile:

```dockerfile
FROM ruby:2.2.4 as rb-app
MAINTAINER Joseph D. Marhee <joseph@marhee.me>
WORKDIR /app
COPY --from=rb-base /usr/local/bundle/ /usr/local/bundle/
...
```
to copy the gems I installed in the previous stage, and then proceed with the rest of the application handling:

```dockerfile
...
ADD app.rb /app/app.rb
ADD Gemfile /app/Gemfile
ADD views/index.erb /app/views/index.erb
ADD views/confirmation.erb /app/views/confirmation.erb
ADD environment.rb /app/environment.rb
ENTRYPOINT ["ruby","app.rb","-o","0.0.0.0"]
```
to complete the image I'll ultimately run.

Going forward, unless you need to update your base image (which this allows you to handle as a separate task), you can target the new application only image stage `rb-app` (i.e. in a CI system that builds and pushes to your registry):

```
docker build --target rb-app -t coolregistryusa.biz/jmarhee/app:latest .
```

and make the image available from the registry per usual from there.
Contributors wanted for draftapp.io
Tags: contributorswanted, opensource, webdev, react
Published: 2018-12-31 02:53:00

---
title: Contributors wanted for draftapp.io
published: true
description: Contribution Needed for draftapp.io
cover_image: https://thepracticaldev.s3.amazonaws.com/i/je3ne77h9hz04wou2fc7.png
tags: contributorswanted,opensource,webdev,react
---

Hi,

I was working on a tool to be like Zeplin.io and Invision Inspect but open source and completely free to the awesome community.

Here is the tool: [Draftapp](https://www.draftapp.io), you can register and explore a demo project.

*The current stack is:*

1. Angular 1.5 for frontend
2. Rails 5 for backend
3. Sketch plugin based on the open source plugin [Sketch Measure]( http://utom.design/measure)

So as you can see the frontend is very outdated, and I want some help in re-writing it in React and Webpack.

We can also have an Electron application for Mac and Windows that would be awesome.

I am also starting in re-writing the backend with Golang to be more efficient an performant.

I really hope to provide an open source tool to the community that have all the features the current non open source tools have.

Here is a GitHub organization for [Draftapps](https://github.com/draftapps).
Frontend [Repo](https://github.com/draftapps/frontend): 

Please if you are interested in contribution fill this [form](https://wazery.typeform.com/to/zYPrZl) ;)

![Landing Page](https://thepracticaldev.s3.amazonaws.com/i/hh7w4sxi7er0500ynhsy.png "Landing Page")

![Canvas](https://thepracticaldev.s3.amazonaws.com/i/je3ne77h9hz04wou2fc7.png "Landing Page")
How do you pimp your blog post?
Tags: question, discuss, tips, devto
Published: 2018-12-30 23:12:43

---
title: How do you pimp your blog post?
published: true
description: 
tags: question, discuss, tips, devto
---

I just wrote my first blog post here at dev.to but found it difficult to pimp it with emojis and highlights. 

### How do you add emojis? What other tips do you have to make articles visually pleasing and interesting?
scoped-style
Tags: javascript, css, cssinjs
Published: 2018-12-30 23:12:39

---
title: scoped-style 
published: true
description: a tiny CSS in JS library
tags: javascript, css, cssinjs
canonical_url: https://www.iamdeveloper.com/posts/scoped-style--36n3/
---

{%github https://github.com/sadick254/scoped-style %}

A new kid on the CSS in JS block.

Plays nicely with Preact, React, Hyperapp and InfernoJS.

An example from the readme for React:

```
import React from "react"
import scoped from "scoped-style"

const styled = scoped(React.createElement)


// define global css
styled.global`
  * {
    margin: 0;
  }

  html,
  body {
    width: 100%;
    height: 100%;
  }
`;

// and scoped css
const Button = styled("button")`
  background: ${props => props.primary ? "orange": "gray"};
  border: none;
  border-radius: 2px;
  :hover {
    padding: 10px;
  }
`

const App = () => (
  <div>
    <Button primary>Login</Button>
  </div>
)

// Your rendering code

```
An open source technical interview framework?
Tags: career, discuss, help, interview
Published: 2018-12-30 20:16:39

---
title: An open source technical interview framework?
published: true
description: 
tags: #careers #discuss #help #interviews
---

Hey all,

First off Happy New Year.

Over these holidays I've been reading a bunch of posts and tweets about how technical interviews are broken. As someone who does hiring, I have to agree. It is a sucky situation for all parties. I've been thinking about a OS framework for technical interviews. 

Need some advice if this is a crazy idea or not? I personally think it could be helpful for companies to adopt ideas from the community to make things better and fairer (less bias). While empowering candidates to follow a path which shows their best self!

Still really really early, with some scaffolding.
But here is what I have on the go: https://fdosani.github.io/better-interviews/


Appreciate any comments or suggestions. Thanks!
Overview of JSX components and prop usage with "jsx-info"
Tags: githunt, webdev, react, opensource
Published: 2018-12-30 18:32:40

---
title: Overview of JSX components and prop usage with "jsx-info"
published: true
description: CLI tool that shows an overview of your component props and their usage in a codebase.
tags: githunt, webdev, react, opensource
---

{% youtube e_vtfYJW9aM %}

Very cool tool by [Brian Mock](https://github.com/wavebeem), which shows an overview of your component props and their usage in a codebase:

{% github wavebeem/jsx-info %}

> Let's say you have a component called `<DataTable>` that takes 43 different props. If you needed to rewrite `<DataTable>` from scratch, you might not want to keep as many different props. Using jsx-info you could analyze which props get used the most and start porting that functionality first.
brain.js - Neural networks in JavaScript
Tags: javascript, githunt, neuralnetworks, opensource
Published: 2018-12-30 16:46:38

This is a fairly remarkable project which offers a library of Neural Networks written in JavaScript.

{% github BrainJS/brain.js %}

Here's an example showcasing how to approximate the XOR function from the README:

```javascript
// provide optional config object (or undefined). Defaults shown.
const config = {
    binaryThresh: 0.5,
    hiddenLayers: [3],     // array of ints for the sizes of the hidden layers in the network
    activation: 'sigmoid'  // supported activation types: ['sigmoid', 'relu', 'leaky-relu', 'tanh'],
    leakyReluAlpha: 0.01   // supported for activation type 'leaky-relu'
};

// create a simple feed forward neural network with backpropagation
const net = new brain.NeuralNetwork(config);

net.train([{input: [0, 0], output: [0]},
           {input: [0, 1], output: [1]},
           {input: [1, 0], output: [1]},
           {input: [1, 1], output: [0]}]);

const output = net.run([1, 0]);  // [0.987]
```

It's actively maintained. Definitely worth checking out.

This post is part of the new GitHunt DEV tag. Follow it out for more like this. 

{% tag githunt %}
Event delegation in JavaScript
Tags: javascript
Published: 2018-12-30 14:08:44

---
title: Event delegation in JavaScript
published: true
description: Event delegation in JavaScript
tags: JavaScript
---

I have been making web development videos to help me solidify what I've been learning. This one is about event delegation in JavaScript. How to add one listener to multiple elements.  https://youtu.be/buVEB6TI3VU
Explain async and await of Javascript like I am five.
Tags: javascript, node, webdev, explainlikeimfive
Published: 2018-12-30 13:49:03

---
title: Explain async and await of Javascript like I am five.
published: true
description: Async and await
tags: Javascript,Node.js,webdev,explainlikeimfive
cover_image: https://thepracticaldev.s3.amazonaws.com/i/o365309v639ot5wq0ndt.gif
---
BxJS Weekly Episode 43 - javascript news podcast
Tags: javascript, node, podcast, news
Published: 2018-12-30 12:35:26

---
title: BxJS Weekly Episode 43 - 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 43 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/links/18-52-Episode-43.md).


You can also watch or listen to this episode on:
- [YouTube](https://youtu.be/zTQIOLQTJ38)
- [Castbox](https://castbox.fm/episode/BxJS-Weekly-Ep.-43-Dec-29%2C-2018-(javascript-news-podcast)-id1378315-id115356742?country=us)
- [iTunes](https://itunes.apple.com/de/podcast/bxjs-weekly/id1441956525)

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) 😉
What are your resolutions for 2019?
Tags: discuss, culture, learning
Published: 2018-12-30 08:59:15

---
title: What are your resolutions for 2019?
published: true
description: 
tags: discuss, culture, learning
---

2019 is just around the corner, and this is the time of year a lot of people traditionally set goals.

Personally, I'm going to be chill:

* Complete at least one pet project, like the game I've had on the go for a decade.
* Contribute to at least one other person's pet project.

I think last year I said I'd come up with a good resolution[^1] for this year, so I've kind of done that.

What are your (development-related or not) goals for the upcoming year?

[^1]: 1080P haha yes v. funny
Show Dev: Klip Space - Copy, paste text across multiple devices
Tags: showdev, discuss, productivity, rails
Published: 2018-12-30 07:22:51

---
title: Show Dev: Klip Space - Copy, paste text across multiple devices
published: true
description: Klip Space is the mini side project I have launched. Any feedback is welcome.  
tags: showdev, discuss, productivity, rails
---
Hey Devs

I have launched my side project Klip Space. Any feedback is welcome. 

http://www.klip.space
Are you running on 100%?
Tags: career, help
Published: 2018-12-30 04:17:59

A few years ago I thrilled with motivation to create new things, to iterate on ideas and to move forward. My style included blind jumping into a project and just crashing on many...many problems. For example, I wanted to create a multiplayer shooter game, but that end up in a giant mess. The only outcome was experience. 

Since I got my first contract job I really stop moving forward. And I found impossible to reinvent myself in some other side projects. Well, the only exception was game jam, where you had to create a game in 48 hours. Limited time, no worries and two free days of fun.

The reason I realised that was my friend. The days where I did a routine job, he jumped straight into a new problem and solved it. He is actually driven by that progress and that’s extremely precious. 

Are we running at 100%? Do we even want to? What happened?

For me, the solution would be enhanced time management. Drop unproductive stuff like gaming. Little goals, plan ahead, cooperate with others on other project and track progress on anything. Plus I’m not a morning bird, so waking up early is actually really exhaustive and while I’ve got a sleep deficit, those management tasks are just unreachable.

Sometimes, there are those moments of pure love for programming, in which you are for any project, but these moments were under many conditions. For example, a healthy sleep cycle, no stress and in general just being happy. But who’s always happy. Who’s running always on 100%. 

I guess the image of my friend is a bit foggy since I hear about his work only at his peak. 

The whole depressing idea of getting a job and creating programs or games for somebody else with money being the main drive is just hurting self-reflection.

What do you think what should I do? How was your first job?
TIL: A preceding space prevents dangerous commands from going into history
Tags: webdev, bash, terminal
Published: 2018-12-30 10:39:13

---
title: TIL: A preceding space prevents dangerous commands from going into history
published: true
tags: webdev, bash, terminal
canonical_url: https://www.stefanjudis.com/today-i-learned/a-preceding-space-prevents-dangerous-commands-from-going-into-history/
---

[Assim Hussain shared on Twitter](https://mobile.twitter.com/jawache/status/1078984435356315648) that he executed a dangerous command by mistake. The command was still accessible in his shell history, and he pressed the UP arrow one time too much. 

I have been in that situation, and you may have been, also. 🙈

I like about Twitter that sometimes people reply with useful tips to avoid future mistakes. So did [Philippe Martin](https://mobile.twitter.com/feloy2/status/1078994363693363201). He shared that **commands executed with a preceding space will not go it into the session history.** That sounds great!

```
# command goes into the history
$ delete everything

# command does not go into the history
$  delete everything
```

I tried it right away, but it didn't work. I'm a [Zsh](http://www.zsh.org/) user, and it turns out that you have to enable it via a config in your `.zshrc`.

```
setopt histignorespace
```

In bash, it should work right away (not tested).

There is one thing to mention though. After the execution of a command, every command will be accessible by pressing the UP arrow (this is a feature). Only when you execute another command preceding space command will be inaccessible.

This little trick prevents your future self from executing a dangerous command when pressing the UP arrow one time too much. 🎉