Skip to content

Instantly share code, notes, and snippets.

View hgmiguel's full-sized avatar

Miguel Angel Huerta Gonzalez hgmiguel

View GitHub Profile
@hgmiguel
hgmiguel / connect_bluetooth_headphones.sh
Created September 6, 2022 14:40 — forked from egelev/connect_bluetooth_headphones.sh
Connect bluetooth headphones on Ubuntu 18.04
#!/usr/bin/env bash
function get_headphones_index() {
echo $(pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}')
}
function get_headphones_mac_address() {
local temp=$(pacmd list-cards | grep bluez_card -C20 | grep 'device.string' | cut -d' ' -f 3)
temp="${temp%\"}"
temp="${temp#\"}"
@hgmiguel
hgmiguel / bitcoin_wash.sh
Created May 12, 2019 00:53
bitcoin watch with bitso
#!/bin/bash
NUMBER=$1
BTC=$(curl --silent "https://api.bitso.com/v3/ticker/?book=btc_mxn" | jq -r '.payload.last')
echo "$BTC$NUMBER"
echo $BTC
while (( $(echo "$BTC$NUMBER" | bc -l) ))
@hgmiguel
hgmiguel / immediately-promotion.groovy
Created June 23, 2017 00:31
Obtiene una lista de usuarios de la variable de ambiente APPROVERS y la injecta al proceso de promoción.
promotionProcess.getPromotionCondition("hudson.plugins.promoted_builds.conditions.ManualCondition").setUsers(build.getEnvVars()["APPROVERS"])
return true
@hgmiguel
hgmiguel / add-server-group.cli
Created October 6, 2016 15:52
[wildfly-cli] add a server-group, server and jvm to wildfly in domain mode
set serverGroupName=${env.WILDFLY_SERVER_GROUP_NAME}
set portOffset=${env.WILDFLY_PORT_OFFSET}
set host=${env.WILDFLY_HOST}
set maxHeapSize=${env.WILDFLY_MAX_HEAP_SIZE}
set permgenSize=${env.WILDFLY_PERMGEN_SIZE}
set jvmOptions=${env.WILDFLY_JVM_OPTIONS}
batch
import json
import boto3
import logging
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
logger = logging.getLogger()
CONFIG = {'hgmigueldb-replica1': 'i-847d9502'}
def get_source_id(message):
@hgmiguel
hgmiguel / wath_rds_logs.sh
Created May 14, 2016 19:18
script para deterctar errores en los logs de postgres rds
#!/bin/bash
INSTANCES="sepa-prod-db-replica-analysis sepa-prod-db-replica1 sepa-prod-db-replica2 sepa-prod-db-replica3 sepa-prod-db-replica4"
DATE=$(date +"%Y-%m-%d")
FILENAME=$(aws rds describe-db-log-files --db-instance-identifier sepa-prod-db-replica1 --filename-contains $DATE --max-items 1 --output text | awk '{print $3}')
#filename="error/postgresql.log.2016-05-14-13"
for DB_INSTANCE in $INSTANCES ; do
echo $DB_INSTANCE
aws rds download-db-log-file-portion --db-instance-identifier $DB_INSTANCE --log-file-name $FILENAME --output text | grep 'ERROR: prepared statement\|connection to client lost'
@hgmiguel
hgmiguel / download.rds.logs.sh
Last active July 13, 2017 14:18
Download rds log file
for i in `aws rds describe-db-log-files --db-instance-identifier ${INSTANCE} --output text | awk '{print $3}' | sed '$d' ` ; do
FILE=`basename ${i}`
if [ ! -e ${INSTANCE}/${FILE} ]; then
aws rds download-db-log-file-portion --db-instance-identifier ${INSTANCE} --log-file-name ${i} --output text > ${INSTANCE}/${FILE}
fi
@hgmiguel
hgmiguel / DemoDynamic.groovy
Created November 11, 2014 03:14
Ejemplo de invocacion dinamica de metodos en groovy
class DemoDynamic {
Map<String, List<String>> permissions = [:]
Boolean hasPermission(String name, String permission){
permission in permissions?."$name"
}
Map createPermission(String name, List<String> permissions) {
this.permissions?."$name" = permissions
this.permissions
@hgmiguel
hgmiguel / busca.groovy
Created October 27, 2014 23:42
busca minas horrible
file = new File('input.txt')
board = [][]
file.eachWithIndex {obj, i ->
if (i == 0) {
(rows, columns) = obj.split(" ")*.toInteger()
} else {
board << ([0] << obj.collect{ it == '*'?'*':0 } << [0]).flatten()
}
}
@hgmiguel
hgmiguel / Collection_Pipeline.groovy
Created July 27, 2014 17:32
Collection Pipeline in groovy
some_articles
.collectMany{article -> article.tags.collect{ [ ( it ), article] }}
.groupBy{it.first()}
.collectEntries {k,v -> [( k ): v.collect {it.last()}]}
.collect {k,v -> [( k ):[articles: v.size(),words:v.collect{it.words}.inject(0) { acc, val -> acc + val }] ]}