Skip to content

Instantly share code, notes, and snippets.

View mauricioprado00's full-sized avatar
🏠
Working from home

mauricioprado00

🏠
Working from home
View GitHub Profile
// ==UserScript==
// @name Lista paises facturas afip
// @namespace http://your.homepage/
// @version 0.1
// @description Agregar lista de paises a la generación de factura de afip
// @author Hugo Mauricio Prado Macat
// @match https://serviciosjava2.afip.gob.ar/rcel/jsp/genComDatosReceptor.do
// @grant none
// ==/UserScript==
#!/bin/bash
# the file whoami.php should be placed in http://someserver/ with this content:
# <?php echo $_SERVER['REMOTE_ADDR'];
function do100tor() {
for i in {1..100}
do
tor > /dev/null 2>&1 &
@mauricioprado00
mauricioprado00 / issues.php
Created January 28, 2016 20:39
look for magento issues with SUPEE-7405
<?php
# use like this:
# cd <yourmagentodir>; php -f isssues.php
$files = `find . -type f -iname "config.xml"`;
$files = explode("\n", trim($files));
foreach ($files as $file) {
@mauricioprado00
mauricioprado00 / dinamically-reading-tables.sql
Last active September 10, 2016 21:57
dinamically reading tables postgresql
create function test(tablename text) RETURNS void as $$
DECLARE
r text;
BEGIN
raise notice 'reading from: %', tablename;
FOR r IN execute ('SELECT sid FROM ' || tablename)
LOOP
-- can do some processing here
raise notice 'sid readed: %', r;
@mauricioprado00
mauricioprado00 / docker-orphan.sh
Created October 13, 2016 09:57
docker build cleanup
#!/usr/bin/env bash
# see https://lebkowski.name/docker-volumes/
# The command doesn’t remove anything, but simply passing the results to xargs -r rm -fr does so.
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
docker ps -aq | xargs docker inspect | jq -r '.[]|.Mounts|.[]|.Name|select(.)'
)
# Hint: docker 1.9 has new volume management system, so it’s way easier with this version:
# docker volume ls -qf dangling=true | xargs -r docker volume rm
#!/usr/bin/env bash
# requires: imagemagik, xdotool, xwininfo
# usage: click-by-image [image-file-to-search] [window partial title] [section x] [section y] [section width] [section height]
# section parameter is to cut the image of the window and make imagemagik faster
image_file=$1
window_title=$2
section_x=$3
section_y=$4
@mauricioprado00
mauricioprado00 / git-addmodified
Last active August 4, 2017 13:02
New command for adding only modified files to stage
#!/bin/bash
# usage:
# git addmodified
git add $(git status --porcelain | awk '/^.M/{print $2}')
# New command for adding only modified files to stage
# save it with:
@mauricioprado00
mauricioprado00 / monitor-user-crontabs.sh
Last active August 16, 2017 09:07
Monitor users without a crontab
#!/usr/bin/env bash
cat <<EOF > /usr/local/etc/icinga-crontabs.sh
#!/usr/bin/env bash
function cleanup-dir() {
rm -Rf /icinga/crontabs
mkdir -p /icinga/crontabs
chmod -R 444 /icinga/
chmod 555 /icinga /icinga/crontabs
}
@mauricioprado00
mauricioprado00 / apache-chrooted.sh
Last active November 1, 2017 15:52
apache chrooted debian
# requires (on ubuntu: apt-get install -y debootstrap)
thisdir=./squeeze-distro
# create chroot system
# debootstrap stable ${thisdir} http://ftp.us.debian.org/debian
debootstrap --arch i386 squeeze ${thisdir} http://archive.debian.org/debian/
# mount devices
dirs=(/dev /dev/pts /dev/shm /tmp)
@mauricioprado00
mauricioprado00 / create-openvpn-server.sh
Created November 2, 2017 23:00
create openvpn server
# a fully automated script to configure an openvpn server and create the config for one user
# tested only on ubuntu
# Configurar un Servidor OpenVPN en Ubuntu 16.04
# from https://www.digitalocean.com/community/tutorials/como-configurar-un-servidor-openvpn-en-ubuntu-16-04-es
server_name="NY-DO"
client_1=mauricio
port=443
server_ip=$(dig +short myip.opendns.com @resolver1.opendns.com)