Skip to content

Instantly share code, notes, and snippets.

@chsjiang
chsjiang / gist:3179122
Created July 25, 2012 22:33 — forked from saetia/gist:1623487
Clean Install – Mountain Lion OS X 10.8 DP3 Update 4
@chsjiang
chsjiang / pg_to_es.py
Created May 13, 2017 02:23
Postgres to Elasticsearch conversor script. It will assumes: - Database is equivalent as an index - Tables are equivalent as a mapping types You must pass a query for retreive data.
#!/usr/bin/python
import psycopg2
import psycopg2.extras
from pyes import *
import argparse
import traceback
import math
def ResultIter(cursor, arraysize=100):
# An iterator that uses fetchmany to keep memory usage down
@chsjiang
chsjiang / tmux-cheatsheet.markdown
Created May 14, 2017 04:52 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
var (
MaxWorker = os.Getenv("MAX_WORKERS")
MaxQueue = os.Getenv("MAX_QUEUE")
)
// Job represents the job to be run
type Job struct {
Payload Payload
}
type Dispatcher struct {
// A pool of workers channels that are registered with the dispatcher
WorkerPool chan chan Job
}
func NewDispatcher(maxWorkers int) *Dispatcher {
pool := make(chan chan Job, maxWorkers)
return &Dispatcher{WorkerPool: pool}
}
func payloadHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
// Read the body into a string for json decoding
var content = &PayloadCollection{}
err := json.NewDecoder(io.LimitReader(r.Body, MaxLength)).Decode(&content)
type PayloadCollection struct {
WindowsVersion string `json:"version"`
Token string `json:"token"`
Payloads []Payload `json:"data"`
}
type Payload struct {
// [redacted]
}
@chsjiang
chsjiang / tmux.cheat
Created January 23, 2018 19:35 — forked from afair/tmux.cheat
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &
@chsjiang
chsjiang / README.md
Created March 2, 2018 06:09 — forked from oodavid/README.md
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

@chsjiang
chsjiang / reinvent-2018-session-videos.md
Created December 27, 2018 21:16 — forked from LukasMusebrink/reinvent-2018-session-videos.md
Links to YouTube videos of AWS re:Invent 2018 sessions

The current list contains 438 sessions. The list will be updated regularly, at least once a day during reinvent. Last update: 2018-12-02 06:58 +00:00

Title Description Video
[NEW LANUCH!] Building modern apps using Amazon DynamoDB transactions (DAT374) DynamoDB transactions enables developers to maintain correctness of their data at scale by adding atomicity and isolation guarantees for multi-item conditional ... IMAGE ALT TEXT{:target="_blank"}
[NEW LAUNCH!] AWS License Manager Deep Dive (CMP393) AWS License Manager is a new service that makes it easy to bring your existing licenses to the AWS cloud and reduce licensing costs. This service offers a ... [IMAGE ALT TEXT](http://www.youtube.com/watch?v=r7pdaM3OAAQ "AWS re:Invent 2018: [NEW LA