Skip to content

Instantly share code, notes, and snippets.

View sw17ch's full-sized avatar

John VanEnk sw17ch

View GitHub Profile
@sw17ch
sw17ch / .bash_profile.sh
Created August 29, 2013 19:02
The most important lines in my .bash_profile
export HISTCONTROL=erasedups
export HISTSIZE=500
export HISTIGNORE=ls:'ls -l':fg
@sw17ch
sw17ch / gist:6511618
Created September 10, 2013 16:03
$ cat ~/.bash_history | cut -f 1 -d " " | sort | uniq
ack
bundle
cat
cd
cd-
ceedling
cp
curl
diff
find
@sw17ch
sw17ch / abbr.rb
Created September 12, 2013 17:26
res = File.read("/usr/share/dict/words").lines.map{|l| l.chomp.downcase}.inject({}) do |cont, w|
a = w.tr('aeiou', '')
cont.tap do |h|
h[a] ||= []
h[a] << w
end
end
most = res.map {|k, v| [k, v.length]}.sort_by {|a| a[1]}.reverse[0][0]
puts "Most commonly used abbreviation: '#{most}' with #{res[most].length} words."
@sw17ch
sw17ch / consec.rb
Last active December 23, 2015 18:09
#!/usr/bin/env ruby
def stats(b, c, t)
puts "Byte: #{b} | Count: #{c} | #{Time.now - t}"
end
MOD_VAL = 255
start = Time.now
last = 0
import Data.Monoid
import Data.Maybe
main :: IO ()
main = do
print $ expression
instance Monoid Integer where
mempty = 0
mappend = (+)
#include <stdio.h>
#include <stdlib.h>
#define IGNORE(X) ((void)X)
#define MAX_ALLOC (1024 * 1024)
#define MIN_ALLOC (128)
int main(int argc, char * argv[]) {
IGNORE(argc);
IGNORE(argv);
#include <stdio.h>
int main(int argc, char * argv[]) {
float wat = 1.0 / 0.0;
printf("%f\n", wat);
return 0;
}
#include <stdio.h>
typedef int (binop)(int a, int b);
int add(int a, int b);
int sub(int a, int b);
int mul(int a, int b);
int div(int a, int b);
int do_op(int a, int b, binop op);
module Main where
main :: IO ()
main = print $ example
-- The binary tree type.
data Tree a = Tree a (Tree a) (Tree a) | Nil
deriving (Show)
-- Breadth-first traversal
#ifndef ManualProfiler_h
#define ManualProfiler_h
#include <stdio.h>
#include <stdint.h>
typedef uint64_t (MPSampleTime)(void * param);
struct MPProfiler {
FILE * profileLog;