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
just a couple of hints as you are learning the language | |
I do very little with apply. If necessary to process a matrix in row form, as this seems to be doing, I would define a function that did the row transformation, then apply it once. | |
sort takes the very useful additional parameter index=T, which will return the sorted order, obviating the need to do separate ranking. | |
For really sophisticated searching of sorted things, there is findInterval, which does binary search. It took me a while to find it in R. But it's incredibly nice. Here's an example of using sort (with i=T), and findInterval together. | |
# si.sample() : | |
# put a arbitrarily sampled sequence of events into a regularly sampled line, |
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
// how can we do a tree in Rust, where each node | |
// tells its children to update, and in turn, the | |
// child may update the parent? | |
// | |
// The following example illustrates the technique. Notice how we | |
// can't let the children have full backpointers to | |
// parent nodes, and instead have to have them point | |
// back to parent.data. Otherwise the two paths | |
// (parent) and (parent->child) overlap, and modifying | |
// parent could unsafely clobber (parent->child) use. |
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 xorshift implements a 64-bit version of Marsaglia's xorshift PRNG as | |
// described in http://www.jstatsoft.org/v08/i14/paper. | |
// The generator has a period of 2^64-1 and passes most of the tests in the | |
// dieharder test suit. | |
package xorshift | |
// *Xor64Source implements the rand.Source interface from math/rand. | |
type Xor64Source uint64 | |
// seed0 is used as default seed to initialize the generator. |
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 | |
// | |
// Starting point is from http://gcmurphy.wordpress.com/2012/11/30/using-epoll-in-go/ | |
// | |
import ( | |
"fmt" | |
"os" | |
"syscall" |
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
// A small SSH daemon providing bash sessions | |
// | |
// Server: | |
// cd my/new/dir/ | |
// #generate server keypair | |
// ssh-keygen -t rsa | |
// go get -v . | |
// go run sshd.go | |
// | |
// Client: |
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 | |
// simple example to show how to process one message at a time with nsq using the go-nsq client library. | |
// see config stuff in var below to play around with different scenarios. | |
import ( | |
"log" | |
"os" | |
"os/signal" | |
"strconv" |
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/perl | |
# | |
# Brad's el-ghetto do-our-storage-stacks-lie?-script | |
# | |
sub usage { | |
die <<'END'; | |
Usage: diskchecker.pl -s <server[:port]> verify <file> | |
diskchecker.pl -s <server[:port]> create <file> <size_in_MB> | |
diskchecker.pl -l [port] |
This file has been truncated, but you can view the full file.
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
~/go/src/github.com/cockroachdb/cockroach (master) $ git checkout beta-20170112 | |
Note: checking out 'beta-20170112'. | |
You are in 'detached HEAD' state. You can look around, make experimental | |
changes and commit them, and you can discard any commits you make in this | |
state without impacting any branches by performing another checkout. | |
If you want to create a new branch to retain commits you create, you may | |
do so (now or later) by using -b with the checkout command again. Example: |
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 bash | |
set -x | |
NS="ns1" | |
VETH="veth1" | |
VPEER="vpeer1" | |
VETH_ADDR="10.200.1.1" | |
VPEER_ADDR="10.200.1.2" |
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
--[[ | |
ProFi v1.3, by Luke Perkin 2012. MIT Licence http://www.opensource.org/licenses/mit-license.php. | |
Example: | |
ProFi = require 'ProFi' | |
ProFi:start() | |
some_function() | |
another_function() | |
coroutine.resume( some_coroutine ) | |
ProFi:stop() |
OlderNewer