Skip to content

Instantly share code, notes, and snippets.

@aldrinmartoq
aldrinmartoq / ejecutar_en_paralelo.rb
Created August 29, 2018 16:26
Ejecuta un comando que convierte archivos en paralelo, desde un directorio origen a otro de destino. Los archivos ya generados no los vuelve a generar.
#!/usr/bin/env ruby
# sudo gem install ruby-progressbar
require 'ruby-progressbar'
module ForkEach
def fork_each(progressbar, max = 4)
pids = []
self.each do |item|
progressbar.increment
#!/usr/bin/env ruby
module ForkEach
def fork_each(max = 4)
pids = []
self.each do |item|
pids << fork { yield item }
pids.delete(Process.wait 0) if pids.length >= max
end
pids.each { |pid| Process.wait pid }
-- THIS SCRIPT HAS NOT BEEN TESTED, PLEASE CHECK CAREFULLY BEFORE RUNNING IT
-- USE AT YOUR OWN RISK
-- Function: public.clone_schema(text, text, boolean)
-- DROP FUNCTION public.clone_schema(text, text, boolean);
CREATE OR REPLACE FUNCTION public.clone_schema(
source_schema text,
dest_schema text,
<script type="text/vnd.graphviz" id="graphviz">
digraph G {
"realizar solicitud de compra" [shape=box];
"analizar presupuesto" [shape=box];
"realizar informe caso" [shape=box];
"tomar medidas" [shape=box];
"realizar cotización" [shape=box];
"inicio" ->
"realizar solicitud de compra" ->
@aldrinmartoq
aldrinmartoq / run.sh
Last active April 20, 2016 14:54
Ejemplo correr script bash con log
#!/bin/bash
export DISPLAY=:0
cd $(dirname "$0")
# tira la salida std y err de este script a este archivo
exec >> spension.log 2>&1
# que muestre los comandos
set -x
require 'webdrone'
a0 = Webdrone.create browser: :firefox, timeout: 10
def entrar_dga(a0)
a0.open.url 'http://dgasatel.mop.cl/'
a0.clic.on 'Ingrese Aquí'
a0.clic.on 'Entrar'
end
require 'webdrone'
a0 = Webdrone.create browser: :chrome, timeout: 10
def bajar_excel_spensiones(a0, y, m, d)
a0.open.url 'http://www.spensiones.cl/safpstats/stats/apps/vcuofon/vcfAFP.php?tf=A'
a0.form.set 'aaaaVCF', y
a0.form.set 'mmVCF', m
a0.form.set 'ddVCF', d
@aldrinmartoq
aldrinmartoq / 01_delta.rb
Last active December 16, 2015 16:25
Ejemplo extraer tarifa más baja de un vuelo
require 'webdrone'
a0 = Webdrone.create browser: :chrome, create_outdir: true, timeout: 30
a0.open.url 'http://www.delta.com/'
a0.shot.screen 'inicio'
a0.form.set 'originCity', 'SCL'
a0.form.set 'destinationCity', 'SDQ'
a0.form.set 'departureDate', '12/24/2015'
a0.form.set 'returnDate', '1/30/2016'
#include <dlfcn.h>
#include <execinfo.h>
// Uso: callmemaybe(2) así por ser…
__attribute__((noinline)) NSString *callmemaybe(int item) {
void *bt[1024];
int bt_size;