Mostrando entradas con la etiqueta Geek. Mostrar todas las entradas
Mostrando entradas con la etiqueta Geek. Mostrar todas las entradas

Matrix(ish)

d
Nombre: Matrix(ish)
Autor: Brett Terpstra @ttscoff
Contribuciones: Lauri Ranta and Carl
Visto en: Brettterpstra
#!/bin/bash
#
# matrix: matrix-ish display for Bash terminal
# Author: Brett Terpstra 2012 
# Contributors: Lauri Ranta and Carl 
#
# A morning project. Could have been better, but I'm learning when to stop.
 
### Customization:
blue="\033[0;34m"
brightblue="\033[1;34m"
cyan="\033[0;36m"
brightcyan="\033[1;36m"
green="\033[0;32m"
brightgreen="\033[1;32m"
red="\033[0;31m"
brightred="\033[1;31m"
white="\033[1;37m"
black="\033[0;30m"
grey="\033[0;37m"
darkgrey="\033[1;30m"
# Choose the colors that will be used from the above list
# space-separated list
# e.g. `colors=($green $brightgreen $darkgrey $white)`
colors=($green $brightgreen)
### End customization
 
### Do not edit below this line
spacing=${1:-100} # the likelihood of a character being left in place
scroll=${2:-0} # 0 for static, positive integer determines scroll speed
screenlines=$(expr `tput lines` - 1 + $scroll)
screencols=$(expr `tput cols` / 2 - 1)
 
# chars=(a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ^)
# charset via Carl:
chars=(ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ン)
 
count=${#chars[@]}
colorcount=${#colors[@]}
 
trap "tput sgr0; clear; exit" SIGTERM SIGINT
 
if [[ $1 =~ '-h' ]]; then
 echo "Display a Matrix(ish) screen in the terminal"
 echo "Usage:  matrix [SPACING [SCROLL]]"
 echo "Example: matrix 100 0"
 exit 0
fi
 
 
clear
tput cup 0 0
while :
 do for i in $(eval echo {1..$screenlines})
  do for i in $(eval echo {1..$screencols})
   do rand=$(($RANDOM%$spacing))
    case $rand in
     0)
      printf "${colors[$RANDOM%$colorcount]}${chars[$RANDOM%$count]} "
      ;;
     1)
      printf "  "
      ;;
     *)
      printf "\033[2C"
      ;;
    esac
   done
   printf "\n"
 
   # sleep .005
  done
  tput cup 0 0
 done
Leer más...

Convertstr.pl -Reverses and converts a string

d
Autor: Dual
Descripción: Reverses and converts a string to base64, binary, hex, and rot13 and provides  the md5, sha1 and sha256 hashes 
Nombre: convertstr.pl


#!/usr/bin/env perl -w

# convertstr.pl - Reverses and converts a string
# to base64, binary, hex, and rot13 and provides
# the md5, sha1 and sha256 hashes 
#
# by dual

use strict;
use MIME::Base64;
use Digest::MD5;
use Digest::SHA qw(sha1_hex sha256_hex);

my $usage = "convertstr.pl - Reverses and converts a string
to base64, binary, hex and rot13, and provides
the md5, sha1 and sha256 hashes
Usasge: perl convertstr.pl 
";

# Get and check args
print $usage and exit unless my $string = shift;
chomp($string);

# Print header
print "Converting \'$string\'...\n\n";

# Reverse
print "REVERSED:\n";
my $reversed = reverse($string);
print $reversed . "\n\n";

# Base64
print "BASE64:\n";
my $base64 = encode_base64($string);
chomp($base64);
print $base64 . "\n\n";

# Binary
print "BINARY:\n";
my $binary = unpack('B*', $string);
print $binary . "\n\n";

# Hex
print "HEX:\n";
my $hex = unpack('H*', $string);
print $hex . "\n\n";

# Rot13
print "ROT13:\n";
if ($string =~ /[^A-Za-z\s]/) {
  print ">>> String must be alphabetic\n\n";
}
else {
  my $rot13 = $string;
  $rot13 =~ tr/A-Za-z/N-ZA-Mn-za-m/;
  print $rot13 . "\n\n";
}

# MD5
print "MD5:\n";
my $md5 = Digest::MD5->new;
$md5->add($string);
my $md5hex = $md5->hexdigest;
print $md5hex . "\n\n";

# SHA1
print "SHA1:\n";
my $sha1hex = sha1_hex($string);
print $sha1hex . "\n\n";

# SHA256
print "SHA256:\n";
my $sha256hex = sha256_hex($string);
print $sha256hex . "\n\n";

# Close out
print "Done.\n"
Leer más...

Base64pl.pl Encode/Decode

d
Autor: Dual
Descripción: Encode / Decode strings usando base64
Nombre: base64pl.pl

#!/usr/bin/env perl -w

# base64pl.pl - Encodes/decodes string(s) using base64
# by dual

use strict;
use MIME::Base64;

my $opt;
my $usage = "base64pl.pl -
Encodes or decodes a string using base64
Usage: perl base64pl.pl <-e data-blogger-escaped-d="d"> 
-e => encode
-d => decode
";

