Skip to content

Instantly share code, notes, and snippets.

Avatar

SHIOYA, Hiromu kwappa

View GitHub Profile
View kana01_pp.rb
data = [
# [ id, input, expected ],
[ 0, "4*5+6&7|8", "44" ],
[ 1, "15*5", "75" ],
[ 2, "15+5", "20" ],
[ 3, "15&5", "5" ],
[ 4, "15|5", "15" ],
[ 5, "30*15*5", "2250" ],
[ 6, "30*15+5", "600" ],
[ 7, "30*15&5", "150" ],
View gist:510926
# -*- coding: utf-8 -*-
require 'cgi'
require 'rexml/document'
require 'open-uri'
class Suggest
attr_reader :response
def initialize
@query_base = "http://www.google.co.jp/complete/search?output=toolbar&hl=ja&q=%s"
View test_zenra.rb
# coding: utf-8
require 'test/unit'
require File.join(File.dirname(File.expand_path(__FILE__)), '..', 'lib', 'zenra')
class ZenraTest < Test::Unit::TestCase
def setup
@appid = ENV['YAHOO_APPID']
end
View python2.6 for homebrew
require 'formula'
<<-COMMENTS
This is the Homebrew formula for Python.
Versions
--------
This formula is currently tracking version 2.6.x.
@kwappa
kwappa / emacs.rb
Created Mar 9, 2011
emacs 23.2 formula for homebrew with `fix-shiftmodifier-with-ime.patch`
View emacs.rb
require 'formula'
class Emacs <Formula
url 'http://ftp.gnu.org/pub/gnu/emacs/emacs-23.2.tar.bz2'
md5 '057a0379f2f6b85fb114d8c723c79ce2'
homepage 'http://www.gnu.org/software/emacs/'
if ARGV.include? "--use-git-head"
head 'git://repo.or.cz/emacs.git'
else
@kwappa
kwappa / emacs.rb
Created Jul 26, 2011
emacs 23.3a formula for homebrew with Xcode4.1 / Lion / --cocoa
View emacs.rb
require 'formula'
class Emacs < Formula
url 'http://ftp.gnu.org/pub/gnu/emacs/emacs-23.3a.tar.bz2'
md5 'f2cf8dc6f28f8ae59bc695b4ddda339c'
homepage 'http://www.gnu.org/software/emacs/'
skip_clean :all
if ARGV.include? "--use-git-head"
View blanker.rb
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
file_name = ARGV[0]
if !file_name || !File.exists?(file_name)
puts "file not found."
exit
end
File.open(file_name) { |f|
@kwappa
kwappa / comp_gacha_oneliner.rb
Created May 10, 2012
コンプガチャをシミュレートしてみよう
View comp_gacha_oneliner.rb
r = Array.new(12).fill(0) ; while (r.include?(0)) do r[rand(r.count)] += 1 ; end ; puts "#{r.count}個のガチャをコンプするために #{r.inject(:+)}回抽選しました。"
@kwappa
kwappa / mb_width.rb
Created Jun 19, 2012
マルチバイト文字まじりの文字列を等幅フォントで表示するために文字数を数える
View mb_width.rb
# -*- coding: utf-8 -*-
require 'rspec'
class String
def mb_width
self.split('').inject(0) { |r, c| c =~ /^[ -~。-゚]*$/ ? r += 1 : r += 2 ; r }
end
end
describe String do
@kwappa
kwappa / Guardfile
Created Jun 21, 2012
guard-rspec, guard-spork, guard-livereload を使うための最低限のGuardfileをメモっておく
View Guardfile
# https://github.com/guard/guard-rspec
guard 'rspec', :version => 2, :all_after_pass => false, :all_on_start => false, :cli => '--color --format nested --fail-fast --drb' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
end
# https://github.com/guard/guard-spork
guard 'spork', :rspec_env => { 'PADRINO_ENV' => 'test' } do
watch('Gemfile')