Skip to content

Instantly share code, notes, and snippets.

@darkseed
darkseed / CorsSupport.scala
Last active August 29, 2015 14:28 — forked from joseraya/CorsSupport.scala
CORS directive for Spray
package com.agilogy.spray.cors
import spray.http.{HttpMethods, HttpMethod, HttpResponse, AllOrigins}
import spray.http.HttpHeaders._
import spray.http.HttpMethods._
import spray.routing._
// see also https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
trait CORSSupport {
this: HttpService =>
@darkseed
darkseed / nnet_plot_update.r
Last active August 29, 2015 14:26 — forked from fawda123/nnet_plot_update.r
nnet_plot_update
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')
import numpy as np
from scipy.spatial.distance import cdist
def nearest_neighbor(samples, targets, samples_to_classify, metric='euclidean'):
return targets[np.argmin(cdist(samples_to_classify, samples, metric=metric), axis=1)]
@darkseed
darkseed / getcolor.py
Last active February 25, 2017 10:25 — forked from zollinger/getcolor.py
import Image, ImageDraw
def get_colors(infile, outfile, numcolors=10, swatchsize=20, resize=150):
image = Image.open(infile)
image = image.resize((resize, resize))
result = image.convert('P', palette=Image.ADAPTIVE, colors=numcolors)
result.putalpha(0)
colors = result.getcolors(resize*resize)
@darkseed
darkseed / lm_example
Last active August 29, 2015 14:23 — forked from yoavg/lm_example
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The unreasonable effectiveness of Character-level Language Models\n",
"## (and why RNNs are still cool)\n",
"\n",
"###[Yoav Goldberg](http://www.cs.biu.ac.il/~yogo)\n",
{
"tests": {
"buttoncolortst" : {
"description" : "Test which button color has a higher click-through.",
"version" : 1,
"rule" : null,
"constants" : {
},
"salt" : "buttoncolortst",
"buckets" : [ {
import sys
import numpy
from nltk.cluster import KMeansClusterer, GAAClusterer, euclidean_distance
import nltk.corpus
from nltk import decorators
import nltk.stem
stemmer_func = nltk.stem.EnglishStemmer().stem
stopwords = set(nltk.corpus.stopwords.words('english'))
  1. General Background and Overview
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
ADD JAR /opt/cloudera/parcels/CDH/lib/hive/lib/hive-contrib.jar;
DROP TABLE raw_log;
CREATE EXTERNAL TABLE raw_log(
IP STRING,
timestamp STRING,
URL STRING,
referrer STRING,
user_agent STRING)