Skip to content

Instantly share code, notes, and snippets.

View kkleidal's full-sized avatar

Ken Leidal kkleidal

  • Genesis Therapeutics
  • Boston, MA
View GitHub Profile
@kkleidal
kkleidal / Makefile
Created October 1, 2015 16:24
Tex Makefile
SRC_FILES=*.tex
pdf:
pdflatex $(SRC_FILES)
clean:
rm *.aux *.log *.pdf
all: pdf
'use-strict';
(function() {
function copyTextArea($selTextArea) {
$selTextArea.select();
var successful = false;
try {
successful = document.execCommand('copy');
} catch (err) {
successful = false;
@kkleidal
kkleidal / searchpdfs
Created May 18, 2015 18:39
Search text of pdfs in working directory
#!/bin/bash
# Based on http://stackoverflow.com/questions/4643438/how-to-search-contents-of-multiple-pdf-files
find $(pwd) -name '*.pdf' -exec sh -c "pdftotext '{}' - | grep --with-filename --label='{}' --color '$1'" \;
@kkleidal
kkleidal / downloader.bash
Last active August 29, 2015 14:21
FileListDownloader
#!/bin/bash
DIR=$(pwd)
DELIMETER="\t"
DOWNLOADS_FILE=$1
DOWNLOAD_TO=$2
MY_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
PRIVATE_KEY=$MY_DIR/mitKeyStore.pem
print "Hello world!"
@everywhere const exact = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092
@everywhere function approx_pi(n::Integer)
current_term = 0.5
sum = current_term
for i=1:n
current_term *= (2 * i) * (2 * i - 1) / (16 * i * i) * (2 * (i - 1) + 1) / (2 * i + 1)
sum += current_term
end
return 6 * sum
@kkleidal
kkleidal / pid.sh
Created January 6, 2015 15:30
PID of Process BASH
#!/bin/bash
# Get the PID of a process matching the pattern specified
# in the first argument as displayed in ps axf
# This line can be used in any script, just replace $1 with the match string:
PID=$(ps axf | grep "$1" | grep -v grep | awk '{print $1}' | head -n1)
echo "$PID"
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
function wrapHTML(html) {
return "<!DOCTYPE html><html><body>" + html + "</body></html>\n";
}
function serveIndex(response, rootPath, localPath, cb) {
@kkleidal
kkleidal / Pair.java
Created November 28, 2014 22:40
Java Pair class
package util;
/**
* Creates a pair of two objects
*
* @param <T1> the type of object 1
* @param <T2> the type of object 2
*/
public class Pair<T1, T2> {
@kkleidal
kkleidal / gitlog.sh
Created November 17, 2014 01:28
Convenient Git log
git log --oneline --graph --color --decorate --all