Skip to content

Instantly share code, notes, and snippets.

@peterbraden
peterbraden / axis.js
Created August 10, 2017 12:41
D3 Axis with overlap avoidance.
var renderAxis = (axis, axelem, maxWidth) => {
var paint = function(x){
axis.ticks(x)
axelem.call(axis)
var width = d3.max(
d3.selectAll('.axes .tick')
.nodes()
.map( (x) => x.getBBox().width))
return (width * x < maxWidth)
}
@peterbraden
peterbraden / issues.md
Last active May 6, 2016 13:10
Tensorflow -> NodeJS Issues

Problem: Need to link to library ../../../bazel-out/tensorflow/libtensorflow.so

  • bazel-out is a symlink within a relative path -> need abspath. Current workaround:
'libraries': [
      #HACK
      "<!(python -c 'import os,sys; print os.path.realpath(sys.argv[1])' ../../../../tensorflow/bazel-bin/tensorflow/libtensorflow.so)"
    ],
@peterbraden
peterbraden / example.html
Created December 16, 2015 14:42
Tooltip sass mixin
<div class='tooltip'>
Hello world
</div>
<div class='t2'>
Hello world
</div>
2015-11-21 15:08:34,190 +0100 WARNING pid=45155 4641013760:Worker-1 downloads.pyo:481 Detected unsynced changes in /Users/peterbraden/Google Drive/Photos when applying DOWNLOAD-DELETE: [u'/Users/peterbraden/Google Drive/Photos/photos/2014/2014-08-09/DSCF9905.JPG', u'/Users/peterbraden/Google Drive/Photos/photos/2015/2015-07-02/DSCF7303.dng']
2015-11-21 15:08:34,190 +0100 ERROR pid=45155 4641013760:Worker-1 workers.pyo:213 Exception while processing change [ImmutableChange(Direction.DOWNLOAD, Action.DELETE, ino=6770201, name=u'Photos', rid=0B4BhBBbuWQqARE9aamNOQ3U0a1k, parent_ino=1590463, is_folder=True, is_cancelled=False, is_priority=False, doc_type=DocType.FOLDER, hash=-2213610710502213993, _constructor_called=True)]
LocalDownloadDeleteConflict: LocalDownloadDeleteConflict: u'Unsynced files within /Users/peterbraden/Google Drive/Photos', recovery plan: RecoveryPlan.UNKNOWN, recovery targets: set([])
More info: Traceback (most recent call last):
File "common/workers.pyo", line 186, in Process
@peterbraden
peterbraden / gist:b0a13390c50e25e1b4da
Last active August 29, 2015 14:09
Lightroom Corruption Post-mortem

I use Lightroom heavily to process my images. I have 400gb of pictures, so there really isn't any other option to manage such a large collection.

Because my photos are very important to me, I've invested serious thought and time into their backups. Even still, last night I realised that Lightroom had crashed, and the catalog had reverted to its state from around a month ago.

This means that I lost a huge amount of categorisation, sorting, and processing from the last month (conservative estimate, 20 hours work).

It appears that the images are intact, however the catalog that stores all 'collection' level metadata has gone.

I have several layers of backup. The first, Google Drive, was useless, as it had backed up the 'backed up' catalog. Because I had designed the backup system for loss, rather than corruption, I didn't have any versioning here, and Google Drive's versioning didn't have a working catalog.

@peterbraden
peterbraden / index.js
Created September 25, 2014 08:50
Retina.js with browserify
var retina = require('retina.js')
retina.Retina.init(window); // <-- Necessary to initialise with window.
@peterbraden
peterbraden / readme.md
Last active August 29, 2015 14:02
Front End Components

Front End Component Spec

In order to write reusable and modular FE code, we need a system to define modular components. This requires:

A Package Manager

FE components need to be installedto the right location with their dependencies.

Examples:

  • Bower
@peterbraden
peterbraden / 1-readme.md
Created May 28, 2014 15:24
Atomic Design Ideas

molecule

Atomic Design building block

You're building with Atomic Design:

myPage.js

var Template = require('molecule');

I don't know if you've heard of type 2 fun. Type 1 fun is the fun that we're all familiar with - eating ice cream in the sunshine with friends, that sort of deeply pleasant thing.

Type 2 fun is when you are hurting, tired, sweaty, kind of regretting life in a lot of ways, the sort of fun where you question you decisions. But afterwards, when you're drinking a beer, your muscles are all warm and glowing, you kind of think, that wasn't so bad, that was fun. That's type 2 fun! I kind of think of it as the Stockholm syndrome of fun.

Now I think if you get into most sorts of sports deeply enough, it kind of becomes type 2 fun - running marathons, triathlons, that sort of thing - those fall deeply into the realm of type 2 fun. But I can't think of a sport that embraces type 2 fun more wholly, more unabashedly, more completely, than mountaineering.

It's hard to argue that shivering in a blizzard at the top of an icy cliff above chasms of death in the worst sorts of weather the planet has is anything more tha

@peterbraden
peterbraden / hipache.pp
Created October 1, 2013 23:25
Hipache Puppet Manifest
class hipache {
include nodejs
include redis
package { 'hipache':
ensure => present,
provider => 'npm',
}