Skip to content

Instantly share code, notes, and snippets.

View cesare's full-sized avatar

SAWADA Tadashi cesare

View GitHub Profile
@cesare
cesare / gist:8907390
Created February 9, 2014 22:59
fetch public keys registered on Github
#!/bin/bash
base_url="https://github.com"
while read name
do
wget "${base_url}/${name}.keys"
done
#!/bin/bash
srcdir="${HOME}/svn/pjproject"
devpath="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer"
arch="i386"
cflags="-O2 -m32 -miphoneos-version-min=4.0"
ldflags="-O2 -m32 -miphoneos-version-min=4.0"
cd ${srcdir}
puts 'Hello! May I help you?'
$stdin.lazy.reduce(Array.new 3) do |history, message|
history = ([message.strip!] + history).take 3
break if history.all? {|msg| msg == 'BYE' }
reply =
case message
when 'BYE'
nil
for file in `ls rubyists/*.jpg`
do
bname=`basename $file .jpg`
convert $file -sepia-tone '80%' sepiatones/$bname.jpg
done
@cesare
cesare / rubyist-pics.rb
Created May 25, 2013 06:34
Usage: rubyist-pics.rb LOCAL/PATH/TO/darashi/rubyistokei/data
#!/usr/bin/env ruby
require 'fileutils'
require 'net/https'
require 'yaml'
datadir = ARGV.shift
filenames = Dir.entries(datadir).select {|name| name =~ /\.(yml|yaml)$/}
rubyists = filenames.map {|filename| YAML.load_file(File.join(datadir, filename)).merge('filename' => filename) }
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Raphael</title>
<style type="text/css">
</style>
</head>
<body>
<div id="holder">
</div>
r = Random.new(19930224); (1..22).sort_by { r.rand }
# => [4, 10, 13, 18, 7, 16, 20, 15, 22, 2, 19, 5, 17, 14, 8, 6, 9, 1, 11, 3, 21, 12]
@cesare
cesare / gist:3929454
Created October 22, 2012 03:14
script to fix the search path of mysql2.bundle installed on MacOSX
#!/bin/bash
mysql_libdir='/usr/local/mysql/lib'
dylib_name='libmysqlclient.18.dylib'
dylib_path="${mysql_libdir}/${dylib_name}"
install_name_tool -change ${dylib_name} ${dylib_path} $1
@cesare
cesare / gist:3296137
Created August 8, 2012 15:49
an example of Ruby Enumerable
class Directory
include Enumerable
def initialize(dirname)
@dirname = dirname
@files = Dir.open(dirname) {|dir|
dir.reject {|name| name == "." || name == ".." }
}
end
import Data.List
data Suit = Spade | Diamond | Club | Heart
deriving (Eq, Show, Ord)
data Card = Card Suit Int
deriving (Eq, Show, Ord)
suit (Card s _) = s
rank (Card _ r) = r