This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example usage: | |
// Triggers an io.ErrUnexpectedEOF on the last read | |
func TestCanDiffWhenOldlistIsCorrupted(t *testing.T) { | |
log.SetOutput(testwriter(t)) // log to testing.Log | |
oldKeys := []s3.Key{{ETag: "1"}, {ETag: "3"}} | |
newKeys := []s3.Key{{ETag: "1"}, {ETag: "2"}, {ETag: "3"}} | |
want := []s3.Key{{ETag: "2"}} | |
oldList := encodeKeys(oldKeys) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// accumulates non-nil errors | |
type errors []error | |
func (e *errors) Ack(err error) { | |
if err != nil { | |
*e = append(*e, err) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pagecount=$(curl -s -H 'Authorization: Bearer DEMO_TOKEN' -X GET https://api.clever.com/v1.1/students | jq '.paging.total') | |
echo "$pagecount pages" | |
now=$(date "+%Y-%m-%d-%H:%M.%S") | |
tmpfile=".$now-tmp_clever.json" | |
touch $tmpfile | |
echo "Saving pages to $tmpfile" | |
for i in $(seq 1 $pagecount); do | |
echo "Getting page $i" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
PROJECTROOT=$GOPATH/src/github.com/<you>/<repo> | |
cd $PROJECTROOT | |
echo "Vetting project." | |
go vet || exit 1 | |
echo "...ok" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"time" | |
) | |
func main() { | |
nobodyListening := make(chan struct{}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"time" | |
) | |
func main() { | |
nobodyListening := make(chan struct{}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// you may set specific environment variables here | |
// e.g "env": { "PATH": "$HOME/go/bin:$PATH" } | |
// in values, $PATH and ${PATH} are replaced with | |
// the corresponding environment(PATH) variable, if it exists. | |
"env": { | |
"GOPATH": "$HOME/gocode" | |
}, | |
// Your shell. e.g. on Linux and OS X, if your shell bash: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func DreamWayOfDoingIt() { | |
clientPool := NewAWSPool(awsCredentials, aws.T1Micro, aws.USEast, 30) | |
serverPool := NewAWSPool(awsCredentials, aws.T1Micro, aws.China, 30) | |
Join(clientPool, serverPool).RunNow(func(h Host) []string { | |
return []string{ | |
"sudo apt-get update", | |
"sudo apt-get upgrade -y", | |
"sudo apt-get install -y mercurial git bzr gcc", | |
"hg clone -u release https://code.google.com/p/go", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Clear the cookies | |
$ rm cookies.txt | |
# Create a user | |
$ curl -v -b cookies.txt -c cookies.txt -X POST 127.0.0.1:8080/api/v0.1/employees -d '{"employeeId":666, "password":"hello"}' | |
HTTP/1.1 201 Created | |
# Try querying without auth | |
$ curl -v -b cookies.txt -c cookies.txt -X GET 127.0.0.1:8080/api/v0.1/employees | |
HTTP/1.1 401 Unauthorized |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var schedule = function(taskArr) { | |
// 1st step: sort data by gain (from max to min) | |
var sortedByGain = insertionSort(taskList, "gain"); | |
var n = sortedByGain.length; | |
var timeSlot = new Array(); | |
// 2nd step: number the jobs 1,2,3,..,n, then | |
for (var i = 0; i < n; i++) { | |
var task = sortedByGain.pop() |