Skip to content

Instantly share code, notes, and snippets.

/*
Write a golang struct called "watchUpdator". The struct creates a etcd connection, looping watch a given key, with timeout. if the key changes or timeouts, call corresponded callback
Here's an example of a Go struct called "watchUpdator" that creates an etcd connection, loops to watch a given key, and calls a corresponding callback function if the key changes or times out:
*/
package main
linuxkit-525400929b77 [~]$ df | grep vda
linuxkit-525400929b77 [~]$ sudo fdisk /dev/vda
Welcome to fdisk (util-linux 2.33).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Selected partition 1
#!/usr/bin/env python
# coding=utf-8
puzzle = [
[8, 1, None, None, None, None, None, None, None],
[None, None, 3, 6, None, None, None, None, None],
[None, 7, None, None, 9, None, 2, None, None],
[None, 5, None, None, None, 7, None, None, None],
[None, None, None, None, 4, 5, 7, None, None],
[None, None, None, 1, None, None, None, 3, None],
menghan@ppfili:~/codespace/moviepp (git::master) $ curl -v 'http://localhost:5000//api/v1/cinemas?Authorization=1&q=%E5%8C%97%E4%BA%AC'
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 5000 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 5000 (#0)
> GET //api/v1/cinemas?Authorization=1&q=%E5%8C%97%E4%BA%AC HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:5000
> Accept: */*
menghan@air:~$ brew doctor
Your system is ready to brew.
menghan@air:~$ brew uninstall python
Uninstalling /usr/local/Cellar/python/2.7.8_2...
menghan@air:~$ brew uninstall mercurial
Uninstalling /usr/local/Cellar/mercurial/3.1.2...
menghan@air:~$ proxy
HTTP/1.1 301 Moved Permanently
Date: Thu, 30 Oct 2014 04:20:41 GMT
Server: gwiseguy/2.0
# -*- coding: utf-8 -*-
import os
import sys
from flask.ext.script import Command, Option
class GunicornServer(Command):
"""Run the app within Gunicorn"""
@menghan
menghan / redirect.sh
Created September 12, 2014 08:46
let the second cat get stdin
#!/usr/bin/env bash
exec 4</dev/null
exec 5<&0
exec 0<&4
echo cat1
cat
echo cat2
cat <&5
menghan@MenghanMac:~$ cat /tmp/diffs
--- httpclient.py 2013-11-15 11:21:29.000000000 +0800
+++ httpclient.pyc_dis 2014-07-04 13:30:27.000000000 +0800
@@ -1,3 +1,4 @@
+#Embedded file name: /Users/menghan/.virtualenvs/common/lib/python2.7/site-packages/tornado/httpclient.py
"""Blocking and non-blocking HTTP client interfaces.
This module defines a common interface shared by two implementations,
@@ -26,20 +27,16 @@
you use a recent version of ``libcurl`` and ``pycurl``. Currently the minimum
@menghan
menghan / post.py
Created May 5, 2014 01:24
debug airvideo in docker
#!/usr/bin/env python
# coding=utf-8
import requests
r = requests.post('http://127.0.0.1:45631/service', data=open('y').read())
print r.text.encode('utf8')
@menghan
menghan / usecpu.go
Created April 17, 2014 15:21
consume cpu at specified percent
package main
import (
"flag"
"log"
"runtime"
"strconv"
"time"
)