Skip to content

Instantly share code, notes, and snippets.

View jacobbubu's full-sized avatar

Rong Shen jacobbubu

  • Li Auto.
  • Beijing, China
View GitHub Profile
@jacobbubu
jacobbubu / configPart.coffee
Last active December 16, 2015 00:49
Alternative WebSocket implementation for ActionHero using
# RFC Web Socket Server
# You must have the web server enabled as well
configData.rfcWebSocket =
mount: "/ws"
localOffset = (new Date).getTimezoneOffset() * 60000
getLocaleStringByTimezoneOffset = (date, offset) ->
localTime = date.getTime()
utc = localTime + localOffset
offsetDate = utc + 3600000 * offset
nd = (new Date(offsetDate))
nd.toLocaleDateString() + ' ' + nd.toLocaleTimeString()
d = new Date()
@jacobbubu
jacobbubu / root_certs.txt
Created May 23, 2013 09:54
root certificates list for iOS and node.js
iOS:
http://support.apple.com/kb/HT5012?viewlocale=en_US&locale=en_US
node.js:
https://github.com/joyent/node/blob/master/src/node_root_certs.h
@jacobbubu
jacobbubu / province.json
Created May 28, 2013 12:23
Link province table of Weibo to geonames.org's data.
[
{
"weiboProvCode": "001011",
"name": "Beijing",
"countryCode": "CN",
"geoNames": {
"alternateNames": [
{
"name": "http://en.wikipedia.org/wiki/Beijing",
"lang": "link"
@jacobbubu
jacobbubu / compactTimezone.json
Last active December 17, 2015 23:29
Very compact and easy to use timezone + daylight saving table. Data comes from [Oslon timezone database](http://www.iana.org/time-zones) (ver. 2013-04-20).
{
"Africa/Abidjan": {
"offset": 0,
"dst": []
},
"Africa/Accra": {
"offset": 0,
"dst": []
},
"Africa/Addis_Ababa": {
@jacobbubu
jacobbubu / object-assign.coffee
Created October 19, 2016 08:54
Object.assign
assign = (target, firstSource) ->
if !target?
throw new TypeError('Cannot convert first argument to object')
to = Object(target)
hasPendingException = false
pendingException = undefined
i = 1
while i < arguments.length
nextSource = arguments[i]
@jacobbubu
jacobbubu / tennisKata.js
Created April 11, 2017 07:53
Flow-type example for Tennis Kata
/* @flow */
type Point = 'Love' | 'Fifteen' | 'Thirty';
type Deuce = 'Deuce';
type PlayerOne = 'Player1';
type PlayerTwo = 'Player2';
type Player = PlayerOne | PlayerTwo;
type GameOfPlayer = {
gameOfPlayer: Player
@jacobbubu
jacobbubu / dgraph.sh
Created August 20, 2017 07:15
Run Dgraph docker image on another port
docker run -it -p 8081:8081 -v ~/dgraph-naive:/dgraph --name dgraph-naive dgraph/dgraph dgraph --bindall=true --memory_mb 2048 --port 8081
@jacobbubu
jacobbubu / gist:5408997
Last active October 10, 2017 20:55
Regular Expression for UTC time offsets validation
^([+]((14|(14[:]?00))|([0][0-9]|[1][01])|([0][0-9]|[1][01])[:]?[0-5][0-9]))|([-]((12|(12[:]?00))|([0][0-9]|[1][01])|([0][0-9]|[1][01])[:]?[0-5][0-9]))$
The offset from UTC is given in the format ±[hh]:[mm], ±[hh][mm], or ±[hh], for exsamples:
Reference to http://en.wikipedia.org/wiki/Zone.tab.
+14:00
+1200
+12
-11:59
-01
@jacobbubu
jacobbubu / ISOCurrencySymbols.csv
Created February 15, 2012 14:31
iOS Currency Symbols
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
ADP ADP
AED AED
AFA AFA
AFN Af
ALK ALK
ALL ALL
AMD AMD
ANG NAf.
AOA Kz
AOK AOK