teleren/devto huggingface dataset:
How Unix programmers at restaurants search menus for their favorite plate
Tags: unix, linux, commandline, comedy
Published: 2018-12-13 10:41:49

---
title: How Unix programmers at restaurants search menus for their favorite plate
published: true
description: 
tags: unix, linux, command-line, comedy
---

A Unix programmer heads over to the local diner to get something to eat for lunch. He, or Bob as he prefers, knows better than to manually scan the entire menu with his eyeballs because it's inefficient. Bob knows that there's a better way to automate the process in searching for what he wants to eat.

Last time he was here he had a pretty good pasta-and-shrimp plate for under 10 bucks. 

Bob wonder's if this same dish is still available. He pops open his laptop running Linux and scrapes the restaurant website menu table into a plain text file. 

`menu.txt`

```text
the menu

steak burrito $11.95
pasta and shrimp $9.75
caesar salad $6.50
```

Now that Bob has the menu, he does a `grep` search for the pasta-and-shrimp plate:

```bash
$ cat menu.txt | grep shrimp

pasta and shrimp $9.75
```

So far so good. He filters for the price column by using `awk` and the `NF` variable (which is the number of columns fields available) in order to get the last column containing the prices:

```bash
$ cat menu.txt | grep shrimp | awk '{print $NF}'

$9.75
```

The starvation is kicking in and he's typing furiously by now. Bob proceeds with `sed` to turn the dollar amount into an integer by replacing everything except for what's inbetween the dollar symbol and decimal period. He'll use a capturing group and replace the contents with the first capture group `\1`:

```bash
$ cat menu.txt | grep shrimp | awk '{print $NF}' | sed -E 's/\$([0-9]+)\..*/\1/g'

9
```

Finally, using the handy `test` command and the less-than flag `-lt`, Bob can check whether the price is less than `10` with the help of `xargs` to pipe the value as the first argument to `test`: 

```bash
$ cat menu.txt | grep shrimp | awk '{print $NF}' | sed -E 's/\$([0-9]+)\..*/\1/g' | xargs -I {} test {} -lt 10 

```

But wait there's no output! Actually, `test` returns an exit status code of `0` if the condition passes or `1` if no match.

