Skip to content

Instantly share code, notes, and snippets.

@ahebrank
ahebrank / sort_files.py
Last active August 29, 2015 14:00
Sort du -sh output by size
import re
import sys
if len(sys.argv)<3:
print "Need an input filename (i.e., du -sh > input.txt) and a csv output filename"
sys.exit(1)
# pass a file with du -h output as the first command line argument
with open(sys.argv[1]) as f:
lines = [x.strip() for x in f.readlines()]
; Register Style Plugin directory
plugins[panels][styles] = panels/styles
@ahebrank
ahebrank / make_svg_stripes.php
Created September 3, 2014 13:17
Make some stripes (because linear gradients just don't work)
<?php
// make an svg given an initial stripe color, initial stripe height, other stripe height, and total overall height
$osh = $_GET['oh']; // stripe height
$h = $_GET['h']; // overall height
$isc = (isset($_GET['c']))? $_GET['c']:""; // optional initial stripe
$ish = (isset($_GET['ch']))? $_GET['ch']:0; // height of initial stripe
$offset = (isset($_GET['offset']))? $_GET['offset']:0; // "offset" (actually just the height of the first stripe)
$altcolors = array("#ededeb", "#e4e4e3");
@ahebrank
ahebrank / csvhwrite.m
Created September 26, 2014 15:18
Write out csv file with header
function csvhwrite(fn, data, hdr)
% function csvhwrite(fn, data, hdr)
% write a csv file with cell array hdr (cols in data must match length of hdr)
if isempty(fn)
fn = spm_input('Filename: ', '+1', 's');
end
if size(data,2)~=length(hdr)
error('Header length does not match data');
@ahebrank
ahebrank / mfcsvread.m
Created October 3, 2014 16:48
read csv with text and numeric data
function outputStuff = mfcsvread(fileName)
%mfcsvread reads a CSV file containing both text & numeric data. MATLAB's
%csvread function will work with all numeric, or all text data, but not
%both. It's common to have a file with a single line of comma separated
%text headers followed by many rows of numeric data. xlsread is limited in
%the number of rows & colums (actually, Excel is the limitation) it can
%read.
%
% The CSV file should look like:
% comma, separated, text, ...
@ahebrank
ahebrank / spag.R
Created May 20, 2015 21:37
spaghetti plots
# construct spaghetti plots in R
# skip to the last few lines for the actual ggplot definition
#
# melt to long format
# in this case, we have subjects with a dv collected
# 1) at multiple timepoints (wave)
# 2) in multiple brain regions (region)
# subjects also have an age, which helps make a prettier spaghetti plot
require(reshape2)
long_data <- melt(wide_data, id.vars=c("ID", "wave", "age"))
# source me and then use:
#
# splitfile("workbook.xlsx", 1)
#
# to extract sheet 1 from workbook.xlsx
# set these if they vary
# subj_col determines the name of the output file
subj_col <- 1
# content_col determines the column with the contents of the file
@ahebrank
ahebrank / cisco.osascript
Last active June 26, 2023 08:20
Automate Cisco AnyConnect VPN client with 2-factor auth on OSX
-- Usage: <script> gatewayHostName username password
-- based on https://gist.github.com/andrewh/7135352 and https://github.com/seanfisk/juniper-network-connect-vpn-applescript/blob/master/juniper.applescript
on run argv
if (count of argv) is not equal to 3 then
return "Usage: <script> gatewayHostName username password"
else
set {gatewayHostName, username, pw} to argv
@ahebrank
ahebrank / main.yml
Last active April 27, 2016 00:40
ansible role for mysql 5.1 on ubuntu 14.04
---
# 5.1 compile from source from https://sonnguyen.ws/install-mysql-5-1-ubuntu-14/ and trial and error
- stat: path=/usr/bin/mysqld_safe
register: mysql_binary
- name: Install build tools
sudo: yes
apt: name={{item}} state=installed
with_items:
@ahebrank
ahebrank / eva-8.x-to-head.patch
Created December 7, 2016 17:50
Bring d.o eva 8.x branch up to working head
diff --git a/README.txt b/README.txt
old mode 100755
new mode 100644
index d2bdcba..27e73b6
--- a/README.txt
+++ b/README.txt
@@ -39,8 +39,7 @@ ourselves.
REQUIREMENTS