Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@eaigner
eaigner / JSONConvertible.swift
Created April 9, 2016 15:13
Convert Objects to and from JSON
import Foundation
protocol JSONConvertible {
}
extension JSONConvertible {
func toJSON() -> [String: AnyObject] {
var json = [String: AnyObject]()
@eaigner
eaigner / lookup.go
Last active September 18, 2015 12:58
CNAME DNS Lookup for GAE
package dns
import (
"bytes"
"errors"
"math/rand"
"strings"
"time"
"golang.org/x/net/context"
@eaigner
eaigner / find.go
Last active January 6, 2016 19:03
// Package bench is a package which contains
// programs of Go Benchmark Competition.
package bench
import (
"syscall"
)
// Find reads the text file on the `path`,
// finds the `s` words on the file and
#!/bin/bash
# vet.bash
function check_dir() {
egrep -rn -e "$2" "$1"
if [[ $? != 1 ]] ; then
echo "$3"
exit $rc
fi
# Setting up dnsmasq for Local Web Development Testing on any Device
Please note, these instructions are for OS X Lion.
First, you need to get the IP address of your machine on your local network. In OS X, the easiest place to find this is in System Preferences > Network. If you're using DHCP on your local network, you will want to make sure your computer requests the same IP address when it renews it's IP address lease. I recommend configuring the DCHP Reservation settings on your router to accomplish this. Otherwise, you can specify a manual address in your network settings:
1. Go to *System Preferences > Network*
1. Click *Advanced...*
@eaigner
eaigner / coord.go
Created August 21, 2013 15:04
Coalesce DB writes using a coordinator
package coord
import (
"sync"
)
// FlushFunc takes all pending objects, writes them, and returns
// the results in the same order, or an error.
type FlushFunc func(v []interface{}) ([]interface{}, error)
@eaigner
eaigner / cloudant.go
Created August 20, 2013 14:39
Cloudant lucene query builder
package cloudant
import (
"bytes"
"reflect"
"strconv"
"strings"
)
const (
@eaigner
eaigner / tree.go
Created August 18, 2013 11:22
In-memory object tree size
package tree
import (
"reflect"
"unsafe"
)
// Cost calculates the memory size of an object tree.
func Cost(v interface{}) uint64 {
return cost(reflect.ValueOf(v))
@eaigner
eaigner / quota.go
Created August 18, 2013 10:27
Quota
package quota
import (
"errors"
"sync"
"time"
)
var QuotaExceededErr = errors.New("quota exceeded")
@eaigner
eaigner / gist:6204685
Last active December 20, 2015 22:19
GoDoc Bookmarklet
javascript:(window.location.href='http://godoc.org/'+window.location.hostname+window.location.pathname)