Skip to content

Instantly share code, notes, and snippets.

View tonywangcn's full-sized avatar
🎯
Focusing

Tony Wang tonywangcn

🎯
Focusing
View GitHub Profile
@tonywangcn
tonywangcn / helpful-docker-commands.sh
Created June 11, 2019 15:54 — forked from garystafford/helpful-docker-commands.sh
My list of helpful docker commands
###############################################################################
# Helpful Docker commands and code snippets
###############################################################################
### CONTAINERS ###
docker stop $(docker ps -a -q) #stop ALL containers
docker rm -f $(docker ps -a -q) # remove ALL containers
docker rm -f $(sudo docker ps --before="container_id_here" -q) # can also filter
# exec into container

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocal you use. And there're two common protocals: SSH and HTTP/HTTPS. Both requires a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocal. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocal you use. And there're two common protocals: SSH and HTTP/HTTPS. Both requires a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocal. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p
@tonywangcn
tonywangcn / gensim_workflow.py
Created June 29, 2017 15:12 — forked from clemsos/gensim_workflow.py
How to calculate TF-IDF similarity matrix of a complete corpus with Gensim
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
This script just show the basic workflow to compute TF-IDF similarity matrix with Gensim
OUTPUT :
@tonywangcn
tonywangcn / pyslow.py
Created May 13, 2017 18:08 — forked from gleicon/pyslow.py
python, phantomjs and yslow
import sys, os, logging, subprocess, json
import gevent
logging.basicConfig(level=logging.DEBUG)
APP_ROOT = os.path.dirname(os.path.realpath(__file__))
YSLOW = os.path.join(APP_ROOT, 'js/yslow.js')
PHANTOMJS = "/usr/local/bin/phantomjs"
@tonywangcn
tonywangcn / scrape.py
Created May 2, 2017 12:17
Web Scraping for Email Addresses and Phone numbers using Python
# Small Python Script to scrape websites for
# email addresses and phone numbers(not a very great RE)
# Author: Dhruv Baldawa (@dhruvbaldawa on twitter)
# Github: http://www.github.com/dhruvbaldawa
import urllib,re
f = urllib.urlopen("http://www.example.com")
s = f.read()
re.findall(r"\+\d{2}\s?0?\d{10}",s)
re.findall(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}",s)
@tonywangcn
tonywangcn / ga.py
Created August 12, 2016 05:25 — forked from mindcont/ga.py
利用基因遗传算法中进行文本匹配
"""Genetic Algorithmn Implementation
"""
#引入随机函数
import random
#定义基因遗传算法顶层接口
class GeneticAlgorithm(object):
# 定义算法初始化
def __init__(self, genetics):
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* @ignore
*/
class OAuthException extends Exception {
// pass
}
class Oauth2_lib {