Skip to content

Instantly share code, notes, and snippets.

View scogle's full-sized avatar
⛰️

Scott Ogle scogle

⛰️
View GitHub Profile
@scogle
scogle / toFlareRercursive.js
Created October 17, 2014 21:19
Recursively convert flat data to the nested flare format
var root = d3z.toFlareRecursive({
data: json,
parentKey: 'superClass',
childKey: 'thisClass',
nameKey: function(obj){
var prefix = obj['thisClass'].match(/\/([a-zA-Z_]*)\#/)[1],
name = obj['thisClass'].match(/\#(.*)>/)[1];
return prefix + ":" + name;
},
sizeKey: function(obj){
@scogle
scogle / SPARQLreturn.json
Last active August 29, 2015 14:07
Example results of a SPARQL query for tree data
{
"keys": ["thisClass", "superClass", "instances"],
"0": { "instances": 0,
"thisClass": "<http://ontologies.semanticarts.com/gist#Equipment>",
"superClass": "<http://ontologies.semanticarts.com/gist#PhysicalIdentifiableItem>" },
"1": { "instances": 0,
"thisClass": "<http://ontologies.semanticarts.com/gist#SomeParentClass>",
"superClass": "None" },
@scogle
scogle / flare.json
Last active August 29, 2015 14:07
An example of the "flare" structure
{
"name": "flare",
"children": [
{
"name": "analytics",
"children": [
{
"name": "cluster",
"children": [
{ "name": "AgglomerativeCluster", "size": 3938 },
@scogle
scogle / toFlareRecursive.js
Created October 7, 2014 16:30
New and improved method to convert recursive structure to the flare format
function toFlareRecursive(options) {
// data: object,
// parentKey: string,
// childKey: string,
// sizeKey: (optional) string or function,
// nameKey: string or function,
// rootName: (optional) string (only used if there's more than one top-level object)
// Return either the value of the name key or the result
@scogle
scogle / toFlareRecursive.js
Created October 6, 2014 19:28
Recursively convert ibeam parent/child output to flare format
function toFlareRecursive(data, parentKey, childKey) {
var root = { 'name': 'Classes', 'children': [] };
function findChildren(d){
var subclasses = _.filter(data, function(obj){
return obj[parentKey] === d[childKey];
});
if ( subclasses.length > 0 ) {
d.children = [];
_.each(subclasses, function(obj){
obj.name = obj.thisClass;
@scogle
scogle / data.json
Last active August 29, 2015 14:07
What is making this fail?
{
"key": "September",
"values": [
{
"key": "30",
"values": [
{
"key": "Semantic Arts",
"values": [
{
@scogle
scogle / nester.js
Last active August 29, 2015 14:07
d3.nest example
// Insert this at the top of the process() function
// This part just converts the flat objec to a flat array, nothing fancy
var flatty = [];
_.each(data, function(obj, key) {
if ( key !== 'keys' ) { flatty.push(obj); }
});
console.log(flatty);
var nested_data = d3.nest() // create the nest object
@scogle
scogle / holiday
Created September 29, 2014 20:29
Trust Me, I’m Lying
After reading “Trust Me, I’m Lying,” I’m inclined to take Holiday’s argument with a grain of salt.
I can’t escape the impression of an ex-con saying “I know scams but this is legit!”
He makes it crystal clear in the central thesis of the book--the media is rife for manipulation and
has even set itself up that way. The problem is that this throws into question Holiday’s
own credibility in writing this book. Why should I trust you if you’ve made it so clear
that your marketable skill is lying?
This is underscored perhaps by the oh-so-frequent mentions of one of Holiday’s flagship clients at the time,
the culturally questionable Tucker Max. I’m not taking issue with the citation of real world cases of
media manipulation; on the contrary I think it’s what lends the book what credibility it does have. But the
@scogle
scogle / cowork.html
Created August 26, 2014 23:59
d3 experiment
<!DOCTYPE html>
<html>
<head>
<title>Cowork</title>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
@scogle
scogle / gist:de32a947f24390553b38
Created August 18, 2014 21:43
sorry for partying
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sorry, the demo is over</title>
<style type="text/css">
html { background: #efefef; }
body {
width: 100%;
max-width: 500px;