eurica

numbers for people.

June 8, 2014
by dave
Comments Off

Using Pebble.js to hit PagerDuty

Pebble released a JavaScript-only API.

To try it out, I threw together a quick script that polls the PagerDuty API for the number of incidents assigned to a user and then vibrates & updates the screen when it changes.

  • I installed the SDK & forked this project.
  • Make the basic changes to appinfo.json
  • All of the interesting code went in app.js
  • Running pebble build rolls app.js and the PebbleJS library up into a 7-8000 line pebble-js-app.js
  • pebble install --phone 192.168.1.29 sends it over.

All told, it was pretty easy,

PebbleJS makes it really easy to throw up a basic UI:

Ordinarily I’d use PDJS, but PebbleJS exposes an ajax object that’s slightly different than jQuery’s 1. Either way the code to hit our API is pretty easy:

Still haven’t figured out configuration side of things, so I’ve just hard coded a read-only UI key for my webdemo account:

Giving the user feedback is pretty easy:

If this is the kind of thing that you want to be involved in, come work at PagerDuty.

  1. As always, I found Runscope invaluable in figuring out what was going on.

May 20, 2014
by dave
Comments Off

Typed Array performance in JavaScript

I was looking at a few JavaScript implementations of Conway’s Game of Life and I was a little underwhelmed by their performance, so I started wondering how much was related to Array performance in JavaScript.

There’s a better option for arrays of ints: Typed Arrays, the smallest object they can store is an 8 bit byte (I only need a boolean), but that’s still a lot less complicated than a full JS object.

Results:
I tested on Firefox and Chrome on a modern MacBook Pro and an old Windows 7 machine. In every case, typed arrays were faster than plain arrays.

Interestingly, Chrome was slightly faster operating on 32 bit words

On Chrome the typed arrays were ~3x faster, on Firefox they were 25% faster. Somehow Firefox managed to take over 12x as long on my old windows box.

Browser (Machine) Int8Array Int32Array Array
Chrome (MacBook Pro) 216.541ms 198.340ms 723.414ms
Firefox (MacBook Pro) 199.7ms 198.96ms 252.67ms
Chrome (Old Win7) 668.000ms 564.000ms 1878.000ms
Firefox (Old Win7) 7355.06ms 7163.35ms 9494.34ms

To test yourself, you can use this code (output goes to the browser console).
Continue Reading →

February 12, 2014
by dave
Comments Off

PagerDuty & Ruby with HTTParty

I’m trying to do more of my hackdays in Ruby, since it’s practically the lingua franca of San Francisco. Since we don’t have an official Ruby library, I used HTTParty.

You’re more then welcome to use it: https://gist.github.com/eurica/8951769

#This is a read-only API key:
webdemo = PagerDuty.new("webdemo","BcRghqyTqokgfx3ADXiq")
# Get incidents:
puts webdemo.get("incidents", :query => "limit=1")

Continue Reading →

January 9, 2014
by dave
Comments Off

Stop LinkedIn from showing candidates’ pictures

ghost_person_200x200_v1I spend a lot of time screening candidates for PagerDuty, and even if it doesn’t mesh with my gut the science says I might be subconsciously favouring mustaches, or be biased towards or against attractive people. So it’s counter-productive to my goals that LinkedIn keeps showing me photos of applicants — enough so that I decided to fix it.

Ideally I’d also swap names for initials since I don’t care about your gender or ethnicity, just what you can do. That’s a little harder since every tool and cultural convention along the way identifies people that way — and sooner or later I’m going to meet the stronger candidates anyway.

Blocking user images from LinkedIn:

User Styles with Stylish (the easy way)

I made a script available on userstyles.org that you can install with on click if you have Stylish

Custom.css in Chrome (the way I did it)

The fact that Stylish wants to “Access your data on all websites, Access your tabs and browsing activity” means that I only turn it on during development.

Chrome lets you specify a Custom.css (most browsers have some equivalent), so I added the following to mine1:

/* LinkedIn Main profile picture, specific enough to not trigger on other sites: .profile-card .profile-picture img */
.profile-card .profile-picture img {
content: url(https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&f=y);
}

