Skip to content

Instantly share code, notes, and snippets.

View qwIvan's full-sized avatar

yang chanfa qwIvan

View GitHub Profile
@qwIvan
qwIvan / app.py
Created March 26, 2018 09:15 — forked from seanbehan/app.py
Flask with Django ORM
'''
Run the following commands (bc. gists don't allow directories)
pip install flask django dj-database-url psycopg2
mkdir -p app/migrations
touch app/__init__.py app/migrations/__init__.py
mv models.py app/
python manage.py makemigrations
python manage.py migrate
@qwIvan
qwIvan / app.py
Created March 26, 2018 09:15 — forked from seanbehan/app.py
Flask with Django ORM
'''
Run the following commands (bc. gists don't allow directories)
pip install flask django dj-database-url psycopg2
mkdir -p app/migrations
touch app/__init__.py app/migrations/__init__.py
mv models.py app/
python manage.py makemigrations
python manage.py migrate
@qwIvan
qwIvan / service.md
Created December 16, 2017 09:19 — forked from tniessen/service.md
Using the "service" tool with ADB and why to avoid it

As it turns out, it is not trivial to control the audio volume of an Android device using ADB. At the time of writing, the only way appears to be using the service tool. Actually, the service command allows to "connect" to a number of services (104 on Android 6.0.1) and invoke functions. Not knowing much about this tool, I managed to completely mute all sounds and speakers of my Nexus 5, and I was stuck without any sound for quite some time. I did not find a way to unmute the sound from within the system UI, so I got to dive a little deeper into this.

If you know which service you want to use, you then need to find its interface declaration. The command

service list

gives you a list of all services with the associated interfaces, if applicable:

...

26 backup: [android.app.backup.IBackupManager]

@qwIvan
qwIvan / 12306.js
Created September 13, 2017 15:06 — forked from browsnet/12306.js
12306验证码识别的demo,百度识图来判断
var http=require("http"),https=require("https"),fs=require("fs");
var exec = require('child_process').execFile;
var UA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36";
//从12306获取图片
getImg().then(function(){
// 改变图片尺寸
return resizeImg();
}).then(function(){
// 把图片裁剪成8个小图片
return cropImg();
global !p
import string, vim
import textwrap
_snips_fns = {}
def py(*args):
import re
old_a = vim.eval('@a')
global !p
import string, vim
import textwrap
_snips_fns = {}
def py(*args):
import re
old_a = vim.eval('@a')
@qwIvan
qwIvan / qqvdl
Created February 13, 2017 04:47 — forked from zmwangx/qqvdl
v.qq.com SHD downloader (腾讯超清视频下载) https://github.com/soimort/you-get/issues/1298#issuecomment-236489420
#!/usr/bin/env zsh
print_progress () print -R $'\e[32m'"$*"$'\e[0m' >&2
print_error () print -R $'\e[31m'"Error: $*"$'\e[0m' >&2
# Obvious parameters
vid=f00213kcpwl
defn=shd
# To be extracted from browser's network inspector
/**
* For Google Voice
* @Author zbinlin <zbinlin@outlook.com>
*/
var sleep = delay => new Promise(resolve => setTimeout(resolve, delay));
var composeClick = function x(btn) {
var rect = btn.getBoundingClientRect();
var x = rect.clientX + rect.width * Math.random();
var y = rect.clientY + rect.height * Math.random();
@qwIvan
qwIvan / log.vim
Created June 16, 2016 08:07
Logging every autocommands events in the log file
augroup EventLoggin
autocmd!
autocmd BufNewFile * call s:Log('BufNewFile')
autocmd BufReadPre * call s:Log('BufReadPre')
autocmd BufRead * call s:Log('BufRead')
autocmd BufReadPost * call s:Log('BufReadPost')
autocmd BufReadCmd * call s:Log('BufReadCmd')
autocmd FileReadPre * call s:Log('FileReadPre')
autocmd FileReadPost * call s:Log('FileReadPost')
autocmd FileReadCmd * call s:Log('FileReadCmd')
@qwIvan
qwIvan / web-servers.md
Created April 23, 2016 18:10 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000