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
>> x = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| | |
?> xml.feed do |ctx| | |
?> xml.title "This isn't a test & certainly does not test \"quotes\"" | |
>> end | |
>> end | |
=> #<Nokogiri::XML::Builder:0x1013c5a30 @arity=1, @context=nil, @parent=<?xml version="1.0" encoding="UTF-8"?> | |
>> x.to_xml | |
=> "<?xml version="1.0" encoding="UTF-8"?>\n<feed>\n <title>This isn't a test & certainly does not test "quotes"</title>\n</feed>\n" | |
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
# Server | |
require 'socket' | |
server = TCPServer.open(2000) # Socket to listen on port 2000 | |
loop { # Servers run forever | |
client = server.accept # Wait for a client to connect | |
sleep 1 | |
client.puts(Time.now.ctime) # Send the time to the client | |
client.close # Disconnect from the client | |
} |
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
goblin:~/git/memcache-client$ gem migrate memcache-client | |
Starting migration of memcache-client from RubyForge... | |
A migration token has been created. | |
Uploading the migration token to seattlerb.rubyforge.org. | |
There was a problem uploading your token: SCP did not finish successfully (1) | |
Asking Gemcutter to verify the upload... | |
Gemcutter is still looking for your migration token. | |
goblin:~/git/memcache-client$ gem list gemcutter | |
*** LOCAL GEMS *** |
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
goblin:~/git/maglev$ maglev-gem install memcache-client | |
ERROR 4141, Stone couldn't start its PageServer and/or SharedPageCache on this machine. | |
See Page Manager's log for more information. | |
, Unable to establish connection to cache page server on remote host: localhost Remote cache creation failed., | |
RUN can't be used prior to logging in. | |
... after error, skipping input source down to % | |
SKIPPED above method/doit due to error preceeding it | |
goblin:~/git/maglev$ rake maglev:status | |
(in /Users/mike/git/maglev) | |
Status Version Owner Pid Port Started Type Name |
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
Rubinius HEAD: | |
Loaded suite /Users/mike/git/rubinius/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader | |
Started | |
Testing 1.7.7 | |
user system total real | |
set:plain:memcache-client 5.709023 0.000000 5.709023 ( 5.708933) | |
set:ruby:memcache-client rake aborted! | |
Command failed with status (): [/Users/mike/git/rubinius/bin/rbx -w -I"lib...] |
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
def exists?(attribs) | |
CustomImage.find_by_account_id_and_hash(attribs['account_id'], attribs['id']) | |
end | |
# Cleaner way of doing the exists? and return/if without making the query twice? | |
# (the query can return nil so memoizing won't work) | |
def some_method(attribs) | |
img = exists?(attribs) | |
return img if img | |
... |
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
s1 = String.new 'foobar' | |
s2 = String.new 'test' | |
meth = 'mike' | |
s1.instance_eval <<-EOM | |
def #{meth} | |
puts "Hello World" | |
end | |
EOM |
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
/opt/ree/bin/passenger-install-nginx-module --auto --auto-download --prefix=/opt/nginx --extra-configure-flags="--with-http_ssl_module --add-module=/tmp/nginx_upload_module-2.0.9 --add-module=/tmp/nginx-upload-progress-module-0.7" |
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
goblin:~/onespot/juneau/imager$ thin start | |
>> Using rails adapter | |
Missing the Rails 2.3.4 gem. Please `gem install -v=2.3.4 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed. | |
goblin:~/onespot/juneau/imager$ gem list rails | |
*** LOCAL GEMS *** | |
rails (2.3.4, 2.1.2) | |
goblin:~/onespot/juneau/imager$ which gem | |
/opt/ree/bin/gem |
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
def to_ascii | |
s = nil | |
begin | |
# fast but fails on bad UTF-8 data | |
s = self.to_s.unpack('U*').collect { |c| (c <= 127) ? c.chr : translation_hash[c] }.join | |
rescue => ex | |
# much slower but doesn't | |
s = self.chars.split('').collect { |c| (c[0] <= 127) ? c : translation_hash[c[0]] }.join | |
end | |