Skip to content

Instantly share code, notes, and snippets.

View jaddison's full-sized avatar

James Addison jaddison

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jaddison on github.
  • I am jamesaddison (https://keybase.io/jamesaddison) on keybase.
  • I have a public key whose fingerprint is AE7B AA19 D3DE 0614 0D08 67B6 1A39 8609 930F 09DB

To claim this, I am signing this object:

@jaddison
jaddison / urls.py
Last active August 29, 2015 14:28
Django URL Dispatcher example
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import Constraint, Resolver404
"""
where the following in in the project settings.py:
SITE_DOMAIN_MY = ('http', 'my.example.com')
@jaddison
jaddison / vagrant-clean.sh
Last active August 31, 2015 18:49 — forked from jdowning/vagrant-clean.sh
Script to clean up Ubuntu Vagrant box before packaging
#!/bin/bash
# This script zeroes out any space not needed for packaging a new Ubuntu Vagrant base box.
# Run the following command in a root shell:
#
# bash <(curl -s https://gist.github.com/justindowning/5670884/raw/vagrant-clean.sh)
function print_green {
echo -e "\e[32m${1}\e[0m"
}
@jaddison
jaddison / gist:973745
Created May 16, 2011 01:02
Intellij IDEA 10 IDE libGDX Desktop application
package com.example.libgdxexample;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
public class DesktopStarter {
public static void main (String[] args) {
new LwjglApplication(new Game(), "Game", 480, 320, false);
}
}
@jaddison
jaddison / gist:973739
Created May 16, 2011 00:52
Intellij IDEA 10 IDE libGDX base application
package com.example.libgdxexample;
import com.badlogic.gdx.ApplicationListener;
public class Game implements ApplicationListener {
public void create () {
}
public void render () {
}
@jaddison
jaddison / gist:1941916
Created February 29, 2012 15:51
django csrf token in jquery
$(document).ready(function() {
// Disable caching of AJAX responses
$.ajaxSetup ({cache: false});
$('html').ajaxSend(function(event, xhr, settings) {
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
// Only send the token to relative URLs i.e. locally.
xhr.setRequestHeader("X-CSRFToken", $.cookie('csrftoken'));
}
});
});
@jaddison
jaddison / gist:1943426
Created February 29, 2012 18:43
adding to the templates tags available by default - add to the top of settings.py for example
from django.template.loader import add_to_builtins
add_to_builtins('django.contrib.staticfiles.templatetags.staticfiles')
add_to_builtins('django.templatetags.i18n')
add_to_builtins('django.templatetags.future')
@jaddison
jaddison / gist:3790821
Created September 26, 2012 21:47
Intellij IDEA 10 IDE libGDX Android application
package com.example.libgdxexample;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
public class ExampleActivity extends AndroidApplication
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
@jaddison
jaddison / gist:4485805
Last active December 10, 2015 20:08
django-simple-templates base.html example
{% load spurl %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
{# the `head-gace-js` block is what you would override in your original template to enable a Google Analytics Content Experiment #}
{% block head-gace-js %}{% endblock %}
{# by placing this canonical link in your base.html <head> section, all A/B template pages benefit - no duplicate content penalties #}
@jaddison
jaddison / gist:4485879
Created January 8, 2013 17:32
django-simple-templates GACE template example.
{% extends "base.html" %}
{% block head-gace-js %}
// paste your Google Analytics Content Experiment JS code here if you're running an experiment.
{% endblock %}
{% block content %}
<h2>Awesome webpage content for businesses.</h2>
{% endblock %}