Skip to content

Instantly share code, notes, and snippets.

@alanho
alanho / gist:1013b6672734a989d296f1e515280e42
Created May 20, 2018 17:10
General Aircon for Puck.js
var isOn = true;
var commands = {
off: [3.3,1.6,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4],
on: [3.3,1.6,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.5,0.3,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,1.2,0.4,1.2,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0.4,0.4,0.4,0.4,0.4,1.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,0.4,1.2,0.4,1.2,0
@alanho
alanho / gist:d52ba700489fa2baf35f
Created July 19, 2015 16:54
### Keybase proof
### Keybase proof
I hereby claim:
* I am alanho on github.
* I am alanho (https://keybase.io/alanho) on keybase.
* I have a public key whose fingerprint is 83EE B426 639B AF7F 1538 24FE 48D2 B7F8 7429 5A5A
To claim this, I am signing this object:
@alanho
alanho / gist:9fe3dbd19901a08014d3
Created June 29, 2015 03:45
lolcommit to video
for f in *; do mv -- "$f" "$(stat -f "%Sm" -t "%Y%m%d%H%M%S" $f)"; done
for f in *; do mv -- "$f" "`stat -f "%Sm" -t "%Y%m%d%H%M%S" $f`.jpg"; done
ffmpeg -framerate 1 -pattern_type glob -i '*.jpg' -c:v libx264 out.mp4
@alanho
alanho / gist:773f73fa19f1dc850338
Created May 28, 2015 07:53
using oink with heroku
heroku logs --tail > log/production.log
cat log/production.log | cut -c 46- | grep 'Oink\|Memory\|Instantiation' > log/production-oink.log
oink --threshold=0 log/production-oink.log
@alanho
alanho / gist:51ea9161ace791da6d3e
Last active October 17, 2016 08:49
101 Ways to Convert HK1980 <> WGS84
Note:
HK1980: SRID 2326 http://spatialreference.org/ref/epsg/hong-kong-1980-grid-system/
WGS84: SRID 4326
Example:
Journey time indicators by Transport Department
https://data.gov.hk/en-data/dataset/hk-td-tis-journey-time-indicators
Location: H1 – JTI at Gloucester Road eastbound near the Revenue Tower (835776.133E, 815604.834N)
@alanho
alanho / gist:c864eb95127c85afe779
Last active August 29, 2015 14:09
keynote address
https://www.icloud.com/keynote/AwBUCAESEE3_Xqz0tbA0jEc5sy8V4oEaKW-PqSEmX8cjtD9nZwWP680GhmKNunoK2ZsU52EMqSz9nh9bLF10UVjjMCUCAQEEIA_qp0vuF9500cZXmhypAXWMII1KhFWLWA7hOyYI6KBJ#Barcamp_2014_Sharing
@alanho
alanho / gist:1e75267250c8abaca1d3
Last active August 29, 2015 14:06
bundle with brew libs
PKG_CONFIG_PATH="/opt/local/lib/pkgconfig:/usr/local/Cellar/imagemagick/6.8.9-1/lib/pkgconfig:$PKG_CONFIG_PATH" C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.8.9-1/include/ImageMagick-6 gem install rmagick
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
<?php
/**
* Coordinates.php
* An utility for converting HK80 to WGS84 coordinates
*
* Copyright (C) 2010, 2013 Kelvin Wong
* Licensed under the MIT License (http://opensource.org/licenses/MIT)
*
* Note: For the glossaries and conventions for coordinates convertion, please refer to
* the website of Geodetic Survey of Hong Kong.
@alanho
alanho / legco_extract.rb
Created April 22, 2013 09:24
Extract voting result JPEGs/PDFs from LegCo website
require "nokogiri"
require "open-uri"
require "uri"
urls = [
"http://www.legco.gov.hk/general/chinese/counmtg/yr08-12/mtg_0809.htm",
"http://www.legco.gov.hk/general/chinese/counmtg/yr08-12/mtg_0910.htm",
"http://www.legco.gov.hk/general/chinese/counmtg/yr08-12/mtg_1011.htm",
"http://www.legco.gov.hk/general/chinese/counmtg/yr08-12/mtg_1112.htm",
"http://www.legco.gov.hk/general/chinese/counmtg/yr12-16/mtg_1213.htm"
@alanho
alanho / gist:5428387
Created April 21, 2013 03:50
Rails with Apache
ServerName www.example.com:80
DocumentRoot "/path/to/rails/app/public"
RewriteEngine On
<Proxy balancer://railsapp>
BalancerMember http://127.0.0.1:5000
BalancerMember http://127.0.0.1:5001
</Proxy>