print $usage and exit unless (defined($opt = shift) && $opt =~ /^(-e|-d)$/);
print $usage and exit unless ($#ARGV > -1);

if ($opt =~ /e/) {
  my $enc_ref = \&encode;
  for my $enc_str (@ARGV) {
    $enc_ref->($enc_str);
  }
}
else {
  my $dec_ref = \&decode;
  for my $dec_str (@ARGV) {
    $dec_ref->($dec_str);
  }
} 

sub encode {
  my $string = $_[0];
  my $encoded = encode_base64($string);
  chomp($encoded);
  print "$string: $encoded\n";
}

sub decode {
  my $string = $_[0];
  my $decoded = decode_base64($string);
  chomp($decoded);
  print "$string: $decoded\n";
}

Fuente
Leer más...

Script de instalación de TOR

d
Autor: Anonymous Mexico
Twitter: @MexicanH @Anonymousmexi @rofl4all @Anon_yuc
Descripcion: Script que automatiza la instalación de Tor

#!/bin/sh

colorise=1

print_welcome ()
{

echo " 
 
  @@@@@@  @@@  @@@ @@@@@@@  @@@@@@  @@@ @@@  @@@  @@@@@@ @@@@@@@  @@@@@@  @@@      @@@     
 @@!  @@@ @@!  @@@   @@!   @@!  @@@ @@! @@!@!@@@ !@@       @@!   @@!  @@@ @@!      @@!     
 @!@!@!@! @!@  !@!   @!!   @!@  !@! !!@ @!@@!!@!  !@@!!    @!!   @!@!@!@! @!!      @!!     
 !!:  !!! !!:  !!!   !!:   !!:  !!! !!: !!:  !!!     !:!   !!:   !!:  !!! !!:      !!:     
  :   : :  :.:: :     :     : :. :  :   ::    :  ::.: :     :     :   : : : ::.: : : ::.: :
  
Coded By: Anonymous Mexico
Twitter: @MexicanH @Anonymousmexi @rofl4all @Anon_yuc
"
}

get_test_url ()
{
echo "Antes de instalar tor, tienes que escribir el nombre de tu distribucion:\n"
echo " Debian unstable (sid) is "'sid'" "
echo " Debian testing is "'wheezy'" "
echo " Debian 6.0 (squeeze) is "'squeeze'""
echo " Debian 5.0 (lenny) is "'lenny'""
echo " Ubuntu 12.04 is "'precise'" "
echo " Ubuntu 11.10 is "'oneiric'""
echo " Ubuntu 11.04 is "'natty'""
echo " Ubuntu 10.10 or Trisquel 4.5 is "'maverick'""
echo " Ubuntu 10.04 or Trisquel 4.0 is "'lucid'""
echo " Ubuntu 9.10 or Trisquel 3.5 is "'karmic'""
echo " Ubuntu 8.04 is "'hardy'"\n"
  echo "distribucion : "
  read  distribucion
  echo 
echo "deb  http://deb.torproject.org/torproject.org $distribucion main" >> /etc/apt/sources.list
clear scr
echo "[*] Instalando las llaves...."
gpg --keyserver keys.gnupg.net --recv 886DDD89
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
echo "Done!!"
clear scr
echo "[*] Actualizando repositorios...."
apt-get update
clear scr
echo "[*] Instalando paquetes deb"
apt-get install deb.torproject.org-keyring
echo "[*] Done!!"
clear scr
echo "[*] Instalando TOR, Privoxy, & Polipo"
apt-get install tor
echo "[*] Done!!"
apt-get install privoxy
echo "[*] Configurando privoxy"
echo "forward-socks4a / 127.0.0.1:9050 . " >> /etc/privoxy/config
apt-get install polipo
echo "[*] Configurando polipo"
cd /etc/polipo/
rm  config > /dev/null
wget --output-document=config http://www.pps.univ-paris-diderot.fr/~jch/software/polipo/config.sample 
echo "Done!!"
echo "Tor ha sido instlado satisfactoriamente."

}

if [ "$colorise" = 1 ]; then print_welcome  ; fi ;
get_test_url
Leer más...

Script Automatizacion para instalar gcc-4.6.2

d
Autor: Joelinoff
Descripción: Script que nos automatiza la instalación de Gcc 4.6.2 descargando, compilando y ejecutando debidamente


#!/bin/bash
umask 0
mkdir -p /shared/tools/gcc/gcc-4.6.2
cd /shared/tools/gcc/gcc-4.6.2
wget http://projects.joelinoff.com/gcc-4.6.2/bld.sh
chmod a+x bld.sh
./bld.sh 2>&1 | tee bld.log
Leer más...

The shell it's alive!

d
Autor: Ricardo Osorio
Twitter: @HackeaMesta
Descripción: Script que permite que la terminal hable y salude
Visto en: HackeaMesta
#!/bin/bash 

ifespeak=`type -p espeak`
 if [ -z $ifespeak ]; then
  echo "Para mejor funcionamiento necesita tener instalado espeak"
  echo "sudo apt-get install espeak"
  echo "sudo yum install espeak"
  echo "Intentalo nuevamente"
  exit 1
 fi
 
NOMBRE=`cat /etc/passwd | grep "^$LOGNAME" | cut -d: -f5 | cut -d' ' -f1` 
HORA=`date | cut -c12-13 | tr -d ' '` 
tiempo=`date +%H:%M` 
dia=`date +%d` 
mes=`date +%m` 
ano=`date +%Y` 
if expr '$HORA <= 4' > /dev/null  
then 
echo 'Buenas noches, '$NOMBRE | espeak -v es-la -s 150 2>/dev/null 
sleep=1 
echo 'Son las, '$tiempo',, horas,, del '$dia',,,, del '$mes',,,, de '$ano'' | espeak -v es-la -s 140 2>/dev/null 
sleep=1 
echo 'el sistema operativo esta listo para usarse' | espeak -v es-la -s 150 2>/dev/null 
sleep=1 
echo ',,,,que disfrutes tu sesión en Debian' | espeak -v es-la -s 140 2>/dev/null 
elif expr '$HORA < = 11' > /dev/null ] 
then 
echo 'Buenos dias, '$NOMBRE | espeak -v es-la -s 150 
sleep=1 
echo 'Son las, '$tiempo', horas,, del '$dia',,,, del '$mes',,,, de '$ano'' | espeak -v es-la -s 140 
sleep=1 
echo 'el sistema operativo esta listo para usarse' | espeak -v es-la -s 150 
sleep=1 
echo ',,,,que disfrutes tu sesión en Debian' | espeak -v es-la -s 140 
elif  expr '$HORA < = 18' > /dev/null 
then 
echo 'Buenas tardes, '$NOMBRE | espeak -v es-la -s 150 
sleep=1 
echo 'Son las, '$tiempo', horas,, del '$dia',,,, del '$mes',,,, de '$ano'' | espeak -v es-la -s 140 
sleep=1 
echo 'el sistema operativo esta listo para usarse' | espeak -v es-la -s 150 
sleep=1 
echo ',,,,que disfrutes tu sesión en Debian' | espeak -v es-la -s 140 
elif expr '$HORA < = 24' > /dev/null  
then 
echo 'Buenas noches, '$NOMBRE | espeak -v es-la -s 150 
sleep=1 
echo 'Son las, '$tiempo', horas,, del '$dia',,,, del '$mes',,,, de '$ano'' | espeak -v es-la -s 140 
sleep=1 
echo 'el sistema operativo esta listo para usarse' | espeak -v es-la -s 150 
sleep=1 
echo ',,,,que disfrutes tu sesión en Debian' | espeak -v es-la -s 140 
fi
El script detecta 3 zonas horarias 
1. Buenos días
2. Buenas tardes
3. Buenas noches
Dependiendo de que hora sea
Damos permisos de ejecución
chmod +x habla.bash
Ejecutamos el script
./habla.bash
Leer más...

