Skip to content

Instantly share code, notes, and snippets.

View cesare's full-sized avatar

SAWADA Tadashi cesare

View GitHub Profile
@cesare
cesare / mongod.conf
Created September 9, 2011 12:58
MacOSX launchd plist file to start MongoDB server
dbpath = /var/mongo/data
logpath = /var/mongo/logs/mongod.log
#!/bin/bash
#
# Emacs 23.3 building procedure for MacOSX
# thanks to http://masutaka.net/chalow/2011-07-31-2.html
#
#
# settings
#
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
require 'growl'
doc = Nokogiri::HTML(open("http://shop.github.com/products/octodex-sticker-pack"))
if doc.css('#puchase-form .sold-out').empty?
Growl.notify do |n|
n.message = 'Octodex Sticker Packs are back!'
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
class String
def &(other)
self.unpack("U*").zip(other.to_s.unpack("U*")).map{|pair| pair.first & pair.last }.pack("U*")
end
end
puts "生" & "死"
import Data.List
intToRoman :: Int -> String
intToRoman = concat . reverse . (zipWith (\f d -> f d) fs) . split
where
split = unfoldr (\n -> if n > 0 then Just ((mod n 10), (div n 10)) else Nothing)
fs = map roman [('i', 'v', 'x'), ('x', 'l', 'c'), ('c', 'd', 'm'), ('m', '$', '#')]
roman (one, five, ten) n
| n >= 0 && n <= 3 = replicate n one
| n == 4 = [one, five]
@cesare
cesare / gist:2703414
Created May 15, 2012 17:17
Sample bash script to build PJSIP library for iphone SDK
#!/bin/bash
srcdir="${HOME}/src/pjproject-2.0-rc"
cd ${srcdir}
(
cat <<END
#define PJ_CONFIG_IPHONE 1
#include <pj/config_site_sample.h>
#
# Nabeatsu
# returns "hoge" if given value is a multiple of 3, or contains '3' in it; otherwise just the value itself (in String).
#
# Restriction of coding:
# DO NOT use conditional branching syntax, such as "if", "unless", "case ... when".
#
module Nabeatsu
class << self
def say(n)
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
@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
@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