Skip to content

Instantly share code, notes, and snippets.

View bobwei's full-sized avatar

Bob Wei bobwei

View GitHub Profile
anonymous
anonymous / bootstrap.sh
Created June 2, 2011 17:19
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@dburger
dburger / gist:1008320
Created June 4, 2011 20:26
Javascript Array Binary Heap
/*
array implementation of a binary heap, example usage:
// can optionally provide a comparison function, a function for a max
// heap is the default if no comparison function is provided
var bh = binaryHeap();
bh.push(5);
bh.push(34);
bh.push(16);
var max = bh.pop(); // 34
@vmihailenco
vmihailenco / authentication.py
Created June 15, 2011 17:49 — forked from zyegfryed/gist:814432
Tastypie OAuth
import logging
from tastypie.authentication import Authentication
import oauth2
from oauth_provider.consts import OAUTH_PARAMETERS_NAMES
from oauth_provider.store import store
from oauth_provider.store import Error as OAuthError
from oauth_provider.utils import get_oauth_request
from oauth_provider.utils import get_oauth_server
@rodbegbie
rodbegbie / facebook.py
Created September 3, 2011 00:15
Hacked version of "official" (but now unsupported) Facebook Python SDK to support OAuth 2.0
#!/usr/bin/env python
#
# Copyright 2010 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@sirleech
sirleech / gist:1824697
Created February 14, 2012 07:48
Amazon EC2 How to Grow Storage

Amazon EBS - How to Grow the Storage

Seen loads of good posts about EBS describing how to use them to provide cross instance persistent storage. Really it's awesome. All the EC2 images store to their own EBS and if the EC2 crashes a new one can be resumed with minimal downtime. Amazon has nice pictures about this use case.

Quite simple to increase the size of an EBS volume, just: create, attach, mount, write, umount, snapshot, create, attach, check, resize, check, mount, delete. We're going to walk through the process using Amazon EC2 command line tools.

Create the initial volume and attach to an EC2 instance.

@corbett
corbett / QuickAndAccurateiOSLocation.m
Created March 17, 2012 15:55
Objective-C to obtain quick and accurate location in iOS
// setup
- (void)viewDidLoad
{
...
self.locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
locationManager.distanceFilter = 250;
self.desiredLocationFreshness = 15.0; // desired freshness in s
self.desiredLocationAccuracy = 100.0; // desired location accuracy in m
@ruby0x1
ruby0x1 / multi-player-html5-games-00-express.js
Created March 27, 2012 15:01
Multi-player games in HTML5
/* Copyright (c) 2012 Sven "FuzzYspo0N" Bergström
http://underscorediscovery.com
MIT Licensed. See LICENSE for full license.
Usage : node simplest.app.js
*/
var
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@tbarbugli
tbarbugli / s3botostorage.py
Created July 25, 2012 21:51
S3BotoStorage
from boto.utils import parse_ts
from django.core.files.storage import get_storage_class
from storages.backends.s3boto import S3BotoStorage
"""
make sure you have this setting
AWS_PRELOAD_METADATA = True
and that you have python-dateutils==1.5 installed
"""
@thesharp
thesharp / ML, Python and virtualenv.md
Created July 25, 2012 22:56
Quick virtualenv fix on Mountain Lion

Quick virtualenv fix on Mountain Lion

Overview

It appears that Apple somehow broke Python in Mountain Lion, so even with the latest Command Line Tools and Xcode 4.4 virtualenv won't properly work. During virtual environment creation it will try to install easy_install inside /Library hierarchy. So let's give it a quick workaround. Let's install custom python into your $HOME-directory using pythonbrew!

Installing proper Command Line Tools

Without the Apple Mac Developer account you won't even see the proper download link for the latest CL Tools and the old one won't work on ML. So here's the link: http://goo.gl/iBTXh. It points towards the Apple website so don't worry.