Skip to content

Instantly share code, notes, and snippets.

View chris-zh's full-sized avatar
🚌
Working from home

Qiandai chris-zh

🚌
Working from home
View GitHub Profile
@chris-zh
chris-zh / config.sh
Last active March 15, 2016 05:58
git 设置和取消代理
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@chris-zh
chris-zh / image.py
Last active March 15, 2016 05:24
支持Python3的图片处理库
#[Pillow说明文档][1]
#[1]:https://pillow.readthedocs.org/en/3.1.x/
#压缩图片尺寸
from __future__ import print_function
import os, sys
from PIL import Image
size = (128, 128)
for infile in sys.argv[1:]:
@chris-zh
chris-zh / ubuntu安装Pillow报错解决方案
Created March 9, 2016 04:13
ubuntu安装Pillow报错解决方案
http://stackoverflow.com/questions/34631806/fail-during-installation-of-pillow-python-module-in-linux
测试成功
@chris-zh
chris-zh / env.py
Last active November 26, 2022 12:04
Python读取.env并设置环境变量
#注意:.env中变量的写法一般是 TEST_KEY = TEST_VALUE。最好去除每个字符两边的空格,否则加到环境变量里也读取不到
def import_env():
if os.path.exists('.env'):
print('Importing environment from .env...')
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
key, value = var[0].strip(), var[1].strip()
os.environ[key] = value
print(os.environ.get('MAIL_SERVER'))
@chris-zh
chris-zh / strip.py
Created March 15, 2016 06:02
Python去除字符串外的空格
" xyz ".strip() # returns "xyz"
" xyz ".lstrip() # returns "xyz "
" xyz ".rstrip() # returns " xyz"
" x y z ".replace(' ', '') # returns "xyz"
@chris-zh
chris-zh / DateHandler.java
Created June 13, 2016 01:22
处理日期格式
/**
* 原始日期类型
* YYYY-MM-DD HH24:MI:ss
* YYYY-MM-DD HH24:MI:ss.0
* YYYY-MM-DD
* YYYYMMDD
* 转换
* 成YYYY-MM-DDTHH24:mi:ss
* '2016-01-01T12:00:00
*
@chris-zh
chris-zh / DataHandlerJava8.java
Created October 9, 2016 06:08
用LocalDateTime处理日期
public static void main(String[] args){
//获得当前日期 2016-10-09T13:15:16.386
LocalDateTime now = LocalDateTime.now();
System.out.println("now = " + now);
//获得3天后 2016-10-12T13:21:01.215
LocalDateTime threeDaysAfterNow = now.plusDays(3);
System.out.println("threeDaysAfterNow = " + threeDaysAfterNow);