Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
spec_hits = []
checks = {
'_spec\.rb$' => ['focus:[:space:]*true'],
'\.rb$' => ['binding\.pry', 'debugger']
}
# Find the names of all the filenames that have been (A)dded (C)opied or (M)odified
filenames = `git diff --cached --name-only --diff-filter=ACM`.split("\n")
@tatsuosakurai
tatsuosakurai / recipe_of_curry.html
Last active December 20, 2015 14:29 — forked from machida/html_practice.html
カレーのレシピ
<!doctype html>
<html lang='ja'>
<head>
<title>カレーのレシピ</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
</head>
<body>
<article>
<header>
<h1>カレーのレシピ</h1>
@tatsuosakurai
tatsuosakurai / gist:5038338
Last active December 14, 2015 05:49
tkbjs 2013-02-26 6.9 プロトタイプによる継承
var parent = {
name: "Papa"
};
var child = object(parent);
alert(child.name);
function object(o) {
function F() {}
F.prototype = o;
[
{ "keys": ["ctrl+shift+j"], "command": "js_run" },
{ "keys": ["super+ctrl+shift+`"], "command": "toggle_side_bar" },
{ "keys": ["ctrl+super+`"], "command": "focus_side_bar" },
{ "keys": ["ctrl+shift+t"], "command": "delete_trailing_spaces" },
{ "keys": ["super+alt+["], "command": "reindent" },
{ "keys": ["ctrl+shift+."], "command": "erb" },
{ "keys": ["super+ctrl+m"], "command": "list_rails_models" },
@tatsuosakurai
tatsuosakurai / app.js
Created October 8, 2012 06:23
Emberjs Sample
console.log('hi');
window.Todos = Ember.Application.create();
Todos.Todo = Ember.Object.extend({
title: null,
isDone: false
});
Todos.todosController = Ember.ArrayController.create({
content:[],
arr = [10,9,9,8,8,6,5]
arr.map{|i| arr.index(i) + 1}
# => [1, 2, 2, 4, 4, 6, 7]
@tatsuosakurai
tatsuosakurai / coffee_memo.coffee
Created April 1, 2012 07:48
CoffeeScript memo
# sort
list.sort((a, b) -> return a.attr1-b.attr1 || a.attr2-b.attr2)
# sleep
Sleep = (ms) ->
d1 = new Date().getTime()
d2 = new Date().getTime()
d2 = new Date().getTime() while d2 < (d1 + ms)
return
# mail
"MailCatcher" http://mailcatcher.me/
mocksmtpd
@tatsuosakurai
tatsuosakurai / gist:1269914
Created October 7, 2011 09:42
9桁の数字を求める
# 1
(rand(900000000)+10 ** 9).to_s
# 2
([(0..9).to_a]*9).map{|i|i.sample}.join
# 3
sprintf("%09d", rand(10 ** 9))
# 4
Array.new(9){ Array(0..9).sample }.join
# 5
9.times.map{rand 10}.join
@tatsuosakurai
tatsuosakurai / gist:1266664
Created October 6, 2011 06:25
jquery-show-password-toggle
// Sample
// http://aaronsaray.com/blog/2010/10/19/jquery-show-password-toggle/
// HTML
// <input type="password" name="password" id="password" class="showpassword" />
// <input type="password" name="password_confirmation" id="password_confirmation" class="showpassword" />
// <input type="checkbox" value="1" name="show_password" id="show_password">
// js
$(function(){