Skip to content

Instantly share code, notes, and snippets.

View stoft's full-sized avatar

Rasmus stoft

  • 07:27 (UTC +02:00)
View GitHub Profile
@stoft
stoft / exif-to-file-metadata.sh
Last active November 29, 2022 21:17
Update file metadata from Exif metadata MacOS
#!/bin/zsh
for file in *.JPG; do
before=`GetFileInfo -d $file`
touch -mt `exiftool -s -s -s -d "%Y%m%d%H%M.%S" -DateTimeOriginal $file` $file;
var=$(exiftool -s -s -s -d "%m/%d/%Y %H:%M:%S" -DateTimeOriginal $file)
SetFile -d "$var" $file;
dir=$(exiftool -s -s -s -d "%Y/%m" -DateTimeOriginal $file)
echo "$dir/$file : $before --> `GetFileInfo -d $file`"
mkdir -p "$dir"
mv -n $file ./$dir/$file
@stoft
stoft / avanza-extract.js
Last active June 3, 2021 08:17
Avanza Extract
console.log([...document.getElementsByTagName('table')]
//AVANZA
.filter(t => t.caption && (t.caption.innerText.toLowerCase().includes("fonder") || t.caption.innerText.includes("Certifikat")))
.map(t => [...t.getElementsByTagName('tbody')]
.map(tb => [...tb.getElementsByTagName('tr')]
.map(tr =>
(tr.cells[2].innerText.replace(/Superräntan\s?$/,"")
+ `\t` + tr.cells[8].innerText.replace(/\s/g,"")
+ "\t" + tr.cells[3].innerText))))
.reduce((acc, e) => e[0].concat(acc).join("\n")
@stoft
stoft / nordnet-extract.js
Last active October 16, 2020 04:44
Nordnet Extract
[...document.getElementsByTagName('div')]
// NORDNET
.filter(e => e.getAttribute('role') === 'row')
.filter(e => !e.getAttribute('class').match('HeaderRow__|FooterRow__'))
.map(r => [...r.children])
.map(cells => cells[1].innerText + '\t' + cells[8].innerText.replace(/\s/, '') + '\t' + cells[3].innerText)
.join("\n") + "\nCash\t" + [...document.getElementsByTagName('h2')]
.filter((e) => e.innerText === "Tillgängligt för handel")[0]
.parentNode.parentNode.childNodes[1].getElementsByTagName('span')[1].textContent.replace(/(\s|SEK)/g,"");
@stoft
stoft / AWS-ECS-mindmap.md
Last active May 7, 2020 08:23
AWS ECS Mindmap
graph TD
    subgraph EC2
        subgraph Network and Security
            secGroup(Security Group)
            inboundRules(Inbound rules)
        end

        subgraph Load Balancing
            loadBalancers(Load Balancers)
@stoft
stoft / logstash.conf
Created March 24, 2014 05:39
Logstash configuration for TCP input, JSON filter and ElasticSearch output
input {
tcp{
port => 5000
}
}
filter {
# Only process messages that have the keywords Audit or System.
if ([message] =~ "Audit|System" ) {
json {
@stoft
stoft / freedom-house-extract.js
Last active June 19, 2019 20:44
Extracts Freedom House's list of countries to an array
// open https://freedomhouse.org/report/countries-world-freedom-2019
// run in Chrome console and then `copy(arr)`
let arr = [];
for (tr of document.getElementsByTagName('tbody')[0].getElementsByTagName('tr')) {
tds = tr.getElementsByTagName('td');
let isTerritory = tds[1].getElementsByTagName('a')[0].innerText.endsWith('*');
let name = tds[1].getElementsByTagName('a')[0].innerText;
arr.push(
{
url: tds[1].getElementsByTagName('a')[0].href,
@stoft
stoft / iis-cerebro.txt
Created April 18, 2017 14:40
Setup IIS 7.5 as proxy for Cerebro
# Setup IIS 7.5 as proxy for Cerebro
# Note: requires basePath in Cerebro config to be '/cerebro/'
# Set up Cerebro server as a server farm
%windir%\system32\inetsrv\appcmd.exe set config -section:webFarms /+"[name='cerebro-farm']" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:webFarms /+"[name='cerebro-farm'].[address='localhost']" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:webFarms /[name='cerebro-farm'].[address='localhost'].applicationRequestRouting.httpPort:"9000" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:webFarms /[name='cerebro-farm'].[address='localhost'].applicationRequestRouting.httpsPort:"9443" /commit:apphost
# Set up routing rules
@stoft
stoft / iis-kibana.txt
Created April 18, 2017 14:37
Set up IIS 7.5 as proxy for Kibana
# Setup IIS 7.5 as proxy for Kibana
# Note: requires server.basePath in Kibana config to be '/kibana'
# Set up Kibana server as a server farm
%windir%\system32\inetsrv\appcmd.exe set config -section:webFarms /+"[name='kibana']" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:webFarms /+"[name='kibana'].[address='localhost']" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:webFarms /[name='kibana'].[address='localhost'].applicationRequestRouting.httpPort:"5601" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config -section:webFarms /[name='kibana'].[address='localhost'].applicationRequestRouting.httpsPort:"5643" /commit:apphost
# Set up routing rules
module Bootstrap.Examples.Signin exposing (..)
import Html exposing (Html, node, label, h2, text)
import Html.Attributes exposing (rel, href, class, for, required, autofocus, type_)
import Html.Events exposing (onCheck, onInput, onSubmit)
import Bootstrap.Grid as Grid
import Bootstrap.Form as Form
import Bootstrap.Form.Checkbox as Checkbox
import Bootstrap.Form.Input as Input
import Bootstrap.Button as Button
@stoft
stoft / recursivehtml2text.py
Last active January 3, 2016 16:39
Short python script to recursively process html files with mark2text.py (https://github.com/aaronsw/html2text) thus converting them to MD docs instead (e.g. a Tomboy notes extracted collection). Written for OSX, YMMV.
import os
import subprocess
import sys
import string
import re
for dir, subdir, files in os.walk( sys.argv[1] ):
for filename in files:
# ignore OSX fs file
if( filename != ".DS_Store"):