Skip to content

Instantly share code, notes, and snippets.


Scott Jappinen jappy

View GitHub Profile
jappy / gist:8441831
Created January 15, 2014 18:40 — forked from xavi/gist:3729307
View gist:8441831
;; Call the renderer-fn macro with a template and it returns a function optimized to render it.
;; This happens at compile-time.
;; At run-time, you call this function with the parameters that will be interpolated into the template,
;; typically (but not limited to) a map.
;; Useful in i18n for variable interpolation, for example. I'm using this to add internationalization
;; support to
;; See usage at the end.
jappy / ParyCudaSearch
Created October 18, 2012 20:46 — forked from ncornwell/ParyCudaSearch
Binary Search in CUDA
View ParyCudaSearch
// : Defines the entry point for the console application.
#include "kernel.h"
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cutil.h>
#include <cuda_runtime.h>
jappy / gist:2143963
Created March 21, 2012 03:04
unix command to report number of lines per file and in total recursively
View gist:2143963
find . -type f | xargs wc -l
jappy / gist:2038841
Created March 14, 2012 19:25
unix command recursive sed like search and replace that works on mac os x
View gist:2038841
# searches from ./
find . -type f|xargs perl -pi -e 's/\t/ /g'
jappy /
Created March 11, 2012 19:19
java class to compute a "levenshtein" or otherwise minimum edit distance on strings with backtrace
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
public class MinimumEditDistance {
public interface CostFunction {
public int cost(int[][] distanceMatrix, CharSequence x, CharSequence y, int i, int j);
jappy /
Created March 11, 2012 17:00
using unix aspell on mac os x instead of unix spell, finds words not in dictionary
tr -sc 'A-Za-z' '\n' < filename.txt | aspell list --mode=none
same as:
tr -sc 'A-Za-z' '\n' < filename.txt | spell -v
jappy / gist:2015517
Created March 11, 2012 08:02
grep examples
View gist:2015517
grep '[A–Z]' #lines with an uppercase char
grep 'ˆ[A–Z]' #lines starting with an uppercase char
grep '[A–Z]$' #lines ending with an uppercase char
grep 'ˆ[A–Z]*$' #lines with all uppercase chars
grep '[aeiouAEIOU]' #lines with a vowel
grep 'ˆ[aeiouAEIOU]' #lines starting with a vowel
grep '[aeiouAEIOU]$' #lines ending with a vowel
grep –i '[aeiou]' #ditto
grep –i 'ˆ[aeiou]'
grep –i '[aeiou]$'
jappy / gist:2015491
Created March 11, 2012 07:54
unix command to sort trigrams from a text in order of frequency
View gist:2015491
# Case sensitive version
tr -sc 'A-Za-z' '\n' < textfile > textfile.words
tail +2 textfile.words > textfile.nextwords
tail +2 textfile.nextwords > textfile.nextnextwords
paste textfile.words textfile.nextwords textfile.nextnextwords | sort | uniq -c > textfile.trigrams
sort -nr < textfile.trigrams
# Case insensitive version
jappy / gist:2015480
Created March 11, 2012 07:51
unix command to sort bigrams from a text in order of frequency
View gist:2015480
# Case sensitive version
tr -sc 'A-Za-z' '\n' < textfile > textfile.words
tail +2 textfile.words > textfile.nextwords
paste textfile.words textfile.nextwords | sort | uniq -c > textfile.bigrams
sort -nr < textfile.bigrams
# Case insensitive version
tr 'A-Z' 'a-z' < textfile | tr -sc 'a-z' '\n' > textfile.words
jappy / gist:2015460
Created March 11, 2012 07:41
unix command to sort words into rhyming order
View gist:2015460
tr 'A-Z' 'a-z' < filename.txt | tr -sc 'a-z' '\n' | rev | sort | uniq | sort -d | rev | less