Skip to content

Instantly share code, notes, and snippets.

View tclh123's full-sized avatar
💭
Be an artist

Harry Lee tclh123

💭
Be an artist
View GitHub Profile
@tclh123
tclh123 / statsd_client.py
Last active December 11, 2015 02:52
from statsd examples
# Steve Ivy <[email protected]>
# http://monkinetic.com
from random import random
from socket import socket, AF_INET, SOCK_DGRAM
class StatsdClient(object):
SC_TIMING = "ms"
SC_COUNT = "c"
SC_GAUGE = "g"
@4000000056d9342114814674 192.168.20.138:55734 - - [04/Mar/2016 15:07:03] "HTTP/1.1 GET /command/uptime" - 200 OK
@4000000056d9342d008673ec 192.168.20.139:39386 - - [04/Mar/2016 15:07:15] "HTTP/1.1 GET /command/check_daemontools_service" - 200 OK
@4000000056d9340739036bbc 192.168.32.14:36057 - - [04/Mar/2016 15:06:37] "HTTP/1.1 GET /command/uptime" - 200 OK
@4000000056d93420084e6184 192.168.32.28:57917 - - [04/Mar/2016 15:07:02] "HTTP/1.1 GET /command/uptime" - 200 OK
@4000000056d934980b43acb4 192.168.32.28:57937 - - [04/Mar/2016 15:09:02] "HTTP/1.1 GET /command/uptime" - 200 OK
@4000000056d934991465179c 192.168.20.138:57595 - - [04/Mar/2016 15:09:03] "HTTP/1.1 GET /command/uptime" - 200 OK
@4000000056d934321ee92b7c 192.168.32.14:37492 - - [04/Mar/2016 15:07:20] "HTTP/1.1 GET /command/check_ps" - 200 OK
@4000000056d934bd189cc224 192.168.32.14:42102 - - [04/Mar/2016 15:09:39] "HTTP/1.1 GET /command/uptime" - 200 OK
@4000000056d9345b2949446c 192.168.32.28:57927 - - [04/Mar/2016 15:08:01] "HTTP/1.1 GET /command/
# coding=utf-8
"""
LICENSE http://www.apache.org/licenses/LICENSE-2.0
"""
import datetime
import sys
import time
import threading
import traceback
@tclh123
tclh123 / raven-shell
Created July 21, 2016 10:04 — forked from barroco/raven-shell
Send Sentry error from shell using curl
#!/bin/sh
SENTRY_KEY=
SENTRY_SECRET=
SENTRY_PROJECTID=1
SENTRY_HOST=sentry.example.com
SCRIPT_ARGUMENTS=$@
capture_error()
{
@tclh123
tclh123 / unicorn.py
Created August 9, 2016 08:13
Simple preforking echo server in Python
"""
Simple preforking echo server in Python.
Python port of http://tomayko.com/writings/unicorn-is-unix.
"""
import os
import sys
import socket
@tclh123
tclh123 / reflect.py
Created August 9, 2016 08:17 — forked from huyng/reflect.py
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@tclh123
tclh123 / http_streaming.md
Created August 25, 2016 10:03 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

# setting up irq affinity according to /proc/interrupts
# 2008-11-25 Robert Olsson
# 2009-02-19 updated by Jesse Brandeburg
#
# > Dave Miller:
# (To get consistent naming in /proc/interrups)
# I would suggest that people use something like:
# char buf[IFNAMSIZ+6];
#
# sprintf(buf, "%s-%s-%d",

KVM OSX Guest 10.11 (El Capitan) with Clover

  • Some notes about this approach:
    • An OSX Installer USB drive for Install OS X El Capitan is created
    • Clover is then installed on the USB drive
    • Clover Configurator is then run on the USB drive
    • The USB drive contents are copied to the VM host
    • VNC is used to connect to the guest UI
  • The qxl virtual video device is used (part of the standard kvm qemu install)
@tclh123
tclh123 / cryptography_3des_demo.py
Created December 14, 2016 07:53 — forked from mrluanma/cryptography_3des_demo.py
Python 用 PyCrypto, M2Crypto, ncrypt, cryptography 3DES ECB mode 加密解密 demo。
import os
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.backends import default_backend
backend = default_backend()
key = os.urandom(16)
text = b'Hello, there!'
padder = padding.PKCS7(algorithms.TripleDES.block_size).padder()