Skip to content

Instantly share code, notes, and snippets.

@libkazz
libkazz / gist:9523385
Created March 13, 2014 07:32
helper で HTML を書く時の性能比較
# 結論
#
# ContentTag >>>>> Inline Erb >> Inline HAML
#
# 可読性とパフォーマンスのどちらを取りたいか考えて選択しましょう
#
#
# Inline HAML
#
@libkazz
libkazz / 0_reuse_code.js
Created March 29, 2014 07:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@libkazz
libkazz / fill with nil
Created August 10, 2014 03:04
fill with nil
# Fill with nil, until list will be the size.
#
# [:a].nilfil(4) #=> [:a, nil, nil, nil, nil]
# [:a,:b,:b,:d,:e].nilfil(4) #=> [:a, :b, :b, :d, :e]
class Array
def nilfil(size)
me = self.dup
me[size - 1] = me[size - 1]
me
@libkazz
libkazz / git_delete_merged.sh
Last active October 5, 2015 20:38
delete merged branches
# これで gitconfig に alias を書けばよい
git branch --no-color --merged 2> /dev/null | grep -v -e '*' -e master | xargs git branch -d
BRIDGE_SIZE = 6
class Amida
def initialize(size)
@answer = rand(size)
@cols = create_cols(size)
@cells = create_cells(10, size)
(10 * size/2).times { add_bridge }
end
@libkazz
libkazz / gist:2955275
Created June 19, 2012 17:01
english numeral
require 'test/unit'
require 'rubygems'
require 'active_support/all'
class EnglishNumeral
MAP1 = [
nil, 'one', 'two', 'three', 'four', 'fice', 'six', 'seven', 'eight', 'nine',
'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'
]
MAP2 = [
@libkazz
libkazz / gist:2995127
Created June 26, 2012 10:59
memcached install memo
% brew install memcached
==> Installing memcached dependency: libevent
==> Downloading https://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/libevent/2.0.18
==> make
==> make install
/usr/local/Cellar/libevent/2.0.18: 48 files, 1.8M, built in 37 seconds
@libkazz
libkazz / gist:3798193
Created September 28, 2012 06:09 — forked from jugyo/nginx.conf
switch rails page cache by user agent
http {
...
server {
listen 8080;
server_name localhost;
#
# Set User Agent type
#
set $ua_type "pc";
@libkazz
libkazz / gist:3799314
Created September 28, 2012 11:36
Error: Your Homebrew is outdated の解決方法

brew のメンテナンス(Error: Your Homebrew is outdated)

brew doctor で出るエラーを解決する。

➜ brew doctor          
  :
Error: Your Homebrew is outdated
You haven't updated for at least 24 hours, this is a long time in brewland!
 :
@libkazz
libkazz / gist:4085015
Created November 16, 2012 07:10
Puts loc entry in sitemap_index.xml.gz

Puts loc entry in sitemap_index.xml.gz

##
# Usage: puts_locs `file`
# Puts loc entry in sitemap_index.xml.gz
# 
function _puts_locs() {
  zcat $1 | \
 ruby -anle '$_.sub(/^.*?/, "").gsub(//, "\n").split("\n").each{|l| puts l.sub(/<\/loc>.*$/, "") }'