This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Convert Array to OrderedHash | |
# | |
# [param] Array arr | |
# [return] OrderedHash | |
# | |
def to_oh( arr ) | |
ActiveSupport::OrderedHash[*arr.zip((0...arr.size).to_a).flatten] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'net/pop' | |
require 'nkf' | |
limit = 700 # nantonaku :-) | |
num = 1 | |
pop = Net::POP3.new( SERVER, PORT ) | |
pop.start( USER, PASS ) { |c| | |
puts 'connecting ...' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby; coding: utf-8 -*- | |
if defined? Rails | |
railsrc = __FILE__ + '.rails' | |
load railsrc if File.exist? railsrc | |
envrc = File.join( Rails.root, '.irbrc' ) | |
load envrc if File.exist? envrc | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model.class.validators.select { |e| | |
e.is_a? ActiveModel::Validations::PresenceValidator | |
}.map { |e| e.attributes }.flatten | |
# => ['foo', 'bar', 'baz'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ /usr/bin/gem install sass | |
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and | |
/usr/bin aren't both writable. | |
WARNING: You don't have /Users/USER/.gem/ruby/1.8/bin in your PATH, | |
gem executables will not run. | |
Successfully installed sass-3.1.2 | |
1 gem installed | |
Installing ri documentation for sass-3.1.2... | |
Installing RDoc documentation for sass-3.1.2... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :tmp do | |
if ( File.exist?('tmp/mails') ) | |
namespace :mails do | |
desc "Clears all files in tmp/mails" | |
task :clear do | |
FileUtils.rm_rf(Dir['tmp/mails/[^.]*']) | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'activesupport', :require => 'active_support' | |
gem 'i18n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def to_php | |
self.inspect.gsub( /[\[{]/, 'array(' ).gsub( /[}\]]/, ')' ) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Example', function() { | |
it('give a block to expect', function() { | |
expect(function() { | |
return 'foo'; | |
}()).toEqual('foo'); // <- function should end with () | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# | |
# put this code #{Rails.root}/lib/tasks or jasmine Rakefile | |
# | |
namespace :jasmine do | |
desc "Install jasmine-jquery" | |
task "install-jquery" do | |
require "open-uri" |