teleren/devto huggingface dataset:
Generating Currency-code-like Name in Ruby
Tags: ruby, cryptocurrency
Published: 2017-11-16 06:47:34

---
title: Generating Currency-code-like Name in Ruby
published: true
description: 
tags: ruby, cryptocurrency
---

Various currencies around. Moreover, rising of crypto currencies increases the number of currency-like stores of value. We will dare to add some into it. At the time, naming currency is a problem.

## What's the Currency Codes?

ISO 4217 delineates how to shorten currency name; currency codes.

> The first two letters of the code are the two letters of the ISO 3166-1 alpha-2 country codes (an omission) and the third is usually the initial of the currency itself. So Japan's currency code is JPY—JP for Japan and Y for yen.

[ISO 4217 - Wikipedia](https://en.wikipedia.org/wiki/ISO_4217)

## Currency Codes for Smart Tokens

Since I had wanted similar one for original currencies backed by smart tokens, I hacked up a tiny library for Ruby named `currency_coder`.

[currency_coder gem](https://github.com/pepabo/currency_coder)

This library converts arbitrary strings (e.g. your name) to currency-code-like short name as below:

```ruby
cc = CurrencyCoder.new

currency_map = {
  "osamu"    => "OSM",
  "mayoto"   => "MYT",
  "kurotaki" => "KRT",
  "putchom"  => "PTM",
  "antipop"  => "ATP",
  "jitsuzon" => "JZN"
}

currency_map.each do |name, code|
  assert_equal code, cc.as_currency_code(name)
end
```

Let's create your own currency using this library!
Mute per WKWebView like Safari!
Tags: objectivec, wkwebkit, apple, macos
Published: 2017-11-16 06:44:55

---
title: Mute per WKWebView like Safari!
published: true
description: 
tags: #objectivec #WKWebKit #apple #macos
---

[MuteableWKWebView](https://github.com/masakih/MuteableWKWebView)

Provide muted property for WKWebView.
Hi, I'm Kosuke
Tags: introductions
Published: 2017-11-16 06:32:28

---
title: "Hi, I'm Kosuke"
published: true
description: my first post
tags: introductions
---

I have been coding for 12 years.

You can find me on [Github](https://github.com/koogawa), [Twitter](https://twitter.com/koogawa) or [StackOverflow](https://stackoverflow.com/users/1155354/kosuke-ogawa) as koogawa.

I live in Japan.

I mostly program in these languages: Swift, Objective-C.

I am currently learning more about PHP, JavaScript, Android.

Nice to meet you.
https://thepracticaldev.s3.amazonaws.com/i/r7v7fcdhjnj8ypngiqkr.png)
Tags: kinmiya
Published: 2017-11-16 06:01:17

---
title: "https://thepracticaldev.s3.amazonaws.com/i/r7v7fcdhjnj8ypngiqkr.png)"
published: true
description: 
tags: #Kinmiya
---
3 years of experience for entry-level Web Dev positions in Toronto.
Tags: positions, experience, discuss
Published: 2017-11-16 05:45:20

---
title: 3 years of experience for entry-level Web Dev positions in Toronto.
published: true
description: Do we actually need 3 years of experience to apply for entry-level positions in web development
tags: positions, experience, discuss
---

I was intrigued by an article by Eric Westcott in LinkedIn (<a href="https://www.linkedin.com/pulse/problem-internships-eric-westcott/?trackingId=9zk5mnmT70PM56yYKiv4qg%3D%3D">Source</a>) and would like you to share your opinion on this issue.

To keep it short: Companies advertise entry-level positions in web development, but still require 3 years of experience. What is the option for recent college graduates in this case?

The author is concerned that if you are applying to an entry-level position, you are not supposed to have any experience. On the other hand, if you have 3 years under your belt, you would not apply to an entry-level, but to a junior position. So, there seems to be an endless loop for those, who just graduated from, say, a college and are looking for an entry-level job (obviously, they can't secure a 3-years experience requirement). I'm concerned, because in a close future, I'll be facing this problem in the 'real world'.

My first reaction and reply to this article was like this:

When I see such a requirement (3 years of experience), I tend to think that employer is focusing not on coding experience itself, but in any relevant experience (communication, meeting deadlines, handling emails, working under pressure or being able to be part of a team). I mean, by this 3-years experience, company is trying to convey, that they do not hire a recent graduate, but they need a person with a working conditions experience.

Am I wrong? What do you think?
UITextFieldのplaceholderの色を変更する方法
Tags: swift, ios
Published: 2017-11-16 05:45:01

---
title: "UITextFieldのplaceholderの色を変更する方法"
published: true
description: 
tags: Swift, iOS
---

## placeholderの色を変更するには一工夫必要

```swift
let textField = UITextField()
textField.placeholder = "名前を入力してください。"
textField.placeholderColor = UIColor.red
```
だいたいこんな感じかなぁと思っていたけど、
全然違った！！


正しくは、こちら！
```swift
let textField = UITextField()
textField.attributedPlaceholder = NSAttributedString(string: "名前を入力してください。", attributes: [NSAttributedStringKey.foregroundColor : UIColor.red])
```
UITextFieldのattributedPlaceholderプロパティに、プレイスホルダーにしたい文字列にattributesを付与するNSAttributedStringを作成して、代入する必要があった。
How to pass initial props from Android native.
Tags: reactnative, android
Published: 2017-11-16 05:23:19

---
title: How to pass initial props from Android native.
published: true
description: 
tags: reactnative,android
---

There is a official document of passing initial props from iOS native, but not Android.

It is passed by getLaunchOptions of ReactActivityDelegate.

So, override createReactActivityDelegate of MainActivity and getLaunchOptions of ReactActivityDelegate.


```java
public class MainActivity extends ReactActivity {
    @Override
    protected ReactActivityDelegate createReactActivityDelegate() {
        return new ReactActivityDelegate(this, getMainComponentName()) {
            @Nullable
            @Override
            protected Bundle getLaunchOptions() {
                Bundle bundle = new Bundle();
                bundle.putString("message", "Hello world from Android Native");
                return bundle;
            }
        };
    }
    ...
}
```

It is received as the props of a root component, which is a second argument of AppRegistry.registerComponent.

```javascript
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text>{this.props.message}</Text>
      </View>
    );
  }
}

...
```
Section or article to use in HTML semantics markup?
Tags: article, section, semantics, html
Published: 2017-11-16 05:16:27

---
title: "Section or article to use in HTML semantics markup?"
published: true
description: Which element to use article or section
tags: article, section, semantics, html
---

If you are wondering, which section element - SECTION or ARTICLE - to use while creating your html markup, just keep in mind this useful and concise definition of both of them and in what way they are different.

<em>Section</em> is to be used, when we talk about something, which is <strong>a part of</strong> something else. For instance, a chapter in the book. Because, the chapter is part of the book along with other chapters.

<em>Article</em> should be used, when we mean something, which exists <strong>on its own</strong>. For instance, a tweet, comment, blog post, newspaper ad. Because, comment is not part of the article, which it refers to, the comment lives by itself.

<a href="https://www.w3.org/TR/html5/sections.html#outline">Source.</a>
My best Python heredoc like Ruby's one
Tags: python
Published: 2017-11-16 04:36:45

---
title: My best Python heredoc like Ruby's one
published: true
description: 
tags: Python
---

# Ruby (I want to do like this with Python)


```rb
sayaka = '美樹 さやか'
kyoko = '佐倉 杏子'

str = <<~HEREDOC
  <div>
    <ul>
      <li>#{sayaka}</li>
      <li>#{kyoko}</li>
    </ul>
  </div>
HEREDOC

puts(str)
```
```
<div>
  <ul>
    <li>美樹 さやか</li>
    <li>佐倉 杏子</li>
  </ul>
</div>
```

Like above, I want to do:

* Ignore leading whitespaces at each line
* Ignore break line after the first `'''`


# Python (How to do that)

```py
def heredoc(str):
  from textwrap import dedent

  return dedent(str).strip()


if __name__ == '__main__':
  sayaka = '美樹 さやか'
  kyoko = '佐倉 杏子'

  str = heredoc(f'''
    <div>
      <ul>
        <li>{sayaka}</li>
        <li>{kyoko}</li>
      </ul>
    </div>
  ''')

  print(str)
```

```stdout
<div>
  <ul>
    <li>美樹 さやか</li>
    <li>佐倉 杏子</li>
  </ul>
</div>
```
Phoenix.Router.NoRouteError 発生時のレスポンス
Tags: api, elixir, phoenix
Published: 2017-11-16 04:00:04

---
title: Phoenix.Router.NoRouteError 発生時のレスポンス
published: true
description: 
tags: api,elixir,phoenix
---

Phoenix 1.3 では `action_fallback` が追加されたためエラーハンドリングがとても簡単になりました。
http://phoenixframework.org/blog/phoenix-1-3-0-released

しかし、`Phoenix.Router.NoRouteError` が発生した場合にはコントローラーまで処理が届かないため、 `action_fallback` は使用できません。
そこで、 `Plug.ErrorHandler` を使用して NoRouteError に対応してみようと思います。

まず、以下のような ErrorView を作成します。

```elixir
# views/error_view.ex
defmodule HelloWeb.ErrorView do
  use HelloWeb, :view

  def render("404.json", _assigns) do
    %{errors: %{detail: "Page not found"}}
  end

  def render("500.json", _assigns) do
    %{errors: %{detail: "Internal server error"}}
  end

  def render(_template, assigns) do
    render "500.json", assigns
  end
end
```

次に、 `Plug.ErrorHandler.handle_errors` をオーバーライドするモジュールを定義します。


```elixir
# router_error_handling.ex
defmodule HelloWeb.RouterErrorHandling do
  defmacro __using__(_) do
    quote do
      use Plug.ErrorHandler

      def handle_errors(conn, %{reason: reason} = %{reason: %Phoenix.Router.NoRouteError{}}) do
        send_resp(conn, conn.status, Poison.encode!(HelloWeb.ErrorView.render("#{reason.plug_status}.json", %{})))
      end
      def handle_errors(conn, %{kind: _kind, reason: _reason, stack: _stack}) do
        send_resp(conn, conn.status, Poison.encode!(HelloWeb.ErrorView.render("500.json", %{})))
      end
    end
  end
end
```

最後に上記モジュールを Router 内で use して終わりです。

```elixir
# router.ex
defmodule HelloWeb.Router do
  use HelloWeb, :router
  use HelloWeb.RouterErrorHandling

 ...
end
```

独自実装の use 反対派の宗教に入っている方は RouterErrorHandling を定義せずに Router 内で直接 Plug.ErrorHandler を use して handle_errors を書く感じでも動作はしました。
私の場合は、 Router にルーティング定義以外の処理を書いてルーティングの見通しが悪くなるのが嫌だったので別モジュールにしています。

`Poison.encode!(HelloWeb.ErrorView.render("#{reason.plug_status}.json", %{}))` に気持ち悪さを感じるので、この辺いい感じにしたい......。
node-imagemagickの使い方（日本語）
Tags: node, javascript
Published: 2017-11-16 03:51:43

---
title: node-imagemagickの使い方（日本語）
published: true
description: 
tags: node,javascript
---

## はじめに

[Lambdaで画像のサムネイルを作る [Stream yields empty buffer対策済] by @hkomachi on @Qiita]( https://qiita.com/komakomako/items/8a6c949cd10b932f71db)

上記の記事を参考に，AWS Lambdaを使って動的画像リサイズを行おうとした際，もうちょっと細かいことをしようとして https://github.com/rsms/node-imagemagick の README読んでもわからなくて，結局慣れない中モジュールのコードを全部読んでしまったのでメモ。

## メソッド紹介

メソッド（の一部）紹介。
上記リポジトリのREADMEの一部和訳と補足。

### identify(args, callback(err, output))

imagemagick の`identify`コマンドと同様に画像の詳細を得る。
`args`には`identify`コマンドの引数をそのまま入力することが可能。
[identify | ImageMagick コマンドリファレンス](http://image-magick.com/2014/09/27/identify/)

```javascript
im.identify(['-format', '%wx%h', 'kittens.jpg'], function(err, output){
  if (err) throw err;
  console.log('dimension: '+output);
  // dimension: 3904x2622
});
```

ファイル名ではなく画像データを直接入れることも可能。
例えば，`aws.s3`でs3バケットからオブジェクトをとってきた（ファイルパスを指定するのが難しい）ときは，

```javascript
s3.getObject(params, (err, data) => {
    if (err) {
    } else {
        im.identify(['-format', '%w', {data: data.Body}], function(err, output){
            if (err) throw err;
            console.log('dimension: '+output);
            // dimension: 3904x2622
        });
    }
});
```
といったようにできる。

### readMetadata(path, callback(err, metadata))

`identify`コマンドを使うが，こっちは結果が`metadata`オブジェクトとして帰ってくる。

### convert(args, callback(err, stdout, stderr))

`convert`コマンドを使う。これも`args`は引数そのまま。
[convert | ImageMagick コマンドリファレンス](http://image-magick.com/2014/09/29/convert/)

### resize(options, callback(err, stdout, stderr))

`convert`コマンドのresize機能を使う。第一引数`options`の内容例を示す。
```javascript
{
  srcPath: 'hoge.jpg', // 元画像パス srcDataと排他
  srcData: null,      // 元画像データ srcPathと排他
  quality: 0.8,
  format: 'jpg',      // 出力フォーマット
  width: 0,           // 出力横幅
  height: 0,          // 出力高さ
  customArgs: []      // 自由にオプションを追加できる
}
```

サイズ指定のあとに`>`や`<`を使って「指定サイズより(大き|小さ)ければ(縮小|拡大)」みたいなのができない。
一通りコード読んで，リサイズするにしても細かいことがしたければ`resize`ではなく`convert`を使ったほうがよいという結論に至った。

### crop(options, callback)

resizeと同様`convert`コマンドのcrop機能を使う。
これも細かくオプションを弄りたければ`convert`関数のほうを使う必要がある。

## さいごに

完璧なラッパーなど存在しない 😢
Starting path to be Front-end Developer as Junior.
Tags: frontend, webdeveloper, junior, webtech
Published: 2017-11-16 03:51:42

---
title: Starting path to be Front-end Developer as Junior.
published: true
description: 
tags: front-end, web developer, junior, web Tech
cover_image: https://thepracticaldev.s3.amazonaws.com/i/o14y2jbddb3j3yw8fo7c.jpg
---

Since I start to learn the path to be a Front-end Developer just to improve my personal skill about it. I get comfortable using Git, Visual Studio Code and the terminal haha.

I am a Junior Developer on this time, what that mean, I'm just in time to focus all my energy to learn stuff to gonna be part of my future as Developer.

In my actual job, my duties are about to DBA stuff, resolving issues about database (I really love it), maintain ours SQL Server with a nice energy to keep running smoothly with lowest issues in each one. But recently I want something else to do, some new fields that are unknown to me, so I decide to start learning some Front-End tech.


###What is to be a DBA in a Front-end tech ?

Since I start I saw all kind of frameworks, librarys and so on. I choose to focus all my attention to one of the mayor JavaScript frameworks at this moment, develop and maintain for Google, Angular.

Is easy with a little time and effort, you get all things to make some basics front-end stuffs using that framework. I hear that React is more lightweight but, for now, first Angular.


###Conclusion.

Just take some courage and learn something new that make you proud of what you do and what learn and study more and more until you feel comfortable with the new technology.

See you later.
The reason why Japanese user suddenly increased on this site.
Tags: meta
Published: 2017-11-16 03:28:59

---
title: The reason why Japanese user suddenly increased on this site.
published: true
description: 
tags: #meta
---

On this site Japanese user suddenly increased around yesterday(Nov.15). There are reasons for this. 

A Japanese posted about dev.to on Twitter.
### - "This site is awesome fast response 😂😂."

And, a lot of Japanese people opened this site and was surprised by so fast response.

And, I'm one of the Japanese who was amazed by that.
ruby を Hot Tags に入れたいぞ
Tags: ruby
Published: 2017-11-16 02:09:55

---
title: ruby を Hot Tags に入れたいぞ
published: true
description: ruby を Hot Tags に入れる空気を醸成していく
tags: ruby
---

gem 入れる時にたまに apt install とか brew とか必要になる部分を自動化するツールを妄想中。
Help with selling DevOps transformation
Tags: devops, agile, productivity, discuss
Published: 2017-11-16 02:50:41

---
title: Help with selling DevOps transformation
published: true
description: DevOps and agile transformation help
tags: DevOps, Agile, productivity, discuss
---

I have been trying to help facilitate a DevOps and Agile transformation at the company I work for. I was wondering if anyone had any helpful tips to help make the transition successful!
I build date and range picker from scratch so you don't have to
Tags: datepicker, rangepicker, javascript, svelte
Published: 2017-11-16 02:45:10

---
title: I build date and range picker from scratch so you don't have to
published: true
description: small date and range picker for web
tags: date-picker, range-picker, javascript, svelte
---

Don't you hate to repeat yourself? For example, I hate working on anything related to user authentication or authorization that isn't directly related to the system I'm working on. I see it as necessary evil, an accidental complexity.

Fortunately, web components are coming and soon we'll get to choose from even more and better UI components and we won't need to reinvent common components from scratch all the time. We are reinventing components because we're always switching to new JS frameworks.

[As Ben Issa puts it](https://youtu.be/8ZTFEhPBJEE?t=1113): assemblers first, crafts people second.

## Motivation
- must be significantly smaller than moment.js + jQuery combo or even moment.js  + custom elements combo
    - ~170 kB (~140 kB for moment + ~30 kB for jQuery, not including calendar library size at all) vs 4.2 kB for nanocal
- must be reusable anywhere on web
    - use it with or without frameworks
    - use it with or without build tools

## Decisions
- I used [svelte](https://svelte.technology/) because it compiles down to plain javascript which makes this library able to run with no runtime or build tool dependencies
- I ripped-off Airbnb's style, because I am no designer nor I wanted to spend time re-inventing calendar style
- For testing I use tape (and not jest or ava) because I want to run tests inside real browser which is targeted runtime

## Future plans
- once web components are available everywhere ™, I'll probably rewrite front-end part into custom element or use svelte's compile to custom elements
- add more style customizations or remove some

I hope my UI decisions will work for some of you. I build this library for myself, documented and open-sourced it for you.

Here's the repo: ⭐️ https://github.com/zigomir/nanocal ⭐️
ignor, a utility to fetch .gitignore templates from gitignore.io.
Tags: git, showdev
Published: 2017-11-15 20:58:10

---
title: ignor, a utility to fetch .gitignore templates from gitignore.io.
published: true
description: I published ignor on Cargo. ignor is a command line utility to fetch .gitignore tempaltes from gitignore.io.
tags: git, showdev
---

I published [`ignor`](https://crates.io/crates/ignor) on Cargo.

You can do this using `ignor`.

```bash
$ ignor rust intellij > .gitignore
```

## Why not use `cURL`?

You can generate .gitignore using a command like this.

```bash
$ curl -L -s https://www.gitignore.io/api/rust,intellij
```

However, it is too difficult for find out in my bash/zsh history.

## Why not use bash/zsh function?

I want to press `space` key instead of `,` key :)
It is tough for me to press `,` key than `space` key. 

---

Thanks to other crates, the LOC is less than 100 and it is easy to understand.
[PR welcome](https://github.com/thara/ignor).


Happy coding!
8 minutes of fame — fzf talk
Tags: terminal, commandline, fzf
Published: 2018-03-03 08:53:47

---
title: "8 minutes of fame — fzf talk"
published: true
tags: terminal,command-line,fzf
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/1024/1*BY3Uq4WgzyvruHuCl4o_Hw.png)

Today we’ve started a new thing in our company(just in case you wondering it’s Outfittery Gmbh) — “8 minutes of fame”. This thing has one idea behind — small lightning talks 8 minutes each. It expected to be periodical. For now, we’ve agreed to do it once a month but will see how it’ll go. Each session contains 4 slots. No slides allowed \* — show code or live demo, or you could just talk for 8 minutes(\* — on some exceptional topics it’s ok to&nbsp;have).

But here I want to summarize the talk I gave —  **How to&nbsp;fzf.**

First of all, what is [**fzf**](https://github.com/junegunn/fzf)? That is command line tool that should simplify your daily life with power of fuzzy finding. That actually the way how it’s pronounced — FuzzyFinder. It is written in **Go** lang and could be easily found on **Github**. The recommended way to **install** it — checkout the repo to ~/.fzf folder and run install script. It will ask you several questions and you are ready to go!(don’t forget to apply shell config modifications with source&nbsp;command)

What is so cool about it? Well, it’s doing one thing but doing it well. As each Unix tools should. It takes a list of lines to STD/IN and produces a filtered list of lines to STD/OUT. But magic happens in the middle =). Under the hood it supports several filter options: default one — fuzzy finding — you type and it tries to understand what you actually mean, strict match, the strict match from the beginning of the line and strict match on the end of the line. Forgot to mention, it is also possible to filter something out — just prepend your query with&nbsp;!(bang).

After you’ve found what you need(with a query or by manual navigation with cursor buttons) just hit enter or even just pick what you need my mouse click.With **-m** flag passed it’s allowed to pick several items from the list(just use Tab or Shift+Tab).

Just with this functionality, this tool becomes useful for integration to you interactive scripts. But it provides more — bunch of cool keybindings(and you can extend it). Here is my favorite:

1. Ctrl+R — fuzzy search on your terminal&nbsp;history;
2. Ctrl+T — find files in current directory and deep inside and return the result to the command line. Super useful when you type some command(let’s say less) and then you hit Ctrl+T and pick file you&nbsp;want;
3. Alt+C — cd to selected directory;
4. ssh \*\* and then Tab — selecting a host from your hosts file or ssh&nbsp;config;
5. kill -9 and then Tab — selecting process to&nbsp;kill;

And there is more, those are just my top list I use daily.  
There are several more things worse to mention: Vim integration and new feature — preview. But, I hope, if you haven’t tried(or maybe you are using fzf already for many years…), just check it. More details you always can find in README file. And I’m going to prepare my next talk for “8 minutes of&nbsp;fame”.
We welcome a wonderful influx of new members from Japan
Tags: meta
Published: 2017-11-15 18:35:27

---
title: We welcome a wonderful influx of new members from Japan
published: true
description: dev.to has received a lot of positive attention/publicity in Japan
tags: meta
---

We're not totally certain what the sequence of events was, but [dev.to](/) has received a lot of positive attention/publicity in Japan in the last 12 hours or so. It has meant a lot of new members and a lot of new posts.

This has been awesome and most of the posts have been great. It's also stretched us further into the territory of "how exactly do we serve the right multilingual experience". We don't have a lot of fully baked features for this yet. The good thing is, we've been thinking about this for a while and should be able to ship some new support soon.

I was already able to quickly ship up one simple adjustment that improves the Japanese language experience, based [on this post](https://dev.to/arccosine/how-to-use-ruby-tag-6nh).

Serving different languages _well_ is a big part of inclusivity and we're excited to improve this part of the platform. Once we're open source, we should be able to do this more effectively as well. We're targeting the beginning of January for the open-sourcing of our code.