Skip to content

Instantly share code, notes, and snippets.

View timesking's full-sized avatar

Timesking timesking

  • Funplus
  • San Francisco
View GitHub Profile
@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)
@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