Skip to content

Instantly share code, notes, and snippets.

@gorhack
gorhack / AppDelegate.swift
Last active December 26, 2015 05:37
File additions to implement Facebook SDK with Swift 2
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)
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 / README.rst
Last active December 28, 2015 19:57 — forked from dupuy/README.rst
Common markup for Markdown and reStructuredText

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.

@gorhack
gorhack / .bash_profile
Last active January 8, 2016 16:35
modify bash_profile on Mac OS X to work with virtual environments
export WORKON_HOME=~/Documents/Development/virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
@gorhack
gorhack / postactivate.bash
Last active January 8, 2016 16:34
Enter/Exit virtual environment when workon/deactiavated
#!/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"