Bob simply echo's *Available* if the previous command was successful by using `&&`, otherwise he'll echo *:(* by using the double pipe `||` if it was not successful:

```bash
$ cat menu.txt | grep shrimp | awk '{print $NF}' | sed -E 's/\$([0-9]+)\..*/\1/g' | xargs -I {} test {} -lt 10 && echo 'Available!' || echo ':('

Available!
```

Voila! there it is, the desired pasta-and-shrimp plate is still the under ten bucks. Bob is happy and proceeds to order his favorite dish.

(hope you liked this intro post to unix pipes and bash commands!)
Floodgateへ接続するpython-shogi
Tags: shogi, protocol, python, csa
Published: 2018-12-13 11:35:48

---
title: Floodgateへ接続するpython-shogi
published: true
description: 
tags: shogi, protocol, python, csa
---

[gunyarakun/python-shogi](https://github.com/gunyarakun/python-shogi/blob/master/scripts/random_csa_tcp_match) に[コンピュータ将棋連続対局場所 (floodgate)](http://wdoor.c.u-tokyo.ac.jp/shogi/floodgate.html)へ[コンピュータ 将棋協会 (CSA)](http://www.computer-shogi.org/)規定の[TCP/IPプロトコル](http://www.computer-shogi.org/protocol/tcp_ip_server_112.html)で接続する、Pythonによるサンプルスクリプトが見つかりました。実際に試してみたら、本当に接続ができて、対局が行われました。

[python-shogi](https://github.com/gunyarakun/python-shogi) は王手、詰みの判定やKIF寄付の読み書きもできるようです。残念ながら開発は止まっているようです。

python-shogiの元になっているのは、[niklasf/python-chess](https://github.com/niklasf/python-chess)で、こちらは活発に開発が行われています。
React Native: Cross-platform differences
Tags: reactnative, crossplatform, javascript
Published: 2018-12-13 11:12:53

---
title: React Native: Cross-platform differences
published: true
description: Examples of differences between components behavior and UI depending on the platform.
tags: #ReactNative, #Cross-Platform, #Javascript
---

Hello, in this article I tried to give you some examples about the differences that you may encounter when using React Native components. Some quick tips and heads-up about these "problems"

https://catalinxyz.com/react-native-cross-platform-or-not/
Brand New Standard Edition of dbForge Studio for PostgreSQL by Devart
Published: 2018-12-13 10:49:25

---
title: Brand New Standard Edition of dbForge Studio for PostgreSQL by Devart
published: true
description: Devart, a recognized vendor of professional database management software for developers and DBAs, announced the release of dbForge Studio for PostgreSQL, v2.0 with new exclusive features and a bunch of essential updates and improvements.
---
**Standard Edition**

Now dbForge Studio for PostgreSQL has two editions, a free Express edition with basic functionality and Standard editions with advanced features. The Standard edition can be evaluated at no cost for 30 days. When this trial period expires, users can purchase a license to continue enjoying exclusive features or it will be limited to a free Express edition.

**The Standard edition includes the following exclusive features:**


*Data Import and Data Export

*Master-Detail Browser

*Data Reports

*Pivot Table

*SQL Snippets

*Query Execution History

*Execute Large Script

*SQL Document

-Context prompt in the FROM list of the SELECT queries

- Full code completion support for the SELECT statement

*Connectivity

-SSH connection

-Connectivity support for PostgreSQL 11.x

-Connectivity support for PostgreSQL 10.x

-Connectivity support for PostgreSQL 8.3, 8.2, 8.1

-Connectivity support for elephantsql.com

*Other Improvements

-Digital signature for the installation file

-FIPS compliance


**dbForge Studio for PostgreSQL** is a GUI tool for database development and management. The IDE for PostgreSQL allows users to create, develop, and execute queries, edit and adjust the code to specific requirements in a convenient and user-friendly interface.

For more information about dbForge Studio for PostgreSQL, please visit https://blog.devart.com/whats-new-in-dbforge-studio-for-postgresql-20.html 

tags: postgresql, postgre client, postgeSQL administration
---
Should I pivot?
Tags: feedback, webdev, help
Published: 2018-12-13 10:12:18

---
title: Should I pivot?
published: true
description: Should I pivot?
tags: #feedback #webdev #help
---
StarTips: https://Startips.io

I recently wrote a post about releasing Startips here: https://dev.to/yuriguernsey/it-feels-so-good-to-finally-release-a-product-4chh

However, I have been getting a lot of feedback that the idea is great but plain. So I was wondering if I should pivot into a news site that post success and failure stories with the founders tips, But in my honest opinion I don't know.

What does everyone think? Should I pivot? If so what should I pivot to, doesn't have to be the news site. I am open to suggestions
Exposing a Promise-Based API from a Reactive Core (v3.0 Journal)
Tags: javascript, react, showdev
Published: 2018-12-19 20:18:58

---
title: Exposing a Promise-Based API from a Reactive Core (v3.0 Journal)
published: true
tags: javascript, react, showdev
canonical_url: https://snipcart.com/blog/redux-middleware-example
---

![Exposing a Promise-Based API from a Reactive Core (v3.0 Journal)](https://snipcart.com/media/203985/redux-middleware-example-1.jpg)

The whole team here is going through very rewarding times lately.

Since we’ve started working on our new shopping cart’s frontend stack, we’ve had the chance to dive deeper into some awesome modern techs.

This rewrite is entirely [done in TypeScript](https://snipcart.com/blog/learn-typescript-why-use-ts), decoupling the theming from a freshly baked SDK.

Redux is also a central piece of this stack. My good friend Jean-Seb already covered why we are using it&mdash;today, let’s move a bit more under the hood.

**I want to use our experience as an example of how to use Redux middleware**. More precisely, I’ll explain how we exposed a promise-based API from a reactive core. To do so, I’ll: 

- Define what exactly Redux middleware is
- Expose more details about our SDK
- Explain how we ended up exposing a promise-based API from it
- Show how we leverage Redux middleware capabilities

> This article is the second chapter of our **v3.0 Journal** where we reveal interesting parts of our shopping cart’s rewrite. To read the entire thing:
> 
>- [Chapter One: How We Use Redux & Redux-Observable with Vue](https://snipcart.com/blog/redux-vue)
>- **Chapter Two: Exposing a Promise-Based API from a Reactive Core**
>- Chapter Three: Making our SDK npm Package TypeScript-Friendly (01/19)
>- Chapter Four: Template Overriding (02/19)

  

→ Read the full post [here](https://snipcart.com/blog/redux-middleware-example)
Vim isn't for everyone. Here is how to make it yours
Tags: vim, neovim, productivity
Published: 2018-12-13 08:18:50

---
title: Vim isn't for everyone. Here is how to make it yours
published: true
description: 
tags: vim, neovim, productivity
cover_image: https://thepracticaldev.s3.amazonaws.com/i/j9yfmgn7fz78qi3ul4kr.jpg 
---

Did I say *Vim isn't for everyone*? I certainly felt that way the first couple of time I tried it. After several failed attempts over the years, I finally made Vim my daily driver. Below I have a couple of tips from my own experiences for people starting out on Vim/Neovim.

1. Start small, *really*
Too much too quickly is a common theme in my past failures trying to learn Vim. Only 6 keys are needed to move the caret left (`h`)/right (`l`)/up (`k`)/down (`l`), delete (`x`) and insert text (`i`). It took me 2 weeks to get comfortable with just the aforementioned 6 keys and weaned myself from reaching for the mouse.

2. Use Vim now
There is practically no need to setup Vim for use in terminal or GVim (Vim in a window) initially. Most editor/IDE has a Vim emulation waiting to be enabled.  

3. Avoid using it under pressure initially
Professional work is hard enough as is without adding Vim to the mix. I got much more successful when I used Vim on my personal project, which I simply enjoy the experience with what I already knew or add one or two commands in a session. I manage to slowly but steadily expand my Vim muscle memory over weeks this way. 

4. Touch typing is important
Touch typing is almost a prerequisite. I have never seen anyone use Vim well without being able to touch type fairly accurately. Weakness in my touch typing flared up when using Vim and I added 5 min of targeted typing exercises at the start of a session until I was comfortable.  

5. Experience default key mapping first before customisation
Some advocate promote customisation early on, citing inefficient key mapping creates bad muscle memory, resulting in a long term impact on productivity. However, I find the default key mapping adequate for most tasks, particularly with Neovim. I also don't like to customise until the keymap really bugs me and the keymap I find more comfortable with is not already taken by something useful.  

Above are some of what I felt worked for me after a number of failed attempt to learn Vim in the past. I now keep a learning-sheet I made with the commands I want to learn. When I got the command sequence stored in muscle memory I will delete it from my learning-sheet to keep it up to date. 

Happy Vim-ming!
Why there is no such thing as the Richardson Maturity Model
Tags: richardson, maturity, rest, api
Published: 2018-12-13 08:01:14

---
title: Why there is no such thing as the Richardson Maturity Model
published: true
description: It ain't what you think it is. And it's "very embarrassing"
tags: richardson,maturity,REST,API
---
One common yardstick used to measure the RESTishness of an API design is what has become known as the **Richardson Maturity Model** (or RMM). Originally known simply as the **Maturity Heuristic**, Leonard Richardson's scale defines the following levels of **maturity** of an API design:

* Level Zero: One URI, one HTTP method
* Level One: Many URIs, one HTTP method
* Level Two: Many URIs, each supporting many HTTP methods
* Level Three: Hypermedia

We can recognise Level Zero as RPC, or SOAP style APIs.

Level One APIs have the concept of resources (or representations), but all requests use one HTTP method (such as `GET` or `POST`). This fails to leverage the HTTP protocol to its fullest, and as Richardson notes, makes it very easy to destroy data by accident.

Level Two is probably the commonest level seen in production APIs today. It represents all of Fielding's mandatory REST constraints apart from HATEOAS.

Level Three is REST, including the hypermedia constraint. Though Richardson in his original discussion (https://www.crummy.com/writing/speaking/2008-QCon/act3.html) states:

> "A lot of people settle for level two because hypermedia is difficult to understand and its value in the web service domain isn't as clear."

Unfortunately, the Richardson Maturity Model has been popularised by Martin Fowler in a somewhat bowdlerised form from the original. Unhelpfully, the graphic on his website, often reproduced, chooses to rename the levels above as:

* Level Zero: The Swamp of POX
* Level One: Resources
* Level Two: HTTP verbs
* Level Three: Hypermedia controls

![Fowler's take](https://thepracticaldev.s3.amazonaws.com/i/tvqx562vgax2h5kr20qu.png)

Even if we accept the application of a maturity model to API design as being somewhat biased, implying as it does that REST APIs are more "mature" than RPC APIs (when in fact they simply serve different needs and purposes), there is little excuse for using pejorative terms like "swamp". "POX" also sounds unpleasant, but here simply means 'Plain Old XML'.

Either way, the popularised version of the RMM makes no distinction between resources and representations and only adds to the confusion between HTTP 'verbs' and HTTP methods, which the original does not.

Richardson himself at RESTFest 2015, in a talk subtitled "What Have I Done?", described the whole thing as "very embarrassing" and clarified that if you want to proceed up the steps of the Maturity Heuristic, you have to have either a technical reason or a political reason to do so. There is also no prize or "glory" at the top - sorry to disappoint. (https://vimeo.com/147237932)

Do please refer to Richardson's original work for more details on this model.

Thanks to Darrel Miller for pointing out Richardson's later talk.
ffmpeg: Using Command Line To Cut Out Media Files
Tags: media, commandline, ffmpeg, ffprobe
Published: 2018-12-13 06:52:14

---
title: ffmpeg: Using Command Line To Cut Out Media Files
published: true
description: It's been much easier to host video files and show them recently on websites. With ffmpeg (and also ffprobe), it's possible to cut them out and adjust their duration before uploading them. I like using command line tools when I deal with simple tasks.
tags: media, command-line, ffmpeg, ffprobe
cover_image: https://thepracticaldev.s3.amazonaws.com/i/yp0vd7jjlf1agwvji4ag.jpg
---

*\* The cover image is originally by [Greyerbaby](https://pixabay.com/en/users/Greyerbaby-2323/) and edited with great appreciation.*

#### Summary

I like using command line tools when I deal with simple tasks, because they:

- run quickly
- need less memory
- work well with target arrays
- enable us to record the orders as text

Well, it's been much easier recently to host video files and show them on websites.
With [ffmpeg](https://ffmpeg.org/ffmpeg.html) (and also [ffprobe](https://ffmpeg.org/ffprobe.html)), it's possible to cut them out and adjust their duration before uploading them.

#### Environment

- ffmpeg / ffprobe: 4.1

<center>✿ ✿ ✿</center>

#### How To Use

##### Cutting Out Media Files

```shell-session
$ ffmpeg -ss %from-seconds% -t %to-seconds% -c copy -i %input.file% %output.file%
```

For example, `ffmpeg -ss 0 -t 17 -i some-in.mp4 some-out.mp4` makes some-out.mp4 whose content is 0-17s of some-in.mp4.

Besides, `-c` is short for `-codec`, and `-c copy` means all the streams will be copied without reencoding.
It's used to escape from deteriorating them.
The manual of main options is [here](https://ffmpeg.org/ffmpeg.html#toc-Main-options).

As to [syntax of time duration](https://ffmpeg.org/ffmpeg-utils.html#time-duration-syntax), both of specified seconds and `HH:MM:SS.m` format are allowed.

```shell-session
$ ffmpeg -ss %from-HH:MM:SS.m% -t %to-HH:MM:SS.m% -c copy -i %input.file% %output.file%
```

For example, `ffmpeg -ss 00:00:00.0 -t 00:00:17.0 -i some-in.mp4 some-out.mp4` is the same to the former example just using `HH:MM:SS.m` format.

##### Getting The Duration

`ffprobe` provides ways to get duration of media files.

In order to get number of seconds, the command is like this:

```shell-session
$ ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 %input.file%
17.017000
```

In order to get `HH:MM:SS.m`, add `sexagesimal` option to the above command:

```shell-session
$ ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 -sexagesimal %input.file%
0:00:17.017000
```

The manual of generic options is [here](https://ffmpeg.org/ffprobe.html#Generic-options).

<center>✿ ✿ ✿</center>

Happy terminaling 🌈
Git Tip: List the Most Recent Branches You Have Been Working On
Tags: git, tip
Published: 2018-12-13 06:45:03

---
title: Git Tip: List the Most Recent Branches You Have Been Working On
published: true
description: List and switch back and forth between multiple git branches with ease.
tags: git, tip
---
In most projects I have worked on, we ended up using feature branches. Since branches in git are cheap, every ticket, no matter how large or small the changes, would have its own feature branch. You would end up having many of those, often, having to switch between one or another.

Git has a built-in checkout attribute for switching back to the previous branch you were working on. This is usually as simple as:

    git checkout -

which is a shorthand for:

    git checkout @{-1}
    # Changing the index will switch back to the n-th previous branch

Switching back and forth is easy, but what if you wanted to go to the branch you were working on a couple of days ago? I bet you don't even remember its name, to begin with. In case you use a git client, such as SourceTree, or something built into your IDE of choice, you might already be having such a functionality. Yet, if you are a fan of the command line, you might be stuck. Git does not provide it out of the box, but can easily be extended with an alias that allows just that.

Let's create a git command that displays a list of the past 10 branches one has worked on, sorted in reverse order:

    git for-each-ref --sort=-committerdate --count=10 --format='%(refname:short)' refs/heads/

Running the command above will give us exactly what we need, but is tedious to write and remember. Thanks to git's aliasing support, we can map this long string of options to a git shorthand sub-command, say, `rb`.

Find an open `~/.gitconfig` and add the following line of code as part of the `[alias]`section. If there is no `[alias]` section, add it as well.

    [alias]
    	rb = for-each-ref --sort=-committerdate --count=10 --format='%(refname:short)' refs/heads/

Once you have saved the file, the new `git rb` command should be at your disposal.

---

# **Acknowledgements and Further Reading**

Thanks to [Jason Rogers](https://coderwall.com/p/jhucga/git-the-last-10-branches-you-ve-worked-on) for being the one whom I got to learn this tip from!

- [https://coderwall.com/p/jhucga/git-the-last-10-branches-you-ve-worked-on](https://coderwall.com/p/jhucga/git-the-last-10-branches-you-ve-worked-on)
- [https://marcgg.com/blog/2015/10/18/git-checkout-minus/](https://marcgg.com/blog/2015/10/18/git-checkout-minus/)

---

_This post was originally published on [my blog](https://preslav.me/2018/12/13/git-tip-last-10-branches/)_
Try to run libp2p(js-libp2p) anyway.
Tags: libp2p
Published: 2018-12-13 06:36:54

---
title: Try to run libp2p(js-libp2p) anyway.
published: true
description: 
tags: libp2p
---

I tried to run [js-libp2p](https://github.com/libp2p/js-libp2p) that Javascript implementation of [libp2p](https://github.com/libp2p).

# What to do.
I tried to run [transfer](https://github.com/libp2p/js-libp2p/tree/0b75f99d752f7960ce4377d54b098be914600200/examples/transports).

# How to do.
I made a [docker image](https://hub.docker.com/r/sot528/libp2pjstest/) of the process above.


```bash
docker run -it sot528/libp2pjstest
```

Run `3.js` in the container.


```bash
root@73b031df5d57:~/work# node 3.js
```

Then, 3 nodes will run and connect each other.


```bash
node 1 is listening on:
/ip4/127.0.0.1/tcp/32907/ipfs/QmVSd89zgVLqC3cUVzN3R3dpA8xextxEFBuACd8uSMXXLM
/ip4/172.17.0.4/tcp/32907/ipfs/QmVSd89zgVLqC3cUVzN3R3dpA8xextxEFBuACd8uSMXXLM
node 2 is listening on:
/ip4/127.0.0.1/tcp/40709/ipfs/QmWe7Md6CyDDXaApaXPijKuXYhpK3uktmMamuw5MzW3zWu
/ip4/172.17.0.4/tcp/40709/ipfs/QmWe7Md6CyDDXaApaXPijKuXYhpK3uktmMamuw5MzW3zWu
/ip4/127.0.0.1/tcp/10000/ws/ipfs/QmWe7Md6CyDDXaApaXPijKuXYhpK3uktmMamuw5MzW3zWu
node 3 is listening on:
/ip4/127.0.0.1/tcp/20000/ws/ipfs/QmeKhkwXHPQ29BzbRJuqzMdkKDzWVwwFreWKRRJDLRvw1H
node 3 failed to dial to node 1 with: Circuit not enabled and all transports failed to dial peer QmVSd89zgVLqC3cUVzN3R3dpA8xextxEFBuACd8uSMXXLM!
node 1 dialed to node 2 successfully
node 2 dialed to node 3 successfully
```

You can try what you want as editing `3.js`.
AoC Day 13: Mine Cart Madness
Tags: adventofcode, discuss
Published: 2018-12-13 05:12:35

---
title: "AoC Day 13: Mine Cart Madness"
published: true
description: "Day 13: We're helping elves avoid crashing their minecarts."
cover_image: https://thepracticaldev.s3.amazonaws.com/i/nxhe6x5r7gi0hp1yx3l1.png
tags: adventofcode, discuss
series: Advent of Code 
---

[Day 13](https://adventofcode.com/2018/day/13) puts us just over halfway!  Hopefully, you're sticking with it and able to keep up.  If not, we've got a weekend coming up.  🎅

Today, we're predicting minecart crashes!  You heard me right: the plants from yesterday have their own minecart infrastructure.  And these minecarts are not well managed.  We'll be parsing some pretty crazy ASCII art inputs and simulating these carts to figure out where they might run into issues.

There's a lot of moving pieces to this one.  Good luck!