Script Cambiando de directorios interactivamente

d
Autor: |Leo Gutiérrez R.
Descripción: Script para cambiar de directorios interactivamente.
 Mail: leorocko13[at]hotmail


#!/bin/bash - 
#===============================================================================
#
#          FILE:  cdprompt.sh
# 
#         USAGE:  ./cdprompt.sh 
# 
#   DESCRIPTION:  Cambio de directorios interactivamente.
# 
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: |Leo Gutiérrez R.| (), |leorocko13[at]hotmail|
#       COMPANY: 
#       CREATED: 02/26/2011 01:51:28 AM CST
#      REVISION:  ---
#===============================================================================
 
select directorio in */ "SALIR"
do
 if [ "$directorio" = "SALIR" ]
 then
  break;
 elif [[ -n "$directorio" ]]
 then
  cd "$directorio"
  break;
 else 
  echo -e "\aError de opción.";
  break;
 fi
done
Leer más...

Nieve en la Terminal

d
Llego la navidad para nuestra terminal demasiado tarde :) pero llego.
Asi que se puede ver que con bash se puede realizar cosas interesantes



#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)

declare -A snowflakes
declare -A lastflakes

clear

function move_flake() {
i="$1"

if [ "${snowflakes[$i]}" = "" ] || [ "${snowflakes[$i]}" = "$LINES" ]; then
snowflakes[$i]=0
else
if [ "${lastflakes[$i]}" != "" ]; then
printf "\033[%s;%sH \033[1;1H " ${lastflakes[$i]} $i
fi
fi

printf "\033[%s;%sH❄\033[1;1H" ${snowflakes[$i]} $i

lastflakes[$i]=${snowflakes[$i]}
snowflakes[$i]=$((${snowflakes[$i]}+1))
}

while :
do
i=$(($RANDOM % $COLUMNS))

move_flake $i

for x in "${!lastflakes[@]}"
do
move_flake "$x"
done

sleep 0.1
done
Guardamos como nieve.sh
chmod +x nieve.sh 
y lo ejecutamos
./neige.sh
Leer más...