Skip to content

Instantly share code, notes, and snippets.

View ravnoor's full-sized avatar

Ravnoor Singh Gill ravnoor

View GitHub Profile
@ravnoor
ravnoor / ppm2png.sh
Last active October 3, 2015 04:53
Convert PPM images generated by AFNI to readily usable PNG format using Imagemagick
#!/bin/sh
#requires image magick
dir=$1
target_dir=$PWD
for f in $PWD/*.ppm
do
ppm=$(basename -s .ppm $f)
@ravnoor
ravnoor / mkv2mp4.sh
Created August 26, 2014 23:23
Convert Matroska MKV to iTunes compatible MP4 format for Airplay streaming on AppleTV.
#!/bin/bash
dir=$1
target_dir=$PWD
for f in $PWD/*.mkv; do
mkv=$(basename -s .mkv $f)
echo $ppm
mpx=$target_dir/$mkv.mp4
if [ ! -in $mpx ]
# Here are a few methods for getting text from PDF files. Do read through
# the instructions carefully! NOte that this code is written for Windows 7,
# slight adjustments may be needed for other OSs
# Tell R what folder contains your 1000s of PDFs
dest <- "G:/somehere/with/many/PDFs"
# make a vector of PDF file names
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE)
#!/bin/bash
# Default Variable Declarations
DEFAULT="Default.txt"
FILEEXT=".ovpn"
CRT=".crt"
KEY=".3des.key"
CA="ca.crt"
TA="ta.key"
@ravnoor
ravnoor / checkip.sh
Created October 18, 2015 17:08
Get external IP address using command line
#!/bin/sh
curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g'
@ravnoor
ravnoor / .profile
Last active October 18, 2015 17:13
User profile for OpenWRT running on DIR-835A1. 18th October 2015
#!/bin/sh
[ -f /etc/banner ] && cat /etc/banner
export PATH=/usr/bin:/usr/sbin:/bin:/sbin
export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
export HOME=${HOME:-/root}
export PS1='\u@\h:\w\$ '
[ -x /bin/more ] || alias more=less
[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
@ravnoor
ravnoor / speedWRT.py
Last active October 30, 2015 18:32
Running speedtest.py on openWRT
# http://www.speedtest.net/speedtest-servers.php [Get server id here]
./speedtest-cli --server 1993 --secure
# id = 1993 for ElectronicBox server in Montreal, QC
@ravnoor
ravnoor / read_nles.m
Last active November 18, 2015 19:39
Read NLES demographic data in Matlab
fid = fopen('DemographicNGrouping_for_NLES_Data_CT.csv');
C = textscan(fid, '%s%d%s%s%s%s%d%d%d%d%d%s%d%d%d','Delimiter',',','CollectOutput', 1);
% reading laterality as a string instead of binary integers.
ID = C{1};
Age = int32(C{2});
Sex = C{3}(:,1); Sex(strcmp(Sex, '1')) = {'F'}; Sex(strcmp(Sex, '0')) = {'M'};
Left = C{3}(:, 2); Right = C{3}(:, 3); Bilateral = C{3}(:, 4);
group = Left;
group(strcmp(group, '1')) = {'LTLE'}; group(strcmp(group, '0')) = {'RTLE'};
% encode binary numbers '0' and '1' in Laterality as RTLE and LTLE.
@ravnoor
ravnoor / read_controls_nles.m
Last active November 18, 2015 18:43
Read controls (NLES-matched) demographic data in Matlab
fid = fopen('DemographicNGrouping_for_controls_Data_CT.csv');
C = textscan(fid, '%s%s%d%s%s', 'Delimiter', ',', 'CollectOutput', 1);
ID = C{1}(:, 1);
path = C{1}(:, 2);
age = int32(C{2});
sex = C{3}(:,1); sex(strcmp(sex, 'male')) = {'F'}; sex(strcmp(sex, 'female')) = {'M'};
group = C{3}(:, 2);
subject_ID_cont = ID;
subject_path_cont = path;
Age_cont = age;
@ravnoor
ravnoor / struct2csv.m
Created November 18, 2015 16:43
Output a structure to a comma delimited file with column headers
function struct2csv(s,fn)
% STRUCT2CSV(s,fn)
%
% Output a structure to a comma delimited file with column headers
%
% s : any structure composed of one or more matrices and cell arrays
% fn : file name
%
% Given s:
%