Skip to content

Instantly share code, notes, and snippets.

@ii0
ii0 / gist:024bef19f8626e36f3bdf9fbceb6026f
Created April 19, 2016 03:06 — forked from iwanbk/gist:2295233
TCP Echo Client in Golang
package main
import (
"net"
"os"
)
func main() {
strEcho := "Halo"
servAddr := "localhost:6666"
tcpAddr, err := net.ResolveTCPAddr("tcp", servAddr)
@ii0
ii0 / Linux 常用命令锦集.md
Created April 25, 2016 02:58 — forked from dotku/Linux 常用命令锦集.md
Linux 相关的内容
  1. 查看版本

     # Finding your kernel release
     $ uname -r
     > 3.16.0-34-generic
     
     # Finding your distribution release
     $ lsb_release -a
     > Distributor ID: Ubuntu  
    

> Description: Ubuntu 14.10

@ii0
ii0 / gist:b5bbc540d4f9d4091841f863fade6624
Created April 25, 2016 15:02 — forked from palexander/gist:2975305
Compiling and running mosh on Dreamhost
# Thanks to @samsonjs for the cleaned up version:
# https://gist.github.com/samsonjs/4076746
PREFIX=$HOME
VERSION=1.2.3
# Install Protocol Buffers
wget http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.bz2
tar -xf protobuf-2.4.1.tar.bz2
cd protobuf-2.4.1
@ii0
ii0 / gist:be0aa35feca85556a6ef50f8fc1d2ca1
Created April 29, 2016 10:27 — forked from mdeous/gist:823821
example: parsing html with lxml and xpath
import lxml.html
html = lxml.html.parse("http://pypi.python.org/pypi") # can take an url, a filename or an object with a .read() method
packages = html.xpath('//tr/td/a/text()') # get the text inside all "<tr><td><a ...>text</a></td></tr>"
print packages
Out[7]:
[u'celery\xa02.2.3',
u'django-celery\xa02.2.3',
u'kombu\xa01.0.3',
@ii0
ii0 / phantom.js
Created August 22, 2016 06:29 — forked from Breefield/phantom.js
PhantomJS Custom Headers
var page = require('webpage').create();
// User-Agent is supported through page.settings
page.settings.userAgent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25';
// This is how you set other header variables
page.customHeaders = {'Referer': 'localhost'};
@ii0
ii0 / gist:751697b29b750d6fafb1df8e23bbd430
Created November 1, 2016 05:45 — forked from hSATAC/gist:5343225
Http Redirect in Golang
package main
import (
"log"
"net/http"
)
func redirect(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "http://www.google.com", 301)
@ii0
ii0 / 0_urllib2.py
Created November 25, 2016 06:59 — forked from kennethreitz/0_urllib2.py
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@ii0
ii0 / futures_test.py
Created December 16, 2016 02:31 — forked from lbolla/futures_test.py
Tornado and concurrent.futures
from concurrent.futures import ThreadPoolExecutor
from functools import partial, wraps
import time
import tornado.ioloop
import tornado.web
EXECUTOR = ThreadPoolExecutor(max_workers=4)
@ii0
ii0 / tmux.conf
Created March 29, 2017 06:04 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@ii0
ii0 / main.py
Created May 12, 2017 01:36 — forked from littlecodersh/main.py
Main script behind itchat robot
#coding=utf8
import itchat
# tuling plugin can be get here:
# https://github.com/littlecodersh/EasierLife/tree/master/Plugins/Tuling
from tuling import get_response
@itchat.msg_register('Text')
def text_reply(msg):
if u'作者' in msg['Text'] or u'主人' in msg['Text']:
return u'你可以在这里了解他:https://github.com/littlecodersh'