This file contains hidden or 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 com.twitter.scalding._ | |
import com.twitter.algebird.{ MinHasher, MinHasher32, MinHashSignature } | |
/** | |
* Computes similar items (with a string itemId), based on approximate | |
* Jaccard similarity, using LSH. | |
* | |
* Assumes an input data TSV file of the following format: | |
* | |
* itemId userId |
This file contains hidden or 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
plot.nnet<-function(mod.in,nid=T,all.out=T,all.in=T,bias=T,wts.only=F,rel.rsc=5, | |
circle.cex=5,node.labs=T,var.labs=T,x.lab=NULL,y.lab=NULL, | |
line.stag=NULL,struct=NULL,cex.val=1,alpha.val=1, | |
circle.col='lightblue',pos.col='black',neg.col='grey', | |
bord.col='lightblue', max.sp = F,...){ | |
require(scales) | |
#sanity checks | |
if('mlp' %in% class(mod.in)) warning('Bias layer not applicable for rsnns object') |
This file contains hidden or 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
// genrate all combinations of integers in range from 0 to `len`-1 | |
// fast as fuck | |
def combIdxs(len: Int, k: Int): Iterator[Array[Int]] = { | |
val arr = Array.range(0, k) | |
arr(k-1) -= 1 | |
val end = k-1 | |
Iterator.continually { | |
arr(end) += 1 | |
if (arr(end) >= len) { |
This file contains hidden or 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 cascading.tuple.{Fields, TupleEntry} | |
import com.twitter.scalding._ | |
import java.net.URLDecoder | |
import scala.util.matching.Regex | |
class BoomerangLogJob(args: Args) extends Job(args) { | |
val input = TextLine(args("input")) | |
val output = TextLine(args("output")) | |
val trap = Tsv(args("trap")) |
This file contains hidden or 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 knapsack_aux(x: (Int, Int), is: List[Int]): List[Int] = { | |
for { | |
w <- is.zip(is.take(x._1) ::: is.take(is.size - x._1).map(_ + x._2)) | |
} yield math.max(w._1, w._2) | |
} | |
def knapsack_rec(xs: List[(Int, Int)], is: List[Int]): List[List[Int]] = { | |
xs match { | |
case x :: xs => knapsack_aux(x, is) :: knapsack_rec(xs, knapsack_aux(x, is)) | |
case _ => Nil |
This file contains hidden or 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
// Taken from the commercial iOS PDF framework http://pspdfkit.com. | |
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved. | |
// Licensed under MIT (http://opensource.org/licenses/MIT) | |
// | |
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it. | |
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit. | |
#import <objc/runtime.h> | |
#import <objc/message.h> |
This file contains hidden or 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 mincepie import mapreducer, launcher | |
import gflags | |
import glob | |
import leargist | |
import numpy as np | |
import os | |
from PIL import Image | |
import uuid | |
# constant value |
This file contains hidden or 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
You can use cURL to upload packet captures to Packetloop. We created a simple script that shows how to login, list capture points, create capture points, upload and also check processing status. | |
## variables | |
PL_ENDPOINT=https://www.packetloop.com | |
PL_USERNAME=... # your packetloop email address | |
PL_PASSWORD=... # your packetloop password | |
## logging in | |
PL_TOKEN=$(curl -3 -s -b cookies.jar -c cookies.jar -X GET "$PL_ENDPOINT/init") | |
curl -3 -s -H "X-CSRF-Token: $PL_TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -b cookies.jar -c cookies.jar -X POST "$PL_ENDPOINT/users/sign_in.json?pretty=true" -d "{ \"user\": { \"email\": \"$PL_USERNAME\", \"password\": \"$PL_PASSWORD\" } }" |
This file contains hidden or 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 celery import chain | |
from django.core.management.base import BaseCommand | |
from . import tasks | |
class Command(BaseCommand): | |
def handle(self, *args, **kwargs): |
This file contains hidden or 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
# Cross-matrix distances and different measurement options, with "proxy" | |
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("proxy", "MASS", "Zelig") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Invent two data frames | |
voterIdealPoints <- data.frame(matrix(rnorm(26*2), ncol = 2)) | |
rownames(voterIdealPoints) <- letters |