Skip to content

Instantly share code, notes, and snippets.

View FingerLiu's full-sized avatar
😀
coding

FingerLiu FingerLiu

😀
coding
View GitHub Profile
@FingerLiu
FingerLiu / decorator-example
Created January 23, 2015 05:04
use decorator to make a function elementwise.
def elementwise(fn):
def newfn(arg):
if hasattr(arg,'__getitem__'): # is a Sequence
return type(arg)(map(fn, arg))
else:
return fn(arg)
return newfn
@elementwise
def compute(x):
@FingerLiu
FingerLiu / install_sqlite_3.14.sh
Created September 14, 2016 08:53 — forked from ziafazal/install_sqlite_3.14.sh
install custom sqlite(3.14) with pysqlite
# install custom sqlite 3.14
wget https://github.com/ghaering/pysqlite/archive/2.8.3.tar.gz
wget https://www.sqlite.org/2016/sqlite-autoconf-3140100.tar.gz
tar -xzvf sqlite-autoconf-3140100.tar.gz
tar -xzvf 2.8.3.tar.gz
cp -av sqlite-autoconf-3140100/. pysqlite-2.8.3/
cd ./pysqlite-2.8.3 && python setup.py build_static install
@FingerLiu
FingerLiu / get_open_port.py
Created June 4, 2017 04:15
获取一个未使用的端口
def get_open_port():
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("",0))
s.listen(1)
port = s.getsockname()[1]
s.close()
return port
@FingerLiu
FingerLiu / im_in_terminal
Created June 4, 2017 04:17
curses 实现命令行聊天界面
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import curses, traceback, string
#-- Define the appearance of some interface elements
hotkey_attr = curses.A_BOLD | curses.A_UNDERLINE
menu_attr = curses.A_NORMAL
#-- Define additional constants
@FingerLiu
FingerLiu / run_benchmark.py
Created June 4, 2017 04:19
benchmark_in_python
# copied from https://github.com/django-guardian/django-guardian/blob/devel/benchmarks/run_benchmarks.py
#!/usr/bin/env python
"""
This benchmark package should be treated as work-in-progress, not a production
ready benchmarking solution for django-guardian.
"""
import datetime
import os
import random
@FingerLiu
FingerLiu / supervim.vimrc
Created June 4, 2017 04:21
超级 vimrc
scriptencoding utf-8
" ============================================================================
" Author: TaoBeier
" Blog: http://moelove.info
" Version: v1.1.0
" Update Time: 2016-09-25
" ============================================================================
" Vundle initialization
" Avoid modify this section, unless you are very sure of what you are doing
@FingerLiu
FingerLiu / setup_odoo.sh
Created June 4, 2017 04:23
odoo 踩坑
doo
add code.cloudist.cc to hosts to speedup download.
set deploy key.
clone seed-ERP
export USER=root
python setup_dev setup_deps
sudo -i -u postgres
@FingerLiu
FingerLiu / xml.snippets
Created June 4, 2017 04:24
odoo_snippet
snippet xml
<?xml version="1.0" encoding="UTF-8"?>
# tag
snippet t
<${1:}${2}>
</$1>
# inline tag
snippet ti
@FingerLiu
FingerLiu / sqldump.sh
Created June 4, 2017 04:25
tcmpdump sql query
#!/bin/bash
#this script used monitor mysql network traffic.echo sql
tcpdump -i eth1 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL)/i)
{
if (defined $q) { print "$q\n"; }
$q=$_;
} else {
$_ =~ s/^[ \t]+//; $q.=" $_";
@FingerLiu
FingerLiu / surf.md
Created June 4, 2017 04:26
在终端科学上网

1. 找到一台 shadowsocks 服务器的配置

2. 在本地 sslocal 连到 shadowsocks 服务器

3. proxychain 或 proxychain-ng 连到 sslocal

4. proxychain curl google.com