Skip to content

Instantly share code, notes, and snippets.

View maccevedor's full-sized avatar

Mauricio Acevedo Rueda maccevedor

View GitHub Profile
@maccevedor
maccevedor / 0_reuse_code.js
Created June 18, 2014 20:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<!DOCTYPE html>
<html>
<body>
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
@maccevedor
maccevedor / new_gist_file_0
Created June 25, 2014 14:29
Create-a-Javascript-Console-in-Sublime-Text
{
"cmd": ["/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc", "$file"],
"selector": "source.js"
}
@maccevedor
maccevedor / gist:c659be779caceae663a0
Created June 26, 2014 19:55
Bloquear con javascript caracteres especiales
//sin permiitr espacios
var r={'special':/[\W]/g}
//con espacios
var s={'special':/[^\w^ñ^(á|é|í|ó|ú)^\s^]/g}
function valid(o,w){
o.value = o.value.replace(r[w],'');
}
function validaremos(o,w){
o.value = o.value.replace(s[w],'');
@maccevedor
maccevedor / Git
Created July 2, 2014 19:17
Iniciar Git desde el terminal o cmd
cd <localdir>
git init
git add .
git commit -m 'message'
git remote add origin <url>
git push -u origin master
@maccevedor
maccevedor / edad
Created July 3, 2014 20:40
Calcular Edad con mysql
SELECT TIMESTAMPDIFF(YEAR, Campo , CURDATE()) AS age
@maccevedor
maccevedor / procedure.sql
Created July 3, 2014 21:58
Ejemplo Procedimiento Almacenado con mysql , recibiendo un parametro
USE bdtienda;   DELIMITER $$ -- inicio DROP PROCEDURE IF EXISTS sp_productoPorCod$$ -- eliminamos si existe un procedimiento con el mismo nombre CREATE  PROCEDURE sp_productoPorCod (IN cod INT) -- creamos el procedimiento con un parámetro de entrada BEGIN  -- inicio cuerpo procedimiento almacenado     DECLARE estadoOfert CHAR(2);  -- declaramos  una variable local para almacenar el estado de Oferta.     /* Hacemos una consulta y el resultado lo almacenamos en la variable declarada*/     SELECT oferta INTO estadoOfert FROM productos WHERE oferta = 'SI' AND codproducto = cod;      IF estadoOfert = 'SI' THEN -- si está en oferta elegimos precio_oferta         SELECT codproducto, nombreproduc, precio_oferta FROM productos WHERE codproducto = cod;     ELSE -- sino el precio_normal         SELECT codproducto, nombreproduc,  precio_normal FROM productos WHERE codproducto = cod;        END IF; END $$  -- fin de cuerpo del procedimiento almacenado DELIMITER ; -- fin   call sp_productoPorCod(2); -- llamamos al proced
@maccevedor
maccevedor / Wordpress
Created July 4, 2014 16:10
Cambiar las url de un sitio con Wordpress
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@maccevedor
maccevedor / push
Created July 5, 2014 15:42
Forzar actualizar todo desde el servidor remoto(cuidado si tienes archivos locales en esta carpeta lso elimina)
git push --all origin