-
查看版本
# 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
package main | |
import ( | |
"log" | |
"net/http" | |
) | |
func redirect(w http.ResponseWriter, r *http.Request) { | |
http.Redirect(w, r, "http://www.google.com", 301) |
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'}; |
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', |
# 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 |
查看版本
# 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
package main | |
import ( | |
"net" | |
"os" | |
) | |
func main() { | |
strEcho := "Halo" | |
servAddr := "localhost:6666" | |
tcpAddr, err := net.ResolveTCPAddr("tcp", servAddr) |
package main | |
import ( | |
"fmt" | |
"http" | |
"io/ioutil" | |
"os" | |
) | |
func main() { |
package main | |
import ( | |
"fmt" | |
"net/http" | |
"time" | |
) | |
var urls = []string{ | |
"http://pulsoconf.co/", |
<? | |
require("redis.php"); | |
require("json.php"); | |
$term = $_GET['term']; | |
$r = new Redis("127.0.0.1","6379"); | |
$r->connect(); | |
$items = $r->zrangebylex("kernel","[$term","[$term\xff",Array("LIMIT","0","10")); |
import redis | |
import threading | |
class Listener(threading.Thread): | |
def __init__(self, r, channels): | |
threading.Thread.__init__(self) | |
self.redis = r | |
self.pubsub = self.redis.pubsub() | |
self.pubsub.subscribe(channels) | |