Skip to content

Instantly share code, notes, and snippets.

# python3
# 3rd party libs
setuptools==42.0.0
Flask==1.0.2
Flask-RESTful==0.3.6
Flask-SQLAlchemy==2.3.2
flask-script==2.0.6
flask_migrate==2.1.1
MySQL-python==1.2.5
#PyMySQL==0.9.2
@de1o
de1o / patch_requests.py
Created April 22, 2018 10:48
add default timeout time for requests
import requests
def _hook_requests():
try:
from requests.sessions import Session
except ImportError:
return
real_send = Session.send
@de1o
de1o / ww.sh
Created April 20, 2018 13:58
weekly-commits
#!/bin/bash
last_sunday=`date -v-sunday +"%Y-%m-%d"`
author=`git config --get user.name`
cmd="git shortlog --author=$author --after=$last_sunday --oneline"
echo $cmd
for i in `ls .`;do
if [ -d ~/Codes/$i ];then
cd ~/Codes/$i
if [ ! -d ".git" ];then
continue
@de1o
de1o / pre-commit
Last active December 2, 2016 07:14 — forked from convexset/commit-msg
git hook for pre-commit to use ESLint and flake8 as a soft guard of code quality (lets things pass if the committer is committed to committing)
#!/bin/bash
# Uses ESLint as a soft guard of code quality for your repo
# allows commits to go through if re-attempted within a pre-set interval
# copy to .git/hooks/commit-msg to have things work
# Based on: https://gist.github.com/wesbos/8aec9d2ff7f7cf9dd65ca2c20d5dfc23
PRESET_TIME_INTERVAL=20
@de1o
de1o / gist:82790c0618643fe307b4
Created March 2, 2015 15:47
toggle showing all file on mac os x
# toggle showing all file on mac os x
toggle_hidden_dotfiles() {
local is_dotfiles_hidden=$(defaults read com.apple.finder AppleShowAllFiles)
if [[ $is_dotfiles_hidden == "No" ]]; then
defaults write com.apple.finder AppleShowAllFiles Yes && killall Finder
else
defaults write com.apple.finder AppleShowAllFiles No && killall Finder
fi
}
alias thide=toggle_hidden_dotfiles

###hello

###hello

@de1o
de1o / queryThenSaveNewWords.scpt
Last active August 29, 2015 14:02
an apple script used in launchbar 5(maybe other launchers also) which can call Youdao Dict to look for new words, and save the new words in an file so you can review them. still has some problem. like, won't work when Youdao Dict was on the frontmost.
on WriteToFile(this_data, target_file) -- (string, file path as string)
do shell script "echo " & quoted form of this_data & ">> " & quoted form of target_file
end WriteToFile
on WordQuery(theString)
tell application "YoudaoDict" to activate
tell application "System Events"
tell process "YoudaoDict"
try
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def format_dict(array):
return {array[0]: {array[1]: array[2],
array[3]: array[4]}}
def proc(array):
if (len(array) % 5):
@de1o
de1o / writelog.c
Created February 12, 2014 06:46
a simple log function in Clang, based on http://blog.linuxphp.org/archives/1474/
#include <stdio.h>
//是Linux 系统的日期时间头文件。通常会包含include time.h
#include <sys/time.h>
// 是ISO C99 标准日期时间头文件。编写的代码平台无关的需要引入
#include <time.h>
//让函式能够接收不定量参数,va_list需要
#include <stdarg.h>
#define DEBUG 1