Skip to content

Instantly share code, notes, and snippets.

@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
@aisipos
aisipos / jsonp-in-flask.py
Created July 20, 2011 01:20 — forked from farazdagi/jsonp-in-flask.py
JSONP in Flask
import json
from functools import wraps
from flask import redirect, request, current_app
def support_jsonp(f):
"""Wraps JSONified output for JSONP"""
@wraps(f)
def decorated_function(*args, **kwargs):
callback = request.args.get('callback', False)
if callback:
@wangyan
wangyan / sys-mon.sh
Created September 14, 2011 15:13
Monitor system mem and load, if too high, restart some service.
#! /bin/bash
#====================================================================
# sys-mon.sh
#
# Copyright (c) 2011, WangYan <webmaster@wangyan.org>
# All rights reserved.
# Distributed under the GNU General Public License, version 3.0.
#
# Monitor system mem and load, if too high, restart some service.
#
@psychemedia
psychemedia / googPlusFrFo-preliminarySketch.py
Created October 14, 2011 19:56
First doodling around a Google Plus friends/followers network grapher
####DEPRECATED
# ABOUT:
# A script that grabs a list of the friends or followers of one or more folk on Google+,
# grabs a sample of their friends, and generates the resulting social graph
# USAGE:
# Requirements: networkx (see DEPENDENCIES)
# Configuration: see CONFIGURATION
# Output: files will be save to the reports directory
@Tsagadai
Tsagadai / Markdown Table of Contents generator
Created March 14, 2012 02:30
A simple jQuery-based Table of Contents generator
/* A simple jQuery-based Table of Contents generator
* I needed a table of contents for some static markdown pages I created
* with bluecloth and rails (I'll make this a gem yet) and this is the result.
*
* This is one of my first afternoon forays into jQuery so it probably isn't
* the greatest code I've ever written. I have fully annotated the code with
* comments for others to learn and understand. Remove them before use.
*
* Requires jQuery
*/
@etotheipi
etotheipi / armory_escrow.md
Created April 4, 2012 21:52
Buyer-Seller Escrow, with or without third-party

Buyer-Seller Escrow, with or without third-party

  • Author: Alan Reiner (Armory)
  • Orig Date: 04 April, 2012 First Draft: Sorting out ideas, and event sequences, handling details like who signs what when and where change outputs and fees fit into the equation.

Example Transaction

Here's an example of Alice and Bob setting up the transaction. Bob posts an item on craigslist, knowing that unknown, untrusted Alice will try to buy it. In this case, Bob is the seller and will set the "Risk Deposit" (could also be "Escrow Deposit"). This can be negotiated by the buyer, but I expect that something like 15-25% would be standard and not a point of contention. Remember, buyer does not trust seller, and vice versa.

@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@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:

@arowser
arowser / gist:3618320
Created September 4, 2012 08:07 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

anonymous
anonymous / gist:3635514
Created September 5, 2012 11:49
Blockchain forks
$ grep -E '^\|' printblocktree.txt
|\
| 90392 (1,40027978) 00000000000ec87057d8 11/8/2010 06:59:03 tx 1
|
|\
| 90676 (1,40261655) 00000000001476bf9bf0 11/9/2010 07:40:40 tx 1
|
|\
| 90858 (1,40369940) 00000000000e21466cd5 11/10/2010 07:41:04 tx 1
|