Skip to content

Instantly share code, notes, and snippets.

View alambike's full-sized avatar

Javier Gómez Rodríguez alambike

View GitHub Profile
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(strftime);
my @dmesg_new = ();
my $dmesg = "/bin/dmesg";
my @dmesg_old = `$dmesg`;
my $now = time();
@alambike
alambike / moshscr
Created March 31, 2014 23:43
mosh lanzando screen (ou enganchandose á última aberta), para dispoñer de scroll
#!/bin/bash
/usr/bin/mosh --no-init $1 -- screen -dR
@alambike
alambike / clearcache.sh
Created April 30, 2014 19:26
Drop RAM cache and clean swap
#!/bin/sh
sync; echo 3 > /proc/sys/vm/drop_caches
swapoff -a && swapon -a
@alambike
alambike / pfdel.pl
Created July 2, 2014 18:47
deletes message from postfix queue containing specified address (accepts '@Domain' as valid address)
#!/usr/bin/perl -w
#
# pfdel - deletes message containing specified address from
# Postfix queue. Matches either sender or recipient address.
#
# Usage: pfdel <email_address>
#
use strict;
@alambike
alambike / purge_old_kernel.sh
Created July 17, 2014 07:18
Purge old kernel images, headers and modules
# http://markmcb.com/2013/02/04/cleanup-unused-linux-kernels-in-ubuntu/
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'| xargs sudo apt-get purge -y
@alambike
alambike / ejemplos
Last active August 29, 2015 14:07
Descarga recursiva dun site
# por ftp con wget
wget -r --user=<usuario> --password=<password> ftp://<host>
# por http con wget
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent --domains <dominio> -H <dominio>
# por http con httrack
httrack "http://<dominio>/" -O <path_almacenamiento> "+*.<dominio>/*" -v
@alambike
alambike / sysctl.conf
Created December 8, 2014 12:02
ubuntu sysctl.conf tune up from rtcamp.com (https://rtcamp.com/tutorials/linux/sysctl-conf/)
### IMPROVE SYSTEM MEMORY MANAGEMENT ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@alambike
alambike / mongodb
Last active August 29, 2015 14:16
NOTAS
# Reparar as tablas de mongodb, por exemplo cando se cerrou mal o servidor, para correxir o erro:
# exception in initAndListen: 12596 old lock file, terminating
mongodb mongod --repair --dbpath /var/lib/mongodb/
chown -R mongodb:mongodb /var/lib/mongodb
@alambike
alambike / .tmux.conf
Last active August 29, 2015 14:21
configuracion do byobu con tmux para poder usar a roda do mouse para facer scroll, e Ctrl-Left ,Right para moverse entre palabras
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
set-window-option -g xterm-keys on