Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
@lxneng
lxneng / schema_convert.sh
Created April 3, 2018 02:56 — forked from shantanuo/schema_convert.sh
script to convert mysql schema to be compatible with data warehouse software
#!/bin/sh
# script to convert mysql schema to be compatible with data warehouse software
# make sure that s3cmd and maatkit utility is installed
db_name=${1:-'test'}
> /root/$db_name.txt
temppath='/mnt/data/pdump1'
host='localhost'
user='maatkit'
@lxneng
lxneng / Draw Pencil Sketches and Play with Photos.ipynb
Created August 27, 2017 08:08
Draw Pencil Sketches and Play with Photos
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lxneng
lxneng / polyphone.ipynb
Created July 5, 2017 10:58
list polyphone word
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lxneng
lxneng / gist:22b1b04e268bb9c9f7e15acac3dc8576
Created March 4, 2017 13:32
Check nginx active connection without HttpStubStatusModule
netstat -an | grep :443 | grep ESTABLISHED | wc -l
@lxneng
lxneng / json_exc.py
Created December 7, 2016 02:21
quick trick for changing exceptions to json
@view_config(context=HTTPException)
def exception_view__upgrade(exc, request):
"""if we end with .json, serve json."""
if (request.path[-5:]).lower() == '.json':
request.environ['HTTP_ACCEPT'] = "application/json"
return exc
@lxneng
lxneng / query.json
Created September 5, 2016 11:21
function_score in es
{
"query": {
"function_score": {
"functions": [
{
"script_score" : {
"script" : "_score * log10(max(doc['like_count'].value, 1)) + ((doc['created_at'].value/1000) - 1412092800)/604800.0"
}
}
@lxneng
lxneng / identify-duplicated-row.ipynb
Created August 31, 2016 07:16
identify-duplicated-row
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
>>> a = unichr(int('5E97', 16))
>>> a
u'\u5e97'
>>> print(a)
>>> "%X" % ord(u'店')
'5E97'
@lxneng
lxneng / cleanup_dag002.sql
Last active August 12, 2016 02:59
cleanup dag info by sql in postgres db
\set dag_id '''dag002''';
delete from xcom where dag_id = :dag_id;
delete from task_instance where dag_id = :dag_id;
delete from sla_miss where dag_id = :dag_id;
delete from log where dag_id = :dag_id;
delete from job where dag_id = :dag_id;
delete from dag_run where dag_id = :dag_id;
delete from dag where dag_id = :dag_id;
@lxneng
lxneng / gist:63937454a0ef69618614b9f784280d9e
Created August 12, 2016 02:57
cleanup dag info by sql in postgres db
\set dag_id '''dag002''';
delete from xcom where dag_id = :dag_id;
delete from task_instance where dag_id = :dag_id;
delete from sla_miss where dag_id = :dag_id;
delete from log where dag_id = :dag_id;
delete from job where dag_id = :dag_id;
delete from dag_run where dag_id = :dag_id;
delete from dag where dag_id = :dag_id;