Skip to content

Instantly share code, notes, and snippets.

// Difference between setTimeout, setImmediate and process.nextTick
var emitter = new require('events').EventEmitter();
setTimeout(function() {
console.log('TIMEOUT 1');
}, 0);
setImmediate(function() {
console.log("IMMEDIATE 1");
});

Choropleth of spanish cities by population

Choropleth using D3.js - List of metropolitan areas in Spain

Information from Wikipedia

<!DOCTYPE html>
<html lang="en">
<head>
<title>dc.js - Spain 2016</title>
<meta charset="UTF-8">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/cosmo/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/dc/2.0.0-beta.25/dc.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css"/>
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.background {
fill: none;
pointer-events: all;
}
.feature {
@ackuser
ackuser / gist:ab43242745081d29421800568689d83a
Created May 23, 2016 10:43 — forked from eranation/gist:3241616
MongoDB Aggregation Framework way for "select count (distinct fieldName) from someTable" for large collections
//equivalent of "select count (distinct fieldName) from someTable"
db.someCollection.aggregate([{ $group: { _id: "$fieldName"} },{ $group: { _id: 1, count: { $sum: 1 } } } ])
@ackuser
ackuser / mongodb_distinct_count.js
Created May 23, 2016 10:43 — forked from clarkenheim/mongodb_distinct_count.js
MongoDB equivalent of an SQL query to get the distinct values of a field in a collection including the count of documents which have each distinct value (distinct with count)
//equivalent of MySQL "SELECT COUNT(*) AS `count`, `fieldName` FROM `someTable` GROUP BY `fieldName
db.someCollection.aggregate([{"$group" : {_id:"$fieldName", count:{$sum:1}}}]);
//as above but ordered by the count descending
db.someCollection.aggregate([{"$group" : {_id:"$fieldName", count:{$sum:1}}}, {$sort:{'count':-1}}]);
@ackuser
ackuser / Install-Docker-on-Linux-Mint.sh
Created September 27, 2016 14:18 — forked from sirkkalap/Install-Docker-on-Linux-Mint.sh
Install Docker on Linux Mint
##########################################
# To run:
# curl -sSL https://gist.githubusercontent.com/sirkkalap/e87cd580a47b180a7d32/raw/d9c9ebae4f5cf64eed4676e8aedac265b5a51bfa/Install-Docker-on-Linux-Mint.sh | bash -x
##########################################
# Check that HTTPS transport is available to APT
if [ ! -e /usr/lib/apt/methods/https ]; then
sudo apt-get update
sudo apt-get install -y apt-transport-https
fi
@ackuser
ackuser / AngularJS Provider Test Example
Created October 10, 2016 11:00 — forked from cesarandreu/AngularJS Provider Test Example
Example of how you can test your AngularJS providers.
Look at the README.
@ackuser
ackuser / todo-spec.js
Created October 10, 2016 15:57 — forked from andresdominguez/todo-spec.js
Sample protractor test for todo list in angularjs.org
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('http://www.angularjs.org');
element(by.model('todoText')).sendKeys('write a protractor test');
element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write a protractor test');
@ackuser
ackuser / index.html
Created October 18, 2016 08:41 — forked from anonymous/index.html
Crossfilter Examples Jazoon Crossfilter example 1: Dimensions // source http://jsbin.com/biruro
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js"
></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.11/crossfilter.min.js"></script>