Skip to content

Instantly share code, notes, and snippets.

View gzxultra's full-sized avatar
🍎
eating apple

Zhixiang gzxultra

🍎
eating apple
  • Seattle, WA
View GitHub Profile
@gzxultra
gzxultra / check_if_file_utf_8.py
Created May 22, 2016 06:05 — forked from binderclip/check_if_file_utf_8.py
simple python script check if file utf-8 coding
import sys
def main():
if len(sys.argv) < 2:
print 'please enter file path'
file_path = sys.argv[1]
with open(file_path, 'r') as f:
s = f.read()
try:
# coding: utf-8
import commands
import time
def get_current_ssh_user():
output = commands.getoutput('users')
return output.split(' ') if output else None
def get_current_ssh_user_set():
def zhprint(obj):
import re
print re.sub(r"\\u([a-f0-9]{4})", lambda mg: unichr(int(mg.group(1), 16)), obj.__repr__())
@gzxultra
gzxultra / Makefile
Created January 31, 2017 08:21
universal Makefile for C/C++ project
#### #######################################################
#
# MAKEFILE FOR C/C++ PROJECT
# Author: swm8023 <swm8023@gmail.com>
# Date: 2014/01/30
#
#### #######################################################
.PHONY: all clean
all:
@gzxultra
gzxultra / examples for pt-online-schema-change
Last active October 30, 2017 03:00
examples for pt-online-schema-change
```shell
pt-online-schema-change \
--execute \
--no-check-alter \
--ask-pass \
--recursion-method none \
--set-vars lock_wait_timeout=3 \
--alter "change serial_code warehouse_code varchar(100) not null default ''" \
u=xcf,h=xcfapp-mysql,D=xcf_mfarm,t=fresh_warehouse
@gzxultra
gzxultra / test.py
Created September 11, 2017 09:36
test_code
d = create_delivery('哎呀,又要测试啦', 'homepage_banner_ad1', 'ad_team',419, 9999,'2017-08-07 10:00:00', '2017-09-15 00:00:00','gzx', {"mobile_website":"1","pc_website":"1","iphone":"4.0.0","android":"100"}, [], [], {"android":{"expose_tracking_url":[],"click_tracking_url":[]},"iphone":{"expose_tracking_url":[],"click_tracking_url":[]},"mobile_website":{"expose_tracking_url":[],"click_tracking_url":[]},"pc_website":{"expose_tracking_url":[],"click_tracking_url":[]}}, {'market_newbie': {'data': [3], 'operator': '>='}})
@gzxultra
gzxultra / sample_nginx.conf
Last active September 13, 2017 04:38
sample_nginx
```conf
server {
listen 80;
server_name
venice-d2.xiachufang.com;
location / {
proxy_pass http://hazelnut:10080;
include proxy_params;
}
@gzxultra
gzxultra / mysql_operation.sql
Last active September 30, 2017 08:16
create user grant privileges
```sql
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON DB_NAME.* TO user_name@'%';
```
@gzxultra
gzxultra / progress_bar.py
Created November 16, 2017 07:25
examples using progress bar
```python
from ec.broker.user_persona import update_user_persona
from mysite.model.user import User
from mysite.model.const.user import STATE_ACTIVE
from mysite.util.orm import ormiter
from progress.bar import Bar
if __name__ == '__main__':
@gzxultra
gzxultra / scrapy.py
Last active December 8, 2017 13:33
scrapy.py
# coding: utf-8
import requests
import re
import hashlib
import simplejson
from bs4 import BeautifulSoup
requests.adapters.DEFAULT_RETRIES = 10
session = requests.session()