Skip to content

Instantly share code, notes, and snippets.

@gorhack
gorhack / postactivate.bash
Last active Jan 8, 2016
Enter/Exit virtual environment when workon/deactiavated
View postactivate.bash
#!/bin/bash
# This hook is sourced after every virtualenv is activated.
PS1="$_OLD_VIRTUAL_PS1"
PROJECT_DIR="$HOME/Documents/Development/virtualenvs/$(basename $VIRTUAL_ENV)"
if [ -d $PROJECT_DIR ]; then
# If we aren't already within the project dir, cd into it
if [[ ! `pwd` == "$PROJECT_DIR*" ]]; then
export PRE_VENV_ACTIVATE_DIR=`pwd`
cd "$PROJECT_DIR"
@gorhack
gorhack / .bash_profile
Last active Jan 8, 2016
modify bash_profile on Mac OS X to work with virtual environments
View .bash_profile
export WORKON_HOME=~/Documents/Development/virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
@gorhack
gorhack / README.rst
Last active Dec 28, 2015 — forked from dupuy/README.rst
Common markup for Markdown and reStructuredText
View README.rst

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

View post_file_stream.py
import requests
from io import BytesIO
def genCatImage():
"""
generates an image from TheCatAPI and returns the image as a Byte stream
"""
# get image from website
r = requests.get('http://thecatapi.com/api/images/get?format=src&type=png')
if r.status_code == requests.codes.ok: # image returned OK
@gorhack
gorhack / AppDelegate.swift
Last active Dec 26, 2015
File additions to implement Facebook SDK with Swift 2
View AppDelegate.swift
import FBSDKShareKit
...
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
application,
openURL: url,
sourceApplication: sourceApplication,
annotation: annotation)
You can’t perform that action at this time.