Skip to content

Instantly share code, notes, and snippets.

View bigsnarfdude's full-sized avatar

BigsnarfDude bigsnarfdude

View GitHub Profile
@bigsnarfdude
bigsnarfdude / gist:a7bb5bb86121d4e74788
Last active August 29, 2015 14:04
Employee Monoid Example for Algebird
case class Employee(val age:Int, val tenure:Int, val salary:Int, val name:String)
case class Monoid(e:Set[Employee]) {
def plus(a:Employee, b:Employee) = {
if (a.age > b.age) a else
if (b.age > a.age) b else
if (a.tenure > b.tenure) a else
if (b.tenure > a.tenure) b else
if (a.salary > b.salary) a else
if (b.salary > b.salary) b else
@bigsnarfdude
bigsnarfdude / gist:ef2b0bc7e555842b56b1
Last active August 29, 2015 14:04
IP Address Monoid for Algebird
import com.twitter.algebird.Operators._
case class IPRecord(val SRCipAddress: String, val DSTipAddress: String, val number: Int) extends Ordered[IPRecord] {
def compare(that: IPRecord): Int = {
val c = this.number - that.number
if (c == 0) this.DSTipAddress.compareTo(that.DSTipAddress) else c
}
object KafkaSpark {
def main(args: Array[String]): Unit = {
if (args.length < 4) {
System.err.println("Usage: KafkaSpark <zkQuorum> <group> <topics> <numThreads>")
System.exit(1)
}
val Array(zkQuorum, group, topics, numThreads) = args
@bigsnarfdude
bigsnarfdude / gist:d217f8a1a6c4aebbf6ea
Created August 9, 2014 05:04
wordcount akka style
import akka.actor.{ Actor, ActorRef, Props, ActorSystem }
case class ProcessStringMsg(string: String)
case class StringProcessedMsg(words: Integer)
class StringCounterActor extends Actor {
def receive = {
case ProcessStringMsg(string) => {
val wordsInLine = string.split(" ").length
@bigsnarfdude
bigsnarfdude / gist:a0584f1eebe241e8704e
Last active August 29, 2015 14:05
Akka WordCount REPL example
// import the AKKA Actor System
import akka.actor.{ Actor, ActorRef, Props, ActorSystem }
// create a couple of records for each word and overall counter
case class ProcessStringMsg(string: String)
case class StringProcessedMsg(words: Integer)
// actor returns a count of words in each line
class StringCounterActor extends Actor {
def receive = {
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
object test {
def main(args: Array[String]) {
val master = "spark://ec2-xx-xx-xxx-xxx.eu-west-1.compute.amazonaws.com:7077"
val sparkHome = "/home/ubuntu/spark/"
@bigsnarfdude
bigsnarfdude / gist:5c899b0383b893455cea
Created August 10, 2014 17:13
random algebird monoids WIP
case class Employee(val age:Int, val tenure:Int, val salary:Int, val name:String)
case class Monoid(e:Set[Employee]) {
def plus(a:Employee, b:Employee) = {
if (a.age > b.age) a else
if (b.age > a.age) b else
if (a.tenure > b.tenure) a else
if (b.tenure > a.tenure) b else
if (a.salary > b.salary) a else
@bigsnarfdude
bigsnarfdude / gist:e09c9bcd0ca5a97e5571
Created September 5, 2014 02:35
Another Scalazon Example Setting the Endpoint
import io.github.cloudify.scala.aws.kinesis.Client
import io.github.cloudify.scala.aws.kinesis.Client.ImplicitExecution._
import io.github.cloudify.scala.aws.kinesis.KinesisDsl._
import io.github.cloudify.scala.aws.auth.CredentialsProvider.DefaultHomePropertiesFile
import java.nio.ByteBuffer
import scala.concurrent.duration._
import scala.concurrent.{Future, Await}
import scala.concurrent.ExecutionContext.Implicits.global
// Declare an implicit Kinesis `Client` that will be used to make API calls.
@bigsnarfdude
bigsnarfdude / gist:5c904ecfc32b46433c65
Created September 8, 2014 17:52
twitterLoader.py
import tweepy
from py2neo import neo4j
consumer_key = "HsYoJ1______Key_Here_______bFh0w"
consumer_secret = "k6D4o6fNBy______Key_Here_________PpZ1vFak86A7m4"
access_token = "364557525-HwlP7I___________Key_Here______mZw8dBRBmIXMFLgS"
access_token_secret = "SF5faO7iNKI_________Key_Here_______p5Aw1304Vbik5D"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
@bigsnarfdude
bigsnarfdude / gist:206d7c32009f48914e27
Created September 23, 2014 05:52
windows forensics
cmd.exe /c set >> CCSAuditDec2010.txt
arp -a >> CCSAuditDec2010.txt
netstat -ns >> CCSAuditDec2010.txt
net accounts >> CCSAuditDec2010.txt
gpresult /V >> CCSAuditDec2010.txt
netstat -ano >> CCSAuditDec2010.txt
tasklist -svc >> CCSAuditDec2010.txt
netstat -ab >> CCSAuditDec2010.txt
route print >> CCSAuditDec2010.txt
ipconfig /all >> CCSAuditDec2010.txt