Skip to content

Instantly share code, notes, and snippets.

@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
@jessykate
jessykate / Jekyll nd Octopress Liquid tag for MathJax.rb
Created February 18, 2011 23:37
A simple liquid tag for Jekyll/Octopress that converts {% m %} and {% em %} into inline math, and {% math %} and {% endmath %} into block equations, by replacing with the appropriate MathJax script tags.
module Jekyll
class MathJaxBlockTag < Liquid::Tag
def render(context)
'<script type="math/tex; mode=display">'
end
end
class MathJaxInlineTag < Liquid::Tag
def render(context)
'<script type="math/tex">'
end
@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"}
@chriseppstein
chriseppstein / _grid-system.scss
Created August 22, 2011 17:43
Building Responsive Layouts with Sass
@import "compass/utilities/general/clearfix";
$gutter-width: 10px; // All grids systems have the same gutter width
$float-direction: left;
$left-gutter-width: ceil($gutter-width / 2) !default;
$right-gutter-width: $gutter-width - $left-gutter-width !default;
$base-line-height: 21px;
$show-grid-background: false;
@mixin centered {
@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
@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