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
@mauricioprado00
mauricioprado00 / show-from-source
Created July 19, 2017 13:23
show from source for phpstorm in ubuntu
#!/usr/bin/env bash
# requires: imagemagik, xdotool, xwininfo
window_id=$(xwininfo -tree -root | grep 'PhpStorm 2016.2.2' | awk '{print $1}')
window_x=$(xwininfo -id $window_id | grep 'Absolute upper-left X' | awk '{print $NF}')
window_y=$(xwininfo -id $window_id | grep 'Absolute upper-left Y' | awk '{print $NF}')
import -window $window_id /tmp/screenshot.jpg
convert -crop 250x40+200+45 /tmp/screenshot.jpg /tmp/toolbar.jpg
position=$(compare -metric RMSE -subimage-search /tmp/toolbar.jpg ~/show-from-source.jpg similarity.jpg 2>&1 | awk '{print $NF}')
@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
@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;
#!/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) {
// ==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==
@mauricioprado00
mauricioprado00 / product-website.php
Last active July 31, 2020 12:03
magento product website assigner
<?php
/**
* Intellimage
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.opensource.org/licenses/osl-3.0.php