Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import sys
import os
import re
import shlex
import subprocess as sp
def main():
lines = sp.Popen(['ps', '-elf'], stdout=sp.PIPE).communicate()[0]
@prehensilecode
prehensilecode / trivial.c
Last active August 29, 2015 14:05
Trivial MPI-CUDA hybrid
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>
int main (int argc, char *argv[])
{
void *a_d;
MPI_Init (&argc, &argv);
cudaSetDevice(0);
printf("hello\n");
cudaError_t ierr = cudaMalloc( (void **) &a_d, 1000);
@prehensilecode
prehensilecode / gmail_monospace.css
Created December 3, 2012 15:12
Userstyle - GMail monospace font
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("mail.google.com") {
/* GMail messages and textarea should use fixed-width font */
.gs .ii, .textarea, textarea.Ak, .editable, .LW-af {
font-family: MonoSpace !important;
}
}
@prehensilecode
prehensilecode / Makefile.system.patch0
Created January 15, 2013 22:21
Patch to get GotoBLAS2-1.13 to compile for Nehalem under PGI 12.5. See also: http://www.pgroup.com/resources/gotoblas/gotoblas_pgi2012.htm
--- Makefile.system 2010-01-28 15:11:08.000000000 -0500
+++ Makefile.system.deac 2013-01-14 11:09:56.280298528 -0500
@@ -278,9 +278,9 @@
ifeq ($(C_COMPILER), PGI)
ifdef BINARY64
-CCOMMON_OPT += -tp p7-64
+CCOMMON_OPT += -tp nehalem-64
else
-CCOMMON_OPT += -tp p7
@prehensilecode
prehensilecode / gist:5471484
Created April 27, 2013 01:20
Trouting script for Colloquy
(*Actions.scpt
Intended for use as a template for context menu script actions
*)
--and here's how you save preferences
property prefs : missing value
property prefsPath : missing value
using terms from application "Colloquy"
on build contextual menu for item blah
@prehensilecode
prehensilecode / glom.c
Created May 9, 2013 15:40
C program to allocate memory as a way of testing system limits.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/resource.h>
void print_rlims(char* name, struct rlimit* const rl)
{
if (rl->rlim_cur == RLIM_INFINITY)
@prehensilecode
prehensilecode / setup_magic.py
Last active December 24, 2015 14:09
Python script to disable built-in Synaptics trackpad, and set up Apple Magic Trackpad the way I like it
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
import sys
import os
import re
import subprocess
def turn_off_tp(tp_id):
subprocess.check_call(["xinput", "--disable", tp_id])
@prehensilecode
prehensilecode / cylon.ino
Last active January 4, 2016 18:39
cylon arduino
void cylon() {
int delayTime = 50;
for (int i = 0; i < 8; ++i) {
digitalWrite(ledPins[i], HIGH);
delay(delayTime);
digitalWrite(ledPins[i], LOW);
}
for (int i = 0; i < 8; ++i) {
digitalWrite(8-ledPins[i], HIGH);
@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
#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