Skip to content

Instantly share code, notes, and snippets.

View jappy's full-sized avatar

Scott Jappinen jappy

View GitHub Profile
@jappy
jappy / gist:2015517
Created March 11, 2012 08:02
grep examples
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
jappy / gist:2015435
Created March 11, 2012 07:32
unix sort cheatsheet
sort –d #dictionary order
sort –f #fold case
sort –n #numeric order
sort –nr #reverse numeric order
sort +1 #start with field 1 (starting from 0)
sort +0.50 #start with 50th character
sort +1.5 #start with 5th character of field
@jappy
jappy / install-aspell.sh
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
jappy / gist:2143963
Created March 21, 2012 03:04
unix command to report number of lines per file and in total recursively
find . -type f | xargs wc -l
@jappy
jappy / ParyCudaSearch
Created October 18, 2012 20:46 — forked from ncornwell/ParyCudaSearch
Binary Search in CUDA
// kernel.cu : 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
jappy / gist:8441831
Created January 15, 2014 18:40 — forked from xavi/gist:3729307
;; 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 https://github.com/xavi/noir-auth-app
;; See usage at the end.
@jappy
jappy / gist:2038841
Created March 14, 2012 19:25
unix command recursive sed like search and replace that works on mac os x
# searches from ./
find . -type f|xargs perl -pi -e 's/\t/ /g'
@jappy
jappy / MinimumEditDistance.java
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
jappy / dos2unix.sh
Created March 10, 2012 18:03
Shell script to convert files with CRLF to LF (Mac/Linux)
#! /bin/sh
for x
do
echo "Converting $x"
tr -d '\015' < "$x" > "tmp.$x"
mv "tmp.$x" "$x"
done