Skip to content

Instantly share code, notes, and snippets.


Larry Zhao larryzhao

Block or report user

Report or block larryzhao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View surge.conf
skip-proxy =,,,,, localhost, *.local, ::ffff:0:0:0:0/1, ::ffff:128:0:0:0/1
bypass-tun =,,
# dns-server =,,
loglevel = notify
BJ-All = custom
BJ-HK-Azure = custom
BJ-US-Azure = custom
vsouza / .bashrc
Last active Feb 22, 2020
Golang setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell, fish or bash.
View .bashrc
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
itamarhaber / 00_copy_key.lua
Last active Jan 29, 2020
The fastest, type-agnostic way to copy a Redis key, as discussed in
View 00_copy_key.lua
-- @desc: The fastest, type-agnostic way to copy a Redis key
-- @usage: redis-cli --eval copy_key.lua <source> <dest> , [NX]
local s = KEYS[1]
local d = KEYS[2]
if"EXISTS", d) == 1 then
if type(ARGV[1]) == "string" and ARGV[1]:upper() == "NX" then
return nil
schneems / gist:c07d93d5a4ade679bbc3
Last active May 15, 2018
Puma Backlog Setting on Heroku
View gist:c07d93d5a4ade679bbc3

Why not set backlog on Heroku?

First read this:

Now we're on the same page. Heroku will re-route bounced requests from your dynos but it assumes when this happens that your entire app is saturated. Each connection gets delayed by 5 seconds, so you're automatically being docked 5 seconds per request.

If you're setting your backlog to a low value (i.e. if you'll ever actually ever hit backlog) then you'll be in for pain. When you get a spike of requests from slashdot/reddit/whatever you're telling your dynos that you would rather they failed then returned slow responses. So this does mean that some requests will be served, but all the others will fail.

If your app ever hits your backlog (no matter what value it is) it is an indicator you don't have enough throughput and you need to scale out to more dynos. If you set this to an arbitrarilly low value, that point comes

krasnoukhov /
Last active Feb 25, 2020
Profiling memory leaky Sidekiq applications with Ruby 2.1

My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.

As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.

I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.

So, in order to profile your worker, add this to your Sidekiq configuration:

elwinar / snake.go
Created Nov 18, 2014
ToSnake function for golang, convention-compliant
View snake.go
package main
import (
// ToSnake convert the given string to snake case following the Golang format:
// acronyms are converted to lower-case and preceded by an underscore.
func ToSnake(in string) string {
runes := []rune(in)
StefanWallin /
Last active Nov 21, 2019 — forked from konklone/ssl.rules
nginx ssl config with multiple SNI vhosts and A+ SSL Labs score as of 2014-11-05

Configuring nginx for SSL SNI vhosts



  • My version of konklones SSL config does not have SPDY support(my nginx+openssl does not support it)
  • You need a default ssl server (
  • Some SSL-options have to be unique across your instance, so it's easier to have them in a common file(ssl.conf).
View PreventGhostClick.js
* Prevent click events after a touchend.
* Inspired/copy-paste from this article of Google by Ryan Fioravanti
* Prevent the click event for an certain element
* ````
* PreventGhostClick(myElement);
View gist:d1c15f3968f4f8272c49
- What do Etcd, Consul, and Zookeeper do?
- Service Registration:
- Host, port number, and sometimes authentication credentials, protocols, versions
numbers, and/or environment details.
- Service Discovery:
- Ability for client application to query the central registry to learn of service location.
- Consistent and durable general-purpose K/V store across distributed system.
- Some solutions support this better than others.
- Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
- Centralized locking can be based on this K/V store.
You can’t perform that action at this time.