Skip to content

Instantly share code, notes, and snippets.

View alfonmga's full-sized avatar
👁️
What you look for is what you find.

Alfon alfonmga

👁️
What you look for is what you find.
View GitHub Profile
# Deployment server info
set :application, "Nombre aplicación aquí"
set :domain, "127.0.0.1"
set :deploy_to, "/var/www/"
set :app_path, "app"
set :web_path, "web"
# SCM info
set :repository, "http://github.com/alfonsomga/*"
set :scm, :git
@alfonmga
alfonmga / nifcif_validador.js
Last active October 20, 2015 01:44
JS validador de NIF & CIF
//Retorna: 1 = NIF ok, 2 = CIF ok, 3 = NIE ok, -1 = NIF error, -2 = CIF error, -3 = NIE error, 0 = ??? error
function valida_nif_cif_nie(a){
var temp = a.toUpperCase();
var cadenadni = "TRWAGMYFPDXBNJZSQVHLCKE";
if( temp!= '' ) {
//si no tiene un formato valido devuelve error
if( ( !/^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$/.test( temp ) && !/^[T]{1}[A-Z0-9]{8}$/.test( temp ) ) && !/^[0-9]{8}[A-Z]{1}$/.test( temp ) ){
return 0;
}
//comprobacion de NIFs estandar
<?php
/*
Creo que llegados a este punto es hora de ponernos algo serios y empezar a inculcar
las buenas prácticas a los programadores, para que poco a poco se vaya consiguiendo
obtener desarrollos con estructura de código similar y homogénea, en vez de lo que
hay ahora, que cada uno pone lo que cree mas oportuno de la manera que cree que es
mas correcta, es muy importante que los proyectos sean fáciles de mantener y que
el código que ha hecho A lo pueda mantener B o incluso C sin tener que recurrir
ninguno a preguntarle a A por que se hizo eso asi o cosas similares.
Es por eso que he pensado en publicar finalmente el manual de coding standards que
@alfonmga
alfonmga / yt-api-rate-video.py
Last active February 25, 2021 22:12
YouTube API: Puntuar vídeo con script de Python
#!/usr/bin/python
import httplib2
import sys
from apiclient.discovery import build
from apiclient.errors import HttpError
from oauth2client.client import flow_from_clientsecrets
from oauth2client.file import Storage
from oauth2client.tools import argparser, run_flow
@alfonmga
alfonmga / yt-api-sub-channel.py
Last active March 2, 2016 17:36
YouTube API: Hacer sub a un canal con script de Python
#!/usr/bin/python
import httplib2
import sys
from apiclient.discovery import build
from apiclient.errors import HttpError
from oauth2client.client import flow_from_clientsecrets
from oauth2client.file import Storage
from oauth2client.tools import argparser, run_flow
/* Randoms */
if (!document.title) {
document.title = document.URL;
}
/* Keylib */
// Alphanumeric
document.addEventListener('keypress', function (e) {
e = e || window.event;
var _yt_www = {};
(function(g) {
var window = this;
var baa, caa, Ca, ab, kaa, bb, cb, db, eb, jb, laa, kb, maa, naa, rb, Db, Tb, uc, uaa, vaa, taa, Vc, $c, ad, gd, id, yaa, nd, rd, ld, jd, Aaa, qd, od, pd, td, zaa, yd, Baa, Caa, Pd, Ud, Wd, Xd, Yd, Gaa, Faa, me, Ae, Haa, Le, Se, Re, Jaa, Kaa, Te, Ue, We, Laa, $e, ff, ef, af, kf, Raa, of, lf, mf, Paa, rf, qf, tf, df, Ye, Xe, Ze, uf, hf, sf, jf, wf, Taa, Oaa, Cf, Df, Gf, Jf, Lf, $aa, dg, eg, hg, fg, aba, og, vg, ug, bba, yg, zg, Ag, Bg, Eg, Gg, Hg, Ig, Lg, Kg, Ng, Jg, Og, Cg, Fg, gba, Pg, Qg, hba, iba, Wg, Yg, $g, oba, nba, mba, hh, lba, jba, kba, pba, oh, qba, ph, rh, rba, sba, sh, th, yh, Ch, Dh, Eh, Hh, Ih, Jh, yba, zba, zh, Bh, xh, xba, Ah, Cba, Rh, Qh, Sh, Bba, Th, Eba, Dba, Fba, Gba, Uh, Vh, na, aaa;
g.ba = function(a) {
return function() {
return g.aa[a].apply(this, arguments)
}
}
;
@alfonmga
alfonmga / http-tries.js
Created November 2, 2016 12:12
http-tries.js
function resilientRequest(options) {
var url = options.url;
var method = options.method || 'GET';
var data = options.data || {};
var callback = options.callback || function() {};
var tries = typeof options.tries !== 'undefined' ? options.tries : 50;
var timeout = options.timeout || 60 * 60 * 1000; //1 hour
if (typeof data === 'object') {
data = objectToQueryString(data);
@alfonmga
alfonmga / referrerRedirect.js
Last active December 16, 2018 19:55
Get referrer from React router location prop
let redirectTo = '/dashboard';
if (location.state && location.state.from) {
const { pathname, search, hash } = location.state.from;
redirectTo = `${pathname + search + hash}`;
}
@alfonmga
alfonmga / mixpanel-proxy.js
Created November 3, 2018 20:28
node.js proxy server to serve mixpanel.js lib from our own domain
const got = require('got')
const cors = require('@koa/cors')
const Koa = require('koa')
const KoaRouter = require('koa-router')
const globalTunnel = require('global-tunnel-ng')
const { PROXY } = process.env
if (PROXY) {
const [ host, port ] = PROXY.split(':')