Choropleth using D3.js - List of metropolitan areas in Spain
Information from Wikipedia
// 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 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 { |
//equivalent of "select count (distinct fieldName) from someTable" | |
db.someCollection.aggregate([{ $group: { _id: "$fieldName"} },{ $group: { _id: 1, count: { $sum: 1 } } } ]) |
//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}}]); |
########################################## | |
# 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 |
Look at the README. |
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'); |
<!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> |