Skip to content

Instantly share code, notes, and snippets.

View rjurney's full-sized avatar

Russell Jurney rjurney

View GitHub Profile
@rjurney
rjurney / test.scala
Created June 17, 2014 23:16
Trying to build a Map inside a map operation
import javax.ws.rs.{QueryParam, GET, Produces, Path}
import scala.Array
import javax.ws.rs.core.{Response, MediaType}
import org.slf4j.{LoggerFactory, Logger}
import org.joda.time.format.{ISODateTimeFormat, DateTimeFormatter}
import org.joda.time.DateTimeZone
import com.securityx.modelfeature.dao.BeaconsDao
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
@rjurney
rjurney / test.sh
Created June 23, 2014 18:55
Failed checkout
Russells-MacBook-Pro:spark rjurney$ git checkout -b pyspark-inputformats mlnick/pyspark-inputformats
fatal: Cannot update paths and switch to branch 'pyspark-inputformats' at the same time.
Did you intend to checkout 'mlnick/pyspark-inputformats' which can not be resolved as commit?
@rjurney
rjurney / jruby.rb
Created June 26, 2014 03:22
Phoenix JDBC connection never returns...
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import com.salesforce.phoenix.jdbc.PhoenixDriver
Java::com.salesforce.phoenix.jdbc.PhoenixDriver
DriverManager.registerDriver("com.salesforce.phoenix.jdbc.PhoenixDriver")
conn = DriverManager.get_connection("jdbc:phoenix:hiveapp1,hiveapp2:2181")
log4j:WARN No appenders could be found for logger (org.apache.hadoop.conf.Configuration).
@rjurney
rjurney / grails.fail
Created June 26, 2014 22:15
Unable to run Lipstick server
[hivedata@hivedev1 lipstick-server]$ ./grailsw run-app
| Running Grails application
| Error 2014-06-26 15:14:08,239 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested
@rjurney
rjurney / udfs.py
Last active August 29, 2015 14:04
How can I optimize this Python code?
from pig_util import outputSchema
import sys, os, re
@outputSchema('matches:bag{t:tuple(name:chararray)}') # I am a pig schema
def match_names(one_name, all_names): #all_names is an array with 150,000 string elements
match_pairs = []
for name_tuple in all_names:
name = name_tuple[0]
match = one_name.find(name)
if match >= 0:
@rjurney
rjurney / happiness.pig
Last active August 29, 2015 14:04
How can I increase the parallelism of the happiness relation? Specifically the STREAM operation that defines the 'happiness' relation.
grouped = GROUP links BY (sourceNameOrIp, destinationNameOrIp, $filter);
sorted_grouped = FOREACH grouped {
sorted_datetimes = ORDER links BY date_time;
GENERATE FLATTEN(group) AS (sourceNameOrIp, destinationNameOrIp, $filter),
sorted_datetimes.(date_time) AS sorted_datetimes,
sorted_datetimes.(log_hash) as sorted_loghashes;
};
sorted_grouped = FOREACH sorted_grouped GENERATE sourceNameOrIp, destinationNameOrIp, $filter, sorted_datetimes, sorted_loghashes;
has_beacons = FILTER sorted_grouped by SIZE(sorted_datetimes) > 1;
has_beacons = FOREACH has_beacons GENERATE SIZE(sorted_datetimes) AS total;
@rjurney
rjurney / foo.json
Created August 12, 2014 22:00
Time Series Example
{
count: 63,
group: {
type: "cefSignatureId",
groupField: "206",
periodSeconds: 600
},
timeSeries: [
{
bitsOutPerSecond: 338021.6,
@rjurney
rjurney / foo.json
Created August 12, 2014 22:01
Time Series Example
{
count: 63,
group: {
type: "cefSignatureId",
groupField: "206",
periodSeconds: 600
},
timeSeries: [
{
bitsOutPerSecond: 338021.6,
@rjurney
rjurney / foo.sql
Created August 12, 2014 22:06
Entropy data in database
0: jdbc:phoenix:hiveapp1> select * from DEV_ENTROPY_TIME_SERIES limit 10;
+------------+-------------+----------------+------------+----------+
| TYPE | GROUP_FIELD | PERIOD_SECONDS | DATE_TIME | ENTROPY |
+------------+-------------+----------------+------------+----------+
| cefSignatureId | 0 | 3600 | 2014-06-11T16:00:00.000Z | 0.545344 |
| cefSignatureId | 0 | 3600 | 2014-06-11T16:10:00.000Z | 0.204304 |
| cefSignatureId | 0 | 3600 | 2014-06-11T16:20:00.000Z | 0.504859 |
| cefSignatureId | 0 | 3600 | 2014-06-11T16:30:00.000Z | 0.764432 |
| cefSignatureId | 0 | 3600 | 2014-06-11T16:40:00.000Z | 0.628618 |
| cefSignatureId | 0 | 3600 | 2014-06-11T16:50:00.000Z | 0.681011 |
@rjurney
rjurney / web_proxy_mef.json
Created August 12, 2014 22:11
Web Proxy MEF - raw records
{
u'applicationProtocol': u'http',
u'bytesIn': 1095,
u'bytesOut': 10733,
u'cefSignatureId': u'200',
u'destinationAddress': None,
u'destinationDnsDomain': u'on24.com',
u'destinationHostName': u'webcast.on24.com',
u'destinationMacAddress': None,
u'destinationNameOrIp': u'webcast.on24.com',