teleren/devto huggingface dataset:
Shareable CLI demo?
Tags: help, beginners, rust
Published: 2019-09-25 12:26:43

Hi folks!

Over the weekend I was enlisted to produce a proof of concept demo, to pitch as part of a project proposal presentation.  Perfect!

I did so, and they're happy (pleased?) with the result.  The demo I've produced is a CLI application that reads an input file from the filesystem specified at runtime.  It outputs to `stdout` and takes input from `stdin`.  Very barebones demo.  I implemented this program in Rust, and suffices for this purpose.  They are planning to screenshare during the presentation to show off the capability.

However, it would be ideal if there were some way to share this demo easily - they could just provide a URL and get something to play with.

Options I've considered:

1) Refactor into a WASM module, build a very simple JS webapp with DOM elements for inputs and outputs.  I've started doing this, but it's non-trivial.
2) Throw the whole thing on a DigitalOcean droplet and let people ssh to the box.
3) Re-implement the whole thing in JavaScript.

I will not be doing #3, this demo has a total useful life of a single day, and it's not worth the effort.  If the project is picked up, we're starting from scratch.

I did take a stab at #1, but it's not straightforward.  I hadn't anticipated this need, so it's not a completely straightforward refactor to also not break the current `stdout`/`stdin` functionality.  I think this is the nicest option, but it is not simple to produce from my current code in one day.  With a little more time, this is absolutely what I would do, but I don't want to rush it.

That leaves me with #2, but I don't really know how safe or reasonable that is. What I'm thinking is that I'd just pop the compiled executable on a droplet with all the demo input files there ready to go, and then users could log in remotely and execute from there.  Is that horrendous?

Pressure is low - what I've produced to date will be fine, this is a nice-to-have that would be great to deliver.  I've only got this afternoon to pull it together, though, so complexity needs to be low.

How would you solve this problem?

*Aside: one of my first ever billable pieces of work was in Rust and I am just over the moon about that*.

*Photo by Thomas Jensen on Unsplash*
Operator Overloading in R
Tags: r, beginners, syntax, tutorial
Published: 2019-09-25 12:11:40

