Skip to content

Instantly share code, notes, and snippets.

@inferno7291
inferno7291 / getJavascript.js
Created September 19, 2016 13:40
GET PHP on Javascript
/**
* var name = $_GET('name');
* OR
* var $_GET = $_GET(), name = $_GET['name']
*/
function $_GET(param) {
var vars = {};
window.location.href.replace( location.hash, '' ).replace(
/[?&]+([^=&]+)=?([^&]*)?/gi, // regexp
function( m, key, value ) { // callback
@inferno7291
inferno7291 / functions.js
Last active September 19, 2016 13:44
Functions on javascript
/**
* Saber si es un numero
*/
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
/**
* Saber si es un integer
*/
$this->languages['es'] = array(
'days' => array(1 => 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado','Domingo'),
'daysShort' => array(1 => 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab','Dom'),
'daysMin' => array(1 => 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa','Do'),
'months' => array(1 => 'Enero','Febrero','Marzo','Abril','Mayo','Junio', 'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'),
'monthsShort' => array(1 => 'Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic')
);
@inferno7291
inferno7291 / passwordRand.js
Last active September 19, 2016 14:56
Generate password random JS/PHP
#JS
function generatePasswordRand(length,type) {
switch(type){
case 'num':
characters = "0123456789";
break;
case 'alf':
characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
break;
case 'rand':
@inferno7291
inferno7291 / youtube.js
Last active November 8, 2016 10:59
Youtube play on click image
var i,c,y,v,s,n;
v = document.getElementsByClassName("youtube");
if(v.length>0){
s = document.createElement("style");
s.type="text/css";
s.innerHTML='.youtube{background-color:#000; max-width:100%;overflow:hidden;position:relative;cursor:hand;cursor:pointer}.youtube .ythumb{bottom:0;display:block;left:0;margin:auto;padding:0;max-width:100%;position:absolute;right:0;top:0;width:100%;height:auto}.youtube .play{filter:alpha(opacity=80);opacity:.8;left:50%;margin-left:-38px;margin-top:-38px;position:absolute;top:50%;width:77px;height:77px;background:url(http://lh6.googleusercontent.com/-KM0uGaLlhKc/UznnNWfT-wI/AAAAAAAAKS0/Nnz3WwdoLxk/s77/play.png) no-repeat}';
document.body.appendChild(s)}
for(n = 0; n < v.length; n++){
@inferno7291
inferno7291 / functions.php
Last active February 27, 2018 08:51
Function on PHP
/**
* Pasar de Kg a toneladas o al reves
*/
function formatKgtoTon($peso,$ton = false){
return $ton ? $peso*1000 : $peso/1000;
}
/**
* Formato europeo + separador decimal
@inferno7291
inferno7291 / clearForm.js
Last active February 27, 2018 08:53
Clear form javascript/jquery
/**
* Limpiar el formulario
*/
function clearForm(id_class_form) {
$(id_class_form).find(':input').each(function() {
switch(this.type) {
case 'password':
case 'select-multiple':
case 'select-one':
case 'text':
@inferno7291
inferno7291 / dates.php
Last active February 27, 2018 11:45
Functions for date on PHP
/************************
* FUNCTION DATE
************************/
/**
* Devolver la fecha de hoy con o sin hora
*/
function dateToday($format = 'Y-m-d',$time = false){
$date = new DateTime();
return $time ? $date->format($format.' H:i:s') : $date->format($format);
}
@inferno7291
inferno7291 / promise.js
Last active December 31, 2018 12:56
Example promise javascript function
/* ES5, using Bluebird */
var isMomHappy = true;
// Promise
var willIGetNewPhone = new Promise(
function (resolve, reject) {
if (isMomHappy) {
var phone = {
brand: 'Samsung',
color: 'black'