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 / utils.ts
Created November 29, 2018 03:07
utils #nodejs #typescriopt
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root',
})
export class Utils {
uniqArray(a: object[]) {
return Array.from(new Set(a));
}
@frankyaorenjie
frankyaorenjie / curl.sh
Created October 11, 2018 07:26
[curl] #shell #curl
curl \
-s \
-x $proxy \
--max-time $TIMEOUT $url \
-w "$port\t%{time_total}\t%{time_namelookup}\t%{http_code}\t%{size_download}\n" \
-o /dev/null
.title-button {
display: flex;
cursor: pointer;
margin: 10px;
color: #ababab;
flex-direction: column;
justify-content: center;
height: 100%;
&:hover {
color: white;
@frankyaorenjie
frankyaorenjie / dump_and_restore.sh
Created July 25, 2018 13:34
[mongodb snippets] #mongodb
# source database: rec_prod, collection: rec_history
# dest database: recognition, collection: recognition_history
mongodump --host rec-shard-0/rec-shard-00-00-cudev.mongodb.net:27017,rec-shard-00-01-cudev.mongodb.net:27017,rec-shard-00-02-cudev.mongodb.net:27017 --ssl --username renjie --password <PASSWORD> --authenticationDatabase admin --db rec_prod -c rec_history -o ./dump/ -q '{timestamp: {$gte: ISODate("2017-08-01T00:00:00.000Z"), $lt: ISODate("2017-09-01T00:00:00.000Z")}}'
mongorestore --host visenze/mongodb-0.data.visenze.com:27017,mongodb-1.data.visenze.com:27017,mongodb-2.data.visenze.com:27017 --username data_api_rw --password <PASSWORD> --authenticationDatabase annotation -d recognition -c recognition_history ./dump/rec_prod/rec_history.bson
@frankyaorenjie
frankyaorenjie / batchgetitem.py
Last active August 20, 2018 11:44
[python3 boto for dynamodb] #aws #dynamodb #python
response = dynamodb.batch_get_item(
RequestItems={
'visearch_production_meta': {
'Keys': batch_i_tx_j_list,
'ProjectionExpression': 'm,nd,nk'
}
}
)
dynamodb_results.extend(response['Responses']['visearch_production_meta'])
@frankyaorenjie
frankyaorenjie / Dockerfile
Last active February 7, 2024 18:02
[Pass parameters from docker run to python] #docker #dockerfile
FROM python:3.6
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
ENV GOOGLE_APPLICATION_CREDENTIALS /service/scripts/application_default_credentials.json
COPY . /service/scripts
WORKDIR /service/scripts
RUN pip install pipenv
@frankyaorenjie
frankyaorenjie / main.js
Last active July 10, 2018 06:20
nodejs
// read big file
split -l 500000 query_log_distinct_6m.csv split_files/
@frankyaorenjie
frankyaorenjie / main.sh
Created June 6, 2018 06:56
useful shell commands
# parallel download
cat /tmp/urls.txt | parallel -j 100 wget --timeout=2 -q {}
@frankyaorenjie
frankyaorenjie / get_table_size.sql
Last active January 22, 2019 14:00
bigquery #bigquery
SELECT
table_id,
SUM(size_bytes)/POW(10,9) AS size
FROM
`data-platform-163807.raw_logs.__TABLES__`
WHERE
table_id LIKE '%20190101'
GROUP BY
table_id
ORDER BY
@frankyaorenjie
frankyaorenjie / create_remote_upstream_branch.sh
Last active March 6, 2022 06:20
[git] git snippets #git
#V2 is branch name
#upstream is remote name
git push upstream HEAD:V2