Skip to content

Instantly share code, notes, and snippets.

View towry's full-sized avatar
🎯
Focusing

Towry Wang towry

🎯
Focusing
  • Shanghai, China
View GitHub Profile
from bs4 import BeautifulSoup
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
USE_PROXY = True
if USE_PROXY:
import requesocks as requests
else:
var __on = false;
var vis = (function(){
var stateKey, eventKey, keys = {
hidden: "visibilitychange",
webkitHidden: "webkitvisibilitychange",
mozHidden: "mozvisibilitychange",
msHidden: "msvisibilitychange"
};
@towry
towry / _service.md
Created February 17, 2016 05:13 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
var data = [61.5, 65.2, 72.3, 75.1, 85.0, 86.2, 61.0, 64.3, 72.1, 75.8, 79.9, 84.8, 63.1, 65.0, 77.0, 74.0, 88.0, 87.0, 60.4, 65.9, 79.5, 70.1, 80.4, 85.9, 90.0];
d3 .select('#chart')
.datum(data)
.call(histogramChart()
.width(700)
.height(250)
.lowerBand(55)
.upperBand(95)
.bins(7)
@towry
towry / zsh.md
Created March 3, 2016 14:20 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu
@towry
towry / poisson.js
Created March 8, 2016 03:16 — forked from nicolashery/poisson.js
Quick JavaScript implementation of Exponential and Geometric random number generators
/* Quick implementation of Exponential and Geometric random number generators
For example you can use it to simulate when an event is going to happen next, given its average rate:
Buses arrive every 30 minutes on average, so that's an average rate of 2 per hour.
I arrive at the bus station, I can use this to generate the next bus ETA:
randomExponential(2); // => 0.3213031016466269 hours, i.e. 19 minutes
*/
@towry
towry / myview.swift
Created April 10, 2016 07:34
custom nsview class
// put this in playground
class MyView : NSView {
override func drawRect(dirtyRect: NSRect) {
let pathRect = NSInsetRect(self.bounds, 1, 1)
let path = NSBezierPath(roundedRect: pathRect, xRadius: 10, yRadius: 10)
path.lineWidth = 4
NSColor.greenColor().setFill()
NSColor.blackColor().setStroke()
path.fill()
@towry
towry / lazy-load.js
Created May 24, 2016 02:01
lazy load images.
/*!
* Copyright 2016 MoSeeker, Inc.
* @author Towry Wang
*/
var verge = require('verge');
var classes = require('dom-classes');
var objectAssign = require('object-assign');
function LazyLoad(options) {
@towry
towry / app.js
Last active October 26, 2016 05:01
history api fallback for vue-router
// usage
import historyFallback from 'lib/polyfill/historyFallback'
import historySupport from 'lib/support/history';
let redirected = historyFallback('/', historySupport ? 'history' : 'hash');
if (!redirected) {
// You app ...
// Vue.use(VueRouter);
@towry
towry / setup_vpn.md
Last active June 22, 2019 22:06
Installing a vps and setup vpn

Initialize the server.

  1. login as root user.
    • ssh root@server_ip_address
  2. create a new user:
    • adduser username
    • Use the usermod command to add the user to the sudo group. usermod -aG sudo username
    • Test sudo access on new user account. su - username
  3. login as new created user.