Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/bash
# You might want to note your old MAC address here. Use this to get it:
# ifconfig en0 | grep ether
MAC_ADDRESS=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
echo "Setting MAC address..."
sudo ifconfig en0 ether $MAC_ADDRESS
ifconfig en0 | grep ether
@graste
graste / eierschalensollbruchstellenverursacher.md
Last active August 29, 2015 13:56
Eierschalensollbruchstellenverursacher
@graste
graste / agavi_routing_gen_options_presets.md
Last active August 29, 2015 13:57
Agavi Routing Options Presets

Agavi gen_options_presets

$route = $this->getContext()->getRouting()->gen('', array(), 'websocket_server');

Result:

ws://project.host.local:8080/
@graste
graste / links.md
Created April 4, 2014 09:38
inuitcss snippets und fiddles
@graste
graste / gist:9972895
Created April 4, 2014 11:47
bower security implications
(12:52:26 PM) The topic for #bower is: Bower package manager • http://bower.io • http://bower.io/search/ • https://github.com/bower • Dev meetings Monday 1:00pm PST, 8:00pm UTC
(12:55:20 PM) graste: hi, noobie question perhaps, but I couldn't find something in the docs that answers it:
(12:55:20 PM) graste: when libs in their bower.json specify too much (and don't do 'ignore: "*"' except the dist/min version)
(12:55:20 PM) graste: is it still the opinion to put bower_components in the pub directory?
(12:55:20 PM) graste: I don't want files that are not necessary - especially for security reasons like someone putting a shady-shiny-upload-example.php in their dist directory
(12:55:27 PM) graste: how does bower handle something like that
(12:55:30 PM) graste: does it at all?
(12:56:06 PM) graste: tl;dr: can I ignore in my project's bower.json everything except dist files?
(12:56:56 PM) zecho left the room (quit: Ping timeout: 265 seconds).
(12:57:50 PM) Munter: Why is this a problem? Other than bandwidth wasted

The map shows traffic accidents recorded in Oslo, Norway, for the year 2013.

The Leaflet Markercluster plugin is wonderful. Since the markerclusters are divIcons you can put whatever you want inside them using the iconCreateFunction. I wanted my clusters to reveal more information than just the marker count and figured a pie chart would do the job. So I told the iconCreateFunction to do some D3 magic and this is the result.

The example is a bit more complicated than necessary due to how my dataset is structured. But if you take a look at the defineClusterIcon() function you'll see that I use d3.nest() to build a dataset for the pie chart based on a given property from all the cluster's children. Then I pass this dataset over to the bakeThePie() function together with instructions on how to style the chart. The function returns svg markup which in turn is placed inside the divIcon.

Feel free to suggest improvements.

// ----
// Sass (v3.3.4)
// Compass (v1.0.0.alpha.18)
// ----
// -----------------------------------------------------------------------------
// Introduction
// -----------------------------------------------------------------------------
// Here is hacky and experimental solution for cross-scopes extends
// ----
// Sass (v3.3.5)
// Compass (v1.0.0.alpha.18)
// ----
// Breakpoint maps
// @key: name of breakpoint
// @value: map of settings for breakpoint
// -@key: type of media query
// -@value: value for current type
// ----
// Sass (v3.3.4)
// Compass (v1.0.0.alpha.18)
// ----
// Here is a map containing all placeholders
// (Follow-up from: http://hugogiraudel.com/2014/03/31/getting-the-most-out-of-sass-placeholders/)
// ---
// - The key is the placeholder's name
// - The value is a map of declarations for the placeholder's content
// Brightness math based on:
// http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
$red-magic-number: 241;
$green-magic-number: 691;
$blue-magic-number: 68;
$brightness-divisor: $red-magic-number + $green-magic-number + $blue-magic-number;
@function brightness($color) {
// Extract color components