Skip to content

Instantly share code, notes, and snippets.

@tmm1
tmm1 / sample.gif
Last active December 11, 2020 07:40
View Profiler
sample.gif
@tanihiro
tanihiro / nginx_unicorn.conf
Created May 23, 2013 23:34
NginxでRailsのUnicornを動かすときの設定ファイル
upstream application-unicorn {
# Unicornのソケットを指定:
server unix:/tmp/unicorn_{application}.sock fail_timeout=0;
}
server {
listen 80;
server_name HOSTNAME;
client_max_body_size 4G;
#! /usr/bin/env ruby
# coding: utf-8
def has_magic_comment?(content)
if content.lines.first =~ /\A#!/
first_line = content.lines.take(2).last
else
first_line = content.lines.first
end
comment = first_line.sub(/(?:\"(?:[^"]|\\\")*\"|\'(?:[^']|\\\')*\'|[^#]*)#/, '').strip
@kenn
kenn / gist:5105175
Last active June 13, 2024 16:37
Unicorn memory usage improvement with Ruby 2.0.0

Unicorn memory usage improvement with Ruby 2.0.0

Here's a preliminary experiment to see how much memory is saved with the new copy-on-write friendly (bitmap marking) GC.

Calculated by memstats.rb https://gist.github.com/kenn/5105061 on Debian x86_64.

Master process:

# ./memstats.rb 20547
@fukajun
fukajun / gist:4222284
Created December 6, 2012 06:48
Letの効果的な使い方
describe "hoge" do
bofore do
get "index" , value
end
context "範囲内に収まるパラメータがくる" do
let (:value) { 123 }
it { response.should eq true }
end
context "範囲内に収まっていないパラメータがくる" do
let (:value) { 123456 }
@mirakui
mirakui / capture.rb
Created November 7, 2012 02:34
capturing stdout and stderr
def capture(options={})
out = options[:out]
err = options[:err] || :out
stdout_old = $stdout.dup
stderr_old = $stderr.dup
$stdout.reopen out
err = $stdout if err == :out
@yonchu
yonchu / color256.sh
Created October 18, 2012 19:10
zsh/bashで256色のカラーパレットを表示
#!/bin/sh
#
# 256色のカラーパレットを表示する
# bash と zsh にて実行可能
#
target_shell=$1
if [ -z "$1" ]; then
target_shell=$(basename "$SHELL")
@terut
terut / unicorn
Created September 6, 2012 11:09
Unicorn multi init.
#!/bin/sh
#
# chkconfig: - 88 12
#
# init.d script for single or multiple unicorn installations. Expects at least one .env
# file in /etc/unicorn
#
## A sample /etc/unicorn/production.env
##
## RAILS_ENV=production
@mirakui
mirakui / memo.txt
Created September 2, 2012 12:48
ffmpeg+ImageMagickによる分割アニメーションGIF作成コマンドメモ
# 元の動画をトリミング
ffmpeg -i DSC_3872.avi -vcodec copy -acodec copy -ss '00:00:04.33' -t '00:00:05.48' trim01.avi
# 横幅500px(tumblrの上限)にリサイズしつつ animated gif に変換
convert -resize 500 trim01.avi trim01.gif
# 明るさ・コントラストをいじりつつ63色に減色(クロップ処理後に1MBに収まるように色数調整)
convert -brightness-contrast 40x40 -colors 63 trim01.gif trim01-v3.gif
# 横3x縦2にクロップする(画像同士の間隔は10px)
convert -crop 160x135+0+0 +repage trim01-v3.gif trim01-v3-1.gif
convert -crop 160x135+170+0 +repage trim01-v3.gif trim01-v3-2.gif
convert -crop 160x135+340+0 +repage trim01-v3.gif trim01-v3-3.gif
@vicentereig
vicentereig / httpd.conf
Created August 10, 2012 10:20
Apache 2 + Proxy Balancer + Thin + Rails Asset Pipeline Development Environment for MacOSX
# These modules should be loaded by default: proxy_module, proxy_balancer_module, rewrite_module
Listen *:80
# You may want to keep the VirtualHost config under extra/*.conf
# Start your thin
<VirtualHost *:80>
ServerName wwww.yourawesomeapp.dev