Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
)
func main() {
size := 3
list := make([]int, size)
for i := 0; i < size; i++ {
@yiting007
yiting007 / dateCompare.go
Created May 13, 2015 16:59
Convert a given string to date then see if it is before or after now
package main
import (
"fmt"
"time"
)
func main() {
layout := "01/02/2006, 03:04PM"
@yiting007
yiting007 / getServiceAccountClient.go
Created May 7, 2015 23:33
GAE get service account client
package gaeOauth
import (
"golang.org/x/net/context"
"golang.org/x/oauth2/google"
"golang.org/x/oauth2/jwt"
)
var scopes = []string{}
@yiting007
yiting007 / subset.js
Last active August 29, 2015 14:20
Get a random subset of the set
var pool = ["1", "2", "3", "4", "5"]
var getRandomSubsets = function (num) { // num: #of elements in the subset
if (num.length > pool) {
return null;
}
var subPool = {};
for (var i = 0; i < num; i++) {
var max = pool.length - 1;
var min = 0;
var pick = Math.floor(Math.random() * (max - min + 1)) + min;
@yiting007
yiting007 / shuffle.go
Created May 4, 2015 22:55
Shuffle an array in Golang
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
array := []int{1, 2, 3, 4, 5, 6, 7}