Skip to content

Instantly share code, notes, and snippets.

@rnaffer
rnaffer / iterator.js
Created June 15, 2017 00:31
Cómo construir mi propio iterador
// Iterador que empieza sobre el índice indicado como parámetro
// ¿Por qué yield?
Array.prototype.myIterator = function* (startIdx = 0) {
while (startIdx < this.length) {
if (this.hasOwnProperty(startIdx)) {
yield [this[startIdx], startIdx];
}
startIdx++;
}
@rnaffer
rnaffer / bucles.js
Last active June 16, 2017 03:07
Explicación básica de los bucles en Javascript con ejemplos
// formas de hacer bucles en javascript
let arr = [1,2,3,4,5];
// foreach ES6
// se puede pasar el this usando la sintaxis antigua
arr.forEach((current, index, array) => {
console.log(current);
});
// for-in
@rnaffer
rnaffer / funciones.js
Last active June 16, 2017 03:04
Explicación sencilla de las funciones en Javascript
// funciones-generador
// yeld es una palabra clave dentro de las funciones generador similar a return
// a dferencia de return, yeld suspende la ejecución para que pueda ser retomada luego
function* quips(name) {
yield "hello " + name + "!";
yield "i hope you are enjoying the blog posts";
if (name.startsWith("X")) {
yield "it's cool how your name starts with X, " + name;
}
@rnaffer
rnaffer / steps
Last active August 10, 2017 15:29
Nuevo proyecto RN + Material UI + Navigation + Redux
1. Instalar React-Native
2. Instalar dependencias iniciales
npm i react-native-material-ui --save
npm install react-native-vector-icons --save
react-native link react-native-vector-icons
yarn add react-native-navigation@latest
npm install --save react-redux
npm install --save redux
npm install --save redux-thunk
npm install --save redux-persist
@rnaffer
rnaffer / android key
Created August 9, 2017 14:26
Generate android key
_
@rnaffer
rnaffer / .java
Created April 11, 2020 21:06
Ejemplo de un renderizador para alineación del texto, colores, frontera y fuente
public class AlignTableCellRenderer extends DefaultTableCellRenderer.UIResource
{
private DefaultTableCellRenderer renderizador;
private int horizontalAlignment=SwingConstants.CENTER;
private Color foregroundColor=null;
private Color backgroundColor=null;
private Border frontera=null;
private int fontstyle=Font.PLAIN;
public AlignTableCellRenderer(JTable table)