Skip to content

Instantly share code, notes, and snippets.

View SpencerCooley's full-sized avatar

Spencer Cooley SpencerCooley

View GitHub Profile
from pyramid.paster import get_app
application = get_app(
'/Users/chrism/modwsgi/env/myapp/production.ini', 'main')
1369463461554 duino write 0204000
{ '0': 'info', '1': 'digitalRead from pin 04' }
1369463461554 duino write 0204000
1369463461560 duino receive
1369463461561 duino receive 04::00
{ '0': 'info', '1': 'digitalRead from pin 04' }
1369463461604 duino write 0204000
{ '0': 'info', '1': 'digitalRead from pin 04' }
1369463461604 duino write 0204000
04::003461609 duino receive 04::00
function ajaxStuff1(value){
//do some ajax stuff with a value with a value parameter
}
function ajaxStuff2(value){
//do some other ajax stuff with a value parameter
}
var doStuffWhenSelectIsChanged = function(theId, ajaxStuff){
$(theId).change(function(){
@SpencerCooley
SpencerCooley / pyramid json api
Last active December 16, 2015 21:09
Reference on how to serialize a sqlalchemy object to json in a pyramid view callable.
@view_config(route_name='members', renderer='json')
def hello_world(request):
user_dict = dict(spencer=users)
serialized_user = [
serialize(user)
for user in DBSession.query(User).all()
]
require 'zip/zip'
the_file = 'Nectir.zip'
the_directory = './directory'
def unzip(zip, unzip_dir, remove_after = false)
Zip::ZipFile.open(zip) do |zip_file|
zip_file.each do |f|
f_path=File.join(unzip_dir, f.name)
@SpencerCooley
SpencerCooley / gist:5026891
Created February 25, 2013 02:07
How to place an array of geojson features on a leaflet map.
//using leaflet.js
var theMap = L.map('the_map_div', {
center: whereYouWantToCenterYourMap,
layers: mapBoxLayer,
zoom: 11,
maxZoom: 18
});
var theFeaures = geoJsonObjectThatYouSentMe;
/*this will not show up*/
.channels-pane
overflow-y:scroll
/*this will throw an error*/
.channels-pane
overflow-y:scroll;
ul.sub-menu{
z-index:2;
}
ul.portfolio-item-filter{
z-index:1;
}
$(function(){
wax.tilejson('http://a.tiles.mapbox.com/v3/stevef22.map-lts93ykh.jsonp',
function(tilejson) {
var map = new L.Map('map-div')
.addLayer(new wax.leaf.connector(tilejson))
.setView(new L.LatLng(29.409694, -98.490372), 13);
$.ajax({
url: "test.html",
context: document.body
}).done(function() {
$(this).addClass("done");
});