Skip to content

Instantly share code, notes, and snippets.

View larsar's full-sized avatar

Lars Preben Sørsdahl larsar

View GitHub Profile
@larsar
larsar / config.txt
Created January 4, 2020 01:31
Config for Raspbee /mnt/boot/config.txt for hassio
enable_uart=1
dtoverlay=pi3-miniuart-bt
dtoverlay=uart0-full
core_freq=250
@larsar
larsar / gen_formatted_codes.sh
Created February 12, 2019 10:16
Generate unique invite codes formatted for print
python3 gen_invite_codes.py > all_codes.csv
sed 's/\([[:digit:]][[:digit:]][[:digit:]]\)\([[:digit:]][[:digit:]][[:digit:]]\)\([[:digit:]][[:digit:]][[:digit:]]\)/\1-\2-\3/' all_codes.csv > formatted_codes.csv
@larsar
larsar / query_diff.sql
Last active April 8, 2022 10:31
Diff result from two different SQL queries
WITH query1 AS (SELECT * FROM ...),
query2 AS (SELECT * FROM ...),
in_query1 AS (SELECT * FROM query1 EXCEPT SELECT * FROM query2),
in_query2 AS (SELECT * FROM query2 EXCEPT SELECT * FROM query1)
SELECT 'query1' AS query, *
FROM in_query1
UNION ALL
SELECT 'query2' AS query, *
FROM in_query2;
@larsar
larsar / delete_es_snapshots.sh
Created September 7, 2017 13:03
Delete Elasticsearch snapshots for a date range
#!/usr/bin/env bash
d=2016-02-14
while [ "$d" != 2016-03-01 ]; do
curl -X DELETE http://<HOST>/_snapshot/<INDEX>/snapshot-`echo $d | tr - .` -H 'content-type: application/json'
d=$(date -I -d "$d + 1 day")
done
@larsar
larsar / keybase.md
Created March 20, 2017 11:38
Keybase verification

Keybase proof

I hereby claim:

  • I am larsar on github.
  • I am larsar (https://keybase.io/larsar) on keybase.
  • I have a public key ASBKn12pNjd5t6lYKZARkU8atBVOYGr-22tU43Nu5RUtfgo

To claim this, I am signing this object:

@larsar
larsar / fetch_repo_urls.sh
Created October 4, 2016 06:54
Simple script for retrieving all rep URLs from Bitbucket Server
#!/usr/bin/env bash
URL="https://<HOST>/rest/api/1.0/projects"
>&2 printf "Enter Bitbucket Server credentials\n"
>&2 printf "Username: "
read username
>&2 printf "Password: "
read -s password
@larsar
larsar / fetch_repo_urls.sh
Created October 4, 2016 06:54
Simple script for retrieving all rep URLs from Bitbucket Server
#!/usr/bin/env bash
URL="https://<HOST>/rest/api/1.0/projects"
>&2 printf "Enter Bitbucket Server credentials\n"
>&2 printf "Username: "
read username
>&2 printf "Password: "
read -s password
@larsar
larsar / test_mail_server_auth.sh
Created April 26, 2016 10:17
Check user authentication with SMTP
#!/usr/bin/env bash
[[ $@ ]] || {
printf "Usage\n\t./$0 server username password\n"
exit 1
}
SERVER=$1
MAILUSER=$2
PASSWORD=$3
/* global _ */
/*
* Complex scripted Logstash dashboard
* This script generates a dashboard object that Kibana can load. It also takes a number of user
* supplied URL parameters, none are required:
*
* index :: Which index to search? If this is specified, interval is set to 'none'
* pattern :: Does nothing if index is specified. Set a timestamped index pattern. Default: [logstash-]YYYY.MM.DD
@larsar
larsar / gist:bc43b7f508b87fe8a9e1
Created June 7, 2014 07:26
Regex for replacing global variable with let in specs in RubyMine.
Search: @(\S*)\s=
Replace: let(:$1) {