Skip to content

Instantly share code, notes, and snippets.

@isalgueiro
isalgueiro / 50-pfsense.conf
Last active January 22, 2022 13:58
Logstash configuration for pfSense firewall logs (filterlog)
input {
# output logs in pfsense to syslog
tcp {
port => 10514
type => "pfsense"
tags => ["unparsed"]
}
udp {
port => 10514
type => "pfsense"
@isalgueiro
isalgueiro / profile.ps1
Last active July 17, 2017 08:46
Windows PowerShell profile setup
$env:LC_ALL="C.UTF-8"
. $env:LOCALAPPDATA\GitHub\shell.ps1
. $env:github_posh_git\profile.example.ps1
. (Join-Path -Path (Split-Path -Parent -Path $PROFILE) -ChildPath $(switch($HOST.UI.RawUI.BackgroundColor.ToString()){'White'{'Set-SolarizedLightColorDefaults.ps1'}'Black'{'Set-SolarizedDarkColorDefaults.ps1'}default{return}}))
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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