Skip to content

Instantly share code, notes, and snippets.

View timesking's full-sized avatar

Timesking timesking

  • Funplus
  • San Francisco
View GitHub Profile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@timesking
timesking / backup-mongodb-to-s3.sh
Created January 16, 2018 14:01 — forked from caraboides/backup-mongodb-to-s3.sh
Simple script to backup MongoDB to S3, without waste diskspace for temp files. And a way to restore from the latest snapshot.
#!/bin/sh
set -e
HOST=localhost
DB=test-entd-products
COL=asimproducts
S3PATH="s3://mongodb-backups-test1-entd/$DB/$COL/"
S3BACKUP=$S3PATH`date +"%Y%m%d_%H%M%S"`.dump.gz
S3LATEST=$S3PATH"latest".dump.gz
/usr/bin/aws s3 mb $S3PATH
@timesking
timesking / sendproxy.go
Last active September 6, 2015 07:19 — forked from aht/sendproxy.go
import "container/ring"
// Use a goroutine to receive values from `out` and store them
// in an auto-expanding buffer, so that sending to `out` never blocks.
// Return a channel which serves as a sending proxy to to `out`.
func sendproxy(out chan<- int) chan<- int {
in := make(chan int, 100)
go func() {
n := 1000 // the allocated length of the circular queue
first := ring.New(n)
phabricator_audit
phabricator_auth
phabricator_cache
phabricator_calendar
phabricator_chatlog
phabricator_conduit
phabricator_config
phabricator_conpherence
phabricator_countdown
phabricator_daemon
@timesking
timesking / MiniJSON.cs
Created December 7, 2012 13:23 — forked from darktable/MiniJSON.cs
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2012 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining
#!/bin/sh -
"exec" "python" "-O" "$0" "$@"
__doc__ = """Tiny HTTP Proxy.
This module implements GET, HEAD, POST, PUT and DELETE methods
on BaseHTTPServer, and behaves as an HTTP proxy. The CONNECT
method is also implemented experimentally, but has not been
tested yet.
@timesking
timesking / gist:1472374
Created December 13, 2011 14:47
用Python写一个本地Sogou代理服务器程序
'''
Hey guys!
This is a the first python program(except hello worlds) I have written.
With HTTPServer, I can easily write a webserver.
Python is such a powerful language that many complicated problems can be
solved by a few lines of code.
Welcome to visit my blog: www.xiaoxia.org
The proxy program is just coded for fun <img src="http://xiaoxia.org/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley">
'''
@timesking
timesking / gist:1472173
Created December 13, 2011 13:46
look for and parse miscellaneous GET POST
# Alexander Sherwin
# 08/14/2005 v1.2
#
# This class is designed to look for and parse miscellaneous <strong class="highlight">data</strong>
# that is not handled internally through <strong class="highlight">Python</strong> (i.e. <strong class="highlight">POST</strong>, GET.)
#
# Currently, upon instantiation of the class it automatically parses
# all <strong class="highlight">POST</strong>, GET and SERVER <strong class="highlight">data</strong> available to the script.
#
# Report any errors, bugs or contributions & additions
@timesking
timesking / miniproxy.py
Created December 12, 2011 15:16
Mini proxy work with Pyhony 2.7
import asyncore, asynchat
import httplib
import socket
import sys
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
from urlparse import urlsplit