Skip to content

Instantly share code, notes, and snippets.

@isalgueiro
isalgueiro / update-alternatives-for-manually-installed-jdk.sh
Created May 15, 2018 10:42
This script update all Java related alternatives to point a manually installed JDK.
#!/bin/bash
# Run update-alternatives for a manual installed JDK
JAVA_HOME=/opt/java/jdk1.8.0_152
java_bins=(appletviewer extcheck idlj jarsigner java javac javadoc javafxpackager javah javap javapackager java-rmi.cgi javaws jcmd jconsole jcontrol jdb jdeps jhat jinfo jjs jmap jps jrunscript jsadebugd jstat jstatd jvisualvm keytool native2ascii orbd pack200 policytool rmic rmid schemagen servertool tnameserv wsgen wsimport xjc jar jmc jmc.ini jstack rmiregistry serialver unpack200)
for java_bin in ${java_bins[@]}; do
echo "Setting $java_bin..."
update-alternatives --install /usr/bin/$java_bin $java_bin $JAVA_HOME/bin/$java_bin 1
@isalgueiro
isalgueiro / updateAWSecurityGroup.bash
Last active December 15, 2020 16:17 — forked from antonmry/updateAWSecurityGroup.bash
Simple bash script to update a Security Group matched by description and port in AWS with your Public IP
#! /bin/bash
publicIP=`dig +short myip.opendns.com @resolver1.opendns.com`
securityGroupIds="sg-stuffstuff"
ruleDescription="This is the string we're using to find our rule"
## Consult previous one
awsOutput=`aws ec2 describe-security-groups --group-ids $securityGroupIds`
ipRangeIndex=`echo $awsOutput | gron | grep $ruleDescription | sed "s/.\+IpRanges\[\([0-9]\+\)\].\+/\1/"`
@isalgueiro
isalgueiro / kubuntu-to-neon.md
Last active April 8, 2018 21:31 — forked from nihathrael/kubuntu-to-neon.md
How to upgrade kubuntu 16.04 -> KDE neon

This worked for me and might not work for you. It's a seriuos change to your system, you need to be familiar with apt and with fixing missing or invalid dependencies.

Try it at your own risk!

Uninstall any KDE or Plasma related package

apt purge kubuntu-desktop plasma-desktop kde-baseapps kde-runtime kubuntu-driver-manager
apt autoremove
@isalgueiro
isalgueiro / golang and angular development environment.md
Created February 7, 2018 10:53
setup a development environment with hot reloading code changes

This is useful for environments where the angular app is served directly from golang. For example, using github.com/julienschmidt/httprouter and having angular build in frontend/dist directory

	router := httprouter.New()
// All your router config here [...]
	router.NotFound = http.FileServer(http.Dir("./frontend/dist"))
	router.RedirectFixedPath = false
	router.RedirectTrailingSlash = false
  http.ListenAndServe(":8080", router)
@isalgueiro
isalgueiro / logstash_geoip.conf
Last active November 30, 2017 09:53
Adding geoip info in logstash is not an straightforward configuration. You need to adapt `location` field to visualize it properly in Kibana (i.e. use it in a map view).
if [remote_host] =~ /.+/ {
geoip {
source => "remote_host"
}
if "_geoip_lookup_failure" not in [tags] {
mutate {
remove_field => ["[geoip][location]"] # para que non mande un array
}
mutate {
convert => {"[geoip][latitude]" => "float"}
@isalgueiro
isalgueiro / parallel_http.R
Created November 29, 2017 13:06
HOW-TO get parallel HTTP connections in R
library(parallel)
library(httr)
library(RCurl)
detectCores()
f <- function(x) {
#h <- httr::handle('http://slowwly.robertomurray.co.uk/')
#httr::GET('http://slowwly.robertomurray.co.uk/delay/2000/url/http://www.google.co.uk', handle = h)
RCurl::httpGET('http://slowwly.robertomurray.co.uk/delay/2000/url/http://www.google.co.uk')
#Sys.sleep(2)
return(T)
@isalgueiro
isalgueiro / jira-get_worklog.php
Created November 7, 2017 17:34
How to get list of worklogs through JIRA REST API
<?php
// https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-get-list-of-worklogs-through-JIRA-REST-API/qaq-p/533633
$server = 'jira.example.com';
$fromDate = '2017-11-07';
$toDate = '2012-11-08';
$project = 'X';
$assignee = 'bob';
$username = 'username';
$password = 'password';
@isalgueiro
isalgueiro / 2utf8.sh
Created November 6, 2017 16:06
Convert all ISO-8859 files to UTF-8
#!/bin/bash
# Convert all ISO-8859 files in $1 directory to UTF-8
error_check() {
res=$1
if [ $res -ne 0 ]; then
echo ""
echo "error $res"
exit $res
@isalgueiro
isalgueiro / _run_metricbeat_with_old_kernels.md
Last active March 16, 2018 09:24
Run metricbeat with old kernels where original init.d script fails with `kernel too old` message

In old kernels (~2.6.20) beats fail to start with a message like this:

FATAL: kernel too old
/bin/bash: line 1:  5496 Segmentation fault      /usr/share/metricbeat/bin/metricbeat-god -r / -n -p /var/run/metricbeat.pid -- /usr/share/metricbeat/bin/metricbeat -c /etc/metricbeat/metricbeat.yml -path.home /usr/share/metricbeat -path.config /etc/metricbeat -path.data /var/lib/metricbeat -path.logs /var/log/metricbeat
                                                           [FAILED]

You can replace original /etc/init.d/metricbeat file with this script to run metricbeat in old Red Hat systems. After replacing the file run checkconfig --add metricbeat so metricbeat starts automatically with every system start.

@isalgueiro
isalgueiro / docker-compose.yml
Created July 18, 2017 12:03
Docker compose for wordpress
version: '3.1'
services:
mywebdb:
image: mysql:5.7
volumes:
- mywebdb_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: supersecretpassword