Skip to content

Instantly share code, notes, and snippets.

View schluppeck's full-sized avatar

Denis Schluppeck schluppeck

View GitHub Profile
@schluppeck
schluppeck / HartigansDipSignifTest.m
Created September 14, 2015 15:46
Significance testing on Hartigans Dip Test [FORTRAN], as implemented by Ferenc Mechler, 2002; and retrieved from http://nicprice.net/diptest/
function [dip, p_value, xlow,xup]=HartigansDipSignifTest(xpdf,nboot)
% function [dip,p_value,xlow,xup]=HartigansDipSignifTest(xpdf,nboot)
%
% calculates Hartigan's DIP statistic and its significance for the empirical p.d.f XPDF (vector of sample values)
% This routine calls the matlab routine 'HartigansDipTest' that actually calculates the DIP
% NBOOT is the user-supplied sample size of boot-strap
% Code by F. Mechler (27 August 2002)
@schluppeck
schluppeck / shell-text-demo.sh
Created September 16, 2015 16:01
demo downloading a text file of a play from command line and then some simple analysis using UNIX command line tools.
# a simple list of UNIX / shell commands to download the Shakespeare play "King
# Richard III" in text format and do a quick demo of text commands.
#
# it uses the command curl to download and grep, tr, wc sort, unique etc.
#
# make a temporary directory somewhere
cd ~
mkdir grepdemo
cd ~/grepdemo
@schluppeck
schluppeck / markdownConversion.sh
Created September 18, 2015 13:52
converting markdown to pdf on command line
# assuming you are on OSX / similar and have pandoc installed
if [[ -z `which pandoc` ]]; then
echo "uhoh..";
echo "consider running: brew install pandoc";
exit 1;
fi
# given a markdown document "notes.md" that you want to convert to PDF
# -f FROM
# example julia code to explain a few important concepts
# - originally run in a jupyter notebook
using PyPlot
using Distributions
# if you get an error with these first two, you might have to
# Pkg.add("PyPlot")
# Pkg.add("Distributions")
@schluppeck
schluppeck / automate-pdf.tex
Created February 21, 2016 16:14
automating PDF creation (making multiple similar, but different documents, eg. thank you cards, certificates, ...)
% example of how to automate / "mail merge" some
%
% e.g. create a multipage PDF document in which only specific things are
% changed on each page (certificates, thank you notes, etc)
%
% to split PDFs, can use a Terminal command (pdftk) or similar
%
% ds 2016-02-20
\documentclass[12pt]{article}
@schluppeck
schluppeck / makeSimpleWordCloud.R
Created December 25, 2016 21:18
text hacking in R
#! /usr/bin/env R
#
# textmine shakespeare's richard iii - turn it into a wordcloud with R
#
# 2016/12/24 - ds
# make sure you have necessary packages
# packages = c("tm", "wordcould")
library(wordcloud)
@schluppeck
schluppeck / run_r_from_terminal.sh
Created December 25, 2016 21:32
running R scripts from Unix terminal
# so you can use bash shell niceties when running R.
R CMD BATCH theRScriptYouWantToRun.R
@schluppeck
schluppeck / cleanup-moodle.sh
Created January 4, 2017 14:00
remove white spaces in a bunch of files downloaded from moodle
# when downloading from moodle, filenames (incl. zip files) have annoying white spaces in them
#
# ds 201701
#filetype, e.g.
ending=.zip
# loop through
for i in *${ending}; do
# make a new filename without blanks
@schluppeck
schluppeck / a5_to_a4.sh
Created February 19, 2017 21:41
turning A5 pdf into 2up A4 pdf
# using pdfjam to turn smaller files into 2-up, A4.
#
# as seen on: http://superuser.com/questions/366490/how-to-merge-multiple-pdf-files-onto-one-page-with-pdftk
#
# brew install homebrew/tex/pdfjam
# the 2017-2-ta.tex file uses the \foreach construct from \usepackage{tikz}
# which allows
# \def\mylist{info/something else/a third thing,
# info/something else/yet another thing}
@schluppeck
schluppeck / UsingGramm.m
Last active March 13, 2017 09:56
grammar of graphics - ideas and how to in R / Matlab
%% introduction to gramm
%
% ds 20170309
%
% the following is adapted from the website for GRAMM
% https://github.com/piermorel/gramm
clear all
close all