Skip to content

Instantly share code, notes, and snippets.

View luizcarraro's full-sized avatar
🏠
Working from home

Luiz Carraro luizcarraro

🏠
Working from home
  • Pato Branco - BR
View GitHub Profile
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@luizcarraro
luizcarraro / br-states-fixtures.js
Created November 10, 2015 20:16
EN: Brazil states as JSON fixtures. PT: Lista de estados brasileiros em formato JSON para fixtures.
module.exports = [{
name: 'Acre',
shortname: 'AC',
codigo_ibge: '12'
}, {
name: 'Alagoas',
shortname: 'AL',
codigo_ibge: '27'
}, {
name: 'Amapá',
@luizcarraro
luizcarraro / additional-route-models.js
Created June 17, 2016 17:32
Return a hash of models to set on the controller
import Ember from 'ember';
export default Ember.Mixin.create({
/**
* the main hook: override to return a hash of models to set on the controller
* @param model
* @param transition
* @param queryParams
*/
additionalModels: function() {},
@luizcarraro
luizcarraro / header-controller.js
Created August 19, 2016 14:17
Collapse Bootstrap Navbar on Ember or Any Single page application
import Ember from 'ember';
export default Ember.Component.extend({
didRender() {
Ember.$('.nav li a').on('click', function(clicked) {
if (!Ember.$(this).hasClass("dropdown-toggle")) {
Ember.$('.navbar-collapse').collapse('hide');
}
});
}
@luizcarraro
luizcarraro / fix-ubuntu-watchman
Created December 5, 2016 11:38
Makes ubunto accept many watchman processes
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
@luizcarraro
luizcarraro / ajax.js
Created December 12, 2016 15:42
Configuração de Ajax no EmberJS com Token JWT nos Headers
import Ember from 'ember';
import AjaxService from 'ember-ajax/services/ajax';
import environment from 'web/config/environment';
export default AjaxService.extend({
host: environment.apiBaseUrl,
session: Ember.inject.service(),
headers: Ember.computed('session.session.content.authenticated.token', {
get() {
let headers = {};
@luizcarraro
luizcarraro / beforeCreate.js
Created January 11, 2017 13:05 — forked from mphasize/beforeCreate.js
Sails-beforeCreate-Policy
/**
* beforeCreate
*
* @module :: Policy
* @description :: Simple policy to inject the user creating a record into the records values.
* Assumes req.user && req.user.id to be set when a user is logged in.
* @docs :: http://sailsjs.org/#!documentation/policies
*
*/
@luizcarraro
luizcarraro / bootstrap.test.js
Created January 16, 2017 11:59
Sails Bootstrap tests
var Sails = require('sails'),
_ = require('lodash');
global.DOMAIN = 'http://localhost';
global.PORT = 1337;
global.HOST = DOMAIN + ':' + PORT;
before(function(callback) {
this.timeout(50000);
@luizcarraro
luizcarraro / modal-route.js
Created March 16, 2017 14:13
Boostrap modal Ember Mixin
import Ember from 'ember';
export default Ember.Mixin.create({
activate() {
this._super();
Ember.run.next(() => {
$(".modal").modal('show');
});
},
@luizcarraro
luizcarraro / filter for ember list.js
Created June 9, 2017 13:05
An example of filter for ember arrays
filterContacts(filter) {
var list = this.get('list');
return list.filter(function (item) {
if(_match(item.name) || _match(item.professionalEmail) || _match(item.jobFunction) || _match(item.department) || _match(item.professionalPhone)) {
return true;
} else {
return false;
}
});