Skip to content

Instantly share code, notes, and snippets.

Avatar
❤️
side project: 🚨 monitory.io 🇹🇼 taiwangoldcard.com ✈️ travelhustlers.co

Eric Khun erickhun

❤️
side project: 🚨 monitory.io 🇹🇼 taiwangoldcard.com ✈️ travelhustlers.co
View GitHub Profile
@erickhun
erickhun / youbikes-count.sh
Last active Sep 30, 2020
Number of YouBike in Taipei, Taiwan
View youbikes-count.sh
# As for 30th september 2020, the city open API gives us:
# Number of YouBike docks in Taipei (does not reflect the number of YouBikes)
curl -sS 'https://ptx.transportdata.tw/MOTC/v2/Bike/Station/Taipei?$format=JSON' | jq -r '[.[].BikesCapacity] | add '
# 16192 docks
# Number of YouBike Stations in Taipei
$ curl -sS 'https://ptx.transportdata.tw/MOTC/v2/Bike/Station/Taipei?$format=JSON' | jq -r ' . | length '
# 399 stations
@erickhun
erickhun / geth-restart.sh
Created Mar 11, 2018
Kill geth when it is stuck
View geth-restart.sh
# This bash script check if your geth is stuck in the same block number every X seconds
FIRST_TIME=true
NB_SECONDS_CHECK=300 #5 minutes
while true
do
JSON_RPC=$(curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}' http://0.0.0.0:8080)
NEW_BLOCK_NB=$(echo $JSON_RPC | python -c 'import json,sys;obj=json.load(sys.stdin);print int(obj["result"], 0)')
@erickhun
erickhun / read_elasticmq_queues.py
Last active Feb 21, 2018
List all your sqs/elastimq queues
View read_elasticmq_queues.py
import boto3
elasticmq_host = 'http://0.0.0.0:9324'
ressource = boto3.resource('sqs',
endpoint_url=elasticmq_host,
region_name='elasticmq',
aws_secret_access_key='x',
aws_access_key_id='x',
use_ssl=False)
client = ressource.meta.client
@erickhun
erickhun / tickets.sh
Last active Sep 30, 2020
Check Taipei Universiade Tickets
View tickets.sh
#!/bin/bash
# Usage : This will check against `page_url` every 180 seconds, put it in a screen or tmux session :
# $ while true; do sh ticket.sh; sleep 180; done
#
page_url='https://tickets.2017.taipei/ticket/area/17_TPE_18/2952'
email='xxx@gmail.com'
#Let's check the length return of the event page
View gist:7c9f53a3203c5c86776bd577cf9636ad
import urllib
import urllib2
import json
import time
import hmac,hashlib
def createTimeStamp(datestr, format="%Y-%m-%d %H:%M:%S"):
return time.mktime(time.strptime(datestr, format))
class poloniex:
@erickhun
erickhun / gist:4e7a362b94bf5394531b
Created Nov 19, 2014
Go Tour Excercice : Picture with Slices
View gist:4e7a362b94bf5394531b
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
picture := make([][]uint8, dy)
for y := range picture {
picture[y] = make([]uint8, dx) // Allocate 2nd slice dimensions
for x := range picture[y] {
@erickhun
erickhun / gist:25539167b081f206d363
Last active Aug 29, 2015
Go Tour Excercice : WordCount with map
View gist:25539167b081f206d363
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
map_result := make(map[string]int)
splitted := strings.Fields(s)