Skip to content

Instantly share code, notes, and snippets.

View ericychoi's full-sized avatar

Eric Choi ericychoi

  • SendGrid
  • Anaheim, CA
View GitHub Profile
@ericychoi
ericychoi / Async.pm
Last active May 30, 2017 19:59
An attempt to implement Async waterfall in AnyEvent perl
package Async;
use warnings;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter);
@EXPORT_OK = qw(waterfall);
# waterfall: executes mutliple subroutines in series, passing result from previous run to the next.
@ericychoi
ericychoi / private.xml
Created April 5, 2017 15:53
Karabiner-private.xml for mapping mouse forward/back buttons to next/prev space
<?xml version="1.0"?>
<root>
<item>
<identifier>private.button_4_next_space</identifier>
<name>Mouse buttons to move spaces</name>
<appendix>Mouse button 4 to next space</appendix>
<autogen>
__KeyToKey__
PointingButton::BUTTON4,
KeyCode::CURSOR_RIGHT, ModifierFlag::COMMAND_L | ModifierFlag::CONTROL_L
@ericychoi
ericychoi / benchmark_keys.pl
Created February 23, 2017 19:33
Perl Benchmark on Keys (with a wrapper function)
#!/opt/perl/bin/perl
use strict;
use warnings;
use Benchmark;
# Perl version 5.010001
# Rate 10^4 keys 10^3 keys 10^5 keys 10^1 keys 10^2 keys
# 10^4 keys 2429401/s -- -0% -1% -2% -2%
@ericychoi
ericychoi / benchmark_keys.pl
Created February 23, 2017 19:01
Perl Benchmark Keys on Hash
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark;
print "Perl version $]\n";
my %subs;
@ericychoi
ericychoi / tcp-proxy.sh
Last active November 26, 2021 13:15
A quick tcp proxy bash script using nc (not my original)
#!/bin/sh -e
# usage: ./tcp-proxy.sh 8080 tweakers.net 80
# script written by
# https://notes.tweakblogs.net/blog/7955/using-netcat-to-build-a-simple-tcp-proxy-in-linux.html
if [ $# != 3 ]
then
echo "usage: $0 <src-port> <dst-host> <dst-port>"
exit 0
@ericychoi
ericychoi / perl-bin-script-template.pl
Last active February 19, 2017 05:10
Perl bin script template
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
use Term::ANSIColor;
# usage:
#
@ericychoi
ericychoi / httpsink.js
Created November 9, 2016 20:40
A simple http sink in node.js
var http = require('http');
var jsonResp = {
"type": "free"
};
var jsonRespPaid = {
"type": "Paid"
}
var port = process.argv[2];
@ericychoi
ericychoi / goget.sh
Created November 4, 2016 17:36
Go Get using Git Clone
# use git clone to clone the go repo to the right location in your gopath
function goget() {
# github.com/foo/bar
GIT_PATH="$@"
# git@github.com:foo/bar.git
GIT_CLONE_PATH=`echo "$GIT_PATH" | perl -lape 's!(.+?)/!git\@$1:!'`
mkdir -p "$GOPATH/src/$GIT_PATH" && git clone "$GIT_CLONE_PATH" "$GOPATH/src/$GIT_PATH"
}
@ericychoi
ericychoi / max_units.go
Created July 13, 2016 21:57
Go: Max Numbers
package main
import "fmt"
const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1
func main() {
curl -s -X GET "apidendpointp1mdw1.sendgrid.net:8082/api/swimlane/user/delete.json?userid=1886158"
curl -s -X GET "apidendpointp1mdw1.sendgrid.net:8082/api/swimlane/user/delete.json?userid=1886162"
curl -s -X GET "apidendpointp1mdw1.sendgrid.net:8082/api/swimlane/user/delete.json?userid=1886163"
curl -s -X GET "apidendpointp1mdw1.sendgrid.net:8082/api/swimlane/user/delete.json?userid=1886179"
curl -s -X GET "apidendpointp1mdw1.sendgrid.net:8082/api/swimlane/user/delete.json?userid=1886184"
curl -s -X GET "apidendpointp1mdw1.sendgrid.net:8082/api/swimlane/user/delete.json?userid=1886205"
curl -s -X GET "apidendpointp1mdw1.sendgrid.net:8082/api/swimlane/user/delete.json?userid=1886207"
curl -s -X GET "apidendpointp1mdw1.sendgrid.net:8082/api/swimlane/user/delete.json?userid=1886208"
curl -s -X GET "apidendpointp1mdw1.sendgrid.net:8082/api/swimlane/user/delete.json?userid=1886209"
curl -s -X GET "apidendpointp1mdw1.sendgrid.net:8082/api/swimlane/user/delete.json?userid=1886211"