Skip to content

Instantly share code, notes, and snippets.

Owen Smith orls

Block or report user

Report or block orls

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@orls
orls / paint-with-farage-head-scaling.js
Last active Aug 29, 2015
Dynamic Nigel Resizer for paintwithnigelfarage.com
View paint-with-farage-head-scaling.js
/**
* SuperDynamicHeadMode for http://paintwithnigelfarage.com
*
* Paste this script into browser's JS console.
*
* Controls:
* press/hold z to smallify Nigel
* press/hold x to embiggenate Nigel
*/
View README.md

Crude demo of a 'layered' force-layout graph.

Run flip() in JS console to switch layers. (You need to change the context fo the chrom dev console to the right iframe first, or use window.frames[0].flip())

This uses the character co-occurence in Les Misérables dataset from the canonical D3 force-layout demo.

The choice of what's in what layer is just based on even/odd-numbered node index. This selection mechanism, and the fact that the graph is very dense, means this might not be the most appropriate dataset to demo the 'layering', but hopefully it gives some hint of its potential.

The intent is that slightly different force-layout rules apply to different layers, giving them structural focus as well as visual.

View README.md

Click to add nodes! Nodes near the cursor will be linked to the new node.

D3's force layout uses the Barnes–Hut approximation to compute repulsive charge forces between all nodes efficiently. Links are implemented as geometric constraints on top of position Verlet integration, offering greater stability. A virtual spring between each node and the center of the chart prevents nodes from drifting into space.

@orls
orls / EnvDefault.py
Last active Nov 26, 2018
Using env vars in argparse
View EnvDefault.py
"""Provides a utility to inject environment variables into argparse definitions.
Currently requires explicit naming of env vars to check for"""
import argparse
import os
# Courtesy of http://stackoverflow.com/a/10551190 with env-var retrieval fixed
class EnvDefault(argparse.Action):
"""An argparse action class that auto-sets missing default values from env
vars. Defaults to requiring the argument."""
View d&b.md

Below content is authored by Darian Shirazi for forbes.com -- I'm just saving it for the record/sharing post-removal


Why Dun & Bradstreet's Monopoly Has Stifled Innovation For 100 Years (Part 1 Of 2)

Original from forbes.com 2013-08-19 13:43. Retrieved from yahoo cache 2013-08-22 00:20

From the movie Boiler Room: "Hey these are the D&B cards. These are our leads...These are good leads. People on these cards buy stock."

View TestDns.java
import java.net.InetSocketAddress;
public class TestDns {
public static void main(String[] args) {
System.out.println(sun.net.InetAddressCachePolicy.get());
InetSocketAddress unresolved = InetSocketAddress.createUnresolved("10.228.174.223", 8020);
System.out.println(unresolved.toString()); // prints 10.228.174.223:8020
System.out.println(unresolved.getHostName()); // prints 10.228.174.223:8020
@orls
orls / MetaObject.php
Created Sep 3, 2011 — forked from CHH/MetaObject.php
PHP does Meta Programming too! (Requires PHP 5.4)
View MetaObject.php
<?php
namespace CHH;
trait MetaObject
{
protected static $metaClass;
static function setMetaClass(MetaClass $metaClass)
{
@orls
orls / gist:870165
Created Mar 15, 2011
Determining freq. distribution buckets
View gist:870165

How to figure out numbers of buckets

Rough way to determine number of buckets/classes to split a dataset into, for frequency distribution analysis / histograms:

2ⁿ⁻¹ < α < 2ⁿ

where α is the size of the dataset.

In other words, find a power of 2 that yields a number just larger than the size of your dataset. Decrementing this power would yield a number smaller.

View loader.js
var fs = require('fs');
var http = require('http');
var path = require('path');
var console = require('sys');
var url = require('url');
var Script = process.binding('evals').Script;
var couchURL = url.parse(process.argv[2]),
couchUser = process.argv[3],
couchPass = process.argv[4],
You can’t perform that action at this time.