Skip to content

Instantly share code, notes, and snippets.

@obeattie
obeattie / s3signurl.py
Created July 19, 2011 10:27
Quick, dirty Python script that spits out a signed url for Amazon S3
#!/usr/bin/env python
import optparse
import sys
from boto.s3.connection import S3Connection
def sign(bucket, path, access_key, secret_key, https, expiry):
c = S3Connection(access_key, secret_key)
return c.generate_url(
expires_in=long(expiry),
@bretthoerner
bretthoerner / ipdb.py
Created August 4, 2011 18:21
ipdb for IPython 0.11
import sys
from IPython.core.debugger import Pdb
from IPython.core import ipapi
def set_trace():
ip = ipapi.get()
def_colors = ip.colors
Pdb(def_colors).set_trace(sys._getframe().f_back)
@tonious
tonious / hash.c
Last active February 17, 2023 02:25
A quick hashtable implementation in c.
/* Read this comment first: https://gist.github.com/tonious/1377667#gistcomment-2277101
* 2017-12-05
*
* -- T.
*/
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
@pjenvey
pjenvey / gist:3808830
Created October 1, 2012 00:38
JSON Serializable SQLAlchemy Object
class JsonSerializableMixin(object):
def __json__(self, request):
"""
Converts all the properties of the object into a dict for use in json.
You can define the following in your class
_json_eager_load :
list of which child classes need to be eagerly loaded. This applies
to one-to-many relationships defined in SQLAlchemy classes.
@kaizhu256
kaizhu256 / gist:4482069
Last active October 20, 2021 16:25
javascript - very fast and simple uuid4 generator benchmarked on http://jsperf.com/uuid4/8
/*jslint bitwise: true, indent: 2, nomen: true, regexp: true, stupid: true*/
(function () {
'use strict';
var exports = {};
exports.uuid4 = function () {
//// return uuid of form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
var uuid = '', ii;
for (ii = 0; ii < 32; ii += 1) {
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

#!/usr/bin/env python
from collections import defaultdict
def calc_probabilities(s="the cat in the hat"):
"""Calculate the probabilities (read: frequencies) of letters in
string `s`.
"""
#!/bin/bash
# You can run this to make fetch automatically prune any time you pull or
# fetch.
#
# git config remote.origin.prune true
git fetch --prune
# Abort early if there are local changes
git checkout master || exit
  • e675f89...a7822d3 master -> master (forced update)
  1. Create a local branch where master belongs.

    git checkout -b fixmaster e675f89

a. If someone pushed to master between the last time you pulled and now you'll need to go to github to get the full hash. Go to https://github.com/<owner>/<repo>/commit/e675f89 and it'll have the full hash on the page.

`git fetch origin <full hash of e675f89>`

git checkout -b fixmaster e675f89