Skip to content

Instantly share code, notes, and snippets.

View decause's full-sized avatar

Remy DeCausemaker decause

View GitHub Profile
@garnaat
garnaat / firstlaunch.py
Created May 18, 2011 12:16
Simple example of creating your first instance in EC2
import boto.ec2
import os, time
# define region_name to be region you want to connect to
region_name = 'eu-west-1'
conn = boto.ec2.connect_to_region(region_name)
# First upload a public key to use for SSH'ing to instance. Use "ssh-keygen" to generate.
fp = open(os.path.expanduser('~/.ssh/mykey.pub'))
material = fp.read()
@garnaat
garnaat / gist:2917662
Created June 12, 2012 13:55
Example using boto to create an IAM role and associate it with an EC2 instance
In [1]: policy = """{
...: "Statement":[{
...: "Effect":"Allow",
...: "Action":["s3:*"],
...: "Resource":["arn:aws:s3:::mybucket"]}]}"""
In [2]: import boto
In [4]: c = boto.connect_iam()
In [5]: instance_profile = c.create_instance_profile('myinstanceprofile')
In [6]: role = c.create_role('myrole')
In [7]: c.add_role_to_instance_profile('myinstanceprofile', 'myrole')
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@toolness
toolness / badgebakery.py
Created April 6, 2013 14:59
Simple Python module for baking of badges, and retrieval of assertion URLs from baked badges.
"""
This small module makes it easy to bake PNG images with links to
Open Badge assertions. It also allows for easy retrieval of the link
from baked PNGs.
For more information on badge baking, see:
https://github.com/mozilla/openbadges/wiki/Badge-Baking
Note that this module requires the PyPNG module:
@rossdylan
rossdylan / onelinepyramid.py
Created May 20, 2013 19:24
oh dear lord, pyramid hello world example in one line
herp = (lambda clist: __import__('wsgiref.simple_server').simple_server.make_server('0.0.0.0', 8080, clist[-1].make_wsgi_app()).serve_forever())((lambda config: [config.add_route('hello', '/hello/{name}'), config.add_view(lambda request: __import__('pyramid.response').response.Response('Hello {0}'.format(request.matchdict['name'])), route_name="hello"), config])((lambda: __import__('pyramid.config').config.Configurator())()))
@ralphbean
ralphbean / list-all-repos.py
Created June 7, 2013 23:17
Script to list all repos for a github organization
#!/usr/bin/env python
""" Print all of the clone-urls for a GitHub organization.
It requires the pygithub3 module, which you can install like this::
$ sudo yum -y install python-virtualenv
$ mkdir scratch
$ cd scratch
$ virtualenv my-virtualenv
@sloria
sloria / bobp-python.md
Last active July 7, 2024 18:13
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@decause
decause / caldashy2014.txt
Created January 22, 2014 02:02
cal -y > cal2014.txt | vim -- or I took the output of cal -y, which displays the calendar for the year, and then stacked the calendars on top of each other, and used vim to normalize spacing. It took a minute, so I figured "hey, maybe this would be useful for someone else to not have to do?"
2014
January
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
@ralphbean
ralphbean / linear-regression-on-text.py
Created May 1, 2014 15:07
Messing around with linear regression over text data
""" Messing around with scikit-learn. """
import sys
import numpy as np
import scipy.sparse
import sklearn.linear_model
import sklearn.datasets
import sklearn.svm