start new:
tmux
start new with session name:
tmux new -s myname
CREATE OR REPLACE FUNCTION generate_object_id() RETURNS varchar AS $$ | |
DECLARE | |
time_component bigint; | |
machine_id int := FLOOR(random() * 16777215); | |
process_id int; | |
seq_id bigint := FLOOR(random() * 16777215); | |
result varchar:= ''; | |
BEGIN | |
SELECT FLOOR(EXTRACT(EPOCH FROM clock_timestamp())) INTO time_component; | |
SELECT pg_backend_pid() INTO process_id; |
# post_loc.txt contains the json you want to post | |
# -p means to POST it | |
# -H adds an Auth header (could be Basic or Token) | |
# -T sets the Content-Type | |
# -c is concurrent clients | |
# -n is the number of requests to run in the test | |
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/ |
# First install tmux | |
brew install tmux | |
# For mouse support (for switching panes and windows) | |
# Only needed if you are using Terminal.app (iTerm has mouse support) | |
Install http://www.culater.net/software/SIMBL/SIMBL.php | |
Then install https://bitheap.org/mouseterm/ | |
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/ |
package main | |
/* | |
URL: https://github.com/mccoyst/myip/blob/master/myip.go | |
URL: http://changsijay.com/2013/07/28/golang-get-ip-address/ | |
*/ | |
import ( | |
"net" | |
"os" |
mgo.SetDebug(true) | |
var aLogger *log.Logger | |
aLogger = log.New(os.Stderr, "", log.LstdFlags) | |
mgo.SetLogger(aLogger) |
To use, place the code in version_trick.go
in your project. Don't forget to change the namespace to match yours to the actual name of your package.
In addition to version_trick.go
, there's a makefile-snippet, that includes the secret sauce for making this trick
work. Be sure to change the package name there as well.
Enjoy!
P.S. Special thanks to @meatballhat by way of @syscomet for showing me this trick!
/* | |
This is an example of a golang gzip writer program, | |
which appends data to a file. | |
*/ | |
package main |
all: json2bson | |
clean: | |
rm -f json2bson | |
json2bson: json2bson.c | |
${CC} $(shell pkg-config --cflags json libmongo-client glib-2.0) -Wall -O0 -ggdb3 -std=c99 ${CFLAGS} \ | |
$(shell pkg-config --libs json libmongo-client glib-2.0) -o $@ $^ | |
check: all | |
./json2bson <test.json >test.bson |
# Hello, and welcome to makefile basics. | |
# | |
# You will learn why `make` is so great, and why, despite its "weird" syntax, | |
# it is actually a highly expressive, efficient, and powerful way to build | |
# programs. | |
# | |
# Once you're done here, go to | |
# http://www.gnu.org/software/make/manual/make.html | |
# to learn SOOOO much more. |