Skip to content

Instantly share code, notes, and snippets.

Brandon Gao reterVision

View GitHub Profile
View verify
Verifying that "retervision.id" is my Blockstack ID. https://onename.com/retervision
@reterVision
reterVision / atomic_test.go
Created May 16, 2015
Benchmark Testing: RWMutex vs sync/atomic
View atomic_test.go
package main
import (
"sync"
"sync/atomic"
"testing"
)
func Benchmark_Lock(b *testing.B) {
var lock sync.RWMutex
@reterVision
reterVision / AppDelegate.swift
Last active Mar 19, 2016
Facebook Login with SDK4.0 and Swift
View AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
@reterVision
reterVision / notes.md
Last active Feb 4, 2019
Linux Performance Tuning
View notes.md

1.1 Linux process management

  • process scheduling
  • interrupt handling
  • signaling
  • process prioritization
  • process switching
  • process state
  • process memory
@reterVision
reterVision / client.go
Last active Feb 26, 2018
Passing file with gob.
View client.go
package main
import (
"bufio"
"encoding/gob"
"log"
"net"
"os"
)
@reterVision
reterVision / udp_client.go
Created Jul 12, 2014
A dummy UDP hole punching sample in Go
View udp_client.go
package main
import (
"encoding/json"
"fmt"
"log"
"net"
"os"
"time"
)
@reterVision
reterVision / insert_pg.go
Created Jul 5, 2014
A trivial program that uses goroutine to insert records into Postgres.
View insert_pg.go
/*
Original idea from
http://www.acloudtree.com/how-to-shove-data-into-postgres-using-goroutinesgophers-and-golang/
*/
package main
import (
"log"
"time"
"os"
View postgres_slave_promote.md

This example is based on having a cascading setup, where you have a single master, a single "primary" slave, and cascading slaves which are being replicated from the primary slave. For an example of this setup, check out http://bartek.im/blog/2012/12/04/postgresql-92-streaming-primer.html

On the existing master, if accessible, stop postgres.

$ sudo service postgresql stop

And better to be safe than sorry. We can't have two masters running. (I only use this in an automated script. If you're doing this manually, you'd know if it was shutoff)

$ kill -9 `sudo cat /var/lib/postgresql/9.2/main/postmaster.pid | head -n 1` &> /dev/null
View nginx-openresty-ubuntu-build-dependencies.sh
# Build dependencies for OpenResty.
sudo apt-get install build-essential libpcre3-dev libssl-dev libgeoip-dev
# Install standard Nginx first so that you get the relevant service scripts installed too
sudo apt-get install nginx
# If you want to access Postgres via Nginx
sudo apt-get install libpq-dev
@reterVision
reterVision / lcs.go
Created Jun 20, 2014
Longest Common Strings in Go
View lcs.go
package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
)
You can’t perform that action at this time.