Skip to content

Instantly share code, notes, and snippets.

View javierwilson's full-sized avatar

javier wilson javierwilson

  • Managua, Nicaragua
View GitHub Profile
@javierwilson
javierwilson / update-wordpress.sh
Created April 24, 2012 15:20
actualizacion de varios sitios de wordpress
#!/bin/bash
SRC=/tmp/wordpress
DST=/var/www
SITES=( example.com example.org example.net )
for site in ${SITES[@]}; do
echo "Upgrading $site"
dir="$DST/$site/public_html"
bak="$DST/$site/public_html.bak"
# backup
@javierwilson
javierwilson / audacity_rescue2.sh
Created May 6, 2012 12:51
recover audacity 2.0 crash data
#!/bin/bash
#Recover from an Audacity 2.0 crash by reassembling the saved data files
#Based on https://gist.github.com/912222
if [ $# != 2 ]; then
echo "ERROR: Not enough arguments"
echo "$0 [SOURCE PATH] [DESTINATION]"
exit 1
fi
@javierwilson
javierwilson / smarty2jinja.pl
Created May 14, 2012 13:07
Convert Smarty template to Jinja
#!/usr/bin/perl
sub rtrim($) {
my $string = shift;
$string =~ s/\s+$//;
return $string;
}
@lines=(<>);
for (@lines) {
s/{if \$(.*?)}/{% if \1 %}/g;
s/{elseif \$(.*?)}/{% elif \1 %}/g;
#!/bin/bash
if [ -z $1 ]; then
echo "Usage: $0 <virtual_machine_name>"
exit
fi
VM=$1
HOMEIMG=/home/$VM
OLDDISK=$HOMEIMG/$VM.img
#!/usr/bin/python
import os, os.path
import fileinput
files_in_dir = os.listdir('.')
for f in files_in_dir:
for line in fileinput.input(f, inplace=1):
#for line in fileinput.input(f):
if line == '<head>\n':
print '%s<script language="javascript">if(self.location==top.location)self.location="index.html?%s";</script>' % (line, f)
@javierwilson
javierwilson / lookup.php
Created April 3, 2013 01:00
looks up an ip address in a DNSBL zone
<?php
$zone = 'dnsbl.example.com';
if (isset($_REQUEST['ip'])) {
$ip = preg_replace('/[^0-9.]/', '', $_REQUEST['ip']);
if(filter_var($ip, FILTER_VALIDATE_IP)) {
$fields = explode('.', $ip);
$fields = array_reverse($fields);
$reverse_ip = implode('.', $fields);
$record = $reverse_ip . '.' . $zone;
$result = dns_get_record($record, DNS_A);
@javierwilson
javierwilson / fabfile.py
Last active July 10, 2017 17:49
yum update with fabric
#
# $ fab set_hosts update
#
from fabric.api import run, env, sudo
from fabric.contrib.console import confirm
env.warn_only = True
def set_hosts():
@javierwilson
javierwilson / decodifica.php
Created April 22, 2013 22:26
decodifica recursivamente código de hackers
<?php
$var = "TEXTO_CODIFICADO_EN_BASE64";
decodifica(base64_decode($var));
function decodifica($text) {
$a = $text;
$a = preg_replace('/eval\((.*)\);/', '\\1', $a);
if (preg_match('/base64_decode/', $a)) {
$a = preg_replace('/base64_decode\("(.*)"\)/', '\\1', $a);
$a = base64_decode($a);
@javierwilson
javierwilson / create_vm.sh
Created October 10, 2013 02:39
Crea una máquina virtual con Fedora 19 (no gráficos!)
#!/bin/bash
NAME=$1
RAM=512
DIR=/var/images
virt-install \
--name $NAME \
--ram 512 \
--disk path=$DIR/$NAME.img,size=10 \
@javierwilson
javierwilson / .bashrc
Last active September 8, 2016 21:12
~/.bashrc & /etc/ssh/ssh_config
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
export GIT_AUTHOR_NAME="Bob Smith"
export GIT_AUTHOR_EMAIL="[email protected]"