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 Module | |
def subclasses | |
classes = [] | |
ObjectSpace.each_object do |klass| | |
next unless Module === klass | |
classes << klass if self > klass | |
end | |
classes | |
end | |
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
// | |
// Regular Expression for URL validation | |
// | |
// Author: Diego Perini | |
// Created: 2010/12/05 | |
// Updated: 2018/09/12 | |
// License: MIT | |
// | |
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it) | |
// |
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
Object.prototype.addEvent = function(evt, handler, useCapt) { | |
//JUST A CHECK TO HANDLE “onclick” and “click” as evt | |
if(evt.match(“^on”)) | |
evt = evt.substr(2); | |
if(this.attachEvent) | |
return this.attachEvent('on' + evt, handler); // FOR IE | |
else if(this.addEventListener) | |
return this.addEventListener(evt, handler, useCapt); // OTHERS | |
else { | |
//IF BOTH FAILS |
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
// everyone's new favorite closure pattern: | |
(function(window,document,undefined){ ... })(this,this.document); | |
// when minified: | |
(function(w,d,u){ ... })(this,this.document); | |
// which means all uses of window/document/undefined inside the closure | |
// will be single-lettered, so big gains in minification. | |
// it also will speed up scope chain traversal a tiny tiny little bit. |
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
<!-- so it turns out that the object tag can act like an iframe | |
but the cool thing is you can nest object tags inside eachother for a fallback path. | |
what this means is you can "objectframe" a site.. and if it fails.. (site down, offline, whatever).. it'll use the next one. | |
so you can objectframe the live site and fallback to a screenshot. | |
or something. | |
demo at : http://jsfiddle.net/paul/CY2FQ/1/ | |
--> |
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
base = 10 | |
def radix_sort(x, max): | |
radix = 1 | |
while radix < max: | |
x = counting_sort(x, radix) | |
radix *= base | |
return x | |
def counting_sort(a, radix): |
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 os | |
import os.path | |
import sys | |
from graphite.render.hashing import ConsistentHashRing | |
instances = [] | |
unwelcome_instances = [] | |
for arg in sys.argv[1:]: | |
unwelcome = False |
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
# Install MacTex: http://mirror.ctan.org/systems/mac/mactex/mactex-basic.pkg | |
$ sudo chown -R `whoami` /usr/local/texlive | |
$ tlmgr update --self | |
$ tlmgr install ucs | |
$ tlmgr install etoolbox | |
# Install pandoc view homebrew |
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
// Let `doAjax`, `fadeIn`, `fadeOut`, and `delay` be promise-returning functions. | |
// In all the following examples, `example` is meant to return a promise that is fulfilled when | |
// all operations are completed, or rejected if any of the steps fail. | |
// ES5 | |
function example() { | |
return doAjax("data.json").then(function (data) { | |
document.getElementById("data").innerText = data; |
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
<html> | |
<head> | |
<title>Test</title> | |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> | |
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> | |
<script src="http://fb.me/react-0.5.1.js"></script> | |
<script src="http://fb.me/JSXTransformer-0.5.1.js"></script> | |
</head> |
OlderNewer