Skip to content

Instantly share code, notes, and snippets.

View angelbladex's full-sized avatar

Luis García angelbladex

View GitHub Profile
@angelbladex
angelbladex / validateIp.sh
Last active August 29, 2015 14:25
Validate Ip Address
#!/bin/bash
#Validate a IP address
function valid_ip()
{
local ip=$1
local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
@angelbladex
angelbladex / validateMac.sh
Last active August 29, 2015 14:25
Validate mac address
#!/bin/bash
if [[ ! -n "$1" ]]; then
echo "Missing data input"
exit
fi
if [ `echo $1 | egrep -i "^([0-9A-F]{2}:){5}[0-9A-F]{2}$"` ]
then
@angelbladex
angelbladex / size-kernel-module.sh
Created July 23, 2015 20:11
Get size of each kernel module on KB
#!/bin/bash
lsmod | awk '{$2/=1024; printf "%s %.2fKB\n",$1,$2}' | sed 's/\./,/g' | awk '{if (NR!=1) {print}}' | column
@angelbladex
angelbladex / list-parameters.sh
Created October 23, 2014 21:55
List parameters each loead kernel module
#!/bin/bash
# This script was created from source of -> http://serverfault.com/questions/62316/how-do-i-list-loaded-linux-module-parameter-values
#This code list parameters of each loaded kernel modules
cat /proc/modules | cut -f 1 -d " " | while read module; do \
echo "Module: $module"; \
if [ -d "/sys/module/$module/parameters" ]; then \
ls /sys/module/$module/parameters/ | while read parameter; do \
echo -n "Parameter: $parameter --> "; \
cat /sys/module/$module/parameters/$parameter; \
@angelbladex
angelbladex / fechas.php
Created September 14, 2014 04:19
Prueba de concepto para obtener fechas de operativos Mercal de la página de Mercal
<?php
//original code written by @willicab > https://pastebin.mozilla.org/6456892
error_reporting(E_ALL);
ini_set('display_errors', 1);
$mes = array(
"ENERO" => "01",
"FEBRERO" => "02",
"MARZO" => "03",
"ABRIL" => "04",
@angelbladex
angelbladex / validate.sh
Last active August 29, 2015 14:05 — forked from hrwgc/validate.sh
validate a url with wget
#!/bin/bash
# simple function to check http response code before downloading a remote file
# example usage:
# if `validate_url $url >/dev/null`; then dosomething; else echo "does not exist"; fi
function validate_url(){
@angelbladex
angelbladex / tree.sh
Created August 19, 2014 00:04
Displays Structure of Directory Hierarchy
#!/bin/sh
#######################################################
# UNIX TREE #
# Version: 2.3 #
# File: ~/apps/tree/tree.sh #
# #
# Displays Structure of Directory Hierarchy #
# ------------------------------------------------- #
# This tiny script uses "ls", "grep", and "sed" #
# in a single command to show the nesting of #
@angelbladex
angelbladex / .bashrc
Last active August 29, 2015 14:02
My alias command on .bashrc
#SomeTimes i delete lnk files on USB drives from my friends,
# i got to directory on /media/USB_DRIVE_NAME and apply next alias
alias deletelnk='sudo find . -iname "*lnk" -exec rm {} \;'
#Using woodim for put blank a cdrom r+w
alias deleteCD='wodim -v dev=/dev/sr0 blank=fast'
#Using woodim for put blank a Dvd r+w
alias deleteDVD='dvd+rw-format -blank=full /dev/sr0'
#Alias for connect to Windows host on one domain via rdesktop,
# require a ip as parameter, e.g.remote 192.168.0.1
alias remote='rdesktop -g 70% -u username -d domanin -a 16'
@angelbladex
angelbladex / strikethroughText.sh
Created October 27, 2013 20:35
Este script tacha el texto recibido por parámetro
#!/bin/bash
echo $@ | sed $"s/./&\xCC\xB6/g"
@angelbladex
angelbladex / colorear.sh
Created October 22, 2013 15:36
Script para convertir algún código en html con resaltado de colores, usando el paquete highlight
#!/bin/bash
if [[ ! -n "$1" ]];
then
echo "Nombre de archivo no ingresado"
exit
fi