Skip to content

Instantly share code, notes, and snippets.

View n0ts's full-sized avatar
🏠
Working from home

Naoya Nakazawa n0ts

🏠
Working from home
  • Freelancer
  • Tokyo, Japan
  • X @n0ts
View GitHub Profile
@n0ts
n0ts / gist:3224126
Created August 1, 2012 05:54
Install nokogiri for Mountain Lion
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
$ bundle config build.nokogiri --with-xml2-include=$HOMEBREW_HOME/Cellar/libxml2/2.8.0/include/libxml2 --with-xml2-lib=$HOMEBREW_HOME/Cellar/libxml2/2.8.0/lib --with-xslt-dir=$HOMEBREW_HOME/Cellar/libxslt/1.1.26
$ gem uninstall nokogiri
$ bundle install
@n0ts
n0ts / gist:3523867
Created August 30, 2012 07:50
nginx rewrite rule
location ~ ^/(.*)/(css|img|js)/.*$ {
set $uri_type $1;
rewrite ^/\w+/(.*[^/])$ /$1;
if ( $uri_type = hoge1 ) {
root /var/www/hoge1/static/;
}
if ( $uri_type = hoge2 ) {
root /var/www/hoge2/static/;
}
expires max;
@n0ts
n0ts / gist:3703973
Created September 12, 2012 03:00
.profile
[ -f /bin/zsh ] && SHELL=/bin/zsh
[ -f /bin/zsh ] && exec /bin/zsh -l
@n0ts
n0ts / gist:3754676
Created September 20, 2012 08:30
Unicorn init script
#!/bin/bash
### BEGIN INIT INFO
# Provides: APPLICATION
# Required-Start: $all
# Required-Stop: $network $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the APPLICATION unicorns at boot
# Description: Enable APPLICATION at boot time.
### END INIT INFO
@n0ts
n0ts / gist:3809694
Created October 1, 2012 05:50
/etc/modprobe.conf - igb and e1000e
options igb RSS=4,4 QueuePairs=0,0 InterruptThrottleRate=100000,100000
options e1000e InterruptThrottleRate=100000,100000
@n0ts
n0ts / gist:3810200
Created October 1, 2012 08:01
keepalived supervisor.conf
[program:keepalived-check]
command=/usr/sbin/keepalived
--use-file /etc/keepalived/keepalived.conf
--dont-fork
--dump-conf
--log-detail
--log-facility 0
--check
--pid /var/run/keepalived_check.pid
redirect_stderr=true
@n0ts
n0ts / sources.repo
Created October 3, 2012 10:58
SRPM yum repository for CentOS 6
[base-source]
name=CentOS-$full_releasever - Base source
baseurl=http://vault.centos.org/$full_releasever/os/Source/
gpgcheck=1
gpgkey=http://vault.centos.org//RPM-GPG-KEY-CentOS-6
priority=1
enabled=1
[updates-source]
@n0ts
n0ts / gist:3856376
Created October 9, 2012 03:19
macrefresh.py
#!/usr/bin/python
#
# macrefresh.py : Update MAC Table with broadcast ARP
#
# 2011/01/23 ver1.0
#
# /etc/rc.local => /usr/local/script/macrefresh.py 1>/dev/null 2>&1 &
import socket
import fcntl
@n0ts
n0ts / gist:3870273
Last active October 11, 2015 14:07
Ruby On Sever Side

Target Application: Rails 2.3.x and Merb 1.3.x => Rails 3.1 or 3.2

Current: Apache 2.2 + Passenger 3.x + REE 1.8.7 without tcmalloc

Step1: Apache 2.2 + Unicorn + REE 1.8.7 with tcmalloc

Step2: Apache 2.2 + Unicorn + Ruby 1.9.3 with jemalloc

Step3: Nginx + Unicorn + Ruby 1.9.3 with jemalloc

@n0ts
n0ts / gist:3936517
Created October 23, 2012 03:51
generate_persistent_net.sh
#!/bin/sh
RULES=/etc/udev/rules.d/75-persistent-net.rules
if [ -f $RULES ]; then
echo "$RULES is already exists."
exit 1
fi
echo "#" > $RULES
echo "# Generated by `readlink -f $0`." >> $RULES