Skip to content

Instantly share code, notes, and snippets.

@dfletcher
dfletcher / tsws
Last active July 21, 2018 12:47
Totally simple web server using Bash and netcat (nc)
Moved to a proprer repositoy, TSWS is a real boy now!
https://github.com/dfletcher/tsws
PRs welcomed.
@johnynek
johnynek / scalding_alice.scala
Created July 18, 2014 17:15
Learn Scalding with Alice
/**
git clone https://github.com/twitter/scalding.git
cd scalding
./sbt scalding-repl/console
*/
import scala.io.Source
val alice = Source.fromURL("http://www.gutenberg.org/files/11/11.txt").getLines
// Add the line numbers, which we might want later
val aliceLineNum = alice.zipWithIndex.toList
@antonio081014
antonio081014 / BinaryTreeLevelTraversal.java
Created August 13, 2013 18:23
Yesterday(8/12/2013), I was asked to implement this problem Binary Tree Level-Order Traversal in a short time. For the first thought, it looks like an easy BFS problem, but quickly I realize a problem how can I track the level of the tree? Haha... At the end, I gave my solution, but the interviewee said my solution is most weird one he has ever …
/**
* This is a demo class in java <br />
* Implementing Binary Tree Traverse Level By Level with BFS and DFS. <br />
* All of the algorithm I implemented use O(N) time and space, N here represents the number of nodes in the tree.
*
*/
import java.util.LinkedList;
import java.util.Queue;
/**
@krishnanraman
krishnanraman / result
Last active December 15, 2015 13:39
Histogram of Normal distribution
import com.twitter.scalding._
import util.Random
// Produce a histogram with 10 bins, of n numbers with Gaussian distribution N(5,1) ~ mean 5, stdev 1.
class HistogramTest(args : Args) extends Job(args) {
def l2t10(x:List[Int]) = Tuple10(x(0), x(1),x(2),x(3), x(4),x(5),x(6), x(7),x(8),x(9))
val tuples = (1 to args("n").toInt).map( x=> Random.nextGaussian + 5)
val bins = 10
@jdegoes
jdegoes / DataScienceInScala.scala
Created February 8, 2013 15:11
Example code for the Creating a Data Science Platform in Scala talk.
object BenchmarkCommon {
import scala.util.Random
val DatasetSize = 10000
val Iterations = 10000
val ArrayPoolSize = 1000
val ArrayPool = {
def randomArray(): Array[Int] = {
val array = new Array[Int](DatasetSize)
@johnynek
johnynek / reach2.scala
Created November 1, 2012 20:35
Second followers in scalding
ackage com.twitter.ads.batch.experimental.oscar
import com.twitter.scalding._
import com.twitter.pluck.job._
import com.twitter.pluck.source._
import com.twitter.pluck.source.matrix._
import com.twitter.pluck.mathematics._
import com.twitter.scalding.mathematics.Monoid
/*
@surjikal
surjikal / monitoring-stack-ubuntu-precise.md
Created May 23, 2012 21:18
Installing a complete monitoring stack on Ubuntu 12.04

Follow these steps to install Graphite on a fresh Ubuntu 12.04 instance. Make sure you read and understand the commands because by the time you read this, things could be outdated.

Graphite

Installing dependencies

# apt-get install libpq-dev
# apt-get install python-dev python-pip python-cairo python-psycopg2
# apt-get install python-django python-django-tagging
@whiter4bbit
whiter4bbit / gist:2011424
Created March 10, 2012 13:31
Dijkstra using scalding
import com.twitter.scalding._
class DijkstraJob(args: Args) extends Job(args) {
val iteration = args.getOrElse("iteration", "0").toInt
Tsv(args("input"), ('node, 'dist, 'adjacent))
.read
.flatMap(('node, 'dist, 'adjacent) -> ('node, 'dist, 'adjacent)) { p: (String, Int, String) =>
val (node, distance, adjacent) = p
(node, distance, adjacent) +: adjacent.split(":").map { part: String =>
@sixtenbe
sixtenbe / analytic_wfm.py
Last active May 27, 2024 01:24 — forked from endolith/peakdet.m
Peak detection in Python
#!/usr/bin/python2
# Copyright (C) 2016 Sixten Bergman
# License WTFPL
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law.
# You can redistribute it and/or modify it under the terms of the Do What The
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See