Skip to content

Instantly share code, notes, and snippets.

View angelbladex's full-sized avatar

Luis García angelbladex

View GitHub Profile
@angelbladex
angelbladex / aMayusculas.sh
Created October 22, 2013 15:32
Script para pasar a mayúsculas, todo lo que recibe
#!/bin/bash
#Convierte a mayúsculas todos los parámetros que recibe
echo $@ | awk '{print toupper($0)}'
@angelbladex
angelbladex / extract
Last active December 14, 2015 00:29 — forked from guerrerocarlos/.bashrc
Un simple script en Bash para facilitar extraer contenido de algunos comprimidos -- An simple script on Bash for extract content from some compressed file
#! /bin/bash
##This can be on /bin/ or /usr/bin or any site of your $PATH
####Based on https://gist.github.com/guerrerocarlos/3977495
if [[ ! -n "$1" ]];then
echo "Archivo no ingresado"
exit
fi
@angelbladex
angelbladex / curlTest.php
Last active October 12, 2015 20:00
some code on PHP for test access to websites with curl
<?php
function nxs_cURLTest($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
//curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
$response = curl_exec($ch);
@angelbladex
angelbladex / totime.sh
Created September 1, 2015 14:28
Convert to human readable, unix timestamp
#!/bin/bash
perl -pe 's/(\d+)/localtime($1)/e'
#i added this script in /usr/local/bin/
#sample usage
#grep youtube /var/log/squid3/access.log | totime
#tail -f /var/log/squid3/access.log | grep "/403" | totime
@angelbladex
angelbladex / sort-ips.sh
Created August 14, 2015 19:40
Sort ip address from a file
#!/bin/bash
sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n addresses_file
@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",