Skip to content

Instantly share code, notes, and snippets.

View GuoJing's full-sized avatar
🎯
Focusing

GuoJing GuoJing

🎯
Focusing
View GitHub Profile
@GuoJing
GuoJing / .screenrc
Created May 4, 2014 05:33
screen rc
shell -$SHELL
altscreen on
startup_message off
autodetach on
nonblock on
defutf8 on
defscrollback 10000
@GuoJing
GuoJing / fui.py
Last active June 25, 2019 13:43
A very simple html tags and attributes filter with BeautifulSoup
from BeautifulSoup import BeautifulSoup
VALID_TAGS = [
'div',
'span',
'a',
'p',
'br',
@GuoJing
GuoJing / .bash_profile
Created May 16, 2014 15:50
simple color config
export TERM="xterm-color"
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] "
@GuoJing
GuoJing / br.sh
Created June 10, 2014 15:24
br.sh
#!/bin/bash
set -e
device=$1
vlanid=$2
interface=vlan$vlanid
bridge="docker0"
modprobe 8021q
@GuoJing
GuoJing / casper.js
Last active August 29, 2015 14:03
casper
var c = require('framework.js');
var _step1_url = c.url + '/mine/info/1'
var _step2_url = c.url + '/mine/info/2'
var _step3_url = c.url + '/mine/info/3'
var _step4_url = c.url + '/mine/info/4'
var _step5_url = c.url + '/mine/info/5'
var check_loaded = function(){
casper.waitForResource(/form_helper\.js$/, function(){
@GuoJing
GuoJing / AppDelegate.m
Created March 25, 2015 15:36
ares thrift server
#import "AppDelegate.h"
#import "gen-cocoa/ares.h"
#import "thrift/Thrift.h"
#import "thrift/transport/TSSLSocketClient.h"
#import "thrift/transport/TTransport.h"
#import "thrift/transport/TSocketClient.h"
#import "thrift/transport/TFramedTransport.h"
#import "thrift/protocol/TBinaryProtocol.h"
@implementation AppDelegate
@GuoJing
GuoJing / socket_server.go
Created December 23, 2015 12:06
simple socket server with keepalive
package main
import (
"fmt"
"net"
"os"
"time"
)
func main() {
syntax = "proto3";
package tutorial;
message Person {
string name = 1;
int32 id = 2;
string email = 3;
enum PhoneType {
import sys
from itertools import chain, combinations
def find_partition(int_list):
A = set()
B = set()
for n in sorted(int_list, reverse=True):
if sum(A) < sum(B):
A.add(n)
else:
@GuoJing
GuoJing / progessbar.py
Created May 17, 2016 06:20
Python Progress Bar
import sys
def print_progress(iteration, total, prefix = '', suffix = '', decimals = 2, barLength = 100):
filledLength = int(round(barLength * iteration / float(total)))
percents = round(100.00 * (iteration / float(total)), decimals)
bar = '#' * filledLength + '-' * (barLength - filledLength)
sys.stdout.write('%s [%s] %s%s %s\r' % (prefix, bar, percents, '%', suffix)),
sys.stdout.flush()
if iteration == total:
print("\n")