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
# if you're requesting anything within '/wp-content/uploads' or '/files' | |
location ~ (/wp-content/uploads|files) { | |
# and it doesn't exist | |
if (!-e $document_root$uri) { | |
# try and match the dimensions from the filename | |
rewrite (\d+)(?:x)(\d+)(?:\.(?:[^\.]+)$) http://lorempixel.com/$1/$2 break; | |
# otherwise just use a default size | |
rewrite .* http://lorempixel.com/800/600 break; | |
} | |
} |
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 argparse | |
argparser = argparse.ArgumentParser(description="This is a Description of the Utility") | |
argparser.add_argument('--foo', '-f', help='help text for --foo argument', default="World") | |
def main(): | |
"""Script Entry Point""" | |
print "Hello %s!" % args.foo |
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
set :test_log, "logs/capistrano.test.log" | |
namespace :deploy do | |
before 'deploy:update_code' do | |
puts "--> Running tests, please wait ..." | |
unless system "bundle exec rake > #{test_log} 2>&1" #' > /dev/null' | |
puts "--> Tests failed. Run `cat #{test_log}` to see what went wrong." | |
exit | |
else | |
puts "--> Tests passed" |
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
// | |
// Start Method Definitions | |
// | |
// match_selector(Node tree, Array selectors) | |
// - top of the node tree | |
// - array of decendant string selectors (think CSS) | |
// | |
var match_selector = function self(node, selectors) { | |
if ( node.values.indexOf(selectors[0]) !== -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
var AppDAL = (function() { | |
var _BASE_URL = "http://"+ window.location.host +"/api/"; | |
var _request = function(resource_uri, method, s_cback, e_cback, data) { | |
data = data || null; | |
var resource_url = _BASE_URL + resource_uri; | |
var xhr = new window.XMLHttpRequest(); | |
xhr.onreadystatechange = function () { |
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
def _facs(num): | |
rv = [1, num] | |
for i in xrange(2, int(math.sqrt(num)) + 1): | |
if not num % i: | |
rv.extend([i,num/i]) | |
return rv |
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
@staticmethod | |
def humanoid_shuffle(items, num_shuffles=6): | |
# how many times items can be pulled from the same list consecutively | |
MAX_STREAK = 10 | |
# divide list roughly in half | |
num_items = len(items) | |
end_range = int(num_items / 2 + random.randint(0, int(.1 * num_items))) | |
first_half = items[:end_range] # list up to 0 - end_range | |
second_half = items[end_range:] # list after end_range - len(items) |
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
<?php | |
class block_map_works extends block_base { | |
public function init() | |
{ | |
$this->title = get_string('map_works', 'block_map_works'); | |
} | |
public function instance_allow_config() |
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
// makeClass - By John Resig (MIT Licensed) | |
function makeClass(){ | |
return function(args){ | |
if ( this instanceof arguments.callee ) { | |
if ( typeof this.init == "function" ) | |
this.init.apply( this, args.callee ? args : arguments ); | |
} else | |
return new arguments.callee( arguments ); | |
}; | |
} |