_Photo by [Adli Wahid](https://unsplash.com/@adliwahid?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/burden?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)_

Although [operator overloading](https://cafe.elharo.com/programming/operator-overloading-considered-harmful/) is generally a [double plus ungood](https://en.wikipedia.org/wiki/Newspeak) idea, it's good to know what a language is capable of, in case you find yourself in need of something in the future.

I recently discovered operator overloading in R.

Most R programmers know how to define a function:

```R
> myfun <- function(x, y) x + y
> myfun(3, 4)
[1] 12
```

But you can also define a function with special symbols in its name, as long as you always surround that function name with backticks:

```R
> `g^h` <- function(x, y) x + y
> `g^h`(3, 4)
[1] 12
```

R also provides the ability to [create _infix_ operators](http://adv-r.had.co.nz/Functions.html) (operators which appear _between_ their two arguments, like `+`). All you need to do is the above, but surround the function name with percent signs, as well:

```R
> `%ytho%` <- function(x, y) x + y
> 3 %ytho% 4
[1] 7
```

As you can see above, when using infix operators, you can drop the backticks. This is precisely how the R pipe operator is defined:

```R
> "%>%" <- function(x,f) do.call(f,list(x))
> sqrt(pi)
[1] 1.772454
> pi %>% sqrt
[1] 1.772454
```

At this point, you might think: "hey, maybe I can redefine `|` to be the pipe operator in R, like it is in most shells". You would be correct:

```R
> "|" <- function(x,f) do.call(f,list(x))
> pi | sqrt
[1] 1.772454
```

But why don't we need percent signs around this function name? It's because you're actually not defining a _new_ function, you're just [_overloading_](https://en.wikipedia.org/wiki/Operator_overloading) an existing one. In this case, it's the [vectorised OR operator](https://www.statmethods.net/management/operators.html).

You can also do silly things like:

```R
> "+" <- function(x, y) x * y
> 3 + 4
[1] 12
> 4 + 5
[1] 20
```

...though I strongly caution against that. (It's confusing and never necessary.)
JavaScript Array - Push/Pop/Shift/Unshift - visual explanation
Published: 2019-09-25 12:06:28

JavaScript array push, pop, shift and unshift with visual explanation.

Push - Add elements to the end of an array (Addition at End)
Pop - Remove an element to the end of an array (Remove at End)

Unshift - Add elements to the start of an array (Addition at Start)
Shift - Remove an element to the start of an array (Remove at Start)

![alt text for accessibility](https://thepracticaldev.s3.amazonaws.com/i/bq5k4b926y1skbykgoq1.png)
Setup Jenkins to autostart after windows restart/reboot
Tags: jenkins, windows, automation, cicd
Published: 2019-09-25 11:57:31

---
title: Setup Jenkins to autostart after windows restart/reboot
published: true
description: 
tags: #Jenkins #Windows #Automation #CI/CD
cover_image: https://thepracticaldev.s3.amazonaws.com/i/omjud895u23hyucwf696.png
---

Hello folks

Recently, I need to setup Jenkins as implementation for automation test on browser on different OS.

One of the problem is that when I restart the master node, the Jenkins is restarted too but almost all of the jobs and builds.

If you met this problem, I have a workaround.

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

Instead of auto run the Jenkins like configuration in jenkins.xml, I run the batch file after the windows restarted automatically.

We will need to do 2 things.

1.Disable the auto run for jenkins in jenkins.xml

jenkins.xml as in my case is located in C:\Program Files (x86)\Jenkins

jenkins.xml file looks like this:


````javascript
<service>
  <id>Jenkins</id>
  <name>Jenkins</name>
  <description>This service runs Jenkins automation server.</description>
  <env name="JENKINS_HOME" value="%BASE%"/>
  <!--
    if you'd like to run Jenkins with a specific version of Java, specify a full path to java.exe.
    The following value assumes that you have java in your PATH.
  -->
  <executable>%BASE%\jre\bin\java</executable>
  <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
```

You need to clear the argument value like this <arguments></arguments>

2.Create the batch file:


In my case it looks like:

````javascript

cd\
cd C:\Program Files (x86)\Jenkins
java -Dhudson.util.ProcessTree.disable="true" -Dhudson.model.DirectoryBrowserSupport.CSP="sandbox allow-scripts; default-src 'none'; img-src 'self' data: ; style-src 'self' 'unsafe-inline' data: ; script-src 'self' 'unsafe-inline' 'unsafe-eval' ;" -jar jenkins.war

```
Open notepad application -> save the file.bat like above

Then put the bat file into startup folder

Click on windows icon -> go to Run -> type shell:startup -> run

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


Put the bat file into that folder.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/29s4ttjjuyy9hoglol46.PNG)

And next time you restarted the windows, jenkins will restart too.

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

I hope this will help you.
Just a quick note to the future.

Notes: If you feel this blog help you and want to show the appreciation, feel free to drop by :

[<img src="https://thepracticaldev.s3.amazonaws.com/i/cno42wb8aik6o9ek1f89.png">](https://www.buymeacoffee.com/dOaeSPv
)

This will help me to contributing more valued contents.
Data affects algorithm performance
Tags: softwaredevelopment
Published: 2019-09-27 08:29:53

---
title: Data affects algorithm performance
published: true
tags: software development
canonical_url: 
---

The title is so obvious that you’re probably wondering why I had to write a blog post about it. I’m also surprised how obvious truths must be repeated in order to comply with them. I’ll explain what inspired me.

### Optimize

Recently I got a task to optimize a piece of software I worked on. This was a part of code I inherited and wasn’t so familiar with. In short, it had to process a list of data input, compute something and save the information to the database. So simple, right? Of course, it had some complicated computation in each iteration, but to my surprise that wasn’t the bottleneck. The bottlneck was in the storing and retrieving data from database. It was done in each iteration because the previous one affected computation of the next one. So a developer before me decided to use the database as a single point of truth and on each iteration he saved the computed data, and retreived it again in the next iteration. For a short while I was angry with this unknown suspect and couldn’t understand why would he do it like that. Then I realized, he couldn’t see the actual slowness of the application because his database was probably almost empty. The actual customer has a lot of data in it, so in each iteration there’s a lot of data to send and retrieve from database. That’s when I got a bit of understanding for the guy, but also reminded myself, next time when I’m trying to write optimal code, have in mind the actual data might affect its performance.
TypeScript. How to add a property to class method?
Tags: typescript, javascript
Published: 2019-09-25 10:54:56

---
title: TypeScript. How to add a property to class method?
published: true
description:
tags: typescript,javascript
---

I have next code:

```typescript

export const getPath = async (from: CurrencyTicker, to: CurrencyTicker): Promise<ExchangePair[]> => {
  const helper = new Helper(from, to);
  const path = await helper.calculatePath()

  return path;
}
getExchangePath.cached = withMemoryCache('exchange-path', CACHE_PAIR_COUNT, ms('5m'), getExchangePath);
```
It works fine, but how can I make same thing with Class?

Something like that

```typescript
class Estimate {
  private readonly helper: Helper;

  constructor(currencyFrom: CurrencyTicker, currencyTo: CurrencyTicker) {
    this.helper = new Helper(currencyFrom, currencyTo);

    // next line throws TS error Property 'cached' does not exist on type '() => Promise<[string, string][]>'
    this.getExchangePath.cached = withMemoryCache('exchange-path', CACHE_PAIR_COUNT, ms('5m'), getExchangePath);
  }

  getPath = async (): Promise<ExchangePair[]> => {
    const path = await this.helper.calculatePath()

    return path;
  }
}

```
Open source contributions (September 2019)
Tags: opensource, developer, github, programming
Published: 2019-09-27 05:09:58

---
title: Open source contributions (September 2019)
published: true
tags: opensource, developer, GitHub, programming
canonical_url: https://roelofjanelsinga.com/articles/open-source-contributions-september-2019
---

![People working together](https://thepracticaldev.s3.amazonaws.com/i/qygo42oi9fqtmm1w3six.jpeg)

# Open source contributions (September 2019)
Last month I've created a blog post mentioning my open-source contributions for august 2019. I found this was a great way to keep track of everything I've learned that month, so I've decided to do the same for September. This month I've been working on 4 packages, 3 of which are completed and could be used by anyone, while one of them is still a proof of concept and is in very early stages.

## The completed packages
The packages below are completed and can be used in any project:

- [roelofjan-elsinga/url-language-extractor](https://github.com/roelofjan-elsinga/url-language-extractor)
- [roelofjan-elsinga/laravel-onesky \*](https://github.com/roelofjan-elsinga/laravel-onesky)
- [roelofjan-elsinga/solarium-luke \*](https://github.com/roelofjan-elsinga/solarium-luke)

The two packages with the asterisk (\*) are forked because the original repository seemed inactive and my proposed changes were required for progression in my projects. This was the first time I forked inactive packages and published them, with my proposed changes, under my own namespace. It was a very interesting experience because I was able to replace the following configuration:

```json
{
  "require": {
    "ageras/laravel-onesky": "dev-master#77e2de4a78bf2172df4129045c40350582aeabdb"
  },
  "repositories":[
    {
      "type": "vcs",
      "url": "https://github.com/roelofjan-elsinga/laravel-onesky"
    }
  ]
}
```

with this:

```json
{
  "require": {
    "roelofjan-elsinga/laravel-onesky": "^1.0"
  }
}
```

That really cleans up the composer.json file for the project.

## The early-stage package

The package below is still in the very early stages of development and shouldn't/can't be used for any project yet. The reason it's already available on GitHub is that I'm trying to formalize the way I'll be generating forms from JSON data. So if you have any thoughts on this, I'd love to hear it.

- [roelofjan-elsinga/flat-file-cms-forms](https://github.com/roelofjan-elsinga/flat-file-cms-forms)

Have you contributed to any open-source projects in September? I'd love to hear what you've been working on (and of course see the code), so let me know on [Twitter](https://twitter.com/RJElsinga).
I made a thing: Javascript Web Starter Projects
Tags: javascript, babel, webpack, react
Published: 2019-09-25 09:56:49

---
title: I made a thing: Javascript Web Starter Projects
published: true
description: Starter projects to help you get going.
tags: javascript, babel, webpack, react
cover_image: https://cdn.vox-cdn.com/thumbor/z7Y0rwLbBA8VwipGFkDiZpKOyas=/0x0:2500x1532/1200x800/filters:focal(1050x566:1450x966)/cdn.vox-cdn.com/uploads/chorus_image/image/63572426/stair1.0.jpg
---
Modern Javascript web development is fantastic, but it can be tricky to get started, especially when getting different technologies to work together.

There are lots of long-form tutorials on the web that explain how to get started with a particular combination of technologies, for example: "[How to set up Webpack with React and Babel](https://www.robinwieruch.de/minimal-react-webpack-babel-setup)". But I usually find these a little frustrating, as they don't cover all the technologies I had in mind, or they cover some technologies I'm not interested in.

So I created a repo on Github with a collection of starter-projects, to be used as a learning aid. Each starter project focuses on minimalism (but usefulness) and *shows how to connect various technologies*.

Here are the goals I tried to stick to:

- Keep projects small, but useful enough to be used as a "starter" template for new projects.
- Project should at the very least render an index.html page and use some Javascript.
- Add lots of code comments to explain technology choices.
- Be specific about package versions of the technologies used.
- Specify an "updated" date, so it's clear how up-to-date a project is.

The projects use a combination of technologies, like ES2018, TypeScript, Babel, WebPack, React, Redux etc. But this isn't an exhaustive list; I imagine many more technologies and combinations of them can be added.

Since there is no particular order or importance to the projects, I decided to name them as "project"-color-animal. So currently the projects have names like: project-navy-cricket and project-neon-gadfly.

As mentioned above, the goal of the overall Github project is to serve as an **additional learning aid** (to be used in conjunction with relevant tutorials on the web), to show how to get going in a very practical way.

Here is the Github repo address: [willemodendaal/javascript-web-starters](https://github.com/willemodendaal/javascript-web-starters)

## On contributing:

If anyone is keen to join in and make life easier for others. Help would be very much appreciated! I'm sure the projects themselves can be simplified, mistakes corrected, or new technology combinations can be added!
How division development applied in tiktok
Published: 2019-09-25 09:32:23

As early as the 2019s, TikTok app makers produced "The division" development logic on the popular Apple 2, a RPG game with God's perspective and pseudo-3D maze adventure. The game and its influential follow-up works, these tiktok web tooltik have been called the three largest RPGs in the development area. Such a hot RPG boom, of course, attracted the attention of Japanese gamer Nishio Ikei. In fact, he is also a big fan of American RPG games. So the game mechanism and world setting of the early Tiktok generation are all from the glittering ideas in "Biography of the Century": the character setting of a protagonist, the labyrinth is also from the perspective of God. And there's a great devil who wants to destroy the world. Moreover, the background of Tiktok development's story is also from the classic Western fable "St. George slaughters the dragon". However, if imitation can make the works sell well, such success is bound to become cheap and short-lived. In fact, the early Tiktok followers apps [instantttfans.club](https://instantttfans.club/) was the first developed game logic to adopt the concept of Da Zuo: the script was personally responsible for Dig Jing Xiong and the human design was handed over to the then "Red Fried Chicken" Yushan Ming (Haven't heard of Tiktok Yim? In terms of publicity, Enix has also invested heavily in advertising in the well-known animation magazine Juvenile JUMP. Such a strong alliance is absolutely a real masterpiece in the Japanese game industry, and the high sales of TikTok's first followers generation of 1.5 million are for this. The best return on investment.
HTML Custom Elements or Web Components
Tags: html, javascript, webdev
Published: 2019-09-25 09:22:04

Greeting Developers...,

I am now creating new HTML elements and reusable web components.I am 17 and I have no idea what to create.But here is a little component what i did.

Updated repo: https://github.com/nayyaung9/custom-web-components

https://github.com/nayyaung9/scale.js

Here is my example component usage

![Example Component](https://thepracticaldev.s3.amazonaws.com/i/358nxax6ykw8iepzl982.png)

![Component result](https://thepracticaldev.s3.amazonaws.com/i/33qy3aputl56u4yd9iap.png)

I want you all to contribute with me...

I wonder how you can give me advice.

Have a nice day...
Let's help us in making our website even better
Tags: webdev, discuss, help
Published: 2019-09-25 09:13:10

---
title: Let's help us in making our website even better
published: true
description: Suggest a few changes that are helpful in making the perfect website.
tags: #webdev #discuss #help
---
We are working on redesigning our website. We want to make it perfect. We need your suggestions.

The link to the current version: https://www.decipherzone.com/

Working on a few changes that are here: https://dev.decipherzone.com/dz/

We would love to get feedback on SEO, design, performance, page speed optimizations, accessibility, and responsiveness. 

Can you help us? Any feedback would be appreciated.

Thanks,
JS objects' example (coffee intensity)
Tags: javascript, objects
Published: 2019-09-25 09:07:20

function intensity(a){
return a+"%";}
//JS objects
var coffee = {
intensity1:intensity(55),
intensity2:intensity(75),
intensity3:intensity(90)  
};

document.write="Coffee is "+coffee.intensity1+" strong"
document.write="Coffee is "+coffee.intensity2+" strong"
document.write="Coffee is "+coffee.intensity3+" strong"
Projetos Brasileiros para fazer pull requests nesse #Hacktoberfest o retorno
Tags: pullrequest, pullrequests, contribuitions, opensource
Published: 2019-09-28 13:56:21

---
title: Projetos Brasileiros para fazer pull requests nesse #Hacktoberfest o retorno
published: true
tags: pull request,pull requests,contribuitions,open-source
canonical_url: "https://jtemporal.com/projetos-brasileiros-para-fazer-pull-requests-nesse-hacktoberfest-o-retorno/"
---

Depois dos sucessos das listas [de 2017](https://medium.com/nossa-coletividad/projetos-brasileiros-para-fazer-pull-requests-nesse-hacktoberfest-4dc9b9b576c0) e [de 2018](https://medium.com/@jessicatemporal/projetos-brasileiros-para-contribuir-nesse-hacktoberfest-vers%C3%A3o-2018-4925959b9411), esse é o terceiro ano que estou fazendo a lista/curadoria de projetos brasileiros para contribuir no #Hacktoberfest.

Vai lá no blog pra conferir uma lista repleta de projetos pra você contribuir nesse mês de Outubro!


[![](https://jtemporal.com/images/clique-aqui-para-ler.png)](https://jtemporal.com/projetos-brasileiros-para-fazer-pull-requests-nesse-hacktoberfest-o-retorno/)
Wordpress workflow in 2019
Tags: wordpress, discuss, help
Published: 2019-09-25 08:03:28

Hi, 

I am new to Wordpress and I study Wordpress through Udemy course and read some articles which are not up to date. 

**Currently I am using**
- No git
- Local by flywheel to create WP project locally
- All in one wp migration to deploy (it will override all things)
- WP Migrate db to update database 
- Ftp or Wordpress file manager plugin to update WP content 

However, I realize that this stack is quite old and I have to do lots of work manually. I want to ask you guys about wordpress workflow in 2019

**Workflow**

**1. Git:**
I am familiar with git but I am not sure how to use it in WP. 
- Should I init git in root of project and use [WP gitignore](https://github.com/github/gitignore/blob/master/WordPress.gitignore) or I init git in wp-content directory?
- Should I ignore plugins

I try to init git in root of project and add gitignore but there are many weird files are tracked by the git and I am not sure if I should ignore them

**2. Webpack**
I am familiar with Webpack since I worked with React. I can easily set up Webpack and Babel to bundle my projects (I set up it in the custom theme). However I am not sure how to optimize WP images. I can see WP has many plugins, [wp-smushit](https://wordpress.org/plugins/wp-smushit/), for that, should I use them or there is a better option. Should I use webpack instead of gulf since I can see that there are many gulp tutorial?

**3. Upload WP content to staging and production**
Currently I use Ftp for that but I know it is the old way. I have to remember which files have been changed then upload them. How can I upload these changed files automatically (when I merge to dev branch for staging and master branch for prodction)? Does it depend on host service because I can see the price is extremely expensive to have that (WPengine ,...)

**4. Push local database to staging and production database**
Since the production database changes constantly (I intend to build Woocommerce web), I cannot use WP migrate pro or All in one migration because it will override the whole db.

Currently, after uploading the wp-content to staging and production, I have to go to production and add page, advanced custom field manually. I can see Advaned custom field has export/import tool, should I use that to push new advaned custom field to production?

If I add a page locally, or add a Advanced custom field. How I push it to production and staging? 

**5. Sync productionDB, stagingDB with local**
In order to keep my local to sync with production, I use WP migrate pro for that because it is no harm to override local DB

**6. What is the difference between wp-sync-db and wp-migrate-pro?**
Thank you guys very much. Could you suggest your development workflow?