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 / gist:36c70653533235efc5013a8db4bb5cb9
Created February 3, 2018 13:19
Test code for Asynchronous loading of echarts
<template>
<v-container grid-list-xl>
<app-header></app-header>
<v-layout row wrap v-if="loading">
<v-flex xs12 class="text-xs-center">
<v-progress-circular
indeterminate
class="primary--text"
:width="7"
:size="70"></v-progress-circular>
@tonywangcn
tonywangcn / gevent_sqlalchemy_example.py
Last active September 16, 2018 03:29
gevent and sqlalchemy usage example
# coding:utf-8
from gevent import monkey, sleep, spawn, joinall
monkey.patch_all()
import datetime
from sqlalchemy import Column, Integer, String, DateTime, Numeric, create_engine, VARCHAR, UniqueConstraint
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
import sqlalchemy
import time
@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 / multithread_log.py
Created April 24, 2017 13:48
multithread demo log
import threading
import logger
logger = logger.handler_configure(clientip='your ip', user='logging_test')
class ThreadUrl(threading.Thread):
def run(self):
@tonywangcn
tonywangcn / sample.json
Created April 24, 2017 13:47
log sample in Mongodb
{
"_id" : ObjectId("58fe7083151099015c678ef0"),
"relativeCreated" : "7.94100761414",
"process" : "372",
"module" : "multithread_log",
"funcName" : "run",
"message" : "Hey log it's a debug",
"clientip" : "your ip",
"filename" : "multithread_log.py",
"levelno" : "20",