Skip to content

Instantly share code, notes, and snippets.

View film42's full-sized avatar
✔️
Verified

Garrett Thornburg film42

✔️
Verified
View GitHub Profile
package id3
/**
* Created by: film42 on: 3/6/15.
*/
object DecisionTreeUtils {
type Vector[A] = List[A]
type Matrix[A] = List[Vector[A]]
(ns hn.realtime
(:require [cheshire.core :refer :all]))
(def base-url "https://hacker-news.firebaseio.com/v0")
(defn get-updates
"Return response regardless of condition"
[] (parse-string (slurp (str base-url "/updates.json")) true))
(defprotocol IPoller
(ns prime)
;; (coll, n) -> coll'
(defn- prime-check [coll n]
(empty? (filter #(zero? (mod n %)) coll)))
(defn is-prime? [n]
(loop [prime-list [] value 2]
(cond
;; Have the list, check for prime
@film42
film42 / MatrixSpiral.java
Created October 9, 2014 05:40
I saw someone mention this as a fun problem, so I did it.
public class SpiralMatrix {
public static void spiralPrint( int[][] matrix ) {
int height = matrix.length;
int width = matrix[0].length;
int currCol = 0;
int currRow = 0;

Keybase proof

I hereby claim:

  • I am film42 on github.
  • I am film42 (https://keybase.io/film42) on keybase.
  • I have a public key whose fingerprint is CF06 2F6F 984C 0FA7 F955 A9D4 B42B B29C 5E42 9824

To claim this, I am signing this object:

@film42
film42 / broker.hpp
Last active August 29, 2015 14:04
Pub/Sub Broker in C++ but it's not threaded
#include <vector>
#include <map>
namespace postal {
template< class T >
class broker {
public:
typedef std::vector< std::function< void ( T ) > > FuncVector;
@film42
film42 / a_stock_pattern_matching.cpp
Last active August 29, 2015 14:04
(WIP) Pattern Matching Algorithm using Stock Tick Data: Uses FooPlot for Rendering Graphs
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include <cmath>
#include "functional.h"
#include "graph.h"
// DATA PARSING
@film42
film42 / rxcpp_pi.cpp
Last active August 29, 2015 14:04
RxCPP PI Stream
auto pi_series = []( long limit ){
return rxcpp::observable<>::range(1, limit)
.map([](int k) {
return ( k % 2 == 0 ? -4 : 4 ) / ( long double )( ( 2 * k ) - 1 );
})
.sum()
.as_dynamic();
};
@film42
film42 / knn.hpp
Last active August 29, 2015 14:04
(WIP) Starting to do a K Nearest Neighbor example. Repo with latest here: https://github.com/film42/knn-property-categorization
//
// knn.h
// k_nearest_neighbor
//
// http://burakkanber.com/blog/machine-learning-in-js-k-nearest-neighbor-part-1/
//
// Created by Garrett Thornburg on 8/1/14.
// Copyright (c) 2014 gt. All rights reserved.
//
@film42
film42 / map.cpp
Last active August 29, 2015 14:03
Implementing generic map and reduce functions for certain collections in c++11 using lambda `std::function`
#include <iostream>
#include <vector>
#include <list>
template<typename T, typename V>
T map(T list, std::function<V (V)> fn) {
T new_list;
for(V& value : list) {
new_list.push_back( fn(value) );
}