Skip to content

Instantly share code, notes, and snippets.

View bholt's full-sized avatar

Brandon Holt bholt

View GitHub Profile
@bholt
bholt / mpihello.c
Created April 1, 2014 17:23
MPI Hello World
#include <mpi.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
MPI_Init(&argc, &argv);
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
@bholt
bholt / .Rprofile
Created April 29, 2014 01:59
R init
setwd(Sys.getenv("PWD"))
# Set hook to be run when Defaults is attached
setHook(packageEvent("Defaults", "attach"),
function(...) { setDefaults(q, save="yes"); useDefaults(q) })
# add Defaults to the default packages loaded on startup
old <- getOption("defaultPackages");
options(defaultPackages = c(old, "Defaults"))
options(repos=structure(c(CRAN="http://cran.fhcrc.org/")))
@bholt
bholt / .gitconfig
Last active August 29, 2015 14:00
Git Config Snippet
[color]
# color whenever it's going to a terminal
ui = auto
[core]
# global excludes go here
excludesfile = ~/.gitignore_global
ignorecase = false
autocrlf = input
@bholt
bholt / graphlab.cpp
Last active August 29, 2015 14:03
Lata code snippet
GlobalAddress<Graph> g;
///////////////////////////////////////////////
// GraphLab synchronous engine: scatter phase
// loop over all vertices in graph
forall(g, [=](Vertex& v){
// only scatter from vertices that have been signaled to do scatter
if (v->active_minor_step) {
v->active_minor_step = false;
@bholt
bholt / wc.cpp
Last active August 29, 2015 14:04
Word Count Example
forall(words, n, [=](string w) {
// hash partitioning
size_t idx = hash(w) % ncells;
delegate(cells+idx, [=](Cell& cell)
{ // runs atomically
if (cell.count(w) == 0) cell[w] = 1;
else cell[r] += 1;
});
});
template< typename T >
void work(T t) {
try { throw t; }
catch (int x) { printf("int\n"); }
catch (std::string x) { printf("string\n"); }
}
int main(int argc, char *argv[]) {
work(0);
@bholt
bholt / keybase.md
Created June 5, 2015 20:13
Keybase proof

Keybase proof

I hereby claim:

  • I am bholt on github.
  • I am bholt (https://keybase.io/bholt) on keybase.
  • I have a public key whose fingerprint is AEAA C7A8 DE91 8434 B88F 88CD EE4E 54E0 0859 5279

To claim this, I am signing this object:

@bholt
bholt / ConcurrentQueue.hpp
Created July 30, 2015 16:00
Concurrent queue built for single-producer/single-consumer that uses a condition variable to signal consumer.
#include <future>
using namespace std;
template< typename T >
class ConcurrentQueue {
Queue<T> q;
mutex m;
condition_variable cv;
bool closed;
@bholt
bholt / color_scheme.r
Created August 12, 2015 17:49
Custom color scheme for ggplot
c.blue <- "#0072B2"
c.yellow <- "#E69F00"
c.green <- "#009E73"
c.red <- "#D55E00"
c.pink <- "#CC79A7"
c.gray <- "#999999"
palette <- c(
'follow'=c.blue,
'newuser'=c.yellow,
@bholt
bholt / slurm-ssh.sh
Created August 18, 2015 01:11
Slurm SSH Script
#!/bin/bash
# usage: slurm-ssh [host] [shell]
# e.g.: salloc -N2 slurm-ssh
# n01 (salloc n[01,04]) >
# or:
# slurm-ssh n01
# or:
# slurm-ssh n01 zsh
DIR=$(pwd)