Skip to content

Instantly share code, notes, and snippets.

View goofmint's full-sized avatar

Atsushi goofmint

View GitHub Profile
# For library test
if __FILE__ == $0 then
end
/opt/local/bin/ruby -I"lib:test" "/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/hoge_test.rb"
emulator @moongift -sdcard ~/.android/sdcard
@goofmint
goofmint / gist:187005
Created September 14, 2009 23:55 — forked from dhh/gist:45076
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
// ==UserScript==
// @name Google Reader Star Opener
// @namespace http://www.sukechan.net/
// @description Starred item open in a lump for Google Reader.
// @include http://www.google.co.jp/reader/view/*
// @include http://www.google.com/reader/view/*
// @version 1.0.1
// ==/UserScript==
(function() {
@goofmint
goofmint / WordPress3 Authorize Algorithm for Ruby
Created November 24, 2010 12:34
wp-includes/class-phpass.phpのパスワード生成部分をRubyで再実装したもの。WordPressの認証をRubyから直接利用した時に。
require 'digest/md5'
def crypt_private(password, setting)
output = '*0'
itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
output = '*1' if setting[0..1] == output
return output if setting[0..2] != '$P$'
salt = setting[4..11]
return output if salt.length != 8
count_log2 = itoa64.index(setting[3])
@goofmint
goofmint / wpautop for ruby
Created December 24, 2010 06:55
WordPress's wpautop function port to ruby.
def wpautop(pee, br = true)
return '' if pee.strip == ''
pee = "#{pee}\n" # just to make things a little easier, pad the end
pee = pee.gsub(/<br \/>\s*<br \/>/s, "\n\n")
# pace things out a little
allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
pee = pee.gsub(Regexp.new('(<'+allblocks+'[^>]*>)'), "\n"+'\1')
pee = pee.gsub(Regexp.new('(<\/'+allblocks+'[^>]*>)'), '\1' + "\n\n")
pee = pee.gsub(/\r\n|\r/, "\n") # cross-platform newlines
if pee.include?('<object')
@goofmint
goofmint / Bug list checker
Created March 10, 2011 03:14
# Bugと言うと、バグリストを返すSkype bot
require 'rubygems'
require 'basecamp'
require 'Skype'
require 'active_support'
project_id = null
Basecamp.establish_connection!('subdomain.basecamphq.com', 'your id', 'your password', true)
Skype.init 'some application name'
Skype.start_messageloop
require 'rubygems'
require 'tinder'
campfire = Tinder::Campfire.new 'your subdomain', :token => 'your api key'
require 'meow'
meep = Meow.new('Meow Test')
room = campfire.find_room_by_name('your room name')
room.listen do |m|
meep.notify('From Campfire', "#{m["user"]["name"]} says #{m["body"]}")
end
@goofmint
goofmint / Skype echo
Created March 23, 2011 22:11
See Chat topic
require 'rubygems'
require 'Skype'
Skype.init 'some application name'
Skype.start_messageloop
Skype::ChatMessage.set_notify do |chatmessage, property, value|
if chatmessage.get_chat.getTopic == "hogehoge" && value == 'RECEIVED' && property == :status
chatmessage.get_chat.send_message "Hei, someone said, #{chatmessage.get_body}!"
end
end