Skip to content

Instantly share code, notes, and snippets.

View hanfeisun's full-sized avatar
🏕️

Hanfei Sun hanfeisun

🏕️
View GitHub Profile
@hanfeisun
hanfeisun / gist:a266d0771402918d95fb
Created May 13, 2015 07:52
HowScalaFutureWorks.scala
import scala.concurrent._
import ExecutionContext.Implicits.global
import scala.concurrent.duration._
val is = 1 to 10 toList
def db = s"${Thread.currentThread}"
def f(i: Int) = Future {
println(db + s" -> \t I'm ${i} -> \t I start to sleep")
Thread.sleep(1*1000)
@hanfeisun
hanfeisun / gist:074f1d01c0e905a704aa
Last active August 29, 2015 14:20
install java8 on centOS
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm
sudo rpm -i jdk-8u45-linux-x64.rpm
# Search jdk
rpm -qa|grep jdk
CREATE EXTENSION postgis;
SELECT postgis_full_version();
SELECT st_geomfromtext('POINT(-1 38)', 4329);
SELECT st_asewkt('0101000020E9100000000000000000F0BF0000000000004340');
SELECT st_geomfromtext('LINESTRING(-13 21,0 0,3 2)') AS mycheckmark;
CREATE EXTENSION postgis;
SELECT postgis_full_version();
SELECT st_geomfromtext('POINT(-1 38)', 4329);
SELECT st_asewkt('0101000020E9100000000000000000F0BF0000000000004340');
SELECT st_geomfromtext('LINESTRING(-13 21,0 0,3 2)') AS mycheckmark;
We can't make this file beautiful and searchable because it's too large.
b,25.8092,-80.24
b,25.8587,-80.2094
b,25.4849,-80.461
b,25.8471,-80.2415
b,25.6849,-80.3125
b,25.7502,-80.2429
b,25.6003,-80.3537
b,25.8306,-80.2661
b,25.926,-80.1617
b,25.9466,-80.2056
SELECT st_geomfromtext('POINT(-1 38)', 4329);
select st_asewkt('0101000020E9100000000000000000F0BF0000000000004340');
select st_geomfromtext('LINESTRING(-13 21,0 0,3 2') as mycheckmark;
SELECT st_geomfromtext('POINT(-1 38)', 4329);
select st_asewkt('0101000020E9100000000000000000F0BF0000000000004340');
select st_geomfromtext('LINESTRING(-13 21,0 0,3 2') as mycheckmark;
"""Library to interface with the GEO (GDS- GEO DataSets) repository"""
import os
import re
import sys
import urllib
import traceback
from datetime import datetime
import time
import enchant
/*
* A white-list based PAC without regexp, by @janlay
* It's just simple and fast.
* Last update: Dec 9, 2013
* Special thanks to @Paveo
*/
function FindProxyForURL(url, host) {
var PROXY = "PROXY 127.0.0.1:8800;SOCKS 127.0.0.1:8801";
var DEFAULT = "DIRECT";
@hanfeisun
hanfeisun / sicp_coin.py
Last active December 30, 2015 16:48
SICP iteration solution
first_denom = {1:1,2:5,3:10,4:25,5:50}
def cc_rec(amount, kinds_of_coins = 5):
if amount == 0:
return 1
elif amount < 0 or kinds_of_coins == 0:
return 0
else:
return cc_rec(amount, kinds_of_coins - 1) + \
cc_rec(amount - first_denom[kinds_of_coins], kinds_of_coins)