Skip to content

Instantly share code, notes, and snippets.

@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)
@rnaffer
rnaffer / android key
Created August 9, 2017 14:26
Generate android key
_
@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 / 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 / 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 / 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 / helpers.js
Last active February 22, 2017 15:48
Usefull Javascript functions
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
@rnaffer
rnaffer / comandos
Last active August 4, 2016 03:24
Comandos comunes Api generator infyom labs
Generar api desde tabla
php artisan infyom:api $MODEL_NAME --fromTable --tableName=$TABLE_NAME
Test api
vendor\bin\phpunit
@rnaffer
rnaffer / tableToSql.js
Created August 1, 2016 16:39
Export table to excel with pure javascript
var tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><?xml version="1.0" encoding="UTF-8" standalone="yes"?><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) };
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table);
var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML };
window.location.href = uri + base64(format(template, ctx));
};
@rnaffer
rnaffer / scroll.html
Created June 27, 2016 16:20
Scroll Position Directiva e implementación - Se usa una marca para medir la distancia del scroll y realizar una accn.
<span scroll-position="scroll"></span>
<div ng-class="{show: scroll > 400, hide: scroll <= 400}">
<h2>I'm here</h2>
</div>