Skip to content

Instantly share code, notes, and snippets.

View gist:9359639
### 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:
View keybase.md

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
scala new wtf 5minutes later
View scalawtf
>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)
View coin-change.dot
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, -"];
View 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 Sep 24, 2015
Question on Uniform in-place shuffle of array in C - stats vs empirical results
View shuffle.c
#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
View cljs-watch.md

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 Aug 4, 2012
Golang Concurrency
View gist:3259872
// 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 Aug 25, 2012
Intro to gradient descent, and why feature scaling leads to better convergence
View gist:3469830
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
View gist:3920027
(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))