Skip to content

Instantly share code, notes, and snippets.

View topicus's full-sized avatar

Mariano Carballal topicus

View GitHub Profile
@topicus
topicus / Web-Worker-HOS.js
Last active January 13, 2017 19:51
High Order Store for Web Workers
export const createSubscriber = (emmiter, store) => handler => {
emmiter.addEventListener('message', (message) => handler(message.data));
if (store) store.subscribe(handler);
};
export const createDispatcher = (emmiter, store) => action => {
emmiter.postMessage(action);
if (store) store.dispatch(action);
};
select(input) {
['option1', 'option2'] : 'label';
['otherOption', 'otherOption2'] : 'label2';
};
select('option1') // returns label
select('option2') // returns label
select('otherOption2') // returns label2
@topicus
topicus / notify
Created January 27, 2016 18:47
bash wrapper to display a notification after a process ends
#!/bin/bash
"$@"
osascript -e "display notification \"Command $1 ends\" with title \"Command status\""
var obj = {
0: 3,
3: 1,
"name": "Mariano",
"age": 32,
"language": "spanish",
"zip": 1425,
"weight": 102
};
var obj = {
"name": "Mariano",
"age": 32,
"language": "spanish",
"zip": 1425,
"weight": 102,
3: 1,
0: 3
};
@topicus
topicus / FizzBuzz.js
Last active October 31, 2015 16:53
Scalable implementation of FizzBuzz problem
'use strict';
for(let i = 1; i <= 100; i++) {
let out = '';
if(i % 3 == 0) {
out = 'fizz';
}
if(i % 5 == 0) {
@topicus
topicus / nvd3-labels-multibarchart.js
Created August 12, 2015 13:45
Add labels to MultiBarCharts in NVD3
// You need to apply this once all the animations are already finished. Otherwise labels will be placed wrongly.
d3.selectAll('.nv-multibar .nv-group').each(function(group){
var g = d3.select(this);
// Remove previous labels if there is any
g.selectAll('text').remove();
g.selectAll('.nv-bar').each(function(bar){
var b = d3.select(this);
var barWidth = b.attr('width');
@topicus
topicus / gist:4b2ee95b7576be2b5e89
Created May 27, 2015 21:04
panopoly general view
$view = new view();
$view->name = 'panopoly_widgets_general_content';
$view->description = 'Administrative view to show content.';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Panopoly General';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
@topicus
topicus / array-from-iterators.js
Created May 24, 2015 18:43
Array.from polyfill with support for iterators
// Production steps of ECMA-262, Edition 6, 22.1.2.1
// Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from
if (!Array.from) {
Array.from = (function () {
var iteratorTypes = [
'[object Map Iterator]', '[object Set Iterator]',
'[object WeakMap Iterator]', '[object WeakSet Iterator]'
];
var toStr = Object.prototype.toString;
@topicus
topicus / gist:6012b6d1cfb61ac80ab7
Last active August 29, 2015 14:18
Visualization entity migration | Destructive
# DROP
drush -y dis visualization_entity visualization_entity_recline_field_reference
drush -y dis uuidreference_select
drush -y pm-uninstall visualization_entity_cartodb_bundle
drush -y pm-uninstall visualization_entity_choropleth_bundle
drush -y pm-uninstall visualization_entity_geojson_bundle
drush -y pm-uninstall visualization_entity
drush -y pm-uninstall visualization_entity_recline_field_reference
drush -y pm-uninstall uuidreference_select