Skip to content

Instantly share code, notes, and snippets.

View DavidYKay's full-sized avatar

David Young-Chan Kay DavidYKay

View GitHub Profile
@alexpw
alexpw / gist:2166820
Created March 23, 2012 04:28
Clojure - macro try-catch
;; Approach 1, verbose
(defmacro try-catch [[lvl-fn fn] body]
(list 'try body
(list 'catch 'Exception 'e
(list lvl-fn 'e
(list ':name (list 'meta '#'fn))))))
(macroexpand '(try-catch [info foo] (reduce + 0 (range 5))))
@kennethreitz
kennethreitz / mongo.py
Created March 13, 2012 22:54 — forked from lstoll/mongo.py
MongoHQ w/ pymongo on Heroku
import os
import pymongo
MONGO_URL = os.environ.get('MONGOHQ_URL')
if MONGO_URL:
# Get a connection
conn = pymongo.Connection(MONGO_URL)
# Get the database
@raulraja
raulraja / gist:1176022
Created August 27, 2011 23:48
Async Operations with ObjectiveC Blocks
/*
* Copyright (C) 2011 47 Degrees, LLC
* http://47deg.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite