Skip to content

Instantly share code, notes, and snippets.

View fujimura's full-sized avatar

Daisuke Fujimura fujimura

View GitHub Profile
// @flow
import React from 'react';
const splitTimeComponent = (t: Date): number[] => {
return [
t.getFullYear(),
t.getMonth(),
t.getDate(),
t.getHours(),
t.getMinutes()
#! /bin/bash
npm --version
npm install
$(npm bin)/eslint --version
$(npm bin)/eslint --fix $(git ls-files | grep -v vendor | grep "js[x]*$") || true
git diff --exit-code && exit 0
git add .
timestamp=`date +'%Y%m%d%H%M'`
commit_comment="eslint --fix $timestamp"
git commit -m "$commit_comment"
@fujimura
fujimura / pre-push.sh
Created November 21, 2016 05:54
pre-push hook to prevent push to master branch
#!/bin/bash
# Taken from http://thinca.hatenablog.com/entry/20150306/1425639218
while read local_ref local_sha1 remote_ref remote_sha1
do
if [[ "${remote_ref##refs/heads/}" = "master" ]]; then
echo "Do not push to master branch!!!"
exit 1
fi
done
@fujimura
fujimura / rubocop_pr.sh
Created October 3, 2016 04:53
Script to make a pull request with the result from rubocop --auto-correct
bundle exec rubocop --auto-correct $(git ls-files | grep -E -v "^(db|bin)" | grep "\.rb$") || true
git diff --exit-code && exit 0
git add .
timestamp=`date +'%Y%m%d%H%M'`
commit_comment="rubocop --auto-correct $timestamp"
git commit -m "$commit_comment"
git checkout -b rubocop-auto-correct-$timestamp
branch_name=`git name-rev --name-only HEAD`
git push -u origin $branch_name
hub pull-request -m "$commit_comment" -h proper-inc:$branch_name
Running Wild - Death or Glory
Mobb Deep - The Infamous
Basic Channel - s/t
Carnage - Dark Recollections
Buffalo Springfield - Again
Os Mutantes - s/t
Bulldoze - The Final Beatdown
Archimedes Badkar - s/t
クラムボン - まちわび まちさび
Lip Cream - s/t
@fujimura
fujimura / resize.js
Created April 14, 2016 07:24
Resize image in browser
const fileToDataUrl = (file) => {
return new Promise((resolve, reject) => {
const reader = new FileReader
reader.onload = (e) => {
resolve(e.target.result)
};
reader.readAsDataURL(file);
});
}
import System.Posix.Signals
import Control.Concurrent
main :: IO ()
main = do
m <- newEmptyMVar
installHandler sigKILL (Catch (putMVar m "Hi")) Nothing
installHandler keyboardSignal (Catch (putMVar m "Hi")) Nothing
takeMVar m >>= print
def json_include x, y
case x
when Hash
return false unless y.is_a? Hash
y.all? { |k, v| json_include(x[k], v) }
when Array
return false unless y.is_a? Array
y.all? { |y_| x.any? { |x_| json_include(x_, y_) } }
else
x == y
@fujimura
fujimura / b.rb
Last active November 29, 2015 15:48
class Client
def initialize
@all_entries = [*1..30].map { |i| "Hello this is #{i}" }
end
def get(option)
from = option[:from_id] || 0
@all_entries[from..(from + 5)]
end
end
#!/bin/bash -e
set -x
# If there are whitespace errors, print the offending file names and fail.
git diff-index --check --cached HEAD
exec git diff --cached --name-only --diff-filter=AM | grep '\.rb$' | xargs rubocop