Skip to content

Instantly share code, notes, and snippets.

View girasquid's full-sized avatar
🦐

Luke Hutscal girasquid

🦐
View GitHub Profile
@girasquid
girasquid / setup.sh
Created September 17, 2012 04:35
How I deploy my side projects
curl -L http://path-to-setup.sh | bash
// Start fading in slowly...
jQuery('.alert').fadeIn("fast", function() {
// This callback gets run once the fadeIn has finished.
jQuery('.alert').fadeOut("slow");
});
@girasquid
girasquid / gist:3427762
Created August 22, 2012 17:29 — forked from mduheaume/gist:3409226
compressing a bunch of id's to construct a url
import random
import string
import base64
import zlib
import bz2
random_ids = [''.join([random.choice(string.ascii_lowercase) for x in range(8)]) for n in range(1000)]
long_string = ','.join(random_ids)
@girasquid
girasquid / menu.rb
Created August 19, 2012 17:11
Rubygame Menu class
require 'rubygame'
class Menu
def initialize screen, font_file, background, menu=[]
@background = background
@default_color = [0, 0, 0]
@selected_color = [255, 255, 255]
@font_size = 24
@selected_index = 0
#bg {
position: fixed;
height: 100%;
width: 100%;
z-index: 0;
}
#bg-overlay {
background: transparent url(images/overlay.png) 0 0 repeat;
position: relative;
@girasquid
girasquid / gist:2952168
Created June 19, 2012 03:39 — forked from TimFletcher/gist:2948882
Django View
from django.shortcuts import render
def some_view(request, template_name='path/to/template.html', extra_context={}):
context = extra_context.copy()
# Request remote page and parse it
foo = 'Some template variable'
context['foo'] = foo
return render(request, template_name, context)
@girasquid
girasquid / gist:1453265
Created December 9, 2011 20:59
How to save a file to a FileField in Django without writing the entire row.
instance.file_field.save(the_filename, file_content, save=False)
MyModel.objects.filter(id=instance.id).update(file_field=instance.file_field)
@girasquid
girasquid / clunky.py
Created November 24, 2011 23:16 — forked from kylefox/clunky.py
class MyThing(object):
def save(self, *args, **kwargs):
# If only I could `my_kwarg = kwargs.delete('my_kwarg')
my_kwarg = kwargs.pop('my_kwarg', False)
print "did some things"
# result = super(SpecialThing, self).save(*args, **kwargs)
if my_kwarg:
print "did other things, because of the kwarg"
# self.do_more_stuff()
@girasquid
girasquid / gist:1293781
Created October 17, 2011 20:58
Fix Bad Request errors with django-piston when using $.post
from piston.utils import Mimer
Mimer.register(lambda s: s, ('text/plain',))
@girasquid
girasquid / ubuntu_setup.sh
Created September 24, 2011 17:30 — forked from kylefox/ubuntu_setup.sh
Automated setup for a Ubuntu server with git, ruby, rvm, nginx.
#!/usr/bin/env bash
# ----------------------------------------------------
#
# Automated setup for a Ubuntu server with git, ruby, rvm, nginx.
# (Used at Carbonmade)
#
# Usage:
# - SCP this file to your server: scp ubuntu_setup.sh you@server:~
# - Make it executable: chmod +x ubuntu_setup.sh
# - Run it: bash ubuntu_setup.sh