Skip to content

Instantly share code, notes, and snippets.

View reinefjord's full-sized avatar

Rupus Reinefjord reinefjord

View GitHub Profile
@reinefjord
reinefjord / appn.sh
Created May 16, 2023 10:15
appending to file if line does not exist
#!/bin/sh
while read -r line
do
grep -q -s "^$line$" "$1" || echo "$line" >> "$1"
done
# usage: echo "line the might exist" | ./appn.sh myfile
@reinefjord
reinefjord / myi3status.sh
Created May 24, 2021 15:39
Adding custom script output to i3status json (output_format = i3bar)
#!/bin/bash
i3status | {
read -r first # read version object
echo "$first" # output version object as is
# read json array stream and collect each element
jq -c --stream --unbuffered 'fromstream(1|truncate_stream(inputs))' | {
# start json array
echo '['
# read each json object (arrays)
while read -r line
@reinefjord
reinefjord / mongo-34-expired-key.md
Last active January 15, 2020 08:51
Mongo 3.4 expired sig key
# apt update
[...]
GPG error: http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 Release:
The following signatures were invalid: EXPKEYSIG BC711F9BA15703C6 MongoDB 3.4
Release Signing Key <packaging@mongodb.com>

The key has expired, but the mongo org has extended the expiry time on the same key available on their website. Download it and import to apt:

import flask
import werkzeug
from teknologkoren_se_v2.translations import translations
def get_string(name):
return translations[name][get_locale()]
def get_locale():
@reinefjord
reinefjord / history-and-back.flask.py
Created May 19, 2019 10:01
Functions for saving user browsing history and getting a url for the previous page visited in flask. Lots of edge cases left.
@app.after_request
def save_response(r):
if flask.request.method == 'POST':
return r
if flask.request.endpoint == 'static':
return r
history = flask.session.get('history', [])
@reinefjord
reinefjord / får.c
Last active February 1, 2018 21:44
får-loop
#include <stdio.h>
#define får for
#define bää printf
int main(void)
{
får (int i = 0; i < 10; i++)
{
bää("%d får\n", i);
}