Skip to content

Instantly share code, notes, and snippets.

View holysugar's full-sized avatar

HORII Keima holysugar

  • Aiming, Inc
  • Tokyo
View GitHub Profile
@holysugar
holysugar / convert_asset_to_inline.rb
Created March 10, 2011 09:53
convert resource url in a html file to data scheme uri
require 'open-uri'
require 'image_size'
class ConvertAssetInline
def initialize
@orig = nil
@cache = {}
end
def convert(url)
#!/usr/bin/ruby
# set ft=ruby ts=2 sts=2 sw=2 fileencoding=utf-8
path = "/Users/holy/work/test-git"
git = '/opt/local/bin/git'
########################
require 'open3'
mysql> SELECT CAST('2011-03-31' AS DATE) BETWEEN '2011-02-28 15:00:00' AND '2011-03-30 15:00:00';
+------------------------------------------------------------------------------------+
| CAST('2011-03-31' AS DATE) BETWEEN '2011-02-28 15:00:00' AND '2011-03-30 15:00:00' |
+------------------------------------------------------------------------------------+
| 0 |
+------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT CAST('2011-03-31' AS DATE) BETWEEN '2011-03-01' AND '2011-03-31';
@holysugar
holysugar / nginx_rotatelogs.bash
Created April 20, 2011 07:44
nginx log rotation script
#!/bin/bash
LOGDIR=/usr/local/nginx/logs
PID=/usr/local/nginx/logs/nginx.pid
NOW=$(date +%Y%m%d-%H%M%S)
cd ${LOGDIR}
for i in *.log; do
mv ${i} ${i}.tmp.${NOW}
@holysugar
holysugar / table2gchart.js
Created April 26, 2011 13:39
convert table.chart to chart image by google (in prototype)
window.onload = function(){
function Chart(table_elem, size, type) {
this.dom = table_elem;
this.size = size;
this.type = type
this.calc();
}
Chart.prototype.rangechars = [
@holysugar
holysugar / bench_randomstring.rb
Created May 20, 2011 05:06
randomstring sample
#!/usr/bin/env ruby
require 'securerandom'
require 'openssl'
require 'base62' # base62 gem
require 'benchmark'
module RandomString
class Concat
@holysugar
holysugar / file_saving_proxy_server.rb
Created July 5, 2011 03:35
file_saving_proxy_server.rb
#!/usr/bin/env ruby
require 'webrick'
require 'webrick/httpproxy'
require "pathname"
class Dumper
def initialize(dir)
@dir = dir
end
@holysugar
holysugar / senkoredb2csv.rb
Created July 22, 2011 02:54
戦コレDB のデータを CSV に落とす。
#!/usr/bin/env ruby
# coding: utf-8
require 'active_support/all'
require 'open-uri'
require 'nokogiri'
require 'cgi'
require 'ir_b'
def parse(no, body)
@holysugar
holysugar / annotate.sh
Created July 27, 2011 13:18
Use annotate_models temporary...
#!/bin/sh
RAILS_ROOT=$(cd $(dirname $0)/..; pwd)
echo $RAILS_ROOT
cd $RAILS_ROOT
cp Gemfile Gemfile.$$
echo "\ngem 'annotate'" >> Gemfile
bundle install
@holysugar
holysugar / rbp-to-jenkins-plot.sh
Created August 26, 2011 12:11
exec rails_best_practices for jenkins plot plugin
#!/bin/sh
cd `dirname $0`/..
OUTDIR=reports
OUTFILE=$OUTDIR/rails_best_practices.properties
TMPFILE=`mktemp $OUTDIR/rails_best_practices.XXXXXX`
mkdir $OUTDIR 2> /dev/null
rails_best_practices > $TMPFILE