Skip to content

Instantly share code, notes, and snippets.

View lorin's full-sized avatar
🤷‍♂️
Nominal

Lorin Hochstein lorin

🤷‍♂️
Nominal
View GitHub Profile
@why-not
why-not / gist:4582705
Last active February 1, 2024 00:44
Pandas recipe. I find pandas indexing counter intuitive, perhaps my intuitions were shaped by many years in the imperative world. I am collecting some recipes to do things quickly in pandas & to jog my memory.
"""making a dataframe"""
df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
"""quick way to create an interesting data frame to try things out"""
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
"""convert a dictionary into a DataFrame"""
"""make the keys into columns"""
df = pd.DataFrame(dic, index=[0])
@joshfinnie
joshfinnie / gist:4046138
Created November 9, 2012 14:54
Installing Mezzanine on Heroku

Lately, I have been looking into Python CMSs. There are many out there, but for some reason or another Mezzanine stuck out as one I should try. Installing it is easy enough, but getting it up on running on my new favorite host, Heroku, was a bit of a challege.

Below you will find the steps that I took to get Mezzanine up and running on Heroku. Please let me know in the comments below if anything didn't work for you.

Setting up the Database

Heroku is shortly depricating Django's standard DATABASES dictionary in favor for a package which takes OS Environment Variables and builds the required dictionary for you. This is a good thing because it makes setting up a database on Heroku very easy. The package is called dj_database_url and it makes short work of getting a PostgreSQL database up and running with Mezzanine. Below is the code that you want to put in Mezzanine's DATABASES section:

import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
@asabaylus
asabaylus / gist:3071099
Created July 8, 2012 14:12
Github Markdown Heading Anchors

Anchors in Markdown

To create an anchor to a heading in github flavored markdown. Add - characters between each word in the heading and wrap the value in parens (#some-markdown-heading) so your link should look like so:

[create an anchor](#anchors-in-markdown)

@ianb
ianb / git-sync.sh
Created January 31, 2012 06:34
An attempt at a simple sync command for git
#!/usr/bin/env bash
set -e
if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
echo "usage: git sync [remote-name]"
echo
echo "Sync's the current repository to another remote host, using git,"
echo "but not using this repository."
echo
@zpao
zpao / README.md
Created June 6, 2011 17:56
autoconf 2.13 homebrew formula

Install

  1. install homebrew
  2. place autoconf.rb into Formula folder: /usr/local/Library/Formula/
  3. run brew install autoconf