Skip to content

Instantly share code, notes, and snippets.

Avatar

Rich Jones Miserlou

View GitHub Profile
@garnaat
garnaat / iam_ec2_example.py
Created September 15, 2010 04:48
Use IAM/boto to provide access to EC2 and S3
View iam_ec2_example.py
"""
IAM boto examples:
In this example we create a group that provides access
to all EC2 and S3 resources and actions and then add a
user to that group.
"""
import boto
#
# First create a connection to the IAM service
@apetresc
apetresc / AWSDemo.java
Created December 31, 2010 08:30
A modified version of the AWS SDK for Android sample code which fetches credentials from awskeyserver.
View AWSDemo.java
package com.amazon.aws.demo;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.net.URL;
import java.net.URLConnection;
@jacobian
jacobian / models.py
Created February 15, 2011 18:11
An example of using many-to-many "through" to augment m2m relationships. See http://www.quora.com/How-do-you-query-with-a-condition-on-a-ManyToMany-model-in-Django for context.
View models.py
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=200)
groups = models.ManyToManyField('Group', through='GroupMember', related_name='people')
class Meta:
ordering = ['name']
def __unicode__(self):
@cspanring
cspanring / pagination.html
Created November 8, 2011 02:53
linaro django pagination template for Bootstrap framework
View pagination.html
{# use in combination with https://github.com/zyga/django-pagination #}
{# and http://twitter.github.com/bootstrap/ #}
{# project-dir/templates/pagination/pagination.html #}
{% if is_paginated %}
{% load i18n %}
<div class="pagination">
<ul>
{% block previouslink %}
{% if page_obj.has_previous %}
@lucasrizoli
lucasrizoli / gist:1603274
Created January 12, 2012 21:33
70 Unique Ways to Encode <
View gist:1603274
<
%3C
&lt
&lt;
&LT
&LT;
&#60
&#060
&#0060
&#00060
@arbales
arbales / handlebars-formatTextForHTML.coffee
Created January 22, 2012 00:08
Replace URLs with links and unicode emoji with images.
View handlebars-formatTextForHTML.coffee
LINK_DETECTION_REGEX = /(([a-z]+:\/\/)?(([a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&amp;]*)?)?(#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(\s+|$)/gi
EMOJI_DIRECTORY = "/path/to/assets/emoji/20x20"
# Handlebars is presumed, but you could swap out
ESCAPE_EXPRESSION_FUNCTION = Handlebars.Utils.escapeExpression
MARKSAFE_FUNCTION = (str) -> new Handlebars.SafeString(str)
# Emoji unicode chars become images.
@timoxley
timoxley / isPortTaken.js
Last active September 21, 2022 15:32
check if a port is being used with nodejs
View isPortTaken.js
var isPortTaken = function(port, fn) {
var net = require('net')
var tester = net.createServer()
.once('error', function (err) {
if (err.code != 'EADDRINUSE') return fn(err)
fn(null, true)
})
.once('listening', function() {
tester.once('close', function() { fn(null, false) })
.close()
@trevorsheridan
trevorsheridan / Installing PostgreSQL on Mac OS X Lion
Created February 29, 2012 19:28
Installing PostgreSQL on Mac OS X Lion
View Installing PostgreSQL on Mac OS X Lion
Postgres manual located here: http://www.postgresql.org/docs/8.4/interactive/index.html
These instructions should work for Postgres 8 and 9
1. INSTALL
$ cd ~/source
$ ftp http://ftp.postgresql.org/pub/source/v8.4.11/postgresql-8.4.11.tar.gz
$ tar -zxvf postgresql-8.4.11.tar.gz
$ rm -r postgresql-8.4.11.tar.gz
$ cd postgresql-8.4.11
$ ./configure
@1337
1337 / pep8.py
Created April 5, 2012 19:52
So many things to hate about PEP 8
View pep8.py
#!/usr/bin/env python
# PEP 20 supersedes PEP 8 http://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds
# Follow PEP 20 if readability is affected by PEP 8
# max length 79 chars, not 80 (http://www.python.org/dev/peps/pep-0008/#maximum-line-length)
"""One-line summary of purpose. # double quoted docstrings; max length 72 chars (http://www.python.org/dev/peps/pep-0008/#maximum-line-length)
# 2nd line must be blank http://www.python.org/dev/peps/pep-0257/#multi-line-docstrings
More things # aligns with the quotes
More things
"""
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active March 30, 2023 22:07
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
View osx-for-hackers.sh
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx