Skip to content

Instantly share code, notes, and snippets.

View codyrioux's full-sized avatar

Cody Rioux codyrioux

View GitHub Profile
2016-03-17 21:41:55.866424: __init__: in
2016-03-17 21:41:55.931150: [(<frame object at 0x109001a00>, '/Users/crioux/.vim/plugged/ensime-vim/ensime_shared/ensime.py', 168, 'lazy_initialize_ensime', [' self.log(str(inspect.stack()))\n'], 0), (<frame object at 0x1090c1440>, '/Users/crioux/.vim/plugged/ensime-vim/ensime_shared/ensime.py', 188, 'setup', [' return lazy_initialize_ensime() and ready_to_connect()\n'], 0), (<frame object at 0x108c0a650>, '/Users/crioux/.vim/plugged/ensime-vim/ensime_shared/ensime.py', 1010, 'client_for', [' if client.setup(quiet=quiet, create_classpath=create_classpath):\n'], 0), (<frame object at 0x7feb3b6433e0>, '/Users/crioux/.vim/plugged/ensime-vim/ensime_shared/ensime.py', 986, 'current_client', [' create_client=create_client)\n'], 0), (<frame object at 0x7feb3b641830>, '/Users/crioux/.vim/plugged/ensime-vim/ensime_shared/ensime.py', 928, 'wrapper2', [' create_client=create_client)\n'], 0), (<frame object at 0x108fdc
@codyrioux
codyrioux / .ensime.gradle
Created March 17, 2016 05:13
Ensime File Generated by Gradle and sbt for same project
(:root-dir "/Users/crioux/src/stash/hello"
:cache-dir "/Users/crioux/src/stash/hello/.ensime.cache.d"
:name "hello"
:java-home "/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home"
:formatting-prefs nil
:scala-version "2.11.8"
:compiler-args ("-Xlint")
:subprojects ((:name "hello"
:source-roots ("/Users/crioux/src/stash/hello/src/main/resources" "/Users/crioux/src/stash/hello/src/main/java" "/Users/crioux/src/stash/hello/src/main/scala" "/Users/crioux/src/stash/hello/src/test/resources" "/Users/crioux/src/stash/hello/src/test/java" "/Users/crioux/src/stash/hello/src/test/scala")
:reference-source-roots ("/Users/crioux/.gradle/caches/modules-2/files-2.1/com.typesafe.akka/akka-actor_2.11/2.3.14/4f0b9a84b193fad2678fb12080c258a1abb85949/akka-actor_2.11-2.3.14-sources.jar" "/Users/crioux/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-reflect/2.11.7/c4d5a9d0a7a6956720809bcebca1b2fe978e5dc6/scala-reflect-2.11.7-sources.jar" "/Users/crioux/.gradle/caches/modules-2/files-2.1/org.apache.commons/com
#
# Drift Generator
#
class DriftingDistributionGenerator(Generator):
"""
A generator which takes two distinct distributions and a changepoint and returns
random variates from the first distribution until it has reached the changepoint
where it linearly drifts to the second distribution.
@codyrioux
codyrioux / LinkedList
Last active November 8, 2021 14:39
Linked list class with a recursive reverse function and main method for testing.
public class LinkedList {
public static class Node {
public int data;
public Node next;
}
public static Node reverse(Node head) {
if (head == null || head.next == null) {
return head;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.lang.Iterable;
import java.util.NoSuchElementException;
import javax.naming.OperationNotSupportedException;
/**
/* Author: Cody Rioux <cody.rioux@uleth.ca>
* Description: A simple toy program to implement fizzbuzz using reinfocement learning.
*
* Notes: This learner is very tightly coupled to the FizzBuzz specific implementation
* functions. This is obviously not a favorable situation. Consider using libCello to
* make a general SARSA learner that takes function parameters for the general case.
*/
#include <stdio.h>
#include <assert.h>
@codyrioux
codyrioux / tfidf.clj
Created September 10, 2013 21:05
An idiomatic implementation of term-frequency inverse-document-frequency in 6 lines of Clojure.
(ns eacl2014.tools.tfidf
"A term-frequency inverse-document-frequency implementation in idiomatic clojure.
A term is a single token, doc is a seq of terms and docs is a seq of docs.")
(defn- log [x] (Math/log x))
(defn- t-in-d? [t, d] (some #{t} d))
(defn- f [t doc] (count (filter #(= t %) doc)))
(defn tf [t doc] (+ 0.5 (/ (* 0.5 (f t doc)) (apply max (map #(f % doc) doc)))))
(defn idf [t docs] (log (/ (count docs) (count (filter (partial t-in-d? t) docs)))))
@codyrioux
codyrioux / genetic-algorithm.clj
Created April 17, 2013 18:00
A genetic algorithm function in clojure.
(ns genetic-algorithm.core
(:use (clojure set))
(:gen-class))
(defn ga
"Main function for running the genetic algorithm.
This will perform the fitness -> selection -> crossover -> mutation cycle
until we have reached the maximum number of generations or our termination
condition specified by terminate? is satisfied.
@codyrioux
codyrioux / positioning.erl
Created January 2, 2012 06:27
Positioning Games
% A naive extension of minimax to solve a multi-player positioning game.
% Author: Cody Rioux
% Email: cody.rioux@gmail.com
% Site: http://codyrioux.github.com
%
% A word of caution, this algorithm has a high computational complexity and takes a very long
% time to run with inputs greater than four players. I mean it. I'd recommend making supper
% after setting the algorithm loose on six or more players. Ten or more I'd recommend letting
% it run while you're on vacation.
%
@codyrioux
codyrioux / prime.erl
Created December 29, 2011 20:52
Naive Prime Sieve
-module(prime).
-export([start/1]).
start(Max) -> io:format("Solution: ~p ~n", [sieve(lists:seq(2, Max), Max)]).
sieve([H|T], Max) -> if H * H > Max -> [H] ++ T; true -> [H] ++ sieve(mark(H, T), Max) end.
mark(X, List) -> lists:filter(fun(Y) -> (Y rem X =/= 0) end, List).