Skip to content

Instantly share code, notes, and snippets.

Avatar
⛰️

Scott Ogle scogle

⛰️
View GitHub Profile
@scogle
scogle / toFlareRercursive.js
Created Oct 17, 2014
Recursively convert flat data to the nested flare format
View toFlareRercursive.js
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 Aug 29, 2015
Example results of a SPARQL query for tree data
View SPARQLreturn.json
{
"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 Aug 29, 2015
An example of the "flare" structure
View flare.json
{
"name": "flare",
"children": [
{
"name": "analytics",
"children": [
{
"name": "cluster",
"children": [
{ "name": "AgglomerativeCluster", "size": 3938 },
@scogle
scogle / toFlareRecursive.js
Created Oct 7, 2014
New and improved method to convert recursive structure to the flare format
View toFlareRecursive.js
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 Oct 6, 2014
Recursively convert ibeam parent/child output to flare format
View toFlareRecursive.js
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 Aug 29, 2015
What is making this fail?
View data.json
{
"key": "September",
"values": [
{
"key": "30",
"values": [
{
"key": "Semantic Arts",
"values": [
{
@scogle
scogle / nester.js
Last active Aug 29, 2015
d3.nest example
View nester.js
// 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 Sep 29, 2014
Trust Me, I’m Lying
View holiday
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
View cowork.html
<!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>
View gist:de32a947f24390553b38
<!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;