Skip to content

Instantly share code, notes, and snippets.

@adorsk
adorsk / modjy_app.py
Created July 6, 2012 20:18
Jython/ModJy reloadable app
import sys
import os
import time
import re
__file__ = '/home/adorsk/projects/gr/georefine/webapp/app.py'
_times = {}
watch_pattern = "georefine"
class RollbackImporter:
@adorsk
adorsk / action_queue.js
Created July 27, 2012 19:47
jQuery Action Queue Sketch
require([
"jquery",
"use!backbone",
"use!underscore",
"_s",
"use!ui",
],
function($, Backbone, _, _s, ui){
@adorsk
adorsk / gist:3201295
Created July 29, 2012 19:30
facets state init
require([
"jquery",
"use!backbone",
"use!underscore",
"_s",
"use!ui",
"Facets"
],
function($, Backbone, _, _s, ui, Facets){
@adorsk
adorsk / gist:3239977
Created August 2, 2012 19:35
Backbone serializer test
require([
"jquery",
"use!backbone",
"use!underscore",
"_s",
"use!ui",
],
function($, Backbone, _, _s, ui){
// Returns the class name of the argument or undefined if
@adorsk
adorsk / js_filepath_tricks.js
Created October 12, 2012 13:55
Tricks for getting path to current JS Script
// in a <script src="foo"> tag.
(function(){
var scripts = document.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++){
console.log(i, scripts[i].src);
}
var thisScript = scripts[scripts.length-1].src;
console.log("thisScript is: ", thisScript);
})();
@adorsk
adorsk / gist:3940948
Created October 23, 2012 19:13
trick for sharing same require_config w/ browser and node
fs = require('fs')
vm = require('vm')
requirejs = require('requirejs')
BASE_URL = __dirname + '/'
requireConfigPath = BASE_URL + 'js/require_config.js'
script = vm.createScript(fs.readFileSync(requireConfigPath))
sandbox = {
require: requirejs,
BASE_URL: BASE_URL,
@adorsk
adorsk / gist:3941170
Created October 23, 2012 19:59
Froth compiling, via requiring a require.js module w/ Froth configs.
fs = require('fs')
vm = require('vm')
requirejs = require('requirejs')
BASE_URL = __dirname + '/'
requireConfigPath = BASE_URL + 'js/require_config.js'
script = vm.createScript(fs.readFileSync(requireConfigPath))
sandbox = {
require: requirejs,
BASE_URL: BASE_URL,
@adorsk
adorsk / rest_test.py
Created November 6, 2012 18:40
Python posting to Drupal, via REST services
import httplib2
import json
import time
base_url = 'http://localhost/services_test/api/external_tasks'
def t2():
login_data = {
'username': 'tasks',
'password': 'tasks'
@adorsk
adorsk / standalone_fab.py
Created November 12, 2012 15:40
Standalone Fabfile
if __name__ == '__main__':
from fabric.main import main
import sys
sys.argv = ['fab', '-f', __file__] + sys.argv[1:]
main()
@adorsk
adorsk / spatialite_indices.py
Created November 15, 2012 21:53
spatialite_indices
def test_foo(self):
limit = 1000
expected_counts = {}
if True:
start_time = time()
for i in range(1, limit):