Skip to content

Instantly share code, notes, and snippets.

View ohvitorino's full-sized avatar

Bruno Vitorino ohvitorino

View GitHub Profile
@ohvitorino
ohvitorino / angularjs15_best_pratices_and_notes.md
Last active July 13, 2016 09:52
AngularJS 1.5 Best practices and Notes

Project generation and structure

  • Angular-seed repo
  • Yeoman angular (strongly advised). Provides commands to generate: directives, controllers, views

ng-cloak attribute

Use ng-cloak directive to hide interpolation tags {{}} in index.html

Ex: <body ng-cloack>

And use ng-bind instead of interpolation to avoid showing {{}}. Ex: <span ng-bind="ctrl.value">?</span>

@ohvitorino
ohvitorino / Overview.txt
Created June 10, 2016 12:04 — forked from juneym/Overview.txt
Task Object, Coordination & Chain of Responsibility Design pattern
Overview:
This was an example I have given to my co-developer who was doing some Task/Coodinator type of code. Hope this is helpful to many other developers out there.
Note that the example only supports one-to-one dependency between TaskObject instance. The TaskAbstract class can be easily modified to support 1-to-many dependency.
For simpicity, I have combined all three classes in this single gist:
1. TaskAbstract
2. TaskObject (extends TaskAbstract)
3. TaskCoordinator (extends TaskAbstract)
@ohvitorino
ohvitorino / prototypal_inheritance.js
Created May 6, 2016 14:27
Prototypal inheritance in javascript (new stuff)
//prototypal inheritance
var human = {
species: "human",
create: function(values) {
var instance = Object.create(this);
Object.keys(values).forEach(function(key) {
instance[key] = values[key];
});
return instance;
},
@ohvitorino
ohvitorino / classical_inheritance.js
Created May 6, 2016 14:16
Classical javascript inheritance
// Classical prototypal inheritance
// This function comes from Node.js
function inherits(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
@ohvitorino
ohvitorino / main.js
Last active May 6, 2016 12:36
Revealing Module Pattern in Javascript
var people = (function(){
var people = ['Will', 'Steve'];
//cache DOM
var $el = $('#peopleModule');
var $button = $el.find('button');
var $input = $el.find('input');
var $ul = $el.find('ul');
var template = $el.find('#people-template').html();
@ohvitorino
ohvitorino / pubsub.js
Created May 6, 2016 12:06 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
@ohvitorino
ohvitorino / csv-to-json.php
Created January 22, 2016 13:00 — forked from robflaherty/csv-to-json.php
Convert CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed
@ohvitorino
ohvitorino / gist:db0e954d334db79f9f82
Last active August 29, 2015 14:14
PostgreSQL: freetds foreign data wrapper
apt-get install freetds-dev
apt-get install libsybdb5 freetds-dev freetds-common
apt-get install postgresql-server-dev-9.3
apt-get install git
git clone https://github.com/GeoffMontee/tds_fdw.git
cd tds_fdw/
apt-get install build-essential
PATH=/usr/lib/postgresql/9.3/bin/:$PATH USE_PGXS=1 make
PATH=/usr/lib/postgresql/9.3/bin/:$PATH USE_PGXS=1 make install
@ohvitorino
ohvitorino / upgrade_pg.sh
Last active August 29, 2015 14:00 — forked from ibussieres/upgrade_pg.sh
Upgrade PostgreSQL from 9.1 to 9.3
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 -y
#In case of error on previous step
# sudo update-alternatives --remove postmaster.1.gz /usr/share/postgresql/9.1/man/man1/postmaster.1.gz
# sudo apt-get install -f
# sudo apt-get install --reinstall postgresql-9.1
################################################
# This should install cartodb (development mode)
# in your Ubuntu 12.04 machine
################################################
#!/bin/bash
sudo apt-get update
sudo apt-get safe-upgrade -y
# git:// port might be closed