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 'flockdb' | |
| flock = Flock.new "localhost:7915", :graphs => { :a_to_b => 1, :b_to_c => 2 } | |
| flock.add(1, :a_to_b, 1) | |
| flock.add(1, :a_to_b, 2) | |
| flock.add(1, :a_to_b, 3) | |
| flock.add(2, :b_to_c, 1) | |
| flock.add(2, :b_to_c, 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
| # Shell commands: | |
| # ∴ sudo gem install twitter-text | |
| # ∴ ruby script/console | |
| Loading development environment (Rails 2.3.5) | |
| >> require 'twitter-text' | |
| => [] | |
| >> include Twitter::Extractor | |
| => Object | |
| >> urls = extract_urls("This has a url: http://twitter.com") |
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
| # From a .vimrc | |
| # Usage: <ESC>,indent<Enter> | |
| # | |
| map <Leader>indent :s/^\( *[^ ]\)/ \1/<CR> |
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
| latin = "6" | |
| egypt = [0x0666].pack('U') # Arabic-Indic 6 - ٦ | |
| china = [0x516d].pack('U') # 六 | |
| braille = [0x2820].pack('U') | |
| chars = [latin, egypt, china, braille ] | |
| patterns = [ /\d/, /[[:digit:]]/, /[[:alnum:]]/] | |
| chars.each do |char| |
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
| latin = "a" | |
| arabic = [0xfeb6].pack('U') # Sheen, ش | |
| cjk = [0x3333].pack('U') # HUIITO, ㌳ | |
| kcodes = [ 'NONE', 'u', 's' ] | |
| chars = [latin, arabic, cjk] | |
| patterns = [ /\w/, /\W/, /[[:punct:]]/ ] | |
| kcodes.each do |kcode| | |
| $KCODE = kcode |
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
| space = " " | |
| japanese_space = [0x3000].pack('U') | |
| puts "---" | |
| puts "Space and \\s : #{!!space.match('\s')}" | |
| puts "Japanese Space and \\s : #{!!japanese_space.match('\s')}" | |
| puts "---" | |
| puts "Space and [[:space:]] : #{!!space.match('[[:space:]]')}" | |
| puts "Japanese Space and [::space:]] : #{!!japanese_space.match('[[:space:]]')}" |
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
| decomposed ="e\xCC\x81" | |
| puts "1: #{decomposed.chars.inspect} // #{decomposed.chars.length}" | |
| puts "2: #{decomposed.chars.normalize(:c).inspect} // #{decomposed.chars.normalize(:c).length}" | |
| puts " 2a: #{decomposed.chars.normalize(:c)[0]}, #{decomposed.chars.normalize(:c)[1]}" | |
| puts " 2b: #{decomposed.chars.normalize(:c).unpack('U*').pack('U')} // #{decomposed.chars.normalize(:c).unpack('U*').pack('U').length}" | |
| puts " 2c: #{decomposed.chars.normalize(:c).unpack('U*').collect{|cp| [cp].pack('U') unless cp.to_s.blank? }} // #{decomposed.chars.normalize(:c).unpack('U*').collect{|cp| [cp].pack('U') unless cp.to_s.blank? }.length}" | |
| puts "3: #{decomposed.chars.normalize(:c).to_s.inspect} // #{decomposed.chars.normalize(:c).to_s.length}" | |
| puts "4: #{decomposed.chars.normalize(:c).to_s.unpack('U'*decomposed.chars.normalize(:c).to_s.length).collect {|x| x.to_s 16}}" | |
| puts "5: #{ActiveSupport::Multibyte::Chars.new(decomposed).length}" |
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
| import java.util.logging.Logger | |
| import javax.servlet.http.{HttpServletRequest, HttpServletResponse} | |
| import org.mortbay.jetty.Server | |
| import org.mortbay.jetty.handler.AbstractHandler | |
| object Test extends AbstractHandler { | |
| val log = Logger.getLogger("handler") | |
| def main(args : Array[String]) = { |
NewerOlder