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
@mgan59
mgan59 / python-tumblr-authenticated-read-with-lxml
Created October 8, 2010 18:08
a code dump for an implemented lxml option for python-tumbl's authenticated reads
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2008 Ryan Cox ( ryan.a.cox@gmail.com ) All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@mgan59
mgan59 / django-generic-view.py
Created February 22, 2011 04:41
a basic cookie cutter view pastie with general imports and a base index action
from django.http import Http404, HttpResponse, HttpResponsePermanentRedirect
from django.template import RequestContext, loader
from django.shortcuts import render_to_response
def index(request):
cxt = {}
return render_to_response('main/index.html',
cxt, context_instance=RequestContext(request))
@mgan59
mgan59 / levenshtein.js
Created May 19, 2011 02:19 — forked from Marak/levenshtein.js
levenshtein function in javascript
function levenshtein(s1, s2) {
// http://kevin.vanzonneveld.net
// + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
// + bugfixed by: Onno Marsman
// + revised by: Andrea Giammarchi (http://webreflection.blogspot.com)
// + reimplemented by: Brett Zamir (http://brett-zamir.me)
// + reimplemented by: Alexander M Beedie
// * example 1: levenshtein('Kevin van Zonneveld', 'Kevin van Sommeveld');
// * returns 1: 3
@mgan59
mgan59 / contextmenu.js
Created May 21, 2011 17:02
jquery context menu plug
// jQuery Context Menu Plugin
//
// Version 1.01
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
//
// More info: http://abeautifulsite.net/2008/09/jquery-context-menu-plugin/
// http://labs.abeautifulsite.net/projects/js/jquery/contextMenu/demo/
//
@mgan59
mgan59 / regex breakdown of filter
Created May 24, 2011 19:08
regex to breakup a mixed object filter, used in a sammyjs script
// best if ran from a console debugger in firefox(firebug) / chrome(jsdebugger)
var str = 'market_cap;min=340,max=400,pe_ratio;min=4,max=23,div_yield;min=3.00,max=6.00';
str.match(/[a-z_]+;([a-z0-9=.]+,?){2}/g);
"""
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
@mgan59
mgan59 / wordwrap.css
Created September 15, 2011 16:44
cross browser wordwrap in css
.wordwrap {
white-space: pre-wrap; /* CSS3 */
white-space: -moz-pre-wrap; /* Firefox */
white-space: -pre-wrap; /* Opera <7 */
white-space: -o-pre-wrap; /* Opera 7 */
@mgan59
mgan59 / gist:4551810
Last active December 11, 2015 05:19
package installs for running dwarf fortress on ubuntu12.04 (32bit)
http://askubuntu.com/questions/64765/i-downloaded-dwarf-fortress-why-wont-it-run
http://www.bay12forums.com/smf/index.php?topic=66142.315
sudo apt-get install libsdl1.2debian libsdl-image1.2 libsdl-ttf2.0-0
@mgan59
mgan59 / mgan_vimrc
Last active December 18, 2015 05:38
morgans vimrc
" enable pathogeon plugin
call pathogen#infect()
" begin the great vim setup
set t_Co=256
set term=screen-256color
set autoindent
set ruler
set smarttab
set number
abaci.io
aback.io
abaft.io
abase.io
abash.io
abate.io
abbe.io
abbess.io
abbey.io
abbot.io