Skip to content

Instantly share code, notes, and snippets.

View MOOOWOOO's full-sized avatar

Jux Liu MOOOWOOO

  • Chongqing, China
View GitHub Profile
@MOOOWOOO
MOOOWOOO / pick_from_json.py
Last active November 19, 2021 10:32
pick data from complex json by key path string
# coding: utf-8
__author__ = 'Jux.Liu'
def pick_from_json(json_obj, key_path, key_sep='.', list_index_start='$_', list_index_end='_$'):
if key_sep in list_index_start or key_path in list_index_end:
raise Exception('pick another key sep')
key_list = key_path.split(key_sep)
sub_obj = json_obj
@MOOOWOOO
MOOOWOOO / flex.css
Created August 11, 2016 04:59
flex
.one-box {
display : flex;
justify-content : center;
align-items : center;
}
.two-one-box {
display : flex;
flex-direction : column;
justify-content : space-between;
for t in range(130000, 140000, 100):
if int(str(t)[2]) > 5:
break
for i in range(t, t+100, 3):
if int(str(i)[-2]) > 5:
break
print('elif {} < int_time <= {}:'.format(i, i + 3))
print("\tres = {} if align == 'floor' else {}".format(i, i + 3))
@MOOOWOOO
MOOOWOOO / tieba.py
Last active January 16, 2019 01:49
auto sign on baidu tieba
# -*- coding:utf-8 -*-
import requests
import re
__author__ = 'Jux.Liu'
# 修改自己的cooki
cookie = ''
# 构建请求头数据
@MOOOWOOO
MOOOWOOO / pip2-upgrade.py
Last active October 7, 2018 15:19
pip-upgrade
#!/usr/bin/python
# -*- coding:utf-8 -*-
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
call("pip2 install --upgrade {}".format(dist.project_name), shell=True)
@MOOOWOOO
MOOOWOOO / argparse.py
Last active May 21, 2018 11:26
argparse
#!/usr/bin python
# coding: utf-8
import sys
from argparse import ArgumentParser
from os.path import exists
def main(*args):
start = args[0].start
@MOOOWOOO
MOOOWOOO / keymap.ahk
Last active September 16, 2017 10:11
ahk bind map
GroupAdd OneNoteGroup, ahk_exe onenote.exe
GroupAdd Xshell, ahk_exe Xshell.exe
GroupAdd Firefox, ahk_exe firefox.exe
GroupAdd VSCode, ahk_exe Code.exe
GroupAdd gitbash, ahk_exe mintty.exe
;;上加一行
$^+o::
Send {Home}{Enter}{Up}
return
@MOOOWOOO
MOOOWOOO / update-mongodb-collection-field-type.js
Created July 25, 2017 06:17
更新mongodb一个集合的某个字段的类型
db.getCollection('years3').find().forEach(function(doc) {
var a = String(doc.date);
var d = new Date(a.substr(0,4)+'/'+a.substr(4,2)+'/'+a.substr(6,2));
db.getCollection('years3').update( {_id: doc._id}, {$set: {date: d}});
});
@MOOOWOOO
MOOOWOOO / cors.py
Last active April 27, 2017 08:47
python decorator of cors
def cors(func):
@wraps(func)
def wrapper_func(*args, **kwargs):
r = make_response(func(*args, **kwargs))
# list your access domain here
# if set 'Access-Control-Allow-Credentials', this cannot be *.
# must match the require domain
r.headers['Access-Control-Allow-Origin'] = '*'
r.headers['Access-Contorl-Allow-Methods'] = 'GET, POST, PUT, DELETE' # list your access methods here
allow_headers = "Referer, Accept, Origin, User-Agent"
@MOOOWOOO
MOOOWOOO / ArgumentParserInit.py
Last active April 10, 2017 08:26
new project use argument parser init
#!/usr/bin/env python
# coding: utf-8
import sys
from argparse import ArgumentParser
def main(*args):
pass