Skip to content

Instantly share code, notes, and snippets.

View Akii's full-sized avatar
🚀
To the Moon

Akii

🚀
To the Moon
View GitHub Profile
IBNR Name Übersicht Bahnhöfe Name Haltestellendaten dist f=wrong
8000491 Ahlten (Han) Altenglan 3 f
8007821 Aldingen Üdingen 2 f
8003331 Alheim-Heinebach Kleinsteinbach 6 f
8013471 Allee-Center Leipzig Böhlen(Leipzig) 9 f
8070185 Allermöhe Alveslohe 4 f
8011017 Alte Wöhr Altefähr 2 f
8000446 Anderten-Misburg Ahrensburg 6 f
8012996 Attilastraße Silberstraße 5 f
8010011 Auerbach (b Mosbach) Auerbach(V) ob Bf 5 f
@Akii
Akii / StarRating.vue
Created February 17, 2020 19:48
Probably accessible star rating component for Vue.
<template>
<div>
<span class="visually-hidden" :aria-hidden="!readonly">{{ starLabel(value) }}</span>
<span v-for="i in [1, 2, 3, 4, 5]" :key="i" :aria-hidden="readonly">
<label class="visually-hidden">
{{ starLabel(i) }}
<input
type="radio"
defmodule Stuff do
use Combine
defmodule ContentRangeRequest do
@moduledoc """
Represents the Range header sent by the client
"""
defstruct key: :id, id: nil, offset: 0, limit: 0, order: :asc
end
def parse_range(range, max_limit \\ 500) do
range_p =
either(
many1(alphanumeric()) |> ignore(space()) |> string() |> ignore(char(";")),
many1(alphanumeric()) |> ignore(char(";"))
)
limit_p = fn a -> a |> ignore(string("limit ")) |> integer() |> ignore(char(";")) end
offset_p = fn a -> a |> ignore(string("offset ")) |> integer() |> ignore(char(";")) end
@Akii
Akii / downtimes.ex
Created January 8, 2020 19:55
GenServer for scale
defmodule Elescore.Projection.Downtimes do
use GenServer
def start_link() do
GenServer.start_link(__MODULE__, nil, name: __MODULE__)
end
def init(_arg) do
# We wait a bit for the disruption projection
Process.send_after(self(), :calculate_downtimes, 30_000)
@Akii
Akii / Submit.hs
Created October 19, 2019 17:07
Must look like magic for some folks
executeForm :: FormV2 -> Bool -> PageM [TagTree LBS.ByteString]
executeForm FormV2 {..} doSubmit = do
initRequest
personalPage personal
disabilitiesPage disabilities
outwardMeetingPoints <- executeOutwardConnection outwardTrainRide (isJust returnTrainRide)
returnMeetingPoints <- executeReturnConnection returnTrainRide
meetingPointsPage outwardMeetingPoints returnMeetingPoints
@Akii
Akii / DOMTransformation.hs
Created October 19, 2019 12:37
TagSoup removing all script tags and adding a base tag
import qualified Data.ByteString.Lazy as LBS
import Text.HTML.TagSoup
import Text.HTML.TagSoup.Tree
addBaseTag :: LBS.ByteString -> [TagTree LBS.ByteString] -> [TagTree LBS.ByteString]
addBaseTag href = transformTree f
where
f (TagBranch "head" attrs subTrees) = [TagBranch "head" attrs (baseTag : subTrees)]
f x = [x]
@Akii
Akii / ConnectionParser.hs
Created October 13, 2019 08:18
Parsing in Haskell is awesome
-- The goal was to parse a text describing the connection which is used by screen readers:
-- Strecke von Karlsruhe Hbf, Abfahrtszeit 11:59 von Gleis 3 nach Berlin Hauptbahnhof, Ankunftszeit 18:03 auf Gleis 2, mit ICE 370
-- Translated:
-- Connection from Karlsruhe Hbf, Departuretime 11:59 from track 3 to Berlin Hauptbahnhof, Arrivaltime 18:03 on track 2, with ICE 370
data Connection
= Departure
{ departStation :: Text
, departAt :: Text
@Akii
Akii / better_slack.js
Last active June 24, 2019 07:55
Basically a starting point of hiding channels and blocking users in Slack
document.addEventListener("DOMContentLoaded", function() {
let hiddenChannels = ['general']
let blockedUsers = ['Slackbot']
let customCss = `
.p-channel_sidebar__static_list div[role="listitem"]:empty { display: none; }
`
hiddenChannels.concat(blockedUsers).forEach(it => {
customCss += `a[aria-label~="${it}"] { display: none; }\n`
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}