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
# encoding: UTF-8 | |
require 'xml' | |
require 'test/unit' | |
class EncodingTest < Test::Unit::TestCase | |
def setup() | |
@xml = <<-EOS | |
<?xml version='1.0' encoding='UTF-8'?> | |
<test> |
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 'test/unit' | |
require 'active_support/all' | |
class TestExtendAndInclude < Test::Unit::TestCase | |
module SomethingExtended | |
mattr_accessor :data_attributes | |
def data_attribute(name) | |
self.data_attributes ||= [] |
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
# | |
# Now run gem-uninstall.sh | |
# The minimum needed for 1.9.2 is rake, rdoc, and minitest, usually they don't deleted | |
# | |
gems=`gem list`.split(/\n/).map{|gem| name=gem.gsub(/\s+\(.+?\)/,""); "gem uninstall -I -x -a #{name}"} | |
File.open("gem-uninstall.sh","w+") do |f| gems.each{|g| f.puts g} 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
# Ruby 1.9.2 | |
password="".tap{|s| 8.times { s << sprintf("%c",Random.new.rand(33..126)) } } | |
# Another way | |
password=(33..126).to_a.shuffle.take(8).map(&:chr).join | |
# Using only safe/printable characters | |
valid_chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a | |
password = valid_chars.shuffle.take(8).join |
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
# The YUM package is too old for use with ruby-sqlite3, use the autoconf package from www.sqlite.org | |
cd /opt | |
wget http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz | |
tar xvzf sqlite-autoconf-3070701.tar.gz | |
ln -s /opt/sqlite-autoconf-3070701 /opt/sqlite3 | |
cd /opt/sqlite3 | |
./configure --prefix=/opt/sqlite3 | |
make | |
make install | |
# Shared library will be installed in /usr/local/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
public class ShowMemory | |
{ | |
public static void main(String args[]) | |
{ | |
long maxBytes = Runtime.getRuntime().maxMemory(); | |
System.out.println("Max memory: " + maxBytes / 1024 / 1024 + "M"); | |
} | |
} |
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
pid = fork do | |
#Signal.trap('HUP', 'IGNORE') # Don't die upon logout | |
10.times do | |
puts "sleeping in child" | |
sleep 10 | |
end | |
end | |
#Process.waitpid(pid) | |
Process.wait |
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/env ruby | |
# Usage: gemspec [-s] GEMNAME | |
# | |
# Prints a basic gemspec for GEMNAME based on your git-config info. | |
# If -s is passed, saves it as a GEMNAME.gemspec in the current | |
# directory. Otherwise prints to standard output. | |
# | |
# Once you check this gemspec into your project, releasing a new gem | |
# is dead simple: | |
# |
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
@child_and_parent = { | |
:b=>:a, | |
:c=>:a, | |
:x=>:a, | |
:d=>:b, | |
:e=>:b, | |
:f=>:c, | |
:g=>:c, | |
:h=>:g, | |
:i=>:h |
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
# If your workers are inactive for a long period of time, they'll lose | |
# their Oracle connection. | |
# | |
# This hack ensures we re-connect whenever a connection is | |
# lost. Because, really. why not? | |
# | |
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
# | |
# From: | |
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
OlderNewer