Skip to content

Instantly share code, notes, and snippets.

@kinopyo
kinopyo / solution_1.rb
Created September 9, 2011 01:20
It shows how to enhance ruby class by define a new method to String class. This is just for study.
class String
def sex_code
if ["male", "男"].include? self
0
elsif self == "女"
1
else
self
end
end
@anyakichi
anyakichi / aquaskk-sticky-key.patch
Created September 26, 2011 15:43
sticky key support for AquaSKK
Index: src/engine/state/SKKEvent.h
===================================================================
--- src/engine/state/SKKEvent.h (revision 157)
+++ src/engine/state/SKKEvent.h (working copy)
@@ -71,7 +71,8 @@
PrevCandidate = (1 << 11),
RemoveTrigger = (1 << 12),
InputChars = (1 << 13),
- CompConversion = (1 << 14)
+ CompConversion = (1 << 14),
@duckpuppy
duckpuppy / compass.rb
Created October 24, 2011 03:34
Jekyll Haml and Compass extensions
begin
require 'compass'
require 'compass/exec'
rescue LoadError
require 'rubygems'
require 'compass'
require 'compass/exec'
end
module Jekyll
@oshow
oshow / app.rb
Created November 16, 2011 09:29
for Rubyist Magazine 0036
# encoding: utf-8
require 'rubygems'
require 'sinatra/base'
require 'sinatra/reloader'
require 'rack/rewrite'
require 'haml'
class App < Sinatra::Base
enable :inline_templates
@chetan
chetan / test_helper.rb
Created February 13, 2012 22:02
spork+simplecove rails3.2
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
require File.expand_path(File.dirname(__FILE__)) + "/test_prefork"
end
@mbleigh
mbleigh / Gemfile
Created March 21, 2012 03:14
Non-Rails Rackup with Sprockets, Compass, Handlebars, Coffeescript, and Twitter Bootstrap
source "https://rubygems.org"
gem 'sprockets'
gem 'sprockets-sass'
gem 'sass'
gem 'compass'
gem 'bootstrap-sass'
gem 'handlebars_assets'
gem 'coffee-script'
@sss
sss / executable-with-subcommands-using-thor.log
Created February 24, 2012 20:16
Revised: Namespacing thor commands in a standalone Ruby executable
$ ./executable-with-subcommands-using-thor.rb
Tasks:
executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task
executable-with-subcommands-using-thor.rb subA [TASK] # Execute a task in namespace subA
executable-with-subcommands-using-thor.rb subB [TASK] # Execute a task in namespace subB
executable-with-subcommands-using-thor.rb test # test in CLI
$ ./executable-with-subcommands-using-thor.rb help
Tasks:
executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task
@hiway
hiway / hello.asm
Last active December 18, 2015 19:19
Program that boots an emulator/computer from a floppy and prints 'Hello, world.'
[bits 16] ; Tell assembler to use 16 bit code.
[org 7c00h] ; BIOS will load us to this address.
;===================================================================
mov si, string_hello ; store string pointer into SI
call print_string
call sleep
;===================================================================
print_string:
@toamitkumar
toamitkumar / gist:952211
Created May 2, 2011 19:35
Inspect and test routes on console (Rails 3)
$ rails console
Loading development environment (Rails 3.0.6)
ruby-1.8.7-p334 :001 > r = Rails.application.routes
Gives you a handle of all the routes (config/routes.rb)
#Inspect a named route:
ruby-1.8.7-p334 :005 > r.recognize_path(app.destroy_user_session_path)
=> {:action=>"destroy", :controller=>"sessions"}
@koseki
koseki / sendgmail.rb
Created March 27, 2009 16:59
rubyで日本語のメール送信
# Send Japanese mail using Gmail SMTP server. You need tlsmail.
# $ sudo gem install tlsmail
require "rubygems"
require "tlsmail"
require "nkf"
require "net/smtp"
def sendgmail(from, to, subject, body, user, pass, host = "smtp.gmail.com", port = 587)
body = <<EOT