And there you go, hopefully it’s worth a minute or two to judge resumes on their content.

  1. Actually, the first thing I tried was to make a user script, GreaseMonkey a simple:

    // ==UserScript==
    // @match http://*.linkedin.com/*
    // ==/UserScript==
    $(".profile-picture a img").attr("src","about:blank")

    But it turned out that the picture was often displayed before jQuery was loaded (which is solvable with old timey raw DOM code) but GreaseMonkey tended to run after the image was displayed, so that’s a non-starter.

December 13, 2013
by dave
Comments Off

Solving Unblockme

I’m really bad at enjoying games, I keep getting distracted and trying to build a bot to beat the game. Unblock Me is an adorable puzzle game for mobile, here’s what I learnt about it.

Unblock_Me_puzzle9The first step was to represent the puzzles. as text. So puzzle 9 would be:

<->^++
^<>|<>
|:)v+^
v+^<>|
++v+^v
<->+v+

The Smiley face represents the red block, the others are fairly self-explanatory. The nice thing about this format is there’s a very simple pattern to look for for possible moves: is there something pointed at a plus sign? (Or a plus beside the smiley)

Solving a puzzle is as simple as doing a breadth first search:

  1. For every board layout we know about (at the beginning it’s just the start board) calculate all the possible boards that we can do in one move.
  2. Did we get the smiley face to column 5? If so: win!
  3. For every board that we don’t know about yet, add it to the list (and record which board it came from as the parent).
  4. Count how many times we’ve been through this and loop over it again.

Once we’ve found a winning board, we know it’s the shortest path since we’ve tried every other set of that many moves. And we can find the solution path by looking following the parents back to the starting board.
Continue Reading →

December 9, 2013
by dave
Comments Off

Yet another thing drones would do better: escort surveillance planes

[Dec 31st Update: The US Navy is on it]

This is a little outside my wheelhouse, but when I read this article about a simulated encounter between Chinese J-11s and J-10s and Japanese P-3C Orion with F-15Js and SAM platforms.

An F-22 costs $150 million, I couldn’t find pricing for an F-15J, but the Korean variant costs $100 million so I assume the same ballpark. Thus the Japanese/American side in this conflict is flying three-quarters a billion dollars in hardware with 10 crew but the entire encounter was determined by long range missiles (that cost about half a million each).

Looking just at the escort role (in this story: $200 million in hardware and 4 crew), it seems like something that drones could take over easily. For comparison an Avenger drone 1 only goes a third as fast as the fighter jets, but at $15 million, it can more than keep up with the P-3C in the story and carry 3 tonnes of weapons. Avengers aren’t designed for air-to-air combat, but it isn’t hard to imagine a similar drone, optimized to carry long range air-to-air missiles that could carry 6-8 AIM-120 AMRAAM. An escort drone could even sacrifice stealth for lower cost or increased performance since the surveillance craft or transport that it would be escorting would light up the radar anyway and it would be preferable for any missile to hit the drone instead.

Arguably 4 drones with 24-32 missiles would also need far fewer pilots, as following another plane in formation is probably well within the capabilities of a drone. In the rare event of hostile action, more pilots could be pulled off more routine missions. Either some or all of the drones could peel off and participate in modern day dog-fighting — get missile lock, fire, repeat, and then try to evade missiles fired at you. Drones of course, could stand their ground and accept being blown up as the (much lower) cost of doing business. (As an added bonus, this suicidal charge is exactly when the missile performs best.)

There’s also the obvious question of whether short-range missiles will ever have a place in dog-fighting again (or if “dog-fighting” will ever happen again in any recognizable form) and why long range air-to-air missiles don’t get a fraction of the attention that the F-35 gets (except apparently, from the Russians). If all missiles have the same range, the faster planes still need to come to the slower drone in order to fine — negating much of the benefit of their speed.

I’m sure I’m missing something, but for the task of escorting a plane that can’t get over 400 knots, drones seem perfect.

  1. The Avenger is still under development, but this is just spitballing — fun fact: it has engines made in Canada!