Skip to content

Instantly share code, notes, and snippets.

@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
arr = [10,9,9,8,8,6,5]
arr.map{|i| arr.index(i) + 1}
# => [1, 2, 2, 4, 4, 6, 7]
@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:[],
[
{ "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 / 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;
@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>
#!/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 / application.js
Last active August 29, 2015 14:00
JavaScript Setting for Rails Controller
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
<% repo = Grit::Repo.new(Rails.root).head.name rescue nil %>
development:
adapter: mysql2
encoding: utf8
database: hoge_development<%= "_#{repo}" %>
javascript:var d=document,t=d.title,u=d.URL,i=d.createElement('input');i.value='['+t+']('+u+' )';d.body.appendChild(i);i.focus();i.select();