This file contains 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
if (process.argv.length !== 4) { | |
console.log("Usage:", process.argv[1], "b start") | |
return; | |
} | |
var b = parseInt(process.argv[2]), | |
start = parseInt(process.argv[3]); | |
if (isNaN(b) || isNaN(start)) { | |
console.log("need numbers"); |
This file contains 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 _ = { | |
objectify: function (arr) { | |
var o = {}, | |
vals = arguments['0']; | |
for (var i = 1; i < arguments.length; ++i) { | |
if (i > vals.length) break; | |
o[arguments[i.toString()]] = vals[i - 1]; | |
} | |
return o; | |
}, |
This file contains 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 _ = {}; | |
_.throttle = function (func, wait, options) { | |
var initial; | |
return function () { | |
if (!initial || new Date() - initial >= wait) { | |
initial = new Date(); | |
func.apply(this, arguments); | |
} |
This file contains 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
// Sample code used for blog post on parsing XML with Go | |
// https://larry-price.com | |
// | |
// Go Playground: https://play.golang.org/p/qiSoxxb5tp | |
package main | |
import ( | |
"encoding/xml" | |
"fmt" |
This file contains 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 "golang.org/x/tour/tree" | |
import "fmt" | |
func walk(t *tree.Tree, ch chan int) { | |
if t == nil { | |
return | |
} | |
walk(t.Left, ch) |
This file contains 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 ( | |
"fmt" | |
) | |
type Fetcher interface { | |
// Fetch returns the body of URL and | |
// a slice of URLs found on that page. | |
Fetch(url string) (body string, urls []string, err error) |
This file contains 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 ( | |
"bufio" | |
"fmt" | |
"math" | |
"math/rand" | |
"os" | |
"strconv" | |
"strings" |
This file contains 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 ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
type Philosopher struct { | |
Name string |
This file contains 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 ( | |
"fmt" | |
"time" | |
) | |
type Philosopher struct { | |
Name string | |
} |
This file contains 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
#!/usr/bin/env python3 | |
import lxc | |
import time | |
import os | |
CONTAINER_NAME='xenial' | |
CONTAINER_PATH='%s/.cache/libertine-container' % os.environ["HOME"] | |
def lxc_work(): |