require 'echo'
echo("foo msg") > "foofile"
echo("foo msg") >> "foofile"
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
require 'nokogiri' | |
doc = Nokogiri.XML File.open(ARGV[0], 'rb') | |
p doc.xpath( | |
'//schema:tokenData', | |
'schema' => 'http://sts.idm.telekom.com/schema/' | |
) | |
p doc.xpath("//soapenv:Body") |
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/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 |
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
<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 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
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 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
# 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 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 SomeClass | |
def initialize(options = {}) | |
load_config | |
set_options(options) | |
end | |
def load_config | |
end | |
def set_options(options) |
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
# This is pretty evil, yeah... I know | |
class Module | |
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
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 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
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| |