Skip to content

Instantly share code, notes, and snippets.

import java.util.*;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
public class Stupid {
public static void run() {
for(int N = 32; N<=1048576;N*=2) {
int[] x = new int[N];
Random rand = new Random();
import scalala.Scalala._;
import scalala.tensor._;
import scalala.tensor.dense_;
object KMeans {
// Returns the centers of the k clusters, and the clusters themselves
def cluster(data: Seq[Vector], k: Int): Seq[Vector] = {
var means = data.take(k);
var converged = false;
@dlwh
dlwh / gist:768617
Created January 6, 2011 21:27
guys, wtf.
from siu wendy <wendy.siu@yandex.ru>
to XXX
date Thu, Jan 6, 2011 at 12:49 PM
subject Happy New Year!
signed-by yandex.ru
hide details 12:49 PM (38 minutes ago)
Hola David!
alguien de gwangju me escribio s/meditacion y me dijo q me mando el correo
porque me inscribi a la lista q es mentira. ya la bloquee. aparte escuche q
@dlwh
dlwh / gist:787473
Created January 20, 2011 05:43
main method for MineMineMine
public static void main(String[] args) {
ProxyBotFactory factory = new ProxyBotFactory() {
@Override
public ProxyBot getBot(Game g) {
return new Overmind(new MineMineMine(), new Properties());
}
};
new ProxyServer(factory).run();
package edu.berkeley.nlp.starcraft.collect;
import java.util.AbstractCollection;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@dlwh
dlwh / gist:1163928
Created August 22, 2011 23:38
sparsematrix sketch
class SparseMatrix[V:Scalar] extends mutable.Matrix[V] {
def numRows = 0
def numCols = 0
def update(i: Int, j: Int, value: V) {}
val scalar = implicitly[Scalar[V]]
def apply(i: Int, j: Int) = null
trait Action {
// ...
def instantiate(inventory: ResourceMap[Resource], units: Iterable[Unit]):ActionMachine
}
class BuildAction(tpe: UnitType) extends AwesomeAction {
def instantiate(inventory: ResourceMap[Resource], units: Iterable[Unit]):ActionMachine = new ActionMachine {
@dlwh
dlwh / gist:1288112
Created October 14, 2011 19:46
visualize classifier
def visualize(trainer: Classifier.Trainer[Boolean,DenseVector[Double]],
data: Iterable[Example[Boolean,DenseVector[Double]]],
npoints: Int = 10000) = {
require(data.head.features.size == 3)
val classifier = trainer.train(data)
val xmin = data.map(_.features(1)).min
val xmax = data.map(_.features(1)).max
val ymin = data.map(_.features(2)).min
val ymax = data.map(_.features(2)).max
val points = for( v <- new HaltonSequence(2).sample(npoints)) yield DenseVector(1.0, xmin + (xmax - xmin) * v.data(0), ymin + (ymax - ymin) * v.data(1))
@dlwh
dlwh / gist:1360921
Created November 12, 2011 18:36
Birgeneau, see paragraph 5

To the Extended UC Berkeley Community:

As you know, yesterday an effort was made to establish an encampment on Sproul Plaza, by the "Occupy Cal" movement. This followed and marred the aftermath of an impressive, peaceful noontime rally on Sproul on behalf of public education, which was attended by some 3,000 participants and observers, including many campus leaders. We compliment the organizers and speakers for setting an example of peaceful protest and mobilization. As we informed the campus community earlier this week, we understand and share the concern of the Occupy movement about the extreme concentration of wealth in US society and the steady disinvestment in public higher education by California and other States.

We want to clarify our position on "no encampments" so you better understand why we do not allow this to occur on our campus. When the no-encampment policy was enacted, it was born out of past experiences that grew beyond our control and ability to manage safely. Past experiences at UC B

@dlwh
dlwh / gist:1756914
Created February 7, 2012 03:13
conll coref
nw/wsj/00/wsj_0020 0 0 The DT (TOP_(S_(NP_* - - - - * * (ARG0* * * * (11
nw/wsj/00/wsj_0020 0 1 U.S. NNP *) - - - - (GPE) * *) * * * 11)
nw/wsj/00/wsj_0020 0 2 , , * - - - - * * * * * * -
nw/wsj/00/wsj_0020 0 3 claiming VBG (S_(VP_* claim 01 2 - * (V*) (ARGM-ADV* * * * -
nw/wsj/00/wsj_0020 0 4 some DT (NP_(NP_* - - - - * (ARG1* * * * * -
nw/wsj/00/wsj_0020 0 5 su