Skip to content

Instantly share code, notes, and snippets.

View akoumjian's full-sized avatar

Alec Koumjian akoumjian

View GitHub Profile
#!/usr/bin/env python
def foo(bar):
"""
Documentation goes here.
"""
bar += 1
return bar
@akoumjian
akoumjian / hello_world.py
Created October 2, 2011 03:48
Hello World
def hello(foo):
"""Testing Github gist to see how embedding works."""
foo += 5
return foo
@akoumjian
akoumjian / indexof_example.js
Created October 31, 2011 19:28
indexof example
var myCars=["Saab","Volvo","BMW"]; // literal array
if (myCars.indexOf("Saab")) {
console.log("It's in the list!")
}
else {
console.log("Nope, not there.")
}
@akoumjian
akoumjian / plupload_s3_django.html
Created December 7, 2011 20:26
plupload s3 django snippet
<script type="text/javascript">
$(document).ready(function () {
$('#uploader').plupload({
runtimes : 'flash,silverlight',
url : '{{ s3.url }}',
max_file_size : '1000MB',
multipart: true,
multipart_params: {
'key': '{{ s3.key }}', // use filename as a key
@akoumjian
akoumjian / gist:1625609
Created January 17, 2012 08:17
Celery Task as Tastypie One Use Resource
@task
def temp_resource(foo, bar):
"""
Generate a temporary resource for use in Tastypie
"""
value1 = foo**2
value2 = foo * bar
return {'field_one': value1, 'field_two': value2}
@akoumjian
akoumjian / gist:1625633
Created January 17, 2012 08:23
Tastypie One Time Retrieval Resource Using Celery Task as object_class
class TempResource(Resource):
class Meta:
resource_name = 'temp_resource'
object_class = temp_resource.delay
authorization = Authorization()
allowed_methods = ['post', 'get']
always_return_data = True
def get_resource_uri(self, bundle_or_obj):
"""
@akoumjian
akoumjian / bootstrap_salt_cloudinit.rst
Created February 1, 2012 02:33
Bootstrapping Salt on Linux EC2 with CloudInit

Boostrapping Salt on Linux EC2 with Cloud-Init

Salt is a great tool for remote execution and configuration management, however you will still need to bootstrap the daemon when spinning up a new node. One option is to create and save a custom AMI, but this creates another resource to maintain and document.

A better method for Linux machines uses Canonical's CloudInit to run a bootstrap script during an EC2 Instance initialization. Cloud-init takes the user_data string passed into a new AWS instance and runs it in a manner similar to rc.local. The bootstrap script needs to:

  1. Install Salt with dependencies
  2. Point the minion to the master
@akoumjian
akoumjian / webserver.sls
Created February 10, 2012 01:44
virtualenv.manage not found...
local:
Data failed to compile:
----------
State virtualenv.manage found in sls webserver is unavailable
@akoumjian
akoumjian / webserver.sls
Created February 10, 2012 03:30
require not working
app-pkgs:
pkg:
- latest
- names:
- python-virtualenv
- python-dev
- libmysqlclient-dev
- libxml2-dev
- mercurial
- git
@akoumjian
akoumjian / webserver.sls
Created February 10, 2012 06:54
broken virtualenv module
/var/www/env/:
virtualenv:
- manage
- no_site_packages: True
- require:
- pkg: python-virtualenv
python-virtualenv:
pkg:
- installed