teleren/devto huggingface dataset:
Bitcoin price ticker in Gnome desktop
Tags: python, bitcoin, gnome
Published: 2019-10-13 17:16:13

Linux is very extensible. You can change almost anything in the system. Are you using the gnome desktop and interested in crypto?

<img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fzdnet2.cbsistatic.com%2Fhub%2Fi%2Fr%2F2017%2F04%2F05%2F57e3026e-94a0-4eb3-a602-30f40d2b60a8%2Fresize%2F770xauto%2F562a1edcfdbd07cf220a7b0053e7c1a1%2Fubuntu-unity.jpg&f=1&nofb=1" alt="gnome desktop">

Why Gnome? Gnome is the default desktop on <a href="https://ubuntu.com">Ubuntu</a>, <a href="https://debian.org">Debian</a>, <a href="https://opensuse.org">OpenSUSE</a> and others.

You can create a gnome extension with argos, using <a href="http://pythonbasics.org">Python</a>. You can create a price ticket for bitcoin. But with a price ticker, it needs to update automatically.

![gnome extension](https://thepracticaldev.s3.amazonaws.com/i/b1b9cedbkdgu97r9otry.png)

How do you do that? 

You can name the file like this:

    NAME.POSITION.TIME.EXTENSION

For instance

    hello.1r.60s.py

Argos will rerun the plugin every 60 seconds.

## Get price

To get the price, you can use the requests module and parse JSON data. There are many APIs available for the bitcoin price like kraken, bitstamp and others. We'll use coinmarketcap

    #!/usr/bin/env python
    
    import re
    from gi.repository import Gio
    from datetime import datetime
    
    import time
    import json
    import requests
    
    def coin():
        data = requests.get('https://api.coinmarketcap.com/v1/ticker/bitcoin/')
        price = data.json()[0]['price_usd']
        btc_price = float(("{0:.2f}").format(float(price))) 
        return btc_price

    usd = float(coin())
    lastupdate = datetime.now().strftime('%H:%M:%S')
    
    #print("Bitcoin $" + str(usd) + " (" + str(lastupdate) + ") | n 
    #iconName=invest-applet")
    print("Bitcoin $" + str(usd) + " | iconName=invest-applet")
    print("---")
    #print("Kraken: $" + str(usd) + " | iconName=gedit bash=gedit  terminal=false")
    print("---")

Now save it as bitcoin.1r.60s.py and it will update the price every 60 seconds. There's a lastupdate variable in the code which you can use, or fork it to create your own clock :P

**Resources:**
* <a href="https://extensions.gnome.org/extension/1176/argos/">Gnome argos plugin</a>
* <a href="https://github.com/p-e-w/argos">Argos documentation</a>
* <a href="https://pythonbasics.org">Learn Python programming</a>
Machine learning para proyectos de seguridad(pycon)
Tags: machinelearning, cybersecurity, python, sklearn
Published: 2019-10-13 16:49:16

---
title: Machine learning para proyectos de seguridad(pycon)
published: true
description:Machine learning para proyectos de seguridad
tags: machine learning,cybersecurity,python,sklearn
---

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

https://speakerdeck.com/jmortega/machine-learning-para-proyectos-de-seguridad-pycon

En esta charla se explicarán los conceptos sobre el machine learning aplicados a la ciberseguridad a través de diferentes casos de uso y ejemplos. Además, se explicarán los principales algoritmos que podemos utilizar para comenzar a desarrollar sistemas de seguridad utilizando distintas técnicas como regresión, árboles de decisión y clustering. Finalmente se mostrará un caso de estudio aplicado a la detección de malware.
My Modal
Tags: codepen, modal, beginners, javascript
Published: 2019-10-13 16:47:11

---
title: My Modal
published: True
tags: codepen, Modal, beginner, javascript
---

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

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

{% codepen https://codepen.io/giandomenico/pen/ZEEQqab %}
⚡ Make Gatsby faster with Preact (1 LOC)
Tags: gatsby, react, preact, performance
Published: 2019-10-13 16:03:58

---
title: ⚡ Make Gatsby faster with Preact (1 LOC)
published: true
description: Make your site faster and better suited for SEO by reducing Javascript with a simple trick
tags: Gatsby, React, Preact, Performance
---

**Note**: I went into more detail on the why for this in my personal blog on the post [Speed up your Gatsby site with 1 line of code 🤯](https://henrique.codes/speed-up-gatsby-site/). There's also a bonus tip there fore further improvements ;)

1. Gatsby uses React as its rendering engine;
1. [Preact](https://preactjs.com) has the same API and is compatible with React, but is significantly smaller;
1. [gatsby-plugin-preact](https://www.gatsbyjs.org/packages/gatsby-plugin-preact/) automatically does the change for you, with no side effects (at least known to me);
1. Simply `yarn add gatsby-plugin-preact preact` and add `'gatsby-plugin-preact'` to your `gatsby-config.js` plugins array;
1. And, voilà, you've got yourself a website with **~100kb less minified JS** (uncompressed, 30.5kb for gzipped), which will load and parse faster, waste less bandwidth and perform better on [Lighthouse](https://developers.google.com/web/tools/lighthouse) scores, leading to better SEO 🎉

Again, for more info on this, refer to the [full post on my blog](https://henrique.codes/speed-up-gatsby-site/) 😉
[git] Keep empty directory by .gitkeep
Tags: git
Published: 2019-10-13 15:52:24

---
title: [git] Keep empty directory by .gitkeep
tags: git
published: true
---

## 🤔 Situation
The repository is like this. The notes directory is empty. How can I keep the empty directory?

```sh
$ tree
.
├── Gemfile
├── Gemfile.lock
├── README.md
├── deleted.enex
├── notes             # <- The empty directory
├── parse.rb
└── parse_to_notable.rb

1 directory, 6 files
```

## 👍 Solution
put an empty file at the directory. `.gitkeep` is popularly used. 

```sh
$ touch notes/.gitkeep
$ ls -A notes/
.gitkeep
```

[like this](https://github.com/n350071/enex-to-markdown/tree/master/notes)

## 🔗 Parent Note
{% link n350071/my-git-note-5259 %}
Kubernetes Self-Healing Reconciliation Loop
Tags: kubernetes, beginners, bitesize
Published: 2019-10-13 15:42:16

---
title: Kubernetes Self-Healing Reconciliation Loop
published: true
description: Kubernetes bitesize series for busy people. No more than 2 min read. Read it while waiting for the coffee to brew. 
tags: kubernetes, beginners, bitesize
cover_image: https://github.com/adipola/my-posts/blob/master/pictures/kubernetes_sun_bitesize.gif?raw=true
series: Kubernetes in Bitesize
---


 **Reconcili WHAT ?!?!**

![](https://media1.tenor.com/images/f731bc793fff63c9f2279164cba1535f/tenor.gif?itemid=4383019)



**Reconciliation** - the action of making one view or belief compatible with another.


Or in a _simpler way_ - maintaining desired state

The deployment desired state is the state we defined in our deployment YAML file. Not sure what it means? have time to spare? Read [here](https://dev.to/adipolak/kubernetes-and-virtual-kubelet-in-a-nutshell-gn4) for example and tutorial.
 
Kubernetes understand it and leverage the controllers to continually check the desired state specified by each resource against the actual state of the cluster. 

Kubernetes later will do any necessary adjustments to keep them in sync. This process is called the __reconciliation loop__. 
Trying to reconcile the actual state with the desired state, forever.

![](https://media1.tenor.com/images/fd0b64bb7d268d0846058a1c39e2999d/tenor.gif?itemid=8921187)

When you first create a Deployment, there is no Pod running, because this is the first time you are creating it. So K8s will start the required Pod immediately. If the Pod was ever to stop, Kubernetes(K8s) will start it again, as long as the Deployment exists.

With creating Deployment, K8d controllers know that the Pod must always be running.  Hence, even if we delete the Pod ourselves, Kubernetes assumes we must probably made a mistake, and starts a new Pod to replace the deleted one.

Reconciliation loop is part of K8s __self healing__ abilities. When something goes wrong, meaning the desired state and the actual state doesn't match, K8s will try to close the gap, forever.

**Until death do them apart...**


![](https://media1.tenor.com/images/c1a25b7744214c9e1550ed66da146870/tenor.gif?itemid=14892304)

K8s will try forever until we either delete the deployment, or its infra fails.



### 💀 Done and want to fully shot down the Deployment? 

Run this:
```bash
kubectl delete all --selector app={app name identifier goes here}
```








### 💡 Want to learn more ? 

__Reconciliation loop__ is a concept that brought to us from the world of __Electronic and system Engineering__. If you are curious to know more about the algorithm and its pros and cons, [read here](https://hackernoon.com/level-triggering-and-reconciliation-in-kubernetes-1f17fe30333d) about Edge and level triggering. 
Another resource for learning K8s are the O'Reilly books, one of them is: [Cloud Native DevOps with Kubernetes](https://www.oreilly.com/library/view/cloud-native-devops/9781492040750/).

**Thank you 🙏**

You are welcome to follow me on [Twitter](https://twitter.com/AdiPolak), happy to take your questions, ideas, and suggestions on topics.
Is anyone else using Apollo and frustrated all the time?
Tags: graphql, discuss
Published: 2019-10-13 15:32:43

My first first experience with Apollo client was a delight. I was connected to my graphql server and up and running in no time. Since then my use cases have become more complex and I find I am always struggling to figure out why the cache hasn't been updated or why my UI didn't rerender. Has anyone else had a similar experience or just me?
Codepen of Flutter
Tags: flutter
Published: 2019-10-13 15:27:35

---
title: Codepen of Flutter
published: true
description: Writing Flutter Code in Browser
tags: flutter
cover_image: https://thepracticaldev.s3.amazonaws.com/i/bt713rlhwq2surruxnku.jpg
---
Ruining Flutter Code in the Browser

Now you can easily run the Flutter Code in Browser

{% youtube _Ycd9Go-JSU %}
The SIMPLEST way to make a pull request 🌲✔️ 
Tags: beginners, webdev, tutorial, hacktoberfest
Published: 2019-10-13 15:24:20

I'm sure many of you have done the following:
1. Google: "How to make make a pull request"
2. Cry when you see the long string of commands that need to be entered and memorised. 
 
*It doesn't need to be that complicated.*

I myself have spent many years using the CLI making many, many mistakes. I just recently moved to GitHub desktop it is so much faster and just an all-round more pleasant experience.


# Step 1 - Install GitHub desktop

Go to https://desktop.github.com/ and download the GitHub desktop. Once downloaded and installed I'd recommend having a little watch of this video to get up to speed with it &mdash; it's definitely worth a watch:

{% youtube 77W2JSL7-r8 %}

# Step 2 - Fork the repository you want to make the pull request to!

Go to the repository &mdash; at the top right of the page, there should be a fork button! 

![Mock housing app](https://i.imgur.com/dVCrU0d.png)

*In this example, I am going to make a pull request to a friend's repository and just update their readme.md*


# Step 3 - Clone the forked repository using GitHub desktop
![Clone the repository](https://i.imgur.com/hHeknRy.png)


![Clone the repo clicking the button](https://i.imgur.com/II1fS9J.png)

# Step 4 - Make and commit your changes

Commit the changes:
![Commit the changes](https://i.imgur.com/ANH1Ekl.png)

Push the changes to your forked repository:
![Push the changes](https://i.imgur.com/Orhd5bF.png)

# Step 5 - Make the pull request!
Go to your forked repo on Github and make sure your changes have been added:

![Forked repo has been updated](https://i.imgur.com/OyowGI2.png)

Click New Pull Request:

![Make the pull request](https://i.imgur.com/CxjUI2T.png)

Check over the changes then click Create Pull Request!

![Make the pull request button](https://i.imgur.com/8CTyX22.png)



# Finally, wait for your beautiful code to be merged!
That's all there is to it, it's very simple and the GitHub desktop tool helps speed up the process &mdash; it also helps in actually understanding what these bloody commands are doing!

I hope this helps, happy hacking!


Thank you, if you like my rambling check out my personal blogging site at https://codeheir.com/

## This blog is sponsored by <a href="https://www.codecanvases.com">Code Canvases</a>

Make your room come alive  with the coolest programming/coding canvases on the market.<a href="https://www.w3schools.com"> codecanvases.com</a> is the number 1 seller for programming prints with 100% exclusively designed canvases. Get them now whilst they're **20% off!!**
![[https://codecanvases.com/](https://codecanvases.com/)](https://cdn.shopify.com/s/files/1/0311/0151/7955/products/jqbr8djyof6ktl8qopmkpvy4_480x480.png?v=1585483987)
Arrow functions, function constructors and generator functions
Tags: javascript
Published: 2019-10-13 15:21:08

---
title: Arrow functions, function constructors and generator functions
published: true
description: A look at different ways to generate functions in Javascript
tags: javascript
---

## A look at different ways to generate functions in Javascript


### Arrow functions (also called lambda functions)
Arrow functions are an ES6 addition to the Javascript standard.

Arrow functions have a shorter, more compact syntax than regular functions.

Here is an example of defining a function with the arrow syntax and assigning it to the justSay identifier.

After defining the function we invoke it with an argument to return.

```
// define the function and assign it to an identifier
const justSay = argument => argument;

// call the function
console.log(justSay("Hello")); // => Hello
```

If there is more than one argument, or there are no arguments, we must surround the argument list with parenthesis.

Also, if there's only one expression in the body of the function, we can omit the return statement.

```
const sayAgain = () => "Hello with no argument";

console.log(sayAgain); // => "Hello with no argument"


const sayOnceMore = (greeting, name) => `${greeting}, ${name}`;

console.log(sayOnceMore("Hi", "Mary")); // => "Hi, Mary"
```

Here's an example of an arrow function passed to the `sort()` method of an array to determine the sort order.

As you can see, the syntax is more succinct than the corresponding function written as a function expression.

```
var values = [0, 3, 2, 5, 7, 4, 8, 1];

values.sort((value1, value2) => value1 - value2);
```

Arrow functions are not just a different way to define functions, they also behave differently from functions defined in other ways.

We will explore those differences in future articles.

### Function constructors

Another way to define functions is through function constructors.

Function constructors are not used often, but they allow us to dynamically construct a new function from a string that can also be dynamically generated.
Here's an example of a function constructor.

```
const sum = new Function('a', 'b', 'return a + b');

console.log(sum(10, 45));  // => 55
```

### Generator functions

We will talk about generator functions more deeply in a following article, but for now let’s just say that by using generator functions we can create functions that can be exited and re-entered later in the application execution while keeping the value of their variables across these re-entrances.

We can define generator versions of function declarations, function expressions and function constructors.
Here's a quick example of a generator function:

```
function* myGen() { yield 1; }
```

Tomorrow we will dive deeper into function parameters and arguments, how to use them, and what the difference between parameter and argument is.

We will also talk about the rest parameter and default parameters.
Building Sitesauce: static sites for everyone
Tags: showdev, static, product
Published: 2019-10-25 13:43:49

---
title: Building Sitesauce: static sites for everyone
published: true
date: 2019-10-13 15:14:48 UTC
tags: showdev,static,product
canonical_url: https://miguelpiedrafita.com/announcing-sitesauce/
cover_image: https://miguelpiedrafita.com/content/images/2019/10/brand.png
---

If you follow me on Twitter you have surely seen me tweet about the project, teasing out little details of my "secret project". I've had a lot of fun with cryptic tweets and blurred out screenshots but now that the project has reached a usable state (in fact both this website you're on right now and the Sitesauce landing page are using it) it's finally come time to announce what this thing I've been building since I came back from LaraconEU actually is.

It all started last Christmas when I was looking to move from my Ghost setup to a static-site generator. I had suffered from a server incident that took my website online and was looking for a solution where my online presence didn't depend on a server going down while I was sleeping. I looked around for better options and noticed that a few sites I had on Netlify had a 100% uptime in the last three months and started looking into Netlify and static sites. While my main concern was with uptime, other benefits like almost-instant loading times, incredible scaling or unbreakable security (there's nothing to hack when you're dealing with HTML files) motivated me to make the move. I continued using Ghost as a data-source but switched to Jigsaw.

It took a while to get things where I wanted them to be. I had to rewrite my Ghost theme to a new templating engine, modify some of the Jigsaw core to make it work like I wanted to and manually trigger a new build every time I changed something. It also meant an added layer of complexity, not being able to instantly preview my changes and more things that distracted me from writing, which is why I had been using Ghost in the first place. I ended up getting all the static benefits, but at a high time & complexity cost, so I started thinking about how to make switching simpler.

What I set out to build was a **one-click solution that got rid of all the drawbacks that I had experienced and worked with any platform** , be it Ghost, Wordpress, Statamic, a Laravel-based blog or any other CMS. I worked on it for a few days, but some technical problems with my implementation made me give up. I threw the code on a private repo and forgot about it.

Fast-forward to LaraconEU, where a new Laravel feature (Lazy Collections) and a talk about improving performance gave me some tips on how could I make my implementation work. I then rescued my old code and managed to get a basic prototype working. Since then, I've been hands-down working on fixing edge-cases and building the best experience for everyone using Sitesauce.

I'm incredibly excited to finally share my work with everyone and continue building it in the open. **You can get more information about Sitesauce and sign up for early access** [**here**](https://sitesauce.app)**.**
Quick Tip! Adding Elements to your DOM dynamically
Tags: javascript, beginners
Published: 2019-10-13 15:05:52

I was playing around with p5.js and blizard.js yesterday, trying to create a fun meme project.

I wanted the screen to go wild a few seconds into it running, and add divs all over the place. 

Here is the final [result](https://www.tiktok.com/@bramcodes/video/6747101605105110277?u_code=d7e11hc0e092gh&preview_pb=0&language=en&timestamp=1570932238&utm_campaign=client_share&app=musically&utm_medium=ios&user_id=6719259012707763205&tt_from=messenger&utm_source=messenger&enter_from=h5_m) (**!!headphones warning!!**)



This is the code I ended up with:

```javascript
function goCrazy () {
    hideAll()
    const downTypes = ["down", "DOWN", "dOwN", "dwn"] //[1]
    const upTypes = ["up", "DOWN", "uP", "upp", "UP"]
    const fontSizes = ['16pt', '24pt', '32pt', '8pt', '72pt']
    const colors = ["black", "white", "red"]
    const colorsUp = ["green", "blue", "magenta"]
    
    for (let i = 0; i < 50; i++) {
        setTimeout(() => { // [2]
            let downer = document.createElement("p")
            downer.innerText = downTypes[floor(random() * downTypes.length)]
            downer.style=`font-size: ${fontSizes[floor(random() * fontSizes.length)]}; position: absolute; left: ${floor(random() * 1000)}px; top: ${floor(random() * 600)}px; color: ${colors[floor(random() * colors.length)]}` //[3]
            document.body.appendChild(downer)
        }, i*100)
        setTimeout(() => {
            let upper = document.createElement("p")
            upper.innerText = upTypes[floor(random() * upTypes.length)]
            upper.style=`font-size: ${fontSizes[floor(random() * fontSizes.length)]}; position: absolute; left: ${floor(random() * 1000)}px; top: ${floor(random() * 600)}px; color: ${colorsUp[floor(random() * colorsUp.length)]}`
            document.body.appendChild(upper)
        }, i*100)
        
    }
}
```

[1] - I used arrays to pick from a selection of choices at random
[2] - You can use `let` (not `var`!) to successfully use `setTimeout` in a regular for loop. This [Stack Overflow answer](https://stackoverflow.com/a/31286220/12060701) explains it well
[3] - I struggled with CSS class attaching and ended up creating generated inline styles. I'm not sure how well this scales but it worked for me.
Daily Challenge #90 - One Step at a Time
Tags: challenge
Published: 2019-10-13 14:56:28

---
title: Daily Challenge #90 - One Step at a Time
published: true
series: Daily Challenge
description: Each row of that matrix contains numbers from 1 to 5 (or to whatever length of the matrix), randomly sorted. 
tags: challenge
---

You have a square matrix of unsigned integer values. Say, 5 + 5.
Each row of that matrix contains numbers from 1 to 5 (or to whatever length of the matrix), randomly sorted. 

You can move through the matrix only one step at the time - either straight down, left-down or right-down. 

Your challenge is to write a code that will start at the middle of the top row, and find the path down with the highest sum.

Example:

For the following matrix, you start in c/0. For this matrix the best path would be: `c/0`, `d/1`, `d/2`, `e/3`, `d/4` which scores `4+4+5+4+5 = 22`.  


![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/6td5nmw1gf6kwuqcdfvf.png)

***
_This challenge comes from [peledzohar](<https://dev.to/peledzohar/>) here on DEV._

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_