Skip to content

Instantly share code, notes, and snippets.

@sritchie
sritchie / WholeFile.java
Created February 2, 2011 17:32
Hadoop input format for swallowing entire files.
package forma;
import forma.WholeFileInputFormat;
import cascading.scheme.Scheme;
import cascading.tap.Tap;
import cascading.tuple.Fields;
import cascading.tuple.Tuple;
import cascading.tuple.TupleEntry;
import java.io.IOException;
import org.apache.hadoop.mapred.JobConf;
@oxbowlakes
oxbowlakes / 3nightclubs.scala
Created May 13, 2011 15:14
A Tale of 3 Nightclubs
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._
@softprops
softprops / build.sbt
Created August 16, 2011 06:53
unfiltered jsonp example
libraryDependencies ++= Seq(
"net.databinder" %% "unfiltered-jetty" % "0.4.1",
"net.databinder" %% "unfiltered-filter" % "0.4.1",
"net.databinder" %% "unfiltered-json" % "0.4.1"
)
@retronym
retronym / ordering-then-by.scala
Created November 5, 2011 23:33
Ordering thenBy
class RichOrdering[A](oa: Ordering[A]) {
def thenBy[B: Ordering](f: A => B): Ordering[A] = new Ordering[A] {
def compare(a1: A, a2: A) = oa.compare(a1, a2) match {
case 0 => Ordering[B].compare(f(a1), f(a2))
case x => x
}
}
}
implicit def ToRichOrdering[A](oa: Ordering[A]): RichOrdering[A] = new RichOrdering(oa)
@austinmarton
austinmarton / recvRawEth.c
Created June 3, 2012 07:55
Receive raw Ethernet frames in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <linux/ip.h>
@why-not
why-not / gist:4582705
Last active February 1, 2024 00:44
Pandas recipe. I find pandas indexing counter intuitive, perhaps my intuitions were shaped by many years in the imperative world. I am collecting some recipes to do things quickly in pandas & to jog my memory.
"""making a dataframe"""
df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
"""quick way to create an interesting data frame to try things out"""
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
"""convert a dictionary into a DataFrame"""
"""make the keys into columns"""
df = pd.DataFrame(dic, index=[0])
@jbilcke
jbilcke / create_video.py
Last active July 25, 2023 07:14
How to create a video using Gephi + Scripting plugin + ffmpeg
execfile("/your/path/to/videomaker.py")
videomaker(
ts_min=1352261778000, # "from" timestamp..
ts_max=1352262378000, # .."to" timestamp
frames=20, # number of images in the video. eg 200 frames for a video at 20 frames per seconds = 10 seconds of video
output_prefix="/path/to/output/dir/frame_", # path where to write the png. images will be prefixed with "frame_"
output_format=".png" # you probably want to leave png here
)
@mrflip
mrflip / tuning_storm_trident.asciidoc
Last active May 27, 2022 23:59
Notes on Storm+Trident tuning

Tuning Storm+Trident

Tuning a dataflow system is easy:

The First Rule of Dataflow Tuning:
* Ensure each stage is always ready to accept records, and
* Deliver each processed record promptly to its destination
@millermedeiros
millermedeiros / osx_setup.md
Last active May 7, 2024 08:01
Mac OS X setup

Setup Mac OS X

I've done the same process every couple years since 2013 (Mountain Lion, Mavericks, High Sierra, Catalina) and I updated the Gist each time I've done it.

I kinda regret for not using something like Boxen (or anything similar) to automate the process, but TBH I only actually needed to these steps once every couple years...

@ayosec
ayosec / Unpack.scala
Created October 6, 2013 12:41
Extract files with Apache Commons Compress, from any archive
package test
import org.apache.commons.compress.archivers.ArchiveStreamFactory
import org.apache.commons.compress.archivers.ArchiveInputStream
import org.apache.commons.compress.archivers.ArchiveEntry
import org.apache.commons.compress.compressors.CompressorStreamFactory
import scala.util.Try
import scala.util.Success
import scala.util.Failure
import java.io.InputStream