Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am oskarth on github.
* I am oskarth (https://keybase.io/oskarth) on keybase.
* I have a public key whose fingerprint is 7CAA 3C75 564F EBB4 1A33 7C4C 9C20 D0AD 8A36 E0E4
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am oskarth on github.
  • I am oskarth (https://keybase.io/oskarth) on keybase.
  • I have a public key whose fingerprint is 7CAA 3C75 564F EBB4 1A33 7C4C 9C20 D0AD 8A36 E0E4

To claim this, I am signing this object:

@oskarth
oskarth / scalawtf
Created May 10, 2014 11:53
scala new wtf 5minutes later
>sbt new progfun
Getting org.scala-sbt sbt 0.13.2 ...
downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.2/jars/sbt.jar ...
[SUCCESSFUL ] org.scala-sbt#sbt;0.13.2!sbt.jar (2719ms)
downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/main/0.13.2/jars/main.jar ...
[SUCCESSFUL ] org.scala-sbt#main;0.13.2!main.jar (13122ms)
downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-interface/0.13.2/jars/compiler-interface-bin.jar ...
[SUCCESSFUL ] org.scala-sbt#compiler-interface;0.13.2!compiler-interface-bin.jar (2064ms)
downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-interface/0.13.2/jars/compiler-interface-src.jar ...
[SUCCESSFUL ] org.scala-sbt#compiler-interface;0.13.2!compiler-interface-src.jar (1525ms)
@oskarth
oskarth / coin-change.dot
Last active August 29, 2015 14:01
Coin change
digraph {
label="Counting change: 100 cents in quarters and dime";
1 [label="100, (10, 25)"];
2 [label="100, 25"];
3 [label="90, (10, 25)"];
4 [label="100, -"];
@oskarth
oskarth / webframework.clj
Created May 25, 2014 20:14
webframework.clj
(ns webframework.core
(require [clojure.string :refer [split]]
[ring.adapter.jetty :refer [run-jetty]]
[ring.middleware.params :refer [wrap-params]]))
;; Every dependency is one cheat point.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; framework questionmark
@oskarth
oskarth / shuffle.c
Last active September 24, 2015 17:08
Question on Uniform in-place shuffle of array in C - stats vs empirical results
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/*
We want to do an in-place uniform shuffle of an array.
Claim: with three elements, we have 3 calls to get_random(0, 2). Three random
choices and three possibilities. Total number of possible sets of choices is
3*3*3=27 How many possible outcomes? 3! = 6. 27 not evenly divisible with 6, so

Using cljs.jar, version 1.7.48.

Desired behavior: ability to watch a single cljs file for changes, without any additional directories.

I'm aware that:

  1. java -cp cljs.jar:src clojure.main watch.clj is the normal command to run.
  2. Single-segment namespaces are not normally recommended.

With that said, it would be very neat to be able to have just a single cljs file and a temporary out directory. How do you best achieve this? What changes have to be made to the FS watcher?

@oskarth
oskarth / gist:3259872
Created August 4, 2012 20:56
Golang Concurrency
// Concurrency in Go
// ----------------------------------------------------------------
// several processes running at the same time
// dealing with lots of things at once (connections, computations)
// long live Murphy's^H^H^H^H^H^H^HMoore's law!
// Three things: execution, syncing/messaging and control flow
// 1) GOROUTINES
// ----------------------------------------------------------------
@oskarth
oskarth / gist:3469830
Created August 25, 2012 19:30
Intro to gradient descent, and why feature scaling leads to better convergence
ml gives computers ability to learn without being explicitly programmed.
# Linear Regression
linear regression is a simple model to find best for for data.
http://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Linear_regression.svg/400px-Linear_regression.svg.png
view above x and y axis as features, generalize to n-dimensional.
# Example
You have a data set with commute and sleep time, salary and happiness (1-10)
for the three features, commute, sleep and salary you want to predict happy
(ns chipper.core
(:use [clojure.contrib.combinatorics :only (selections)])
(:use [clojure.pprint :only (pprint)])
(:require [clojure.tools.macro :as macro]))
(defn bool-space
"Generates every possible boolean n-tuple."
[n]
(selections [0 1] n))