This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
textfile = open("./line-chat.txt", 'r') | |
reg_date = re.compile("\w{3}\.,\s\d{1,2}\/(\d{1,2}\/\d{4})") | |
reg_hour = re.compile("\d{2}:\d{2}\t") | |
mapSenders = {} | |
for line in textfile: | |
matches_date = reg_date.findall(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LAST_DUMP_FILE=./last_dump | |
DATE=`date +%Y-%m-%d_%H-%M` | |
FILENAME="dump_"${DATE} | |
EMAIL='xxx@gmail.com' | |
function check_status () { | |
## Each curl is specific to a given user. You can get the proper curl via the Chrome dev tool in network tabs -> copy -> copy curl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |