Skip to content

Instantly share code, notes, and snippets.

View fernandocanizo's full-sized avatar
🎃
Working from home

Fernando Lucio Canizo fernandocanizo

🎃
Working from home
View GitHub Profile
# npm basics
- Install packages locally under node_modules directory:
```
npm install <package_name>
```
- Install packages globally, useful for applications:
```
sudo npm install -g <package_name>
@fernandocanizo
fernandocanizo / node.js.tools.and.libraries.txt
Created May 23, 2015 03:44
Node.js tools and libraries
# Node.js tools and libraries
## Tools
- Monitor for any changes in your source code and automatically restart your server
In development:
```
sudo npm install -g nodemon
@fernandocanizo
fernandocanizo / logger.js
Created October 7, 2015 13:28 — forked from CootCraig/logger.js
PhantomJs logger, logs to file and console.
// logger = require('logger');
// logger.log_to_console(true);
// logger.log_to_folder('log','_app.log');
// logger.set_log_level('DEBUG');
// logger.info('Happy to be here.');
exports.logger = (function() {
var that = {};
that.levels = {
"TRACE": 0,
"DEBUG": 1,
@fernandocanizo
fernandocanizo / gist:86d2430ae9b8d416ab19
Created December 21, 2015 02:29 — forked from mapio/gist:1050635
A test comparing defaultdict and groupby for grouping
from timeit import Timer
from operator import attrgetter
from random import randint
def timeit( stmt, setup ):
t = Timer(stmt=stmt, setup=setup)
print "%.2f usec/pass" % (100000 * t.timeit(number=10000)/10000)
class Person(object):
def __init__(self, age):
@fernandocanizo
fernandocanizo / A bunch of funky CSS3 Toggle Buttons.markdown
Last active March 11, 2016 21:18
A bunch of funky CSS3 Toggle Buttons

A bunch of funky CSS3 Toggle Buttons

A collection of toggle buttons that use CSS3 transitions to animate their state when interacted with. Created using HTML and CSS (no JS). By Ashley Nolan.

Uses the checkbox :checked state to differentiate between state, and therefore is still semantic and accessible.


Twitter: https://twitter.com/AshNolan_

@fernandocanizo
fernandocanizo / ways.to.check.properties.on.objects.js
Created June 14, 2016 23:52
Ways to check for an object property
"use strict";
// There are three ways to check if an object has a property:
const obj = {
one: 1
};
const otherObj = Object.create(obj);
@fernandocanizo
fernandocanizo / gist:399f62aa0684ee59c45e89fa532a26ab
Created June 15, 2016 01:30
Using reduce to apply a pipeline of functions
"use strict";
const pipe = functions => data => {
return functions.reduce((value, func) => func(value), data);
};
const pipeline = pipe([
n => n + 1,
n => n * 2,
n => n * n,
@fernandocanizo
fernandocanizo / sleep.js
Last active June 15, 2016 12:16
sleep function for JS
"use strict";
function sleep(milliseconds) {
return new Promise((resolve) => setTimeout(resolve, milliseconds));
}
sleep(1).then(() => console.log('finished'));
@fernandocanizo
fernandocanizo / json_postgres.js
Created July 28, 2016 16:14 — forked from gerzhan/json_postgres.js
Example of json document storage in postgresql and querying (with knex.js)
var connectionString = 'postgres://localhost:5432/postgres';
var Promise=require('bluebird');
var knex = require('knex')({
client: 'pg',
connection: {
user: 'postgres',
database: 'postgres',
port: 5432,
@fernandocanizo
fernandocanizo / xyz_vs_tms.md
Created August 26, 2016 20:05 — forked from tmcw/xyz_vs_tms.md
The difference between XYZ and TMS tiles and how to convert between them

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.