Skip to content

Instantly share code, notes, and snippets.

View bssanchez's full-sized avatar

Brandon Sanchez bssanchez

View GitHub Profile
@bssanchez
bssanchez / drop_all_tables.sql
Created September 26, 2017 18:19
Drop all tables of database without delete the database
-- For prevent revisión of foreign keys
SET FOREIGN_KEY_CHECKS = 0;
-- OPTIONAL: If you have too much tables
SET GROUP_CONCAT_MAX_LEN=32768;
-- Initialize var @tables
SET @tables = NULL;
-- Set appropriate value for table, schema_naame can be Concatenated too
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
FROM `information_schema`.`tables`
@bssanchez
bssanchez / img_thumb_generator.php
Last active September 26, 2017 18:28
Generate thumbnails by cli with PHP using GD Library
<?php
/**
* @autor: Brandon Sanchez
* @Description: Herramienta en el conocido lenguage php para la generacion de thumbnails
* sobre las imagenes contenidas en una carpeta.
* @Creacion: 13/04/2013
* @Actualizacion: 04/07/2013 (Se agrego salida general a un unico formato)
*/
error_reporting(0);
@bssanchez
bssanchez / blackjack.php
Created September 26, 2017 18:27
Blackjack game in php cli
<?php
/*
* Juego de blackjack en consola
* programado en php
*
* @author Brandon Sanchez
*/
class blackjack
{
@bssanchez
bssanchez / perlbot.pl
Created September 26, 2017 18:29
IRC bot in perl
#!/usr/bin/perl
use strict;
use IO::Socket;
################################################################
# Prueba perl de botIRC #
# Objetivo del proyecto aprender manejo de perl con algunas #
# de sus funciones y sobre todo sockets xD... #
# #
@bssanchez
bssanchez / phpbotrss.php
Created September 26, 2017 18:32
PHP Bot for consulting rss from forums smf and send to user who sends request
<?php
/**
* @autor: Brandon Sanchez
* @license MIT 2014, Brandon Sanchez
* @todo Consultar los RSS de los foros en un archivo txt para
* enviar por privado al usuario que lo pida con !news
*
* @filesource $archivoURL es la ruta del archivo que tiene los foros
* y sus respectivas urls, el formato debe ser así en cada
* linea:
@bssanchez
bssanchez / Upload.php
Created September 26, 2017 18:34
PHP class for upload files
<?php
/**
* Clase que encapsula las funciones de subida de archivos con su
* seguridad correspondiente
* @author Brandon Sanchez
*
*/
class Upload
{
@bssanchez
bssanchez / l33t.pl
Created September 26, 2017 18:36
IRSSI plugin for write in l33t format
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "1.0";
%IRSSI = (
authors => "kid_goth",
contact => "g0th4ck[at]gmail[dot]com",
name => "leet",
licence => "Pa todos y todas",
@bssanchez
bssanchez / fullbackup.sh
Created September 26, 2017 18:38
Full backup with bash in server LAMP
#!/bin/bash
#################################################
## Script para Backups servidor LAMP ##
#################################################
## Poner en true si solo es un sitio
UNSITIO=false
## Directorio de backup y temporal
BKDIR="/home/user/backups"
@bssanchez
bssanchez / jqbs3_validate.js
Created September 26, 2017 18:41
Validate form javascript using twitter bootstrap 3 classes and jquery
function validar_datos(form_id, password1, password2) {
var regex = {"number": /^[0-9]+$/, "email": /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,4}$/, "date": /^([0-9]{4}\-[0-9]{2}\-[0-9]{2})$/};
var flag = true;
$(form_id + ' input').each(function(key, input) {
$(input).removeAttr('title').parent().removeClass('has-error');
if ($(input).hasClass('required')) {
if (($(input).val() == '' || $(input).val() == '-1')) {
flag = false;
$(input).attr('title', 'Este campo es requerido.').parent().addClass('has-error');
} else if (!$(input).hasClass('no-regex') && $(input).attr('type') != 'text') {
@bssanchez
bssanchez / Num2Text.php
Last active September 26, 2017 18:45
script en PHP para convertir número a su forma de texto
<?php
/**
* Tomado de:
* Copyright 2007-2008 Brenton Fletcher. http://bloople.net/num2text
* @link http://stackoverflow.com/q/277569/367456
* @question Is there an easy way to convert a number to a word in PHP?
*
* Bajo la licencia de CC-Wiki on Stackoverflow.
* http://creativecommons.org/licenses/by-sa/3.0/