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
window.addEventListener('load', function() { | |
// This 'createWrapper' method is super weird and awkward and I'm not proud of | |
// it at all. But right now it's the only option for defining custom sequence | |
// types that wrap arbitrary sources. In a future version I will come up with | |
// something much better, swear to God. | |
var jqueryWrapper = Lazy.createWrapper(function(selector, eventName) { | |
var source = this; | |
$(selector).on(eventName, function(e) { | |
source.emit(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
/** | |
* Using yield to create a generator -- only possible in ES6/Harmony. | |
*/ | |
function fibonacci(limit) { | |
var fn1 = 1; | |
var fn2 = 1; | |
while (1) { | |
var current = fn2; | |
fn2 = fn1; | |
fn1 = fn1 + current; |
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 'nokogiri' | |
file = ARGV[0] | |
if !File.exist?(file) | |
puts "File #{file} does not exist." | |
exit | |
end | |
html = File.read(file) |
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 Agent(name) { | |
this.name = name; | |
this.command = function(subordinate, description, instructions) { | |
console.log(this.name + " tells " + subordinate.name + ": '" + description + "'"); | |
instructions.apply(subordinate); | |
}; | |
this.getCoffee = function() { | |
var recipients = Array.prototype.slice.call(arguments); |
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
# Disable XML parameter parsing completely as a stopgap measure until upgrading to Rails 2.3.16 | |
# to defend against arbitrary code execution vulnerability; see: | |
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion | |
ActionController::Base.param_parsers.delete(Mime::XML) |
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
using System; | |
using System.Text; | |
namespace FastStringConcatenation | |
{ | |
public class FastString | |
{ | |
const int DefaultCapacity = 32; | |
readonly StringBuilder buffer; |
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 static class EvilStringHelper | |
{ | |
private static readonly Action<string, int, char> _setChar; | |
private static readonly Action<string, int> _setLength; | |
static EvilStringHelper() | |
{ | |
if (Environment.Version.Major < 4) | |
{ | |
MethodInfo setCharMethod = typeof(string).GetMethod( |
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() { | |
function expand($) { | |
function text($element) { | |
return $.trim($element.clone().children().remove().end().text()); | |
} | |
function isFixedOrFloating($element) { | |
try { | |
if ($element.css("position") === "fixed") { | |
return true; |
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
import sublime | |
import sublime_plugin | |
class NumberCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
selection = self.view.sel() | |
for region in selection: | |
try: | |
value = int(self.view.substr(region)) | |
self.view.replace(edit, region, str(self.op(value))) |
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
Show hidden characters
[ | |
{ "keys": ["ctrl+alt+r"], "command": "randomize" } | |
] |
NewerOlder