Skip to content

Instantly share code, notes, and snippets.

View owenthereal's full-sized avatar
🚀
Hacking

Owen Ou owenthereal

🚀
Hacking
View GitHub Profile
@owenthereal
owenthereal / main.go
Created January 23, 2021 04:45 — forked from walm/main.go
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)
@owenthereal
owenthereal / reader.go
Created November 1, 2019 20:41 — forked from jmackie/reader.go
Pass a single io.Reader to multiple goroutines
/*
Package fan is a little concurrent io experiment.
Example Use Case
----------------
You have a function that takes a single io.Reader as an argument. You would like
to pass that reader to several processing functions. You could just make the
function accept an io.ReadSeeker, invoke each function serially in a for loop,
seeking after each call. But that's not cool.
@owenthereal
owenthereal / atlanta.md
Created January 5, 2018 00:06 — forked from wfarr/atlanta.md
A list of things to do in Atlanta

Restaurants

Krog Street Market - Variety - $-$$$

Located in Inman Park, right on the Beltline, Krog Street Market offers a decent variety of food options, including Nashville-style hot chicken, dumplings, Tex-Mex, pizza, and more. Prices vary by restaurant.

Ponce City Market - Variety - $-$$$

In Midtown / Poncey Highlands area, right on the Beltline, Ponce City Market has a number of restaurant options available open for breakfast, lunch, and dinner. Formerly a city hall record storage facility, and before that a Sears warehouse, it's now a mixed-use development with restaurants, bars, shops, and housing.

@owenthereal
owenthereal / keybase.md
Last active October 5, 2017 17:15
keybase.md

Keybase proof

I hereby claim:

  • I am jingweno on github.
  • I am jingweno (https://keybase.io/jingweno) on keybase.
  • I have a public key whose fingerprint is 0086 0833 0662 DA39 1EB3 EC3F 2EA8 119A E4BF 9F74

To claim this, I am signing this object:

diff --git a/commands/init.go b/commands/init.go
index ef55871..d63de61 100644
--- a/commands/init.go
+++ b/commands/init.go
@@ -1,8 +1,6 @@
package commands
import (
- "path/filepath"
-
@owenthereal
owenthereal / grep_cellar
Last active August 29, 2015 14:00
grep_cellar
$ pwd
/opt/boxen/homebrew/Library/Formula
$ grep -ri "Cellar" *
argp-standalone.rb: cellar :any
aria2.rb: cellar :any
asciidoc.rb: cellar :any
at-spi2-atk.rb: cellar :any
autojump.rb: . /usr/local/Cellar/gautojump/HEAD/etc/autojump.fish
bagit.rb: # put logs in var, not in the Cellar
require 'pusher-client'
socket = PusherClient::Socket.new('5df8ac576dcccf4fd076')
socket.subscribe('common')
handler = lambda do |event, data|
p [event, data]
end
events = ['job:created', 'job:started', 'job:finished', 'job:canceled',
@owenthereal
owenthereal / multiple_connection_pools.rb
Last active December 23, 2015 08:58
Quickly get it to work
config1 = { :database => "db1", :host => "localhost", :port => 15432 }
spec1 = ActiveRecord::Base::ConnectionSpecification.new(config1, "postgresql_connection")
handler1 = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
handler1.establish_connection("db1", spec1)
handler1.connection_pools.values.first.with_connection { ... }
config2 = { :database => "db2", :host => "localhost", :port => 15432 }
spec2 = ActiveRecord::Base::ConnectionSpecification.new(config2, "postgresql_connection")
handler2 = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
handler2.establish_connection("db2", spec2)
@owenthereal
owenthereal / msgpack_perf.rb
Last active December 16, 2015 15:29
Benchmark of serialization with msgpack (https://github.com/msgpack/msgpack-ruby) vesus Oj (the fatest JSON library https://github.com/ohler55/oj)
require 'benchmark'
h = { 'one' => 1, 'array' => [ true, false ] }
n = 50000
require 'oj'
Benchmark.bmbm do |x|
x.report('Oj.dump') { n.times { Oj.dump(h) } }
end