Skip to content

Instantly share code, notes, and snippets.

@cuppster
cuppster / template.js
Last active October 11, 2023 20:06
Template backbone.js code that encapsulates a datatable.net table within a view for a hypothetical auction listings application.
/*
* Template backbone.js code that encapsulates a
* datatable.net table within a view for a hypothetical ;)
* auction listings application.
*/
var HomeRouter = Backbone.Router.extend({
routes: {
'refresh' : 'refresh',
@cuppster
cuppster / flask_gridfs_images.py
Created March 12, 2013 18:24
Recipe for downloading images into a mongoDB gridfs collection, then serving the images with a Flask application. No temp files created.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
SYNOPSIS
flask_gridfs_images.py --start
flask_gridfs_images.py --add <IMAGE_URL>
DESCRIPTION
@cuppster
cuppster / node-express-cors-middleware.js
Created April 9, 2012 16:02
express.js middleware to support CORS pre-flight requests
app.use(express.methodOverride());
// ## CORS middleware
//
// see: http://stackoverflow.com/questions/7067966/how-to-allow-cors-in-express-nodejs
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
@cuppster
cuppster / README.md
Created September 12, 2020 14:50 — forked from klokan/README.md
NASA Blue Marble

NASA Blue Marble

Prepared for MapTiler: http://www.maptiler.com/ or other GDAL tools

GDAL vrt

Download the high-resolution images from http://visibleearth.nasa.gov/view.php?id=73751

wget http://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73751/world.topo.bathy.200407.3x21600x21600.A1.jpg
wget http://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73751/world.topo.bathy.200407.3x21600x21600.A2.jpg
@cuppster
cuppster / README.md
Created September 12, 2020 14:50 — forked from klokan/README.md
NASA Blue Marble

NASA Blue Marble

Prepared for MapTiler: http://www.maptiler.com/ or other GDAL tools

GDAL vrt

Download the high-resolution images from http://visibleearth.nasa.gov/view.php?id=73751

wget http://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73751/world.topo.bathy.200407.3x21600x21600.A1.jpg
wget http://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73751/world.topo.bathy.200407.3x21600x21600.A2.jpg
@cuppster
cuppster / 1.cs
Created September 3, 2012 18:39
Promises for C# using Generics
/*
modified from original source: https://bitbucket.org/mattkotsenas/c-promises/overview
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Promises
@cuppster
cuppster / quantize.py
Created November 2, 2012 23:08
Quantize An Image To A Custom Palette
import sys
import numpy as np
import scipy.ndimage as nd
from scipy.cluster.vq import vq
from scipy.misc import imsave
def crayola_9():
"""
Palette of the first 8 crayola colors + white
"""
@cuppster
cuppster / getcomics.py
Created January 30, 2013 06:18
Mini-framework for scraping web pages with python using PyQuery, decorators and generators.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, re
import itertools
from functools import wraps
from pyquery import PyQuery as pq
class scrape:
@cuppster
cuppster / 1.js
Created August 23, 2012 15:45
Anonymous backbone.js view models
// ## Site Navigation View
//
var SiteNavView = Backbone.View.extend({
model: new (Backbone.Model.extend({
defaults: {
hasNew: undefined,
}
})),
@cuppster
cuppster / comics.py
Created January 30, 2013 05:50
Mini-framework for scraping web pages with python using PyQuery, decorators and generators.
class NewComics:
def __init__(self):
self.pages = None
@scrape.route('/newreleases')
def weekly(self, url, d):
# save the total number of pages
if self.pages is None: