Skip to content

Instantly share code, notes, and snippets.

View lpirola's full-sized avatar

Lucas Pirola lpirola

  • São Paulo, Brazil
View GitHub Profile
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@lpirola
lpirola / geojson-conversion.sh
Last active August 29, 2015 14:06 — forked from benbalter/geojson-conversion.sh
Transforma arquivos shapefiles em GeoJSON de maneira automatizada
# Conversão em massa de arquivos shapefiles para geojson usando ogr2ogr
# Para mais informações, veja http://ben.balter.com/2013/06/26/how-to-convert-shapefiles-to-geojson-for-use-on-github/
# Observação: Assumo que você está rodando o script em uma pasta com um ou mais arquivos zipados contendo shapefiles
# e a saída será como geojson com crs:84 SRC (para uso no github ou por aí)
# conversão em geojson
function shp2geojson() {
ogr2ogr -f GeoJSON -t_srs crs:84 "$1.geojson" "$1.shp"
}
@lpirola
lpirola / build-rpm-instal-haproxy.sh
Last active August 29, 2015 14:16 — forked from cbschuld/gist:cdcaf062da5b34eede37
Script to build rpm package and install haproxy in amazon ami linux aka centos 6.5
#!/bin/sh
wget "http://www.haproxy.org/download/1.5/src/haproxy-1.5.11.tar.gz"
rpmdev-setuptree
mv haproxy-1.5.11.tar.gz ~/rpmbuild/SOURCES/
git clone git://github.com/lucaspirola/haproxy-centos.git
cp haproxy-centos/conf/* ~/rpmbuild/SOURCES/
cp haproxy-centos/spec/* ~/rpmbuild/SPECS/
cd rpmbuild/
rpmbuild -ba SPECS/haproxy.spec
import type from 'type-of-is'
export default function parse( input ){
if( type( input, String ) ){
return input
}
else if( type( input[ 0 ], Array ) ){
return input.map( parse )
}

Three.JS Cubes

Reduce boilerplate in Redux

  • Create actions similar to Flummox.
  • Generate action ids.
  • Supports actions with decorators, promises, and therefore ES7 async.
@lpirola
lpirola / 1_phantomErrors.js
Created March 22, 2017 20:10 — forked from artjomb/1_phantomErrors.js
Error event handlers for PhantomJS and CasperJS: PhantomJS and CasperJS don't show errors on the page by default. This can give clues as to what did go wrong.
var page = require('webpage').create(),
url = 'http://example.com/';
// Put the event handlers somewhere in the code before the action of
// interest (opening the page in question or clicking something)
// http://phantomjs.org/api/webpage/handler/on-console-message.html
page.onConsoleMessage = function(msg, lineNum, sourceId) {
console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")');
};
@lpirola
lpirola / track.js
Created March 28, 2017 01:56 — forked from nioufe/track.js
import LogmaticJs from 'logmatic-js';
const track = function (verb) {
// Event fields
const _verb = verb;
let _object = null;
let _target = null;
let _start = null;
@lpirola
lpirola / Dockerfile
Created March 28, 2017 15:01 — forked from yefim/Dockerrun.aws.json
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
# Example Dockerfile
FROM hello-world
@lpirola
lpirola / postgres-cheatsheet.md
Created April 2, 2017 20:56 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

If run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*