Skip to content

Instantly share code, notes, and snippets.

View seliopou's full-sized avatar
💭
I may be slow to respond.

Spiros Eliopoulos seliopou

💭
I may be slow to respond.
View GitHub Profile
@seliopou
seliopou / _.md
Created November 6, 2015 17:30
Tributary inlet
@seliopou
seliopou / rdio_scrape.js
Last active November 17, 2015 23:05
Quick and dirty script to scrape a playlist from Rdio and print it to the console in a csv format.
/* rdio_scrape.js
*
* Quick and dirty script to scrape a playlist from Rdio and print it to the
* console in a csv format.
*
* XXX NB TODO READ THIS: Playlists are loaded lazily by Rdio, so make sure
* that when you navigate to a new playlist page you scroll from beginning to end
* and back again, making sure that all the songs have been rendered on the way
* back up.
*
@seliopou
seliopou / chart.js
Created December 18, 2012 21:57
A reusable chart combinator for D3.
var chart = (function() {
function copy(o) {
return Object.keys(o).reduce(function(no, k) {
no[k] = o[k];
return no;
}, {});
}
return function(defaults, _cstr) {
return function() {
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>twenty-five suns</title>
<style>
svg {
background: rgb(237, 237, 237);
}
path {
@seliopou
seliopou / _.md
Created February 18, 2013 23:11
orbitals

Instead of adding methods to d3.selection, make a transform its own object that you can define independently of a selection. So this...

d3.selectAll("g.label")
  .translate(function(d) { return [20,d.x*10]})
  .rotate(40)
  .scale(function(d) {return [d.size,2]})

... would turn into this:

@seliopou
seliopou / d3-transform-chaining.md
Last active December 15, 2015 16:09
A discussion of the API behavior of d3-transform.

d3-transform chaining

An unnecessarily thorough analysis

The Methods of d3.selection

When you look at the behavior of the methods on a d3.selection, they fall into one of two categories:

  • those that create a new selection, e.g., .filter(), .exit(), .enter(), .append(), etc.; and
  • those that mutate the existing selection, e.g., .attr(), .style(), on(), etc.

Question: Are these categories disjoint and exhaustive?

@seliopou
seliopou / gist:5623971
Created May 21, 2013 23:02
how to do that thing
var g = svg.selectAll('g')
.data(/* the data */)
g.enter().append('circle')
g.selectAll('circle')
.attr('r', function(d) { /* radius */ })
@seliopou
seliopou / Permutation.hs
Created July 17, 2013 16:10
Random Code, Permutations, and unsafePerformIO
module Permutation
( permute -- :: RandomGen g => [a] -> g -> ([a], g)
, permuteST -- :: RandomGen g => [a] -> g -> ST s ([a], g)
, permuteIO -- :: [a] -> IO [a]
, unsafePermute -- :: [a] -> [a]
) where
import Control.Monad ( foldM )
-- N.B. Unsafe operations have been deprecated in the original module and have
-- been moved to Control.Monad.ST.Unsafe.
@seliopou
seliopou / angstrom_perf.txt
Last active May 14, 2016 14:41
Angstrom benchmarks
$ ./pure_benchmark.native -q 30 +time # 4.02.3
Estimated testing time 1m (2 benchmarks x 30s). Change using -quota SECS.
┌──────┬──────────┬──────────┬───────────────┬─────────┬──────────┬──────────┬────────────┐
│ Name │ Time R^2 │ Time/Run │ 95ci │ mWd/Run │ mjWd/Run │ Prom/Run │ Percentage │
├──────┼──────────┼──────────┼───────────────┼─────────┼──────────┼──────────┼────────────┤
│ json │ 1.00 │ 21.16ms │ -0.59% +0.62% │ 18.67Mw │ 239.28kw │ 239.28kw │ 47.53% │
│ http │ 1.00 │ 44.52ms │ -0.28% +0.29% │ 32.01Mw │ 65.11kw │ 65.11kw │ 100.00% │
└──────┴──────────┴──────────┴───────────────┴─────────┴──────────┴──────────┴────────────┘
$ ./pure_benchmark.native -q 30 +time # 4.03.0+flambda
Estimated testing time 1m (2 benchmarks x 30s). Change using -quota SECS.