Skip to content

Instantly share code, notes, and snippets.

View jackhftang's full-sized avatar

Jack Tang jackhftang

View GitHub Profile
@jackhftang
jackhftang / designer.html
Last active August 29, 2015 14:16
designer
<link rel="import" href="../paper-input/paper-input.html">
<polymer-element name="my-element">
<template>
<style>
</style>
<div horizontal center-justified layout>
<paper-input id="paper_input1"></paper-input>
<paper-input id="paper_input"></paper-input>
function abcdefghppp(base, width, callback){
var i;
var cnt = 0;
var used1 = new Array(base);
var used2 = new Array(base);
var sp = new Array(width);
var table = new Array(base);
for(i=0; i<base; i++) table[i] = new Array(base);
var tableLen = new Array(base);
'use strict';
const SIZE = 6;
const BASE = SIZE - 1;
const HORI = 0;
const VERT = 1;
const SPACE = '.';
const TARGET = '+';
@jackhftang
jackhftang / dnsmasq-block-ads.sh
Last active June 26, 2016 02:59 — forked from frafra/dnsmasq-block-ads.sh
dnsmasq block ads
#!/bin/bash
FILE=/tmp/list
cat > $FILE <<-END
address=/2mdn.net/0.0.0.0
address=/360yield.com/0.0.0.0
address=/adgrx.com/0.0.0.0
address=/adnxs.com/0.0.0.0
address=/ads.yahoo.com/0.0.0.0
var mongoose = require('mongoose')
var hapi = require('hapi')
mongoose.connect('mongodb://localhost/test');
var Something = mongoose.model('Something', mongoose.Schema({
something: String
}));
var server = new hapi.Server()
#!/usr/bin/env python3
# Problem: http://9gag.com/gag/a6Qq368
def ex(*arg):
return [ i for i in range(10) if not i in arg ]
def c0p0(a,b,c):
arr = []
for i in ex(a,b,c):
for j in ex(a,b,c,i):
@jackhftang
jackhftang / shortener_b62d6.js
Last active September 6, 2016 13:29
In general, encode integer into string, and then decode it back. The encoded sequence look completely random and suitable for shortener. This implements allow integer of range 0 to 62^6-1 = 56800235583 > 2^35
const digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
const digitsReverse = (function(){
var arr = digits.split('');
var table = {};
for(var i=0; i<arr.length; i++) table[arr[i]] = i;
return table;
})();
const dim = 6;
const modulo = 62;
const shift = [26, 13, 47, 40, 11, 19];
@jackhftang
jackhftang / shortener_b36d7.js
Last active September 6, 2016 13:30
permute integer range [0, 56800235583]
const digits = "0123456789abcdefghijklmnopqrstuvwxyz";
const digitsReverse = (function(){
var arr = digits.split('');
var table = {};
for(var i=0; i<arr.length; i++) table[arr[i]] = i;
return table;
})();
const dim = 7;
const modulo = 36;
const shift = [11, 21, 21, 23, 4, 24, 1];
@jackhftang
jackhftang / SimpleHTTPServerWithUpload.py
Created December 27, 2016 01:19 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@jackhftang
jackhftang / google_sheet.js
Created March 10, 2017 10:03
An easy google sheet for landing page
var SHEET_NAME = "Sheet1";
function doGet(e) {
return handleResponse(e);
}
function doPost(e) {
return handleResponse(e);
}