Skip to content

Instantly share code, notes, and snippets.

View stoft's full-sized avatar

Rasmus stoft

  • 12:49 (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 / 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 / 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 / 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 / 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 / christmas_tree_golf.ex
Last active December 5, 2015 10:46
Elixir Golf Christmas Tree Puzzle
iex(134)> m=String;for x<-0..10,y=x<1&&"*"||x>9&&"H"||"0",z=1<x&&x<10&& m.rjust("0",x-1,?0)||"",do: IO.puts m.rjust(z,8)<>y<>z
*
0
000
00000
0000000
000000000
00000000000
0000000000000
000000000000000
@stoft
stoft / DiscoBoxen.elm
Last active November 30, 2015 22:10
Displays 10 boxes, one of them randomly switching off every cycle (200ms).
module DiscoBoxen where
import Array exposing (fromList, get)
import Color exposing (Color, black, white, green, red, blue, yellow, brown, purple, orange)
import Graphics.Element exposing (Element, spacer, color, flow, right, show)
import List exposing (foldr, (::))
import Random exposing (generate, initialSeed)
import Time exposing (every, millisecond, second)
drawSquare : Int -> Int -> Color -> Element