require 'echo'
echo("foo msg") > "foofile"
echo("foo msg") >> "foofile"
This file contains 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
ARGV.each { |email| | |
next if User.find_by_email email | |
buzz_team_users = [ 'default@example.org' ] | |
user_sending_invite = buzz_team_users.rand | |
user = User.find_by_email user_sending_invite | |
invitation = Invitation.new | |
invitation.sent_to_email = email | |
invitation.sent_by_user_id = user.id | |
invitation.note = "Hey, we want you to join buzz" |
This file contains 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
require 'rubygems' | |
require 'nokogiri' | |
puts "nokogiri: #{Nokogiri::VERSION}" | |
puts "libxml: #{Nokogiri::LIBXML_VERSION}" | |
count = 0 | |
File.open(ARGV[0], "r") do |input| | |
reader = Nokogiri::XML::Reader(input) { |cfg| |
This file contains 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 Fancy | |
def self.test | |
puts "Ask me a question:" | |
t = gets | |
puts "You said: #{t}" | |
puts "What about this other thing?" | |
t2 = gets | |
puts "Now you said: #{t2}" | |
end | |
end |
This file contains 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
# This is pretty evil, yeah... I know | |
class Module | |
end |
This file contains 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 SomeClass | |
def initialize(options = {}) | |
load_config | |
set_options(options) | |
end | |
def load_config | |
end | |
def set_options(options) |
This file contains 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
# heredocs can continue the code on the same line: | |
class SomeController | |
def render opts | |
p opts | |
end | |
def setup; false; end | |
def action_a | |
### |
This file contains 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
SUBJECT: About An Imaginary Number Literal (Translation) | |
This post is the summary of a recent discussion in [ruby-dev] about imaginary numbers. | |
In [ruby-dev:38843] 複素数リテラルについて http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/38843 , | |
Matz suggested introducing an imaginary number literal to ruby. After his new patch is applied, we can use the following syntax: | |
2i | |
2.0i | |
He also showed some issues about: |
This file contains 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
<html xmlns="http://www.w3.org/HTML/1998/html4" xmlns:xdc="http://www.internet.com/custom"> | |
<head></head> | |
<body> | |
<p></p> | |
<xdc:user id='11'> | |
<div></div> | |
<foo></foo> | |
<xdc:name /> | |
</xdc:user> | |
<xdc:employees /> |
This file contains 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/ruby -w | |
def ensure_data_file | |
unless defined? DATA | |
const_set(:DATA, File.open($PROGRAM_NAME, 'r+')) | |
DATA.seek 0, IO::SEEK_END | |
DATA.puts | |
DATA.puts('__END__') | |
end | |
DATA |