Instantly share code, notes, and snippets.

View user_test.go
func TestUserFail(t *testing.T) {
func() {
defer func() {
if r := recover(); r == nil {
t.Errorf("TestUserFail should have panicked!")
}
}()
// This function should cause a panic
CreateUser(12, "hello")
View pre-commit
#!/bin/sh
#
# Note this is mostly the standard git pre-commit.sample which can be found
# in your repo's .git/hooks/ directory with golang fmt added at the bottom.
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
View GolangJSONCustomMarshal.go
/*
In a fairly typical webapp data model you often want to send
the client different "views" of the data model.
Many database and caching tools require the base model to be quite
standard with json tags and types, so the following approach is
ideal:
Based on this blog post and SO question:
View xorm_jsonb_struct_field_issue.go
package main
import (
"fmt"
"github.com/go-xorm/xorm"
_ "github.com/lib/pq"
"math/rand"
"time"
)
View python_multiprocessing_pool_with_queues.py
from multiprocessing.pool import ThreadPool as Pool
from multiprocessing import Queue as PQueue
import Queue
my_dict = {
'url1': 'url2',
'url3': 'url4',
}
my_q = PQueue()
View bash_profile
#!/bin/bash
# --------------------------------------------------------------------------- #
# These are git settings from:
# http://neverstopbuilding.net/gitpro/
# --------------------------------------------------------------------------- #
#source ~/.git-completion.bash
#source ~/.git-prompt.sh
#
# Settings for python virtual envs and the python virtualenvwrapper
View cheatsheet.go
/* This document is for quick ref while learning golang */
// Allocating Slices
// Using slice literals
// Make a slice of strings
strs := []string{"aaa", "bbb", "ccc", "ddd"}
// Bytes
key := []byte("5e8487e6")
// Declaring a var my_slice for later makeage
View boom_auth_node.js
/*
Filename: boom_auth_node.js
An example of creating your signedHash for use with Boom! Payments
First make sure to download blowfish.js from:
http://sladex.org/blowfish.js/ext/blowfish.js
This example assumes you are using node.js to create the signed access token
View sharded_guid.py
#!/usr/bin/env python
# Written by Warren Runk
# This file is free software in the public domain.
import base64
import random
import uuid
View guid_python.py
#!/usr/bin/env python
# Written by Warren Runk
# This file is free software in the public domain.
import base64
import uuid