Skip to content

Instantly share code, notes, and snippets.

@thoroc
thoroc / 0_reuse_code.js
Last active August 29, 2015 14:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@thoroc
thoroc / README.md
Last active August 29, 2015 14:22 — forked from nitaku/README.md

For each hexagon in the tiling, draw its rectangular coordinates. The Y coordinate identifies the row, while the X identifies a sort of zig-zag column.

This type of coordinate system is widely used to address hexagons in a tiling, but has a drawback: It is not possible to interpret the coordinates of the hexes around the origin as unit vectors, therefore it is not possible in general to sum them to an hex position vector to obtain another one.

Compare with another take on hexagonal coordinates, which solves the problem.

Two example hexagons are also highlighted, to show the possibility of addressing an hexagon by using its coordinates.

@thoroc
thoroc / README.md
Last active August 29, 2015 14:22 — forked from ZJONSSON/README.md

d3.legend

d3.legend is a quick hack to add a legend to a d3 chart. Simply add a g and .call(d3.legend). Any elements that have a title set in the "data-legend" attribute will be included when d3.legend is called. Each title will appear only once (even when multiple items define the same data-legend) as the process uses a set based on a existing names, not an array of all items.

Color

By default the color in the legend will try to match the fill attribute or the stroke attribute of the relevant items. Color can be explicitly defined by attribute "data-legend-color"

Order

The order of items in the legend will be sorted using the top of the bounding box for each included item. The order can be explicitly defined by attribute "data-legend-pos"

<script src="jszip.min.js"></script>
<script src="FileSaver.min.js"></script>
<script src="https://raw.githubusercontent.com/Stuk/jszip/master/dist/jszip.min.js"></script>
<script src="https://raw.githubusercontent.com/eligrey/FileSaver.js/master/FileSaver.min.js"></script>
(function (main, modules) {
'use strict';
var zip = new JSZip();
for (var property in modules) {
#!/bin/bash
NOCOLOR='\e[0m'
REDCOLOR='\e[37;41m'
function usage {
code=${1:-0}
echo "Usage: $0 [-h] [-p] [-r] [-f] [-c] [-d css|js|f|b] [-e dev|prod] [project_name]
where:
@thoroc
thoroc / getlibs
Created October 30, 2013 14:48 — forked from linuxundich/getlibs
#!/bin/bash
#The MIT License
#
#Copyright (c) 2007 Cappy
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is