Skip to content

Instantly share code, notes, and snippets.

package main
import (
"flag"
"fmt"
"github.com/chrislusf/glow/flow"
"github.com/dgruber/ugego/pkg/accounting"
"os"
"strings"
)
@prehensilecode
prehensilecode / change_categories.py
Last active February 14, 2017 16:38
Change node categories in Bright Cluster Manager
#!/usr/bin/python
### Change all node categories
from sys import exit
import os
# import Bright Cluster Manager bindings
import pythoncm
--- 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()])
#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));
@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
@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 / 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 / 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 / foo.csv
Created May 15, 2018 20:19
Sample CSV to test pandas.read_csv()
A B C D E
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
@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