This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Simple funnel example, with three exit points</title> | |
<script src="http://archive.org/includes/jquery-1.10.2.min.js" type="text/javascript"></script> | |
<script src="http://www-will.archive.org/includes/analytics.js?v=20fd7fa_854659" type="text/javascript"></script> | |
</head> | |
<!-- the data-ec="my-app" means we'll get context counts for participate. data-app="my-app" sets limits (esp for the data-convert | |
items) on the events to capture. | |
on load, this will fire an event with {app:"myapp", ec: "myapp", t:"event", ea: "participate"} | |
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* From a file that contains | |
* doc_id w1 w2 w3 ... lines, separated by tabs | |
* return an inverted index Map of w -> Set(doc_id) | |
* | |
* @param filename well isn't it obvious | |
* @return Map[String,Set[String]] | |
*/ | |
import scala.collection.immutable.Map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOCIAL MEDIA MESSAGES | |
MESSAGE 1: KEEP INTERNET ARCHIVE FREE AND AD-FREE | |
TWITTER: | |
On #GivingTuesday help keep @InternetArchive free & ad-free forever! Your gift matched 2-1. https://archive.org/donate | |
FACEBOOK: | |
Tomorrow is #GivingTuesday. By supporting @InternetArchive you are putting knowledge in the hands of millions of people. Please help keep us free and ad-free forever! If you find us useful, please give what you can today. https://archive.org/donate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2011 Will Fitzgerald. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
/* | |
Package bitset implements bitsets. | |
It provides methods for making a bitset of an arbitrary | |
upper limit, setting and testing bit locations, and clearing | |
bit locations as well as the entire set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object SalaryWorld extends App { | |
val rules = Seq( | |
('allowance, 1.2), | |
('bonus, 1.1), | |
('tax, 0.7), | |
('surcharge, 0.9) | |
) | |
def salary(config: Set[Symbol], base: Double) = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object GOption { | |
def some[A](a: A): GOption[A] = new GOption[A] { | |
def cata[B](n: => B, s: A => B): B = sys.error("Implement me") | |
} | |
def none[A]: GOption[A] = new GOption[A] { | |
def cata[B](n: => B, s: A => B): B = sys.error("Implement me") | |
} | |
} | |
trait GOption[+A] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def countMonotonicityBreaks(items: Seq[Int]): Int = | |
items.sliding(2). // two items at a time | |
filter(p => p.size == 2 && p(0) != p(1)). // remove any equalities | |
map{p => p(1).compare(p(0))}. // get -1 and 1 values; must have 2 values | |
sliding(2). // take *these* two at a time | |
count(p => p.size == 2 && p(0) != p(1)) // count when the differ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz.Order | |
case class WeightedConcept(id: String, weight: Double) | |
val concepts = List(WeightedConcept("one", 1.0), WeightedConcept("two", 0.5)) | |
val weightOrder: Order[WeightedConcept] = implicitly[Order[Double]].contramap[WeightedConcept](_.weight) | |
concepts.sorted(weightOrder.toScalaOrdering) | |
concepts.sorted(weightOrder.reverseOrder.toScalaOrdering) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; scala-mode2 found here: https://github.com/hvesalai/scala-mode2 is much better than the scala mode that comes with scalac | |
(add-to-list 'load-path "~/.emacs.d/scala-mode2/") | |
(require 'scala-mode) | |
; http://www.emacswiki.org/emacs/RainbowDelimiters | |
(add-hook 'scala-mode-hook 'rainbow-delimiters-mode) | |
; I get ensime from git: | |
; https://github.com/aemoncannon/ensime | |
; then run `sbt stage` inside the ensime source directory, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def split_random(n) | |
def td(n) | |
[take(n),drop(n)] | |
end | |
def split_random_acc(n,l, acc) | |
head,tail = l.td(rand(n)+1) | |
return (acc + [head]) if tail==[] | |
split_random_acc(n, tail, acc + [head]) |