Skip to content

Instantly share code, notes, and snippets.

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

Pedro J. Parra pedroparra

🏠
Working from home
View GitHub Profile
@pedroparra
pedroparra / products.jade
Created February 16, 2015 12:16
Shuffle in Jade
- function shuffle(o){ for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); return o; };
- var shuffleProductos = shuffle( products );
@pedroparra
pedroparra / app.js
Last active August 29, 2015 14:16
Express js. Using a different less folder.
/*
Less source folder: /less
Destination folder: /public/css
*/
var lessMiddleware = require('less-middleware');
app.use(lessMiddleware(path.join(__dirname, 'less'), {
dest: path.join(__dirname, 'public'),
compress: false,
preprocess: {
@pedroparra
pedroparra / Readme.md
Created April 27, 2015 17:43
Install Rvm, ruby and Rhc (Openshift)

Install Rvm, ruby and Rhc (Openshift)

RVM

Ruby

  • rvm list known
  • rvm install 2.2.1
  • rvm use 2.2.1
@pedroparra
pedroparra / readme.md
Created May 5, 2015 08:42
Fix nvm PATH node

OSX

All I needed to do was adding this line to .bash_profile // .zshrc export PATH="$PATH":~/.node/bin

Ubuntu/Debian

Add this line to .bashrc // .zshrc export PATH="$HOME/npm/bin:$PATH"

@pedroparra
pedroparra / example
Created June 24, 2015 11:14
npm list global without listing the dependencies.
npm ls --depth 0 -g
@pedroparra
pedroparra / componentWillMount.js
Last active August 29, 2015 14:27
React Js componentWillMount
// Ecmascript 5
var MyComponent = React.createClass({
componentWillMount: function() {}
console.log('El componente aun no está disponible en el DOM');
return { data:[] };
},
render: function() {
<div>Soy un component</div>
}
});
@pedroparra
pedroparra / componentDidMount.js
Last active September 15, 2016 08:39
React Js componentDidMount
// Ecmascript 5
var MyComponent = React.createClass({
componentWillMount: function() {
console.log('El componente aun no está disponible en el DOM');
return { data:[] };
},
componentDidMount: function() {
console.log('El componente está disponible en el DOM');
@pedroparra
pedroparra / componentWillReceiveProps.js
Created August 13, 2015 19:03
React Js componentWillReceiveProps
// Ecmascript 5
var MyComponent = React.createClass({
componentWillReceiveProps: function(next_props){
this.setState({ loading: true });
},
render: function() {
className = this.state.loading ? 'loading' : 'loaded';
return(<div className={className}>Soy un component</div>)
@pedroparra
pedroparra / shouldComponentUpdate.js
Last active August 29, 2015 14:27
React Js shouldComponentUpdate
// Ecmascript 5
var MyComponent = React.createClass({
shouldComponentUpdate: function(next_props, next_state) {
return false;
}
// Despues del primer render, nunca volver a renderizarse.
render: function() {
<div>Soy un component</div>
@pedroparra
pedroparra / componentDidUpdate.js
Created August 13, 2015 19:32
React Js componentDidUpdate
// El metodo recive las propiedades previas y el estado previo.
componentDidUpdate: function(prev_props, prev_state) {}