Skip to content

Instantly share code, notes, and snippets.

View acanimal's full-sized avatar

Antonio Santiago acanimal

View GitHub Profile
@acanimal
acanimal / rasterize_element.js
Created September 16, 2012 14:25
Rasterize only the specified element instead the whole page (PhantomJS)
var page = require('webpage').create(),
system = require('system'),
address, output, size;
if (system.args.length < 4 || system.args.length > 6) {
console.log('Usage: rasterize_element.js URL filename selector [paperwidth*paperheight|paperformat] [zoom]');
console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
phantom.exit(1);
} else {
address = system.args[1];
@acanimal
acanimal / gist:4183609
Created December 1, 2012 17:59
SublimeText2 current user preferences
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"font_size": 10,
"highlight_line": true,
"rulers": [80,120],
"draw_minimap_border": true
}
@acanimal
acanimal / gist:4533748
Created January 14, 2013 21:34
Boilerplate code to create custom jQuery plugins
/**
* On the head set the plugin's name, version, author details and license
* for example, for example:
*
* ------------------------------------------------------------------------
*
* jquery-plugin.js Version 0.1
* jQuery Plugin Boilerplate code helps creating your custom jQuery plugins.
*
@acanimal
acanimal / gist:8198685
Created December 31, 2013 15:50
OpenLayers3, given an initial layer (a group or a single layer) finds recursively a layer with the specified key-value.
/**
* Finds recursively the layer with the specified key and value.
* @param {ol.layer.Base} layer
* @param {String} key
* @param {any} value
* @returns {ol.layer.Base}
*/
function findBy(layer, key, value) {
if (layer.get(key) === value) {
@acanimal
acanimal / gist:8348529
Created January 10, 2014 08:20
Full screen OpenLayers3 sample
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="http://ol3js.org/en/master/build/ol.css" type="text/css">
<style>
html, body {
width: 100%;
height: 100%;
}
body {
@acanimal
acanimal / README.md
Last active August 29, 2015 14:04
OL3 Canvas test

The pies are created in a loop:

for(i=0; i<1500; i++) {
  coordinates.push([-180+360*Math.random(), -90+180*Math.random()]);
  p = 100*Math.random();
  data.push([p, 100-p]);
  colors.push(['#'+(0x1000000+(Math.random())*0xffffff).toString(16).substr(1,6), '#'+(0x1000000+(Math.random())*0xffffff).toString(16).substr(1,6)]);
}

and rendered in the canvasFunction like:

@acanimal
acanimal / bootstrap-slider.js
Last active August 29, 2015 14:04
OL3+BT test
/* =========================================================
* bootstrap-slider.js v2.0.0
* http://www.eyecon.ro/bootstrap-slider
* =========================================================
* Copyright 2012 Stefan Petre
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@acanimal
acanimal / test_geom.html
Created August 2, 2014 16:09
Test geometries OL3
<!doctype html>
<html lang="en">
<head>
<title>The Book of OpenLayers3 - Theory and Practice</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="http://ol3js.org/en/master/css/ol.css">
@acanimal
acanimal / specification.js
Last active November 4, 2020 09:40
Specification pattern in JavaScript
"use strict";
/**
* Specification base class
* @class
*/
var Specification = {
and: function(spec) {
return new AndSpecification(this, spec);
},
@acanimal
acanimal / specification-callback.js
Created September 2, 2015 06:04
Specification pattern with callback style
"use strict";
/**
* Specification base class
* @class
*/
var Specification = {
and: function(spec) {
return new AndSpecification(this, spec);
},