Skip to content

Instantly share code, notes, and snippets.

import os, os.path
import sys
# Unless your project is already on your PYTHONPATH by default, you need to add it:
# project_directory should point to your project's parent directory.
project_directory = os.path.join(os.path.dirname(__file__), '..')
if project_directory not in sys.path:
sys.path.append(project_directory);
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
@lettertwo
lettertwo / gist:740721
Created December 14, 2010 17:12
Detects which mode mod_wsgi is running in
# Detect which mode the wsgi module is in.
# Uncomment this to see whether or not the wsgi module is in daemon mode, which is necessary for the monitor.
def application(environ, start_response):
status = '200 OK'
if not environ['mod_wsgi.process_group']:
output = 'EMBEDDED MODE'
else:
output = 'DAEMON MODE'
@lettertwo
lettertwo / absurl.py
Created April 27, 2011 22:35
A template tag to create an absolute URI.
from django.template import Library
from django.templatetags.future import URLNode, url
register = Library()
class AbsoluteURLNode(URLNode):
def __init__(self, view_name, args, kwargs, asvar, legacy_view_name=True):
super(AbsoluteURLNode, self).__init__(view_name,
args,
kwargs,
@lettertwo
lettertwo / gist:7035980
Created October 18, 2013 03:16
sakabako/scrollMonitor#18
<html>
<head>
<style type="text/css" media="screen">
.spacer {
display: block;
height: 1600px;
}
.block {
display: block;
@lettertwo
lettertwo / A.js
Created May 7, 2014 14:02
An illustration of the Webpack 1.1.8 entry emission issue when in watch mode (https://github.com/webpack/webpack/issues/256)
// This is our entry point.
// We use `require.ensure` to tell webpack to generate a chunk that bundles `B.js`
require.ensure(['./B'], function (require) {
require('./B');
});
@lettertwo
lettertwo / keybase.md
Created June 20, 2014 14:02
keybase.md

Keybase proof

I hereby claim:

  • I am lettertwo on github.
  • I am lettertwo (https://keybase.io/lettertwo) on keybase.
  • I have a public key whose fingerprint is A847 07CA 5BDE 19DD 577D 980F 9BAF 835E 8C44 D70C

To claim this, I am signing this object:

@lettertwo
lettertwo / webpack.config.coffee
Created January 15, 2015 20:42
Example of Webpack config for building an isomorphic JS app for both client and server
path = require 'path'
webpack = require 'webpack'
fs = require 'fs'
ExtractTextPlugin = require 'extract-text-webpack-plugin'
ProgressPlugin = require 'webpack/lib/ProgressPlugin'
flag = require 'node-env-flag'
settings = require './src/settings'
scriptExportsLoader = path.join __dirname, 'script-exports-loader'
@lettertwo
lettertwo / vim.md
Created April 8, 2019 14:56
Philosophy of VIM

Philosophy of Vim

  • most of programming time is spent editing, not writing.
  • editing is a process of manipulating text in ways beyond just writing, such as deletion, replacement, reordering, duplication, formatting, etc.
  • since writing (input) is a relatively small part of the whole of programming, making the other tasks easier by default can be a productivity win.
  • os shortcuts for editing can't get 'shadowed' by custom actions, since they take the form of commands in 'normal' (command) mode

A Modal Editor

@lettertwo
lettertwo / machine.js
Last active November 17, 2019 03:20
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@lettertwo
lettertwo / machine.js
Created November 17, 2019 17:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions