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 Foo | |
@@foo = nil | |
def self.seti( value ) | |
@foo = value | |
end | |
def self.setc( value ) | |
@@foo = value | |
end | |
def self.geti | |
@foo |
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
// http://phrogz.net/SVG/convert_path_to_polygon.xhtml | |
function pathToPolygon(path,samples){ | |
if (!samples) samples = 0; | |
var doc = path.ownerDocument; | |
var poly = doc.createElementNS('http://www.w3.org/2000/svg','polygon'); | |
// Put all path segments in a queue | |
for (var segs=[],s=path.pathSegList,i=s.numberOfItems-1;i>=0;--i) segs[i] = s.getItem(i); | |
var segments = segs.concat(); |
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
var versionByLevelAndDigits = { | |
L : { | |
41 : 1, | |
77 : 2, | |
127 : 3 | |
}, | |
M : { | |
34 : 1, | |
63 : 2, | |
101 : 3 |
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' | |
xml = <<ENDXML | |
<top> | |
<node1> | |
<value>mmm</value> | |
<value>zzz</value> | |
<value>ccc</value> | |
</node1> | |
<anothernode> | |
<value>zzz</value> |
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
function stackData(plot, s, datapoints) { | |
if (s.stack == null) | |
return; | |
/******************************************************************************************** | |
* series:{ reverseStack:true } causes the first series to be stacked at the top, | |
* the last series at the bottom. (Vertical ordering matches the legend.) | |
* | |
* Does not properly support excluding specific series from stacking; it's all or none. | |
* |
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
file = ARGV[0] | |
2.times do | |
lines, bytes = 0,0 | |
start = Time.now | |
contents = File.open(file,'rb'){ |f| f.read } | |
contents.scan(/.+/) do |line| | |
lines += 1 | |
bytes += line.size | |
end | |
elapsed = Time.now-start |
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
file = ARGV[0] | |
2.times do | |
lines, bytes = 0,0 | |
start = Time.now | |
contents = File.open(file){ |f| f.read } | |
contents.scan(/.+/) do |line| | |
lines += 1 | |
bytes += line.size | |
end | |
elapsed = Time.now-start |
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
file = ARGV[0] | |
2.times do | |
lines, bytes = 0,0 | |
start = Time.now | |
File.foreach(file) do |line| | |
lines += 1 | |
bytes += line.size | |
end | |
elapsed = Time.now-start |
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
# gem install remix; needed to uninclude modules | |
require 'remix' | |
class Class | |
@tweaks = Hash.new{ |h,k| h[k]=Hash.new{ |h,k| h[k] = Module.new } } | |
class << self; attr_reader :tweaks; end | |
def when_tweaked_as(name,&block) | |
Class.tweaks[name][self].class_eval(&block) | |
end | |
def apply_tweak(name,mod=nil) |