Skip to content

Instantly share code, notes, and snippets.

@prehensilecode
prehensilecode / spark_sbin_slaves.diff
Created October 4, 2017 18:46
Diff to integrate Apache Spark standalone with Univa Grid Engine (other environment stuff needed)
--- ./slaves.sh 2017-10-04 14:40:05.607320037 -0400
+++ /mnt/HA/opt/apache/spark/2.2.0/sbin/slaves.sh 2017-10-04 14:24:55.986020350 -0400
@@ -80,20 +80,29 @@
fi
fi
-
-
# By default disable strict host key checking
if [ "$SPARK_SSH_OPTS" = "" ]; then
@prehensilecode
prehensilecode / vboxmanage_cheat_sheet.txt
Last active October 18, 2019 02:00
VirtualBox commandline cheat sheet
# start a guest in headless mode
vboxmanage startvm guestvmname --type headless
# add a nic (number 2) to guest, setting it to be on the host-only network, and make it a virtio device
vboxmanage modifyvm guestvmname --nic2 hostonly --nictype2 virtio --hostonlyadapter2 vboxnet0
# remove nic number 2
vboxmanage modifyvm guestvmname --nic2 none
# turn on host i/o cache - needed for the virtual disk on ext4 on older kernels
@prehensilecode
prehensilecode / get_module_version.py
Last active September 12, 2017 18:40
Query a module version programmatically using pip
import pip
# get installed modules (aka "distributions")
for m in pip.get_installed_distributions():
print(m.version)
@prehensilecode
prehensilecode / keybase.md
Created September 8, 2017 00:08
Keybase proof

Keybase proof

I hereby claim:

  • I am prehensilecode on github.
  • I am prehensilecode (https://keybase.io/prehensilecode) on keybase.
  • I have a public key ASA97l831aYgYr301QTZYegfhmwZcAQl0ce9eidljz2R7go

To claim this, I am signing this object:

@prehensilecode
prehensilecode / omp_glom.c
Created March 30, 2017 21:36
Dumb program to just allocate some memory in each thread using OpenMP
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#define K 1024l
#define MEG 1048576l
#define GIG 1073741824l
#include <stdio.h>
#include <complex.h>
int main(void)
{
float complex c = 3.0 + 4.0 * I;
long d;
d = c;
printf ("%f %+fi\n", creal(c), cimag(c));
--- setup.py.orig 2012-07-20 16:03:50.000000000 -0400
+++ setup.py 2017-02-22 10:56:13.558487862 -0500
@@ -49,6 +49,14 @@
if not (sys.version_info[0] >= 2 and sys.version_info[1] >= 4):
exit_with_error("You need Python 2.4 or greater to install PyTables!")
+# Version comparison
+# cribbed from: https://zxq9.com/archives/797
+def ver_tuple(z):
+ return tuple([int(x) for x in z.split('.') if x.isdigit()])
package main
import (
"flag"
"fmt"
"github.com/chrislusf/glow/flow"
"github.com/dgruber/ugego/pkg/accounting"
"os"
"strings"
)
#Operation Latency (ns) Comment
L1 cache reference 0.5
Branch mispredict 5
L2 cache reference 7 14x L1 cache
Mutex lock/unlock 25
Main memory reference 100 20x L2 cache 200x L1 cache
Compress 1K bytes with Zippy 3000
Send 1K bytes over 1 Gbps network 10000
Read 4K randomly from SSD 150000 ~1GB/sec SSD
Read 1 MB sequentially from memory 250000
@prehensilecode
prehensilecode / latency.txt
Created July 9, 2016 19:48 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD