teleren/devto huggingface dataset:
Bash Functions: A more powerful Alias
Tags: terminal, beginners, productivity, linux
Published: 2017-12-24 18:59:24

---
title: "Bash Functions: A more powerful Alias"
published: true
description: Have you ever wanted more control over bash aliases?
canonical_url: https://medium.com/@aarohmankad/bash-functions-a-more-powerful-alias-1e91b4ca0298
tags: #terminal, #beginners, #productivity, #linux
---

If you use bash a fair amount, you probably have [some aliases set up](https://codeburst.io/use-bashrc-alias-to-become-a-more-efficient-programmer-60f0765edbe0). However, have there been times you wish you had some more control over the functionality of your alias?

> Let’s examine one example: a bash alias and a bash function for extracting a file.

With an alias, we can easily abstract out the complicated `tar` command to simply `extract`.

{% gist https://gist.github.com/aarohmankad/8d4c9d77a987551c49ccd50bb950e139 %}

Now we can type `extract file.tar.gz` or `extract file.tgz` and the command will extract the file. We can even specify output directories!

But what if we can’t rely on our downloaded file to have `.tar.gz` / `.tgz` extensions? Well in that case, a function for `extract` makes more sense!

{% gist https://gist.github.com/aarohmankad/7c8122897bcfda2f57a67c5f84277fd5 %}

Now we can call `extract` without worrying about our file extension! We can just trust that the function will do exactly what it’s meant to.

So how can I start using bash functions?

First, import a file called `.bash_functions` in your `.bashrc`.

{% gist https://gist.github.com/aarohmankad/da9d6b4399fb2b0a3df766e1c7f56c91 %}

Now you can either [download my `.zsh_fns` file](https://gist.github.com/aarohmankad/f17876d7550ff9dd1891727160b0f248) (bash functions for `zsh`) as a starting point, or create your own at `~/.bash_functions`!

Note: You must restart terminal or type `source .bashrc` in your terminal to start using the new bash functions
Developing GameClosure with Docker and Gitlab CI
Tags: gameclosure, docker, cicd, gitlab
Published: 2018-03-26 20:02:48

---
title: Developing GameClosure with Docker and Gitlab CI
published: true
tags: gameclosure,docker,cicd,gitlab
canonical_url: 
---

Develop games with HTML5 game framework GameClosure using Docker and Gitlab CI.

<amp-img on="tap:lightbox" role="button" tabindex="0" width="800" height="365" layout="responsive" src="/assets/img/gameclosure.png"></amp-img>
## Docker for Development

Following the guide of GameClosure, I made a Dockerfile that has `gameclosure/devkit` **installed** where I copied `manifest.json, package.json` and run the commands to **install dependencies** :

```
COPY --chown=node manifest.json package.json ./
    RUN devkit install
    COPY --chown=node ./package.json ./
    RUN npm install
    CMD ["devkit", "serve"]
```

**My project** only needs **2 folders:** `src` for source codes and `resources` for assets. These are the folders required by GameClosure, everything else are dependencies and installed in the docker image. Using `docker-compose`, I **mount these folders** to the container and **expose port** `9200`.

```
volumes:
        - ./src:/home/node/game/src
        - ./resources:/home/node/game/resources
    ports:
        - 9200:9200
```

From the host machine, I can access devkit page via browser at `localhost:9200` as normal.

## Continous Deployment

In order to build the project, I need another `docker-compose` configuration to **mount** a `build` folder and **run the build command** instead of `serve`.

```
volumes:
        - ./build:/home/node/game/build
    command: devkit debug browser-mobile
```

I didn’t want to build the game manually, so I used Gitlab CI/CD service to have it **runs** the container, **builds** the game and **deploys** to Gitlab Pages for me. I create this `.gitlab-ci.yml` file with `pages` job that _build the game into_ `*public*` _artifacts_:

> Unlike Github Pages which can only build Jekyll, Gitlab Pages can automatically build almost anything with its CI/CD service.

```
pages:
        stage: deploy
        script:
            - docker-compose -f docker-compose.yml -f docker-compose.browser-mobile.yml up
            - cp -a build/debug/browser-mobile/. public/
        artifacts:
            paths:
                - public
```

Now, everytime I push to my Gitlab repository, the game will be built and served at Gitlab Pages.
Babel Plugin for auto binding your react component/Class methods
Published: 2017-12-24 15:34:15

---
title: "Babel Plugin for auto binding your react component/Class methods"
published: true
description: This babel plugin will auto bind your component methods in the constructor with "this" so your don't have to do it yourself and will save you from unexpected bugs like this accessing "name" of undefined.
tags: 
---
https://github.com/HarshwardhanSingh/autobinder
What testing tools/frameworks does the DEV team use? 🤔
Tags: discuss, testing, tools
Published: 2017-12-23 18:46:50

---
title: What testing tools/frameworks does the DEV team use? 🤔
published: true
description: 
tags: #discuss #testing #tools
---

If so, why?

Did you guys try different ones before deciding to stick to X or Y?
packagemain #0 - Building gRPC blockchain Server & Client in Go
Tags: go, grpc
Published: 2017-12-23 17:39:14

---
title: "packagemain #0 - Building gRPC blockchain Server & Client in Go"
published: true
description: In this video I am building a gRPC Server & Client in Go, by implementing blockchain service.
tags: go, golang, grpc
---

In this video I am building a gRPC Server & Client in Go, by implementing blockchain service.

I am reviewing the following Go packages:
https://godoc.org/google.golang.org/grpc
https://github.com/golang/protobuf

https://www.youtube.com/watch?v=gju-bml4kdw
WebRTC が利用している RTP 拡張の簡単な紹介
Tags: webrtc, rtp, japanese
Published: 2017-12-23 17:16:15

---
title: WebRTC が利用している RTP 拡張の簡単な紹介
published: true
description: 
tags: webrtc,rtp,japanese
---

WebRTC は RTP を利用して音声や映像を送受信していますが、 RTP には RTP 拡張という好き勝手に拡張できる仕組みがあります。

[RFC 8285 \- A General Mechanism for RTP Header Extensions](https://tools.ietf.org/html/rfc8285)

つい最近、古い RFC が上書きされたこともあり、せっかくなので WebRTC が利用している RTP 拡張について簡単に紹介してみました。

RTP 拡張については RFC 読めばわかるので割愛します。

## Chrome M63

Chrome は積極的に RTP 拡張を利用しています。Chrome というよりは libwebrtc がという印象です。

```
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:4 urn:3gpp:video-orientation
a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
```

## Firefox 57

Firefox は必要最低限という印象です。あまり拡張には興味がなさそうです。

```
a=extmap:1/sendonly urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:1 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
```

## RTP 拡張概要

RTP 拡張は SDP に定義し Offer/Answer でやり取りする際に対応しているかどうかを判断します。

extmap:1 の 1 をローカル ID といい、そのハンドシェイクで m= の単位で好き勝手に決めて良いと決まっています。

実際 Firefox の場合はローカル ID 1 が２つあります。これは m= で区切られているからです。

ローカル ID の後ろに /sendonly というのがありますが、これはダイレクションといい、この拡張を利用する方向を明示します。

あとは URI です。 IETF の場合は urn:ietf ... という感じです。それ以外は http:// という感じで書くルールになっています。

## RTP 拡張紹介

### urn:ietf:params:rtp-hdrext:ssrc-audio-level

ssrc-audio-level 拡張です。これは音声のみに利用される拡張で、その RTP パケットの音量が 0-127 で含まれてきます。

0 が一番大きな音で、127 が一番小さな音です。全ての RTP パケットに含まれます。

### urn:ietf:params:rtp-hdrext:toffset

この機能は abs-send-time が対応していない場合に利用される仕組みです、WebRTC では abs-send-time には対応しているので、何も気にすることはありません。

### http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time

abs-send-time (Absolute Send Time) です。簡単に言うと RTP の timestamp とは別に淡々と incremnt されていく値です。といってもずーっと増えるのではなく、24 ビットです。

これを利用することで RTP の SeqNum が「古いのか新しいのか」を判断することが可能になります。便利です。

### urn:3gpp:video-orientation

マニアックな拡張です。これは「角度」を取れる拡張です。90 度回転したなどのフラグが入ってきます。

受け取り側は映像が「回転したこと」に気付くことができます。

### http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01

https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01

ソケットから送信した順番の番号が入ってきます。これだけだと何に使うのかわからないと思います。

Transport-wide RTCP Feedback Message という RTCP フィードバックメッセージを前提としています。

これについては、長くなるので「そんなのがあるんだな」程度で。

### http://www.webrtc.org/experiments/rtp-hdrext/playout-delay

情報がなさすぎてこれわかっていません。そもそも URL が 404 です。

https://github.com/webrtc/webrtc-org/pull/117

### http://www.webrtc.org/experiments/rtp-hdrext/video-content-type

リアルタイムか、スクリーンシェアなのかなどが入ってきます。

### http://www.webrtc.org/experiments/rtp-hdrext/video-timing

仕様と実装が違うので要注意です。エンコードの開始時間と終了時間が入ってきます。フレームごとのタイミング情報をおくるために使われます。

## まとめ

RTP 拡張は WebRTC をブラウザで P2P として利用するには気にする必要はありません。ただ、これらの拡張を利用することで得られている統計情報もあったりしますので、chrome://webrtc-internals と仲良くなりたい人はなんとなく覚えておくことをお勧めします。
ちょっとしたコマンドをさくっとClojureScriptで書けるスターターキットchochoiをつくった
Tags: clojurescript, node, generator, cli
Published: 2017-12-23 15:22:57

---
title: ちょっとしたコマンドをさくっとClojureScriptで書けるスターターキットchochoiをつくった
published: true
description: とにかく簡単に素早くコマンドをつくれることを目指しました
tags: clojurescript, nodejs, generator, cli
---

ClojureやClojureScriptを使って、ちょっとしたコマンドラインのプログラムを作る方法はたくさんあります。
多くはleiningenやbootを使ったもので、高機能かつ素晴らしいものですが、個人的に欲しいものは以下のものです。

- NodeJS上で動くコマンドのためのプロジェクトを自動生成できる
- clojurescriptで処理を記述できる
- プロジェクト生成のジェネレータの起動に時間がほとんどかからない
- 起動から実行までの時間も早い
- ビルドもなるべく時間がかからない。leiningenやbootにも依存しない
- npmでインストール可能
- ビルド時は、コマンドのインストールまでやってくれる
- なんか楽しそう(コマンドの実行結果がキャッチー)

## 何を作ったの？

`chochoi`というClojureScriptベースのCLIコマンドを生成可能なツールです。`chochoi`は日本語でいう「ちょちょい」であり、簡単かつ迅速にコマンドプロジェクトを作成します。

- [chochoiのリポジトリ](https://github.com/karad/chochoi)
- [chochoiのnpmパッケージ](https://www.npmjs.com/package/chochoi)

`hello`というコマンドを作りたいときに、`chochoi new hello`と実行することで、`hello`コマンドをビルド可能なプロジェクトファイル一式が生成されます。

まだバージョンは`0.0.5`でして、発展途上です。[descjop](https://github.com/karad/lein_template_descjop)を作ってた時に、自動生成関係で「うーん」と思っていた部分が主に改善されているはずです。（descjopもこっちベースで作り直す予定）

※ まだMacでしか動作確認はしていません。Windowsはパスの問題を解決する必要がありそうです。Linuxはたぶん動きそう。

## 使い始める前の準備

`cljs.jar`を https://github.com/clojure/clojurescript/releases/latest でダウンロードしておき、これをローカルストレージのどこかに配置します。

そして、`CLJS_PATH`という環境変数を設定しておきます。

こんな感じです。

```
export CLJS_PATH="/Users/XXXXX/.cljs/cljs.jar"
```

## chochoiのインストール

`chochoi`をインストールします

```
$ npm install -g chochoi
```

## helloプロジェクトをつくってみる

例として、`hello`というコマンドを作ってみましょう。

`chochoi new hello`を実行するとこんな風にファイルが生成されます。

```
$ chochoi new hello

⚡ init chochoi project...

-------------------------------
- create : ./hello
- create : ./hello/src/hello
- create : hello/src/hello/core.cljs
- create : hello/src/hello/command.cljs
- create : hello/.gitignore
- create : hello/build.clj
- create : hello/build.js
- create : hello/config.js
- create : hello/package.json
- create : hello/README.md
-------------------------------

👍 completed.
```

## helloプロジェクトをビルドをする

helloディレクトリが生成されているので、移動し、`chochoi build`コマンドを実行します。

```
$ cd hello
$ chochoi build

⚡ build chochoi project...

completed linked command.

completed clojurescript build.
up to date in 0.055s
/Users/XXXXX/.nvm/versions/node/v8.7.0/bin/hello -> /Users/XXXXX/.nvm/versions/node/v8.7.0/lib/node_modules/hello/out/main.js
/Users/XXXXX/.nvm/versions/node/v8.7.0/lib/node_modules/hello -> /Users/XXXXX/study/chochoi/hello

👍 completed.
```

すると、ビルドが完了し、なおかつ、コマンドとして登録されます。

## 実行する

あとは実行するだけです。

```
$ hello kaz
Hello world! kaz
```

すぐ起動するし、速いですね！

## 処理をいじるには

`src/hello/command.cljs`で実行処理が書かれているので、ここを変更するだけです。

```
(ns hello.command
  (:require [cljs.nodejs :as nodejs]))

(defn command [args]
  (println "Hello world!" (str (first args))))
```

みなさまの、ごスターをお待ちしております

- [chochoiのリポジトリ](https://github.com/karad/chochoi)
What are some project ideas that beginners can work on to show in their portfolio?
Tags: discuss
Published: 2017-12-23 15:11:54

---
title: What are some project ideas that beginners can work on to show in their portfolio?
published: true
description: 
tags: discuss
---

Unfortunately I can't come up with project ideas! Whilst learning, I'm always creating something, but it's usually a todo app, ecommerce concept, a portfolio or blog. 

Can you share some ideas? As @ben said [here](https://dev.to/ermal/is-it-possible-to-get-a-web-development-job-if-i-have-a-6-year-gap-2kjd)

> You should start working on random projects regardless of how they fit your portfolio, more for learning.

I would love to have few fresh ideas, even if some might never end up in the portfolio, or regardless whether I'll be able to finish them.

I am considering contributing to open source but the task feels overwhelming. (The best advice I heard on the topic is, to contribute on projects you already use, but what if that's not an option?)
Event Sourcing Distilled
Tags: ddd, eventsourcing, log, events
Published: 2017-12-23 13:19:43

---
title: Event Sourcing Distilled
published: true
description: Short explanation of Event Sourcing.
tags: ddd,event-sourcing,log,events
---

*tl;dr*. Event Sourcing is this...

```js
f1(state, command) -> events
f2(state, events) -> state    // the golden function
```
instead of this..

```js
f(state, command) -> state
```

---

Event Sourcing (ES) has been steadily rising in popularity as a result of recently trending topics including Domain Driven Design (DDD), microservices, distributed logs, and others. There are many articles that explain ES in terms of these topics, but I felt the need to explain it a different state, agnostic to any particular tech choice or context.

Fundamentally, ES is an alternate way to represent state. That's it.

Take a moment to think about any system that is familiar to you. Write down one or two commands (actions) you can perform and what you observe to be the effect of that command. From a user's perspective this makes sense. I have an *intent*, I send a command expressing my intent, and I observe the effect of that command on the state.

This abstraction can be expressed as a function that takes the current state of the system and a command and returns the new state of the system (errors or rejections being omitted for brevity).

```js
f(state, command) -> state
```

What I now have to *observe* is the new state. *How* you observe the state is determined by what the API provides (list of objects, object by id, etc).

Rather than going from state to state, ES breaks up this state transition into two functions. The first function takes the same arguments, the previous state and the command, but now returns one or more events. 

```js
f1(state, command) -> events
```

Recall the command expressed the *intent* of the action to be performed. The events also capture the intent of the change, but also express *what* changed as a result of the command. Events are past tense and thus *immutable facts* that cannot be changed.

The second part of the transition is taking the current state and applying the events to yield the new state.

```js
f2(state, events) -> state
```

Applying only the new events to the current state is common for *online* command processing. However, this function can be used to re-create the state at any point in time if need be by some offline process. This is done by passing the *null* state and the full history of events up to some point in time.

Why is this useful? Decoupling how the events are produced (by commands) from how events are applied to the state enables changing the implementation of the state or how the events are ultimately applied. Since events capture the intent and what changed, they *are* the source of the truth for the state. The state is simply a structure expressing the culmination of these events up to some point in time.

Making events first-class provides additional advnatages such as enabling inspection for operational or auditing reasons and making it easy to broadcast events to other interested components in the system for real-time event-driven updates.
Here's What Cloudways is Giving to Developers This Christmas Eve.
Tags: webdev, php, showdev, devops
Published: 2017-12-23 08:08:39

---
title: Here's What Cloudways is Giving to Developers This Christmas Eve.
published: true
description: 
tags: webdev, php, showdev, devops
cover_image: http://www.cloudways.com/blog/wp-content/uploads/XMAS-Blog-Banner.gif
---

[Cloudways](https://www.cloudways.com/en/php-cloud-hosting.php) is a managed cloud hosting platform for PHP applications, CMS, and Frameworks. Providing the best six providers including DigitalOcean, Linode, AWS, Vultr, Kyup, and GCE.You can Launch Servers and applications with the complete stack on the above providers in few clicks and enjoy the discounts credit.

##The ThunderStack

Cloudways Engineers has built their own PHP Thunderstack on the top of best technologies:

![](https://www.cloudways.com/blog/wp-content/uploads/stack-linode-cloudways-768x448.png)

##Exceptional Features

Here are some of the features you must know about.  

1.Choose from Multiple Cloud Infrastructures like DigitalOcean, Google, Amazon, and more.

2.Deploy multiple web applications, including WordPress, Magento, Drupal, WooCommerce and PHP Based apps.

3.Get real-time insights about your servers on popular channels with integrated CloudwaysBot.

4.Deploy servers on multiple datacenters

5.Cloudways gives you 24/7 support with Live Chat and ticketing system

6.Most operations on Cloudways can be performed in 1-Click, like Cloning, Backups, Restore, and Server Scaling.

7.Build awesome web applications by collaborating with your team from within the Platform.

8.Test your web applications before going live on the built-in staging mechanism
Monitor 15+ applications from within the Platform.

9.You can deploy FREE SSL from Let's Encrypt in 1-Click.

10.Thunderstack, in-house caching recipe, ensures that your websites load 100 times faster than average.

11.Manage a lot of website from the Cloudways Platform using the Projects feature.

##Sit Back & Relax

So, what you need to do this Christmas🎄? Nothing sit back, relax, control your web applications and servers with mouse clicks. Here's the demo:

![](http://www.cloudways.com/blog/wp-content/uploads/launch-linode.gif)
Free / Open Source Server Monitoring & Alerting?
Tags: discuss, devops, learning
Published: 2017-12-23 03:34:31

---
title: Free / Open Source Server Monitoring & Alerting?
published: true
description: looking for some guidance on monitoring a single server
tags: discuss, devops, learning
---

I have a server provided by SSD nodes which I use for my business website along with a few small node.js applications.  At the moment due to the size of these projects I have the web, app and database layers all hosted on the same single server. Whilst I have automated most tasks for managing this server I currently have no single simple view of its resource allocation nor any monitoring/ alerting in place if things go downhill. 

I'm on the lookout for any free/open source monitoring and alerting applications.  I've used Webmin in the past I'm not 100% confident it covers this area fully.

Any options put forward are appreciated!
Facebook Noise Filter
Tags: discuss, opensource, electron, webscraping
Published: 2017-12-22 23:31:57

---
title: Facebook Noise Filter
published: true
description: Stay away of non interest content on your Facebook feed!, facebook-noise-filter scrape your Facebook feed and filter all post of your interest given a set of keywords.
tags: discuss, opensource, electron, webscraping
cover_image: https://images.pexels.com/photos/243204/pexels-photo-243204.jpeg?w=1260&h=750&dpr=2&auto=compress&cs=tinysrgb
---
*Originally published on my [blog](https://redknot.io/articles/writing-realtime-poll-w-go)*

Sometimes our Facebook news feed is a little bit noisy, a lot of people posting their thoughts, a lot of funny or hilarious thing and any other useless stuff, and i say useless because in some specific moments we don't want to get that kind content.

In a lot of cases we feel tempted to close our Facebook account, but in some cases is not too simple, because we have external services linked to our account like Spotify or Airbnb even Facebook development projects

This week I was working on new open source project thinking about that situation, which i called `Facebook Noise Filter`, the original idea was a simple `puppeteer` scraping script that log in at Facebook for me, and filter the news feed content based on specific set of keywords.

A few days after, the script was done, and i saw potential on that and i decided implement it as desktop application with `electron`, today i completed the proof of concept for that desktop app and i would like share with all of you the idea, the prototype and make an open invitation to contribute or comment it, all of your thoughts are welcome!

The source code of this project could be found [here](https://github.com/lexmartinez/facebook-noise-filter), and there are a couple of screenshots of our prototype.. i hope you enjoy it!

![](https://github.com/lexmartinez/facebook-noise-filter/raw/master/screenshots/screenshot-1.png)

![](https://github.com/lexmartinez/facebook-noise-filter/raw/master/screenshots/screenshot-feed.png)
Explain like I am five how to write a javascript function that transcribes an audio file from the client using Google Speech API
Tags: explainlikeimfive
Published: 2017-12-22 21:14:59

---
title: Explain like I am five how to write a javascript function that transcribes an audio file from the client using Google Speech API
published: true
tags: explainlikeimfive
---

* Title says explain but by all means do demonstrate.
* The audio source is a file and not client microphone. Ultimately same thing.
(please do not explain the difference between a file input in a browser and Node)
* I read somewhere that audio files shorter than _some length_ do not require an API key. Is this true?
* In this particular case spaghetti code is fine.
Office Dogs
Tags: workplace, culture, dogs, discuss
Published: 2017-12-22 16:02:27

---
title: Office Dogs
published: true
description: 
tags: workplace, culture, dogs, discuss
---

Technically, my workplace isn't dog-friendly, but since it's the last Friday before Christmas, I'm breaking the rules. These are my 4-legged coworkers for the day.

![Dec 22/17 office chihuahuas](http://vincent.grovestine.com/_share/171222-psmox_at_office.jpg)

Does anyone else bring their dogs to the office? Do you find it has a positive (or negative) effect on morale and productivity?
hi
Tags: hi
Published: 2017-12-22 15:09:12

---
title: hi
published: true
description: hi
tags: hi
---

hi

# hi

* hi
* hi
* hi

## hi

* [x] hi
* [ ] hi
* [ ] hi

### hi

1. hi
2. hi
3. hi

#### hi

hi|hi|hi
-|-|-
hi|hi|hi


##### hi

[hi](http://hi.hi)


![hi](https://thepracticaldev.s3.amazonaws.com/i/tshqwdvt9ev0rgzl37fi.jpeg)