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 <prototype> | |
// (2001000).withDelimiters(); // "2,001,000" | |
// (9821).withDelimiters("_"); // "9_821" | |
// (1221).withDelimiters(",", 100); // "12,21" | |
Number.prototype.withDelimiters = function(s, k) { | |
if (!s) s = ","; | |
if (!k) k = 1000; | |
var o = [], | |
i = Math.floor(this); |
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
class Memcached::MultiPartRailsCache | |
MAX_KEY_LENGTH = 255 # Actually overshooting what the client will let you send through | |
# but this means our chunk sizes will just a few bytes of headroom | |
# as we split | |
PART_SIZE = 1.megabyte - MAX_KEY_LENGTH | |
def initialize(rails_cache) | |
@rails_cache = rails_cache | |
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
class Memcached::CompressedRailsCache | |
def initialize(rails_cache) | |
@rails_cache = rails_cache | |
end | |
def get(key, raw = true) # raw is discarded | |
v = @rails_cache.get(key) | |
Marshal.load(Zlib::Inflate.inflate(v)) if v | |
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
<!doctype html> | |
<html> | |
<head> | |
<title>xhr status code test</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js"></script> | |
<script type="text/javascript"> | |
//<![CDATA[ | |
document.observe('dom:loaded', function() { | |
var body = $$('body')[0], | |
template = new Template("<span class=\"script_example\"><pre class=\"body\">#{body}</pre><button class=\"trigger_script\">Execute</button></span>"), |
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
Array.prototype.shuffle = function() { | |
var i = this.length, k, e; | |
while (--i) { | |
k = Math.floor(Math.random() * i); | |
if (k != i) { | |
e = this[i]; | |
this[i] = this[k]; | |
this[k] = e; | |
} | |
} |
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
/** | |
* | |
* Base64 encode / decode | |
* http://www.webtoolkit.info/ | |
* | |
**/ | |
var Base64 = (function() { | |
// Private methods for UTF-8 encoding and decoding |
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 'stringio' | |
class Capistrano::Logger | |
class StringIOProxy < StringIO | |
def initialize(proxy_target) | |
@proxy_target = proxy_target | |
super('') | |
end | |
def write(*args) |
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
Factory.sequence :luhn do |n| | |
def luhn?(n) | |
odd = false | |
0 == n.to_s.scan(/\d/).inject(0) { |a, d| | |
i = d.to_i * (odd = !odd ? 2 : 1) | |
a + (i > 9 ? i - 9 : i) | |
} % 10 | |
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
function AsynchDispatcher() { | |
var listeners = [], | |
m = 'message', | |
w = window; | |
function receiveMessage(index) { | |
index = parseInt(index.data || index); | |
setTimeout(listeners[index], 10); | |
if (index) { |
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
package { | |
import net.flashpunk.Entity; | |
import net.flashpunk.FP; | |
import net.flashpunk.graphics.Graphiclist; | |
import net.flashpunk.graphics.Text; | |
public class HUD extends Entity { | |
[Embed(source = "assets/fonts/pf_tempesta_seven.TTF", embedAsCFF=false, fontFamily = "what")] | |
public var myvar:String; |