Skip to content

Instantly share code, notes, and snippets.

View mgan59's full-sized avatar
💭
Building The Future, what about you?

Morgan Craft mgan59

💭
Building The Future, what about you?
View GitHub Profile
======================================================
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10
======================================================
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu
8.10. The article is targeted at a production environment, but keep in mind
this is a more generalized environment. You may have different requirements,
but this article should at least provide the stepping stones.
The article will use distribution packages where nesscary. As of 8.10 the
@banksean
banksean / perlin-noise-classical.js
Created February 15, 2010 10:00
two Perlin noise generators in javascript. The simplex version is about 10% faster (in Chrome at least, haven't tried other browsers)
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
@isaacs
isaacs / comma-first-var.js
Created April 6, 2010 19:24
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
"""
jQuery templates use constructs like:
{{if condition}} print something{{/if}}
This, of course, completely screws up Django templates,
because Django thinks {{ and }} mean something.
Wrap {% verbatim %} and {% endverbatim %} around those
blocks of jQuery templates and this will try its best
@antom
antom / str_list_ended.php
Last active June 7, 2024 11:36
Returns a string list with the final instance of $glue found substituted with $last - eg. "a, b, c, d, e" -> "a, b, c, d and e" if glue is ', ' and $last is ' and '.
function str_list_ended($value, $glue = ', ', $last = ' and ') {
return preg_replace(
"/($glue)(?!.+$glue)/",
$last,
(is_array($value) ? implode($glue, $value) : $value)
);
}
@jfsiii
jfsiii / node-flot.js
Created November 20, 2010 21:22
Creating a Flot chart using node-canvas
var document = require("jsdom").jsdom(),
window = document.createWindow(),
jQuery = require('jquery').create(window),
fs = require('fs'),
script = document.createElement("script");
window.Canvas = require('canvas');
script.src = 'https://gist.github.com/raw/790339/3b0171c3e9b749bb93fff5d642eaa687f02939a5/jquery.flot.node-canvas.js';
script.onload = function ()
{
@jfsiii
jfsiii / flot node mods
Created November 20, 2010 21:25
diff of changes required to SVN version of Flot 0.6 to get it running on Node (with node-canvas)
39a40,41
> width: null,
> height: null,
701c703,709
< var c = document.createElement('canvas');
---
> var c;
> if (typeof Canvas !== "undefined"){
> c = new Canvas(width, height);
> } else {
@siculars
siculars / paginate-riak.js
Created January 11, 2011 14:50
populate riak and return some of that data
/*
// paginate-riak.js
// use riak-js to paginate a set of data from a bucket in riak
//
// call the file like so:
//
// node paginate-riak bucketname start end
//
// ie.
//
@io41
io41 / paginated_collection.js
Created February 22, 2011 10:10 — forked from zerowidth/paginated_collection.js
Pagination with Backbone.js
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
typeof(options) != 'undefined' || (options = {});
this.page = 1;
typeof(this.perPage) != 'undefined' || (this.perPage = 10);
},
fetch: function(options) {
@tj
tj / fix-to.styl
Created February 22, 2011 14:26
custom properties with Stylus
fix-to(pos...)
position fixed
if length(pos) == 2
{pos[0]} 0
{pos[1]} 0
else if length(pos) == 4
a = pos[0..1]
b = pos[2..3]
{a[0]} a[1]
{b[0]} b[1]