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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# -cat:Images_from_Wiki_Loves_Monuments | |
import sys, os | |
# Set your path to pywikipedia here | |
sys.path.append("/Users/hay/htdocs/checkouts/pywikipedia/") | |
import wikipedia, config, pagegenerators | |
import urllib2, codecs | |
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 delay = (function(){ | |
var timer = 0; | |
return function(callback, ms){ | |
clearTimeout (timer); | |
timer = setTimeout(callback, ms); | |
}; | |
})(); | |
$('input').keyup(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
#target "Illustrator" | |
/** | |
* sort layers (with sublayer) | |
*/ | |
var doc = app.documents[0]; | |
var lay = doc.layers; | |
var array_primary = []; | |
for (var i=0, iL=lay.length; i < iL ; i++) { |
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
// index.haml | |
$(function() { | |
App.init(); | |
}); | |
//application.js | |
var App = { | |
VMs : { | |
global : { | |
mainTemplate : ko.observable() |
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> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> | |
<script> | |
$(document).ready(function() { | |
var colortest = $("#colortest"); | |
for (i = 1; i <= 300; i++) { | |
var c = genColor(); | |
var newhtml = "<span style='font-family:\"Courier\",monospace;width:50px;height:30px;background-color:#" + c + "'>#" + c + "</span>"; | |
colortest.html(colortest.html() + newhtml); |
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
// This bit is important. It detects/adds XMLHttpRequest.sendAsBinary. Without this | |
// you cannot send image data as part of a multipart/form-data encoded request from | |
// Javascript. This implementation depends on Uint8Array, so if the browser doesn't | |
// support either XMLHttpRequest.sendAsBinary or Uint8Array, then you will need to | |
// find yet another way to implement this. (This is left as an exercise for the reader, | |
// but if you do it, please let me know and I'll integrate it.) | |
// from: http://stackoverflow.com/a/5303242/945521 | |
if ( XMLHttpRequest.prototype.sendAsBinary === undefined ) { |
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
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob | |
var rhinoStorage = localStorage.getItem("rhino"), | |
rhino = document.getElementById("rhino"); | |
if (rhinoStorage) { | |
// Reuse existing Data URL from localStorage | |
rhino.setAttribute("src", rhinoStorage); | |
} | |
else { | |
// Create XHR and FileReader objects | |
var xhr = new XMLHttpRequest(), |
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 to detect if a box of given color is visible on screen or not */ | |
is_box_visible = function(color) { | |
var selector; | |
selector = "." + color + "box:visible"; | |
return $(selector).length > 0; | |
}; | |
$.when(async_if(is_box_visible, 'green') /* green box is visible */, | |
async_if(is_box_visible, 'red') /* red box is visible */ | |
).then( |
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
// Handy function to render dynamic parameters in a dust.js helper | |
function renderParameter(name, chunk, context, bodies, params) { | |
if (params && params[name]) { | |
if (typeof params[name] === "function") { | |
var output = ""; | |
chunk.tap(function (data) { | |
output += data; | |
return ""; | |
}).render(params[name], context).untap(); | |
return output; |
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
// The recursive tree view | |
var TreeView = Backbone.Marionette.CompositeView.extend({ | |
template: "#node-template", | |
tagName: "ul", | |
initialize: function(){ | |
// grab the child collection from the parent model | |
// so that we can render the collection as children | |
// of this parent node |
OlderNewer