Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View indiejoseph's full-sized avatar
🏠
Working from home

Joseph cheng indiejoseph

🏠
Working from home
View GitHub Profile
@indiejoseph
indiejoseph / brew.txt
Created July 3, 2012 04:10 — forked from leesmith/brew.txt
Homebrew: install specific version of formula
cd /usr/local
brew versions postgresql
git checkout -b postgresql-8.4.4 [some hash]
brew install postgresql
git checkout master
git branch -d postgresql-8.4.4
http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula
@indiejoseph
indiejoseph / gist:3047593
Created July 4, 2012 14:13
UserScript - XHR Interceptor
function Interceptor(nativeOpenWrapper, nativeSendWrapper) {
XMLHttpRequest.prototype.open = function () {
// Code here to intercept XHR
return nativeOpenWrapper.apply(this, arguments);
}
XMLHttpRequest.prototype.send = function () {
this.onloadend = function() {
if(this.capture) {
console.log(this.responseText);
@indiejoseph
indiejoseph / gist:6129633
Created August 1, 2013 08:46
SenseCloud - Arduino code
#include <SPI.h>
#include <Ethernet.h>
// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(192,168,1,123); // Device IP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sight Reading Machine</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body style="margin: 0; padding: 0;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
@indiejoseph
indiejoseph / gist:9243727
Last active August 29, 2015 13:56
Schema.org: Mailchimp confirm subscription
<span itemscope itemtype="http://schema.org/EmailMessage">
<span itemprop="description" content="We need to confirm your email address."></span>
<span itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction">
<meta itemprop="name" content="Confirm Subscription">
<span itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<meta itemprop="url" content="https://sightreadingmachine.us7.list-manage.com/subscribe/smartmail-confirm?u=d3fc6=b673c9cc2799bb4b47ca&id=abb8a8adb6&e=3dfc6cfa34&inline=true">
<link itemprop="method" href="http://schema.org/HttpRequestMethod/POST">
</span>
</span>
</span>
@indiejoseph
indiejoseph / gist:9244089
Created February 27, 2014 03:55
Schema.org: Spotify listen
<span itemscope itemtype="http://schema.org/EmailMessage">
<meta itemprop="description" content="Jim Hall 的 Stella by Starlight 已在 Spotify 上架!">
<span itemprop="about" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="Stella by Starlight">
<span itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<meta itemprop="url" content="http://www.spotify.com/redirect/email-wp/?username=1211379188&template_name=notify_new_album.html&utm_medium=email&open=http%3A%2F%2Fopen.spotify.com%2Falbum%2F7JSVEy2xPiVRyluX9N6csF">
<meta itemprop="name" content="在 Spotify 收聽"></span>
</span>
</span>
</span>
@indiejoseph
indiejoseph / gist:9252049
Created February 27, 2014 15:17
Schema.org: Dropbox share folder
<script type=3D"application/ld+json">
{
"action": {
"url": "https://www.dropbox.com/invite?k=3DiZfxq5WwbyhujKJcmTocBE8ouwjT7zKr"
"name": "View folder"
"@type": "ViewAction"
}
"@context": "http://schema.org"
"@type": "EmailMessage"
"description": "shared folder invitation"
@indiejoseph
indiejoseph / gist:9621725
Created March 18, 2014 14:56
Express 4.x Router index.coffee
fs = require 'fs'
path = require 'path'
router = (require 'express').Router()
role = require './role'
# acl
router.use '/admin*', role.isAuthorized()
@indiejoseph
indiejoseph / gist:7bd16acc3958348bd1d6
Created May 2, 2014 10:16
基于统计模型的人名识别
编码 意义 例子
B 姓氏 (张)华平先生 ;(欧阳)修
C 双名的首字 张(华)平先生
D 双名的末字 张华(平)先生
E 单名 张(浩)说“: 我是一个好人”
F 前缀 (老) 刘 、(小) 李
G 后缀 王(总) 、刘(老) 、肖(氏) 、吴(妈) 、叶(帅)
K 人名的上文 又(来到)于洪洋的家.
L 人名的下文 新华社记者黄文(摄)
M 两个中国人名之间的成分 编剧邵钧林(和)稽道青说
@indiejoseph
indiejoseph / increment_number.sql
Created May 16, 2014 03:06
Increment number in MySQL
SELECT
`chars`.`id`,
@n := @n +1 AS `index`
FROM
`characters` AS `chars`,
(SELECT @n := -1) AS `m`;