Skip to content

Instantly share code, notes, and snippets.

View ledsun's full-sized avatar

shigeru.nakajima ledsun

View GitHub Profile
@ledsun
ledsun / async_test.rb
Created June 1, 2017 02:34
Rubyのasync_test関数
def async_test
q = SizedQueue.new(1)
yield(Proc.new{ q.push :done })
q.pop
end
it '結果が1であること' do
async_test do |finish|
@ledsun
ledsun / Dockerfile
Last active February 26, 2017 14:46
minimum alpine environment for therubyracer
FROM ruby:2.4.0-alpine
ENV LANG ja_JP.UTF-8
RUN apk update && \
apk upgrade && \
apk add --update\
build-base \
ruby-dev
@ledsun
ledsun / run.sh
Created January 17, 2017 01:27
技術書典エゴサーチスクリプト
npm install twitter
node search.js | jq .statuses | jq .[] | jq '.text, .created_at, .id_str'
@ledsun
ledsun / Dockerfile
Last active December 5, 2016 09:32
FROM alpine:3.3
RUN apk add --no-cache curl
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY cacert.pem /usr/src/app/
@ledsun
ledsun / gist:015d3ad1dc092954f962f79f8c4c33bb
Last active October 18, 2016 14:26
directory配下のjsonファイルを集めて、まとめてJavaScriptとして返す
const allFilesStat = files
.filter((f) => f.endsWith('json'))
.map((f) => fsp
.stat(`${directory}/${f}`)
.then((stats) => ({
name: f,
mtime: stats.mtime
}))
)
process.stdin.on('readable', () => {
var chunk = process.stdin.read();
if (chunk !== null) {
console.log(chunk)
}
})
echo 'デイリー' | node .
@ledsun
ledsun / gist:660604e66ed0c943b7c73912bbe250bd
Created September 25, 2016 04:45
submitイベントの検証の途中で使ったコード、buttonのdefault typeがsubmitなのを見過ごしている。思う様に動いてない
<!DOCTYPE html>
<body>
<form id="f" action="http://example.com" method="get">
<button type="submit">送信</button>
<button id="button2">送信</button>
</form>
<script type="text/javascript">
f.addEventListener('submit', (e) => {
console.log('hi')
})
@ledsun
ledsun / index.js
Created July 20, 2016 02:15
cpxのtransformerを書く練習
const cpx = require('cpx')
const {
Transform
} = require('stream')
class MyTransform extends Transform {
constructor(options) {
super(options);
}
_transform(data, encoding, callback) {
<!DOCTYPE html>
<html>
<body>
Resize the window and this document wraped and height of this document is changed. So, the table will move but the bottom boder of the table will not move.
<div style="transform: translate3d(0px, 0px, 0px);">
</div>
<table style="border-collapse: collapse;">
<thead style="border-bottom-width: 1px; border-bottom-style: solid;">
<tr>