Skip to content

Instantly share code, notes, and snippets.

Avatar
✔️
Verified

Garrett T film42

✔️
Verified
View GitHub Profile
@film42
film42 / example.clj
Last active Aug 29, 2015
Fermat based primality tester written in Clojure
View example.clj
;;
;; Checkout this page for large prime numbers: http://primes.utm.edu/lists/small/small3.html
;;
;; Testing a 300 digit prime number
(def some-large-prime 290245329165570025116016487217740287508837913295571609463914348778319654489118435855243301969001872061575755804802874062021927719647357060447135321577028929269578574760547268310055056867386875959045119093967972205124270441648450825188877095173754196346551952542599226295413057787340278528252358809329N)
(is-prime? some-large-prime) ;;=> true || Elapsed time: 216.512 msecs
;; Testing a long even number
(def some-long-even-number 709127341927349283740927349823749237492734092873492842N)
View simplex.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApplication1 {
class SimplexSolver {
private int[] N; // Indicies of non-basic variables
@film42
film42 / euler_11.clj
Last active Aug 29, 2015
Project Euler #11
View euler_11.clj
(ns euler.euler-11
(:require [clojure.string :as s]))
(def grid-data
"Open data from file"
(slurp "files/11.txt"))
(defn- get-grid
"Get the matrix from the slurped text. Break on new lines, then split and parse for Ints"
[]
@film42
film42 / jane-street-rain-collection.clj
Last active Aug 29, 2015
An Interview Question from Jane Street: Given some topology, assume it rained and settled, return a new map of the collected rain fall.
View jane-street-rain-collection.clj
(ns rain-topology)
;; An Interview Question from Jane Street:
;; Given some topology, assume it rained and settled,
;; return a new array of the collected rain fall.
;; _
;; _| | _
;; _| | _| |
;; | |_| |
;;
@film42
film42 / map.cpp
Last active Aug 29, 2015
Implementing generic map and reduce functions for certain collections in c++11 using lambda `std::function`
View map.cpp
#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) );
}
@film42
film42 / knn.hpp
Last active Aug 29, 2015
(WIP) Starting to do a K Nearest Neighbor example. Repo with latest here: https://github.com/film42/knn-property-categorization
View knn.hpp
//
// 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 / rxcpp_pi.cpp
Last active Aug 29, 2015
RxCPP PI Stream
View rxcpp_pi.cpp
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 / broker.hpp
Last active Aug 29, 2015
Pub/Sub Broker in C++ but it's not threaded
View broker.hpp
#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 Aug 29, 2015
(WIP) Pattern Matching Algorithm using Stock Tick Data: Uses FooPlot for Rendering Graphs
View a_stock_pattern_matching.cpp
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include <cmath>
#include "functional.h"
#include "graph.h"
// DATA PARSING
View keybase.md

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: