Skip to content

Instantly share code, notes, and snippets.

View aybabtme's full-sized avatar
👶
I may be slow to respond. Newborn in the house.

Antoine Grondin aybabtme

👶
I may be slow to respond. Newborn in the house.
View GitHub Profile
@aybabtme
aybabtme / clever.sh
Created April 18, 2014 20:38
> To apply, email us at jobs+n@getclever.com, where n is the number of students in the Clever sandbox API data set with a last name that begins with the letter 'V'. Send us one or more things from [resume, github profile, recent side projects, linkedin URL, Stack Overflow profile, etc], and let us know how you solved our 'puzzle.'
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"
#!/bin/sh
set -e
PROJECTROOT=$GOPATH/src/github.com/<you>/<repo>
cd $PROJECTROOT
echo "Vetting project."
go vet || exit 1
echo "...ok"
package main
import (
"log"
"time"
)
func main() {
nobodyListening := make(chan struct{})
package main
import (
"log"
"time"
)
func main() {
nobodyListening := make(chan struct{})
{
// 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:
@aybabtme
aybabtme / wishful_thinking.go
Created January 11, 2014 15:38
wishful_thinking.go
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",
# 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
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()
#!/usr/bin/env Rscript
# install.packages(gregmisc)
require("gregmisc")
allPerm <- permutations(n = 5, r = 2, v = 0:4, repeats.allowed=TRUE)
allXY <- data.frame(allPerm)
colnames(allXY) <- c("X", "Y")
f_XY <- function(x, y) {
@aybabtme
aybabtme / ring_election.go
Created November 23, 2013 22:52
Attempt at describing the ring election algorithm described in assignment 4 of CSI3505...
package main
type Phase int
var (
// Track how many phases necessary
phase = Phase(0)
)
// States