Skip to content

Instantly share code, notes, and snippets.

View cjlarose's full-sized avatar

Chris LaRose cjlarose

View GitHub Profile
@cjlarose
cjlarose / rubocop-auto-correct-range
Last active November 12, 2017 21:18
Rubocop with support for autocorrecting only within a specified line range
#!/usr/bin/env ruby
DEBUG = false
start_line_index, end_line_index, filename = ARGV
start_line = start_line_index.to_i - 1
end_line = end_line_index.to_i - 1
source_lines = STDIN.readlines
lines_before = source_lines[0...start_line]
@cjlarose
cjlarose / Dockerfile
Last active February 12, 2017 23:49
localstack Dockerfile
FROM debian:jessie
RUN echo "deb http://httpredir.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y build-essential python python-pip python-dev curl maven
RUN apt-get install -t jessie-backports -y ca-certificates-java openjdk-8-jre-headless openjdk-8-jdk-headless
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get install -y nodejs
import Test.HUnit (Assertion, (@=?), runTestTT, Test(..), Counts(..))
import System.Exit (ExitCode(..), exitWith)
import qualified LinkedList as L
exitProperly :: IO Counts -> IO ()
exitProperly m = do
counts <- m
exitWith $ if failures counts /= 0 || errors counts /= 0 then ExitFailure 1 else ExitSuccess
testCase :: String -> Assertion -> Test
(ns robot-sim.core)
;; robot = { :direction [0 1], :position [4, 5] }
(defn rotate-right [[x y]]
[y (- x)])
(defn rotate-left [[x y]]
[(- y) x])
@cjlarose
cjlarose / # nginx - 2016-04-07_14-18-17.txt
Created April 7, 2016 21:25
nginx on Mac OS X 10.11.4 - Homebrew build logs
Homebrew build logs for nginx on Mac OS X 10.11.4
Build date: 2016-04-07 14:18:17
@cjlarose
cjlarose / byte_seq.clj
Last active October 21, 2015 00:08
Lazy byte sequence in Clojure given something to read from (like stdin)
;; Similar to https://clojuredocs.org/clojure.core/line-seq,
;; but is byte-oriented instead of line-oriented
(defn byte-seq [^java.io.BufferedReader rdr]
(lazy-seq
(let [ch (.read rdr)]
(if (= ch -1)
'()
(cons ch (byte-seq rdr))))))
@cjlarose
cjlarose / Main.hs
Created September 19, 2015 00:26
Default implementation
class Bytes a where
toBytes :: a -> List UInt8
width :: Int
addWithCarry :: a -> a -> (Tuple Boolean a)
default addWithCarry a b = case (addLists (toBytes a) (toBytes b)) of
(Cons 0 sum) -> (Tuple false a)
(Cons 1 sum) -> (Tuple true a)
otherwise -> error
@cjlarose
cjlarose / download.sh
Created July 18, 2015 18:53
Download KGS game recrods
wget -r -l1 -H -t1 -nd -N -A.bz2 -erobots=off http://u-go.net/gamerecords/
for f in *.tar.bz2; do tar xf $f; done
OPENCLC=/System/Library/Frameworks/OpenCL.framework/Libraries/openclc
BUILD_DIR=./build
EXECUTABLE=main
.SUFFIXES:
KERNEL_ARCH=i386 x86_64 gpu_32 gpu_64
BITCODES=$(patsubst %, mykernel.cl.%.bc, $(KERNEL_ARCH))
$(EXECUTABLE): $(BUILD_DIR)/mykernel.cl.o $(BUILD_DIR)/main.o $(BITCODES)
clang -framework OpenCL -o $@ $(BUILD_DIR)/mykernel.cl.o $(BUILD_DIR)/main.o
@cjlarose
cjlarose / integer_test.c
Last active August 29, 2015 14:09
MIN_INT fail
void printint(int);
int f() {
int n;
n = -2147483648;
printint(n);
return n;
}