Skip to content

Instantly share code, notes, and snippets.

@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
#!/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:
<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) {
@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"

@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 / 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

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

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

Intro

Setup GitHub Pages "gh-pages" branch as a subfolder within the "master" project on your local checkout.

IMPORTANT

If you plan on switching between different branches (e.g. git checkout master-experiment then revert back with git checkout master) you will loose your child folder from this tutorial (because it's in your .gitignore and is not part of your master branch).

@thoroc
thoroc / fix-php-coding-style.sh
Last active May 3, 2017 13:55 — forked from zhouyl/fix-php-coding-style.sh
Fix PHP Coding Style for Symfony2 project
#!/bin/bash
# we are assuming php-cs-fixer installation path
BIN=/usr/local/bin/php-cs-fixer
# install php-cs-fixer
if [ ! -f $bin ]; then
echo "Preparing to install php-cs-fixer ..."
wget http://cs.sensiolabs.org/get/php-cs-fixer.phar -O $bin
chmod a+x $bin
@thoroc
thoroc / gist:a0b01517e1b156421403369543ba8690
Last active May 23, 2016 08:21 — forked from dfinzer/gist:8059ce0b43c476fcb986e8b3096aeafd
Command for creating new aliases from the previous command
## source: https://medium.com/the-lazy-developer/an-alias-for-new-aliases-c6500ae0f73e#.76kiw5euv
new-alias() {
local last_command=$(echo `history |tail -n2 |head -n1` | sed 's/[0-9]* //')
echo alias $1="'""$last_command""'" >> ~/.bash_profile
. ~/.bash_profile
}