Skip to content

Instantly share code, notes, and snippets.

View frankyaorenjie's full-sized avatar
🎯
Focusing

Yao Ren Jie姚仁捷 frankyaorenjie

🎯
Focusing
  • ViSenze
  • Singapore
View GitHub Profile
@frankyaorenjie
frankyaorenjie / gist:11372221
Created April 28, 2014 13:35
zookeeper connect
package com.google.code.or.Sample;
import org.apache.log4j.Logger;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;
import java.io.IOException;
@frankyaorenjie
frankyaorenjie / py
Created January 10, 2017 14:32
mysql login protocol
# Python implementation of the MySQL client-server protocol
# http://dev.mysql.com/doc/internals/en/client-server-protocol.html
# Error codes:
# http://dev.mysql.com/doc/refman/5.5/en/error-messages-client.html
from __future__ import print_function
from ._compat import PY2, range_type, text_type, str_type, JYTHON, IRONPYTHON
import errno
from functools import partial
import hashlib
@frankyaorenjie
frankyaorenjie / redshift_table_vacuum_skew
Created April 25, 2017 03:05
Redshift table vacuum skew
select tbl as tbl_id, stv_tbl_perm.name as table_name,
col, interleaved_skew, last_reindex
from svv_interleaved_columns, stv_tbl_perm
where svv_interleaved_columns.tbl = stv_tbl_perm.id
and interleaved_skew is not null;
@frankyaorenjie
frankyaorenjie / vtt_source.sql
Created April 25, 2017 08:04
bigquery regex
WITH params AS
(SELECT "[vtt_source=visenze_admin&error_page=5&error_limit=100]" as param
UNION ALL
SELECT "[__vs_inner=true&vtt_source=visenze_admin]" as param
UNION ALL
SELECT "[a=1]" as param)
SELECT
REGEXP_EXTRACT(param, r"vtt_source=(\w+)")
AS vtt_source
@frankyaorenjie
frankyaorenjie / export_bigquery_table_schema_json
Last active June 14, 2023 11:37
export bigquery table schema
bq show --format=prettyjson data-platform-163807:samples.wikipedia | jq '.schema.fields'
@frankyaorenjie
frankyaorenjie / bq_insert
Last active June 13, 2017 12:51
bq insert/delete
echo '{"date_hour":"1497232800","event_action":"visit","account_id":"6","campaign_id":"271","path":"/women/","media_type":"image","count":"183","vtt_source":"","style_id":""}' | bq insert ctc_stats.event_action_stats_hourly
bq rm -ft dashboard.dashboard_search_history\$20170303
@frankyaorenjie
frankyaorenjie / deploy_cloud_function.sh
Last active August 4, 2017 03:17
deploy cloud functions
gcloud beta functions deploy dashboardRecHistoryFunction --stage-bucket visenze-data_platform-cloud_function --trigger-topic rec_history --memory 128
@frankyaorenjie
frankyaorenjie / .vimrc
Created June 16, 2017 02:37
vim setting
syntax on
set et
set nu
set hlsearch
set paste
set copyindent
@frankyaorenjie
frankyaorenjie / snippet.java
Created August 11, 2017 03:26
aws s3 v4 sign
import com.amazonaws.HttpMethod;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
import java.net.URL;
public class Test {
@frankyaorenjie
frankyaorenjie / do.sh
Last active February 27, 2018 03:36
update all pip packages
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install --upgrade --user