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
require 'rubygems'
require 'benchmark'
gem 'dalli', '=1.0.2'
require 'dalli'
TEST_DATA_NUM = 100
$memcached = Dalli::Client.new('127.0.0.1:11211')
# ベンチマークを計測する
@n0ts
n0ts / gist:827153
Created February 15, 2011 06:03
benchmark-memcache
require 'rubygems'
require 'benchmark'
gem 'memcache', '=1.2.13'
require 'memcache'
TEST_DATA_NUM = 100
$memcached = Memcache.new(:server => '127.0.0.1:11211')
# ベンチマークを計測する
require 'date'
require 'fileutils'
require 'rubygems'
gem 'activesupport', '=2.3.11'
require 'active_support'
file_count = 0
Dir::foreach('db/migrate') do |v|
next if v == "." or v == ".." or v == ".svn"
@n0ts
n0ts / rsync.exclude
Created February 22, 2011 08:39
cobbler /etc/cobbler/rsync.exclude configuration
### files to exclude from "cobbler import" commands that use
### rsync mirrors. by default ISOs, PPC code, and debug
### RPM's are not transferred. Some users may want to
### re-enable debug RPM's.
**/debug/**
**/alpha/**
**/source/**
**/SRPMS/**
**/*.iso
**/kde-i18n**
@n0ts
n0ts / set_schema_migrations.rb
Created March 17, 2011 08:16
insert db migration version to schema_migrations table
require 'optparse'
ENV['RAILS_ENV'] = ENV['RAILS_ENV'] || 'development'
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
opts = {}
ARGV.options {|opt|
opt.on('-s', '--save', 'save') {|v| opts[:save] = v }
opt.parse!
@n0ts
n0ts / gist:1010407
Created June 6, 2011 14:59
Install auto vm /etc/rc.local for Xen Dom0
We couldn’t find that file to show.
@n0ts
n0ts / xendoamins-init
Created June 6, 2011 15:04
Patch for Xen 4.1.0 /etc/init.d/xendomains
184,185c184
< NM=$($CMD create --quiet --dryrun --defconfig "$1" |
< sed -n 's/^.*(name \(.*\))$/\1/p')
---
> NM=$(cat "$1" | sed -n 's/^.*<name>\(.*\)<\/name>$/\1/p')
286c285
< shortdom=$(echo $dom | sed -n 's/^.*\/\(.*\)$/\1/p')
---
> shortdom=$(echo $dom | sed -n 's/^.*\/\(.*\)\.xml$/\1/p')
291c290
@n0ts
n0ts / xendomains-sysconfig
Created June 6, 2011 15:54
Patch for Xen 4.1.0 /etc/sysconfig/xendomains
56c56
< XENDOMAINS_SAVE=/var/lib/xen/save
---
> XENDOMAINS_SAVE="
89c89
< XENDOMAINS_RESTORE=true
---
> XENDOMAINS_RESTORE=false
@n0ts
n0ts / ksm.y
Created June 26, 2011 03:06
stand-alone bash version of vdsm's ksm.py
#!/bin/sh
# stand-alone bash version of vdsm's ksm.py
# monitor system memory load and tune ksm accordingly
#
# needs testing and ironing. contact danken@redhat.com if something breaks.
DEBUG=1
KSMCTL="ksmctl"
KSM_MONITOR_INTERVAL=${KSM_MONITOR_INTERVAL:-60}
KSM_NPAGES_BOOST=${KSM_NPAGES_BOOST:-300}
@n0ts
n0ts / create_bridge.sh
Created June 26, 2011 04:01
create brdige from ethX to brX
for iface in /etc/sysconfig/network-scripts/ifcfg-eth*; do
iface_name=`egrep "^DEVICE=" $iface`
iface_no=${iface_name##DEVICE=eth}
iface_br=ifcfg-br${iface_no}
cp $iface $iface_br
sed -i -e "s/^DEVICE=eth${iface_no}/DEVICE=br${iface_no}/g" $iface_br
sed -i -e 's/^HWADDR=/#HWADDR=/g' $iface_br
echo "TYPE=Bridge" >> $iface_br
sed -i -e "s/^BOOTPROTO=/#BOOTPROTO=/g" $iface