Skip to content

Instantly share code, notes, and snippets.

View alienrobotwizard's full-sized avatar

Esme Mora alienrobotwizard

  • BetterLesson
  • California
View GitHub Profile
@alienrobotwizard
alienrobotwizard / dagre.min.js
Created April 1, 2014 14:24
With 'cluster' branch of dagre; sane graph
(function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var j=typeof require=="function"&&require;if(!h&&j)return j(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}var f=typeof require=="function"&&require;for(var g=0;g<d.length;g++)e(d[g]);return e})({1:[function(a,b,c){var d=typeof self!="undefined"?self:typeof window!="undefined"?window:{};d.dagre=a("./index")},{"./index":2}],2:[function(a,b,c){c.Digraph=a("graphlib").Digraph,c.Graph=a("graphlib").Graph,c.layout=a("./lib/layout"),c.version=a("./lib/version"),c.debug=a("./lib/debug")},{"./lib/debug":3,"./lib/layout":4,"./lib/version":19,graphlib:25}],3:[function(a,b,c){var d=a("./util");c.dotOrdering=function(a){function e(b){var d=a.children(b);d.length?(c+="subgraph cluster_"+b+" {",c+='label="'+b+'";',d.forEach(function(a){e(a)}),c+="}"):(c+=b,a.node(b).dummy&&(c+=" [shape=diamond]"),c+=";")}var b=d.
@alienrobotwizard
alienrobotwizard / dagre.min.js
Created April 1, 2014 14:18
With 'cluster' branch of dagre
(function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var j=typeof require=="function"&&require;if(!h&&j)return j(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}var f=typeof require=="function"&&require;for(var g=0;g<d.length;g++)e(d[g]);return e})({1:[function(a,b,c){var d=typeof self!="undefined"?self:typeof window!="undefined"?window:{};d.dagre=a("./index")},{"./index":2}],2:[function(a,b,c){c.Digraph=a("graphlib").Digraph,c.Graph=a("graphlib").Graph,c.layout=a("./lib/layout"),c.version=a("./lib/version"),c.debug=a("./lib/debug")},{"./lib/debug":3,"./lib/layout":4,"./lib/version":19,graphlib:25}],3:[function(a,b,c){var d=a("./util");c.dotOrdering=function(a){function e(b){var d=a.children(b);d.length?(c+="subgraph cluster_"+b+" {",c+='label="'+b+'";',d.forEach(function(a){e(a)}),c+="}"):(c+=b,a.node(b).dummy&&(c+=" [shape=diamond]"),c+=";")}var b=d.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<style>
svg {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<style>
svg {
#!/usr/bin/env python
import os
import sys
import shutil
import random
import tempfile
import Queue
from org.apache.pig.scripting import Pig
%default STEPSIZE 0.1
import 'macros/linear_model.pig';
data = load '$data' as (x:double, y:double);
--
-- The weights are given a schema file by the python driver script
-- to avoid having to manually specify and arbitrarily large schema
-- with identical column schemas
/*
* Run one iteration of gradient descent for the given weights and features
* with step size alpha. Returns the updated weights.
*
* features - Relation with the following schema:
* {response:double, vector:tuple(f0:double,f1:double,...,fN:double)}
*
* w - Relation with **exactly one tuple** with the following schema:
* {weights:tuple(w0:double,w1:double,...,wN:double)}
*
@alienrobotwizard
alienrobotwizard / get_logical_plan.rb
Created September 9, 2013 12:34
Get Pig Logical plan easily without running script - jruby
#!/usr/bin/env jruby
require 'java'
PIG_JAR = File.join(ENV['PIG_HOME'], 'pig.jar')
require PIG_JAR
import 'java.util.Properties'
import 'java.io.FileReader'
raw_student_activity = load '$INSTITUTION_PATH/student_activity/*' using civitas.analytics.pig_udf.PigStorageAvroSchema('$STUDENT_ACTIVITY_SCHEMA');
raw_instructor_activity = load '$INSTITUTION_PATH/instructor_activity/*' using civitas.analytics.pig_udf.PigStorageAvroSchema('$INSTRUCTOR_ACTIVITY_SCHEMA');
student_count_mappings = load '/tmp/umuc/student_activity_count_mappings.csv' using PigStorage(',') as (cnt_name:chararray, activity_type:chararray, activity_name:chararray);
instr_count_mappings = load '/tmp/umuc/instructor_activity_count_mappings.csv' using PigStorage(',') as (cnt_name:chararray, activity_type:chararray, activity_name:chararray);
student_event_log = foreach (join raw_student_activity by activity_name left outer, student_count_mappings by activity_type) generate
student_id, section_id, term_id, activity_pk, timestamp,
(student_count_mappings::activity_name is null ? raw_student_activity::activity_type : student_count_mappings::activity_n
edges = LOAD 'graph.tsv' AS (v1:chararray, v2:chararray);
--
-- Augment the edges with the sizes of their outgoing adjacency lists.
--
grouped_edges = GROUP edges BY v1;
aug_edges = FOREACH grouped_edges GENERATE FLATTEN(edges) AS (v1, v2), COUNT(edges) AS v1_out;
aug_dups = FOREACH aug_edges GENERATE v1, v2, v1_out;
--
-- Compute the sizes of the intersections of outgoing adjacency lists