teleren/devto huggingface dataset:
Recent changes in go-sqlite3
Tags: go, sqlite3
Published: 2017-11-15 06:39:27

---
title: Recent changes in go-sqlite3
published: true
description: Recent changes in go-sqlite3
tags: go, sqlite3
cover_image: https://thepracticaldev.s3.amazonaws.com/i/3pgvz0wma5xng2orj1ly.jpg
---

In brief, I added some important features in [go-sqlite3](https://github.com/mattn/go-sqlite3).

# Hook events

It was introduced before, but it was not the default. Now you can use this in default. To use this, you need to register hook.

To be honest, I don't think this way is not smart, but no way to do in Go master.

```go
sql.Register("sqlite3_with_hook_example",
	&sqlite3.SQLiteDriver{
		ConnectHook: func(conn *sqlite3.SQLiteConn) error {
			conn.RegisterUpdateHook(func(op int, db string, table string, rowid int64) {
				switch op {
				case sqlite3.SQLITE_INSERT:
					log.Println("Notified of insert on db", db, "table", table, "rowid", rowid)
				}
			})
			return nil
		},
	})
```
Then you can see when the record is inserted/deleted/updated. Similar to triggers but easier to handle events, I think. For example, this may be helpful to make replication of the database.

# Get limits

This also need to register hook.

```go
var sqlite3conn *sqlite3.SQLiteConn
sql.Register("sqlite3_with_limit", &sqlite3.SQLiteDriver{
	ConnectHook: func(conn *sqlite3.SQLiteConn) error {
		sqlite3conn = conn
		return nil
	},
})
db, err := sql.Open("sqlite3_with_limit", "./foo.db")
if err != nil {
	log.Fatal(err)
}
defer db.Close()
```

After connect to your database, you can use `SQLite3Conn#GetLimit()`.

```go
varnum := sqlite3conn.GetLimit(sqlite3.SQLITE_LIMIT_VARIABLE_NUMBER)
```

# Export Go func into your SQL

`RegisterFunc` export your Go function into your SQL. 

```go
sql.Register("sqlite3_custom", &sqlite.SQLiteDriver{
	ConnectHook: func(conn *sqlite.SQLiteConn) error {
		if err := conn.RegisterFunc("pow", pow, true); err != nil {
			return err
		}
		return nil
	},
})
```

`pow` should be like below. Just call `Math.Pow`. Note that you must use int64 instead of int for the arguments/return types of the func.

```go
func pow(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}
```

That's all to be done for enable this feature. So now you can call `pow` in your query.

```go
err = db.QueryRow("SELECT pow(2,3)").Scan(&i)
if err != nil {
	log.Fatal("POW query error:", err)
}
```
If you want to use regular expression in the query:

```go
sql.Register("sqlite3_with_go_func", &sqlite3.SQLiteDriver{
	ConnectHook: func(conn *sqlite3.SQLiteConn) error {
		return conn.RegisterFunc("regexp", func(re, s string) (bool, error) {
	            return regexp.MatchString(re, s)
		}, true)
	},
})
```
Why do some engineers in Japan wants to post poops ?
Tags: poem
Published: 2017-11-15 06:29:04

---
title: Why do some engineers in Japan wants to post poops ?
published: true
description: 
tags: poem
---

I don't understand that but somehow, several people post some useless articles.(ofcouse, also this article will be the same)

They're not about techs, engineerings, web and other useful topic.

They always post poops at everywhere in the internet world.

But maybe, is it same in other contries?

I do want to know about that.
sudo apt-get install zsh
Tags: install, ubuntu, zsh
Published: 2017-10-14 18:24:14

---
title: sudo apt-get install zsh
published: published
description: Install zsh on Ubuntu Desktop, Ubuntu Server 16.04.3, Linux Mint, VagrantBox
tags: Install, Ubuntu, ZSH
---

```shell
vagrant@vagrant:~$ sudo apt-get install zsh
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  zsh-common
Suggested packages:
  zsh-doc
The following NEW packages will be installed:
  zsh zsh-common
0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
Need to get 3822 kB of archives.
After this operation, 14.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 zsh-common all 5.1.1-1ubuntu2 [3170 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 zsh amd64 5.1.1-1ubuntu2 [651 kB]                                                                                                
Fetched 3822 kB in 10s (365 kB/s)                                                                                                                                                            
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "en_US:",
        LC_ALL = (unset),
        LC_CTYPE = "de_LU.UTF-8",
        LANG = "en_US"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously unselected package zsh-common.
(Reading database ... 86860 files and directories currently installed.)
Preparing to unpack .../zsh-common_5.1.1-1ubuntu2_all.deb ...
Unpacking zsh-common (5.1.1-1ubuntu2) ...
Selecting previously unselected package zsh.
Preparing to unpack .../zsh_5.1.1-1ubuntu2_amd64.deb ...
Unpacking zsh (5.1.1-1ubuntu2) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up zsh-common (5.1.1-1ubuntu2) ...
Setting up zsh (5.1.1-1ubuntu2) ...
update-alternatives: using /bin/zsh5 to provide /bin/zsh (zsh) in auto mode
update-alternatives: using /bin/zsh5 to provide /bin/rzsh (rzsh) in auto mode
```
When use ancestor query in GAE, you don't have to be use a existed entity.
Tags: python
Published: 2017-11-15 06:28:10

---
title: When use ancestor query in GAE, you don't have to be use a existed entity.
published: true
description: 
tags: #python 
---

But it is better to use a existed entity.


```
from google.appengine.ext import ndb

class Customer(ndb.Model):
    name = ndb.StringProperty()

class Purchase(ndb.Model):
   price = ndb.IntegerProperty()

customer_entity = Customer(name='me', id='aaa@example.com')
purchase1 = Purchase(parent=customer_entity.key, price=100)
purchase2 = Purchase(parent=customer_entity.key, price=200)
purchase1.put()
purchase2.put()
print Purchase.query(ancestor=customer_entity.key).fetch()
#[Purchase(key=Key('Customer', 'aaa@example.com', 'Purchase', 5414888608366592), price=200), Purchase(key=Key('Customer', 'aaa@example.com', 'Purchase', 5977838561787904), price=100)]

key = ndb.Key('user', 'bbb@example.com')
purchase3 = Purchase(parent=key, price=100)
purchase4 = Purchase(parent=key, price=200)
purchase3.put()
purchase4.put()
print Purchase.query(ancestor=key).fetch()
#[Purchase(key=Key('user', 'bbb@example.com', 'Purchase', 4711201166589952), price=200), Purchase(key=Key('user', 'bbb@example.com', 'Purchase', 6540788515209216), price=100)]
```
Unity chan Live for UnrealEngine 4
Tags: ue4
Published: 2017-11-15 06:18:11

---
title: Unity chan Live for UnrealEngine 4
published: true
description: 
tags: UE4
---

# TLDR;

https://github.com/shop-0761/UnitychanLIVE-UE4Ver-

# Introduction
I transplanted "unity chan live" what is one of the most famous Unity Demo Contents in Japan.  

Unity Project

https://github.com/unity3d-jp/unitychan-crs

Movie

https://youtu.be/M_GUlXJ52YA


UE4 ver. Movie

https://youtu.be/Bt-d3hQUurM

and my project can play on Android(Galaxy S6).

https://twitter.com/shop_0761/status/861739294444068865
(ヽ´ω`)ﾄﾎﾎ･･
Published: 2017-11-15 06:04:43

---
title: (ヽ´ω`)ﾄﾎﾎ･･
published: true
description: (ヽ´ω`)ﾄﾎﾎ･･
tags: 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/f15kg0fu3irvbcxhst6u.jpg
---

```
‹‹\(´ω` )/››‹‹\( 　´)/›› ‹‹\( ´ω`)/››~♪
```

![](https://thepracticaldev.s3.amazonaws.com/i/nmaud18rv3njwnvf84ed.jpg)

```
‹‹\(´ω` )/››‹‹\( 　´)/›› ‹‹\( ´ω`)/››~♪
```


![](https://cdn.blog.st-hatena.com/css/theme/sushiyuki/images/lane.gif)
Firefox Quantum Released
Tags: webdev, firefox, browser, rust
Published: 2017-11-15 06:03:57

---
title: "Firefox Quantum Released"
published: true
description: Firefox Quantum Released Today.
tags: [webdev, firefox, browser, rust]
---
![Firefox Quanrum img](https://thepracticaldev.s3.amazonaws.com/i/0t6hmuii4t89hh67oqhr.PNG "Firefox Quantum")

##CSS engine using Rust.
##Speed up&Tuning.
##Add-on for WebExtensions Only.


- WebExtensions Installed Add-on List
[Firefox Quantum Add-ons (WebExtensions)](https://addons.mozilla.org/ja/firefox/collections/takimura/webextensions/)

- visit My websites [here](https://coron.tech/)
- visit Twitter [here](https://twitter.com/cv_k/)


###[Firefox Quantum Download here](https://www.mozilla.org/firefox/new/)


this post is tested.

Thanks you.
getting regex in a quick way
Tags: regex
Published: 2017-11-15 05:53:45

---
title: getting regex in a quick way
published: true
description: getting regex in a quick way for temporary, tiny task
tags: #regex
---


create snippets

    #!/usr/bin/env ruby
    # -*- coding: utf-8 -*-

    # escape.rb

    def main()
        ARGV.each do |arg|
            puts(Regexp.escape(arg))
        end
    end

    if __FILE__ == $0 then
        main()
    end

run

    $ ./escape.rb "http://www.google.com/"
    http://www\.google\.com/


:D
Use Storybook with Vuejs
Tags: vue
Published: 2017-11-15 05:52:11

---
title: Use Storybook with Vuejs
published: true
description: 
tags: vuejs
---

![Screen Shot 2017-08-21 at 17.08.26.png](https://qiita-image-store.s3.amazonaws.com/0/7565/3baf1c3e-520a-9c3c-0d14-b4b46518b7f1.png)


[Storybook](https://storybook.js.org/) Since 3.2, support for Vuejs has been added, so I will try using it at once.

Storybook is a tool that makes it easy to create catalogs of components, cataloging self-made components in the project and how to use it.

![Screen Shot 2017-08-21 at 16.54.49.png] (https://qiita-image-store.s3.amazonaws.com/0/7565/899f8ef8-1dd4-5e4c-8dfb-56e431a37b6c.png)


## Installation of storybook / cli


```bash
npm i - g @ storybook / cli
```


Prepared by existing Vuejs project

```bash
cd Directory where vuejs project is located
```

Installing the storybook

```bash
getstorybook
```

## Start storybook server

```
yarn run storybook
```

In this state, opening http://localhost:6006/ opens the default setting screen.

## Add component

To add a component to a storybook, add a definition to `index.js` in the` stories` directory created with `getstorybook`.

You can change this `stories` directory by editing` .storybook / config.js`.


## Reference material

* [Introducing: Storybook for Vue  🎉 – Storybook – Medium](https://medium.com/storybookjs/introducing-storybook-for-vue-940f222541c5)
* [Announcing Storybook 3.2 – Storybook – Medium](https://medium.com/storybookjs/announcing-storybook-3-2-e00918a1764c)
* [storybook/MIGRATION.md at master · storybooks/storybook · GitHub](https://github.com/storybooks/storybook/blob/master/MIGRATION.md#from-version-31x-to-32x)
How fast dev.to is!
Tags: devto
Published: 2017-11-15 05:47:48

---
title: How fast dev.to is!
published: true
description: Everyone is interested in the speed of dev.to.
tags: dev.to
---

Today I looked up the techniques how dev.to is doing for speed. Seems to be that use ServiceWorker for fetching contents and store cache. Also use webp images smaller size. pre-fetching contents when mouse-over the link. Embeding CSS-inline to avoid blocking rendering. also external resources ex font.

Great! There are many things to be helpful.

https://dev.to/ben/making-devto-insanely-fast
HTTP/2はどのような状況でも速度向上が見込めるような万能な技術ではない
Tags: http2
Published: 2017-11-15 05:36:38

---
title: HTTP/2はどのような状況でも速度向上が見込めるような万能な技術ではない
published: true
description: 
tags: http2
---

ここ最近、俄かにHTTP/2が流行の兆しを見せているように見える。言及されぬ技術は使われず、そして使われぬ技術は存在しない物であるのと同義であると私は考えるので悪い事ではないのだが、本来HTTP/2を使う上で注意すべきである点を無視して言及しているように見えるので一度深く熟考する必要があるのではないだろうか。

HTTP/2は複数の要求を一つの接続に纏め上げられる通信規格であり、従来のHTTP/1.1による通信に於いて存在していた大きな速度遅延の要因をなくす事は、確かに出来ている。だがHTTP/2は現在の実装状況に於いてはTLSを上層に配す、HTTPSである事を求められている。HTTPSは暗号化と復号の処理だけではなく、証明書の確認も行われる事になる為に、HTTPよりも速度は低下する事になってしまっている。数十程度の接続しかなされないようなウェブページであれば、HTTP/2を使う事によって得られる速度向上よりも、HTTPSを使う事による速度低下の方が大きくなり、結果として速度が低下してしまう事になる。HTTP/2による恩恵が得られるのは、画像が数百枚も貼付されているウェブページや、Ajaxによる動的な情報取得を繰り返し短時間の内に幾つもの通信が常に発生し続けるようなウェブアプリケーションに限られると私は考える。文書が主体となり、画像が数枚しかないようなウェブページでは全く意味のないどころか、逆に悪影響を与える結果にしかならないのではないか。

また、同一のホスト名による通信でなければ、HTTP/2による速度向上の恩恵には与れない。厳密に言えば、同一の証明書に於いてエイリアスの指定を行ったり、コモンネームにワイルドカードを使用したりする事により、複数ホスト名を使う事が出来る。だが、ホスト名が限定されてしまう事には変わりない。例えば、Amazon S3といったストレージサービスを使い、画像ファイル等の配信を行っている場合に、HTTP/2は全く効果を発揮しない。

そして、HTTP/2はHTTPSでの通信となっている事が現状では必須である都合上、今までHTTPで提供されていた場合にはURIが変わってしまう。301 Moved Permanentlyと`Location`ヘッダーを用いた転送を行う事により、既存のURIから誘導する事は可能であるが、[クールなURIは変わらない](https://www.kanzaki.com/docs/Style/URI)というウェブの基本的な考えが通用しなくなってしまう。かてて加えて、もしいつかHTTP/2を使うのを止めようと考えた時にも、今度はHTTPSを常に維持し続けなければならなくなる。HTTPの維持はそう面倒な事ではないが、HTTPSの維持は証明書の絡みもあり、多少とはいえ煩わしさがある。今後の事を考えれば、必ずしも必要であると断定出来ない場合には避けるべきであろう。

現在多く使われているウェブサーバーはApacheとnginxの二つだろう。ApacheにはHTTP/2に対応するためのモジュールが存在しており、またnginxでは標準でHTTP/2の対応が備わっている。いずれの場合にも簡単にHTTP/2の対応を施す事が出来る。その為に他の速度向上の方法を試す前に気軽にHTTP/2を使おうと考える者もいるであろう。だが、HTTP/2によって速度が向上する場合は非常に限定的である。きちんと自身の提供する物がどういった物であるのかを考え、HTTP/2が適切でない場合には、適切な他の手段を使用するべきである。

例えばWordPressを使用している場合はPHP自身の速度の遅さやMySQLを用いた情報の授受によって生じる速度低下の方が通信によるボトルネックよりも致命的であると考えられる。APCの導入やmemcached等を使った適切なキャッシュを行う方が速度向上には有効だろう。またJavaScriptによる動的な操作を多用するようなウェブページであればDOM操作を適切に行う事により、処理が遅くなってしまう事が避けられ、閲覧者の体感する速度向上は非常に大きくなる。現在のJavaScriptは多くの実装がJITにより高速に動作するようになったが、DOM操作は非常に遅いままである。適切な記述をしなければ、その積み重ねにより無視出来ない致命的な速度遅延を招く。HTTP/2を使うよりも有効で、そして現実的な方法が幾つも存在している。

とはいえ、機密性の高い情報のやり取りを行う必要があり、元よりHTTPで提供する事が考えられず、HTTPSにする必要がある場合にはHTTP/2を使っても損はない。HTTP/2に限らず、こうした最新の技術は深く考えた上で適材適所に合致するような適切な選択をそのつどに行っていくのが肝要である。
How to test traits by unit testing
Tags: php
Published: 2017-11-15 05:33:34

---
title: How to test traits by unit testing
published: true
description: 
tags: php
---


As PHP traits can not be instance by its self, it seems impossible to unit test. However, by making ordinary classes that use a trait, you can write test code for traits.

```php
<?php

trait Greetable {
	public function hello(int $repeat): string {
		return str_repeat('Hello!', $repeat);
	}
}

class GreetableBeings {
	use Greetable;
}

class GreetableTest {
	public function testHello() {
		$g = new GreetableBeings();
		assert($g->hello(1) === 'Hello!');
		assert($g->hello(2) === 'Hello!Hello!');
		assert($g->hello(3) === 'Hello!Hello!Hello!');
	}
}

(new GreetableTest)->testHello();
```


Since [anonymous class] can be used from PHP 7, we no longer have to bother to create a class for testing.

[anonymous class]: http://php.net/manual/en/language.oop5.anonymous.php


```php:PHP7以上
<?php

trait Greetable {
	public function hello(int $repeat): string {
		return str_repeat('Hello!', $repeat);
	}
}

class GreetableTest {
	public function testHello() {
		$g = new class { use Greetable; }; // anonymous class
		assert($g->hello(1) === 'Hello!');
		assert($g->hello(2) === 'Hello!Hello!');
		assert($g->hello(3) === 'Hello!Hello!Hello!');
	}
}

(new GreetableTest)->testHello();
```
Writing a small bare-metal container
Tags: container, ruby
Published: 2017-11-15 05:16:26

---
title: Writing a small bare-metal container
published: true
description: Writing a small bare-metal container with Shell and Ruby
tags: 
  - container
  - ruby
---

First, run `debootstrap` command.


```console
$ sudo mkdir /root/devto
$ sudo debootstrap --variant=minbase \
    jessie \
    /root/devto \
    http://ftp.jp.debian.org/debian
```

Then, prepare a small ruby script:

```ruby
# $ cat after-unshare.rb 
#!/usr/bin/env ruby
container_name = ARGV[0]
raise unless container_name
Dir.mkdir "/sys/fs/cgroup/cpu/#{container_name}" rescue puts("skip")
File.write "/sys/fs/cgroup/cpu/#{container_name}/cpu.cfs_period_us", "100000"
File.write "/sys/fs/cgroup/cpu/#{container_name}/cpu.cfs_quota_us",   "30000" # 30%
File.write "/sys/fs/cgroup/cpu/#{container_name}/tasks", $$.to_s
Dir.chroot "/root/#{container_name}"
Dir.chdir "/"
system "mount --make-rprivate /"
system "mount -t proc proc /proc"
system "hostname #{container_name}.example.com"

exec "bash -l"
```

After all, run this ruby script via `unshare(1)` with options below:

```console
$ chmod a+x after-unshare.rb
$ sudo unshare \
    --fork \
    --pid \
    --mount \
    --uts \
    `pwd`/after-unshare.rb devto
```

That's it!! You're got into the container!!

```console
root@devto:/# ps auxf
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.3  0.3  20288  3240 ?        S    05:13   0:00 bash -l
root         7  0.0  0.2  17496  2080 ?        R+   05:13   0:00 ps auxf
```
Challenge: find 'Kaprekar numbers'
Tags: challenge, fun, puzzle
Published: 2017-11-13 22:47:42

---
title: "Challenge: find 'Kaprekar numbers'"
published: true
description: Write a solution to find Kaprekar numbers
tags: challenge, fun, puzzle
---

I saw this tweet over the weekend—

{% twitter 929715470655254535 %}

Via [Wikipedia](https://en.wikipedia.org/wiki/Kaprekar_number)—
>In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts—either or both of which may include leading zeroes—that add up to the original number. For instance, 45 is a Kaprekar number, because 452 = 2025 and 20 + 25 = 45.

## Challenge

In the language of your choice, write a script to find the first 8 Kaprekar numbers.  `1, 9, 45, 55, 99, 297, 703, 999`

Two clarifications via @ripsup [here](https://dev.to/peter/challenge-find-kaprekar-numbers-14m/comments/1ao8):
>First gotcha is the second part of the split numbers must be positive (no zeros). The second part was that you add a zero to the front if the length is odd.

Post your solution in the comments below!
As Postfacto Sunsets, RemoteRetro Rises: Introducing RemoteRetro
Tags: news, agilexp, products, labs
Published: 2017-12-12 22:16:36

---
title: "As Postfacto Sunsets, RemoteRetro Rises: Introducing RemoteRetro"
published: True
tags: News,Agile/XP,Products,Labs
canonical_url: https://www.stridenyc.com/blog/postfacto-sunsets-remoteretro-rises
---

[![As Postfacto Sunsets, RemoteRetro Rises: Introducing RemoteRetro](https://www.stridenyc.com/hubfs/a0SUdPG9kSnenunblBZdNyonHPM1C3np0VzvBYxLSFQ31v9bh4k5xw_b0FK3CnhAh1G8fHpnLcnkd0qkM7jiQ6qHSCJ_ULnmCSSm0dIbpLV4NXyWKTHWIW0Cnmn9YnpYI-1.png?t=1510610998873) ](https://www.stridenyc.com/blog/postfacto-sunsets-remoteretro-rises)

Pivotal has announced that as of December 4, 2017, Postfacto.io will shut down.

Although we are sad to see Postfacto go, Stride is proud to announce the open beta of [RemoteRetro](https://remoteretro.org/)! RemoteRetro is a real-time application for conducting retrospectives with distributed teams. RemoteRetro provides an intuitive, safe, fun experience for tech teams, providing guidance as the retrospective progresses, and automating many common facilitation tasks, including participation tracking, item sorting, and action-item distribution.

The beta is live at [remoteretro.org](https://remoteretro.org/), and the code is open-source and available at [https://github.com/stride-nyc/remote\_retro](https://github.com/stride-nyc/remote_retro).

 FAQ:

Q. Looks cool, but... what's a retro?

A.'Retro' is short for retrospective. A retrospective is one of the core Agile ceremonies. Retrospectives are used by teams to reflect on the events of their past iteration, with the aim of identifying where they can improve and generating action items that will help them make those improvements.


Q. Who can use RemoteRetro?

A. Anyone with a Google account of any kind can enter a retrospective!


Q. My team is entirely colocated. Should we use RemoteRetro?
A. You certainly could, but we don't recommend it, as there's no substitute for face-to-face communication. Use a whiteboard! Read our guidebook on how to run a collocated retrospective.


Q. Why is RemoteRetro open source?

A.The entire software development community stands on the shoulders of giants, and Stride is no exception. We talked it over and were unanimous in our desire to give back to the open source community.


Q. Where can I learn about planned features and updates?

A. Our backlog resides in GitHub issues, which can be viewed in priority order via the wonderful ZenHub Chrome extension.


Q. How many people should participate in a retro?

A. Ideally, a retrospective will contain no more than 10 people. Beyond 10, folks check out because they feel they can go unnoticed. If you can, keep the numbers low!


Q. How can I submit feedback on my experience?

A. Users are presented with a survey at the close of their first retro. Additionally, bugs and feature requests can be filed via GitHub issues at https://github.com/stride-nyc/remote_retro/issues/new or via email at remote_retro@stridenyc.com
The Mysterious (Edge) Case of Vallie O'Keefe
Tags: rails, rspec
Published: 2017-11-14 16:50:33

---
title: The Mysterious (Edge) Case of Vallie O'Keefe
published: true
description: Recently, one or two tests would fail randomly on our CI suite and I would see a message similar to this
tags: rails, rspec
---

Sometimes when a test fails, my first reaction will be to instantly re-run our continuous integration suite, without investing the time to evaluate the failing spec. This is a habit I want to overcome. To justify myself here, I do this because I will eventually acknowledge the problem when it happens repetitively, enough to annoy me. We're often preoccupied with a different task, and slowing down to thoroughly look at a random unrelated failing spec is hard to do.

Recently, one or two tests would fail randomly in our CI suite and I would see a message similar to this:

![](https://thepracticaldev.s3.amazonaws.com/i/8zziniklijauujx1xf1x.png)

For those of you who aren't familiar with RSpec, what it is saying is that it can't find `Vallie O'Keefe` in the response but it is clearly displayed there. I instantly rerun the spec and 90% of the time it would pass. But the problem is it would come back and haunt randomly here and there.

After about 2 weeks of this random failing spec (which had been appearing throughout our request specs, and only appeared to happen to me for some reason), I said to myself "Alright, what the hell is going on?". I ran the possible failing spec a few times locally and it seems to pass. I immediately realized this was a rare edge-case that I will hit if I repeatedly if I ran the spec 50+ times. So, I whipped up a script and I patiently sat and stared at it.

On the 20th attempt, the spec finally failed.

![](https://thepracticaldev.s3.amazonaws.com/i/jkv4n03dq2jr6hi6n4st.png)

It turns out that whenever [the `Faker` gem](https://github.com/stympy/faker), which randomly generates test data, created an output that contains an apostrophe, the apostrophe was getting encoded/escaped in HTML. When this happens, `Vallie O'Keefe` won't get matched with `Vallie O&#39Keefe`. What baffled me is that the response's content is unescaped when it is rendered on the CI suite. To remedy this, I had to escape what I wanted to match the response with. Below, for an example:

`expect(response.body).to eq CGI.escapeHTML(@thing.name)` 

I wish I knew this before we start writing request specs. BUT MORE IMPORTANTLY, I wish I slowed down and investigated it so that I could take precautionary measure for all the future request specs. Instead, I now have to manually spot failing request specs on CI and update as I go.
3 reasons why using kotlin for unique article is bad idea
Tags: android
Published: 2017-11-14 16:05:57

---
title: 3 reasons why using kotlin for unique article is bad idea
published: true
description: 
tags: android
---

~~1~~3 reasons why using kotlin for unique article is bad idea:

1. Folks at android studio hasn't normal kotlin -> java converter
2. Folks at android studio do have normal java -> kotlin converter
3. Most of people that will read your next article are beginners 


The beginners who barely get into android java world, but wanted dat article, become frustrated.


So your 3-5 files in kotlin without java alternative can ruin your tutorial and make beginners feel ashamed and lost once again (google are terrible on documentation and showing examples; and the most well made courses on internet shows how to make hello world app).


Let's make android fun ~~again~~ at last by providing java alternative!