Skip to content

Instantly share code, notes, and snippets.

View gustavohenke's full-sized avatar

Gustavo Henke gustavohenke

View GitHub Profile
@gustavohenke
gustavohenke / svg2png.js
Created February 18, 2014 15:27
SVG to PNG
var svg = document.querySelector( "svg" );
var svgData = new XMLSerializer().serializeToString( svg );
var canvas = document.createElement( "canvas" );
var ctx = canvas.getContext( "2d" );
var img = document.createElement( "img" );
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) );
img.onload = function() {
@gustavohenke
gustavohenke / collect-angular-scopes.js
Last active December 28, 2019 01:50
Collect all Angular.js scopes
function collect( element ) {
var scope;
var watchers = [];
element = angular.element( element );
scope = element.data("$scope");
if ( scope ) {
watchers = scope.$$watchers || watchers;
}

Keybase proof

I hereby claim:

  • I am gustavohenke on github.
  • I am gustavohenke (https://keybase.io/gustavohenke) on keybase.
  • I have a public key whose fingerprint is 1FFB E83F 4C57 C8D0 A65C 4388 7A48 53C4 38D5 C9BB

To claim this, I am signing this object:

@gustavohenke
gustavohenke / windows_restart.sh
Last active January 10, 2018 00:24
"Windows restart"
# Put me in your .bash_profile and enjoy rainy days reinstalling deps
windows_restart() {
rm -rf node_modules
if [ -f "yarn.lock" ]; then
yarn
else
npm install
fi
}
/**
* Recursively unions the types of the properties of T.
* TODO: Deal with arrays
*
* @example
* type SomeObject = { a: { b: { c: boolean } }, d: string };
* const x: DeepUnion<SomeObject>; // boolean | string
*/
type DeepUnion<T extends object> = {
[K in keyof T]: T[K] extends object ? DeepValues<T[K]> : T[K];