This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -L http://path-to-setup.sh | bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Start fading in slowly... | |
jQuery('.alert').fadeIn("fast", function() { | |
// This callback gets run once the fadeIn has finished. | |
jQuery('.alert').fadeOut("slow"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#bg { | |
position: fixed; | |
height: 100%; | |
width: 100%; | |
z-index: 0; | |
} | |
#bg-overlay { | |
background: transparent url(images/overlay.png) 0 0 repeat; | |
position: relative; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
instance.file_field.save(the_filename, file_content, save=False) | |
MyModel.objects.filter(id=instance.id).update(file_field=instance.file_field) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from piston.utils import Mimer | |
Mimer.register(lambda s: s, ('text/plain',)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |