Skip to content

Instantly share code, notes, and snippets.

Akii

Block or report user

Report or block Akii

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Akii
Akii / Submit.hs
Created Oct 19, 2019
Must look like magic for some folks
View Submit.hs
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 Oct 19, 2019
TagSoup removing all script tags and adding a base tag
View DOMTransformation.hs
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 Oct 13, 2019
Parsing in Haskell is awesome
View ConnectionParser.hs
-- 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 Jun 24, 2019
Basically a starting point of hiding channels and blocking users in Slack
View better_slack.js
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`
View ibnr_mapping.csv
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
View Body.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}
View ChunkChan.hs
chunkChan :: Int -> Int -> TChan a -> IO [a]
chunkChan numItems timeoutSeconds chan = do
maybeRead <- timeout (timeoutSeconds * 60 * 1000) . atomically $ replicateM numItems (readTChan chan)
case maybeRead of
Just as -> return as
Nothing -> do
as <- emptyChannel chan
if null as
then chunkChan numItems timeoutSeconds chan
else return as
View WhyTho.hs
instance (Ord a) => Ord [a] where
compare [] [] = EQ
compare [] (_:_) = LT
compare (_:_) [] = GT
compare (x:xs) (y:ys) = case compare x y of
EQ -> compare xs ys
other -> other
View gist:3f792f149b23a23dca0ecab9230e0569
-- This is part of a pipeline that continously produces `ev`s
-- Essentially this is a fold or scan. I call `a` a "projection" of a series of `ev`s
projectionConsumer :: IORef a -> (ev -> a -> a) -> Consumer ev IO ()
projectionConsumer ref f = for cat $ modifyIORef' ref . f
-- projectionBConsumer :: IORef b -> (ev -> b -> b) ...
-- I now have this issue of composing multiple of these folds
-- What I resorted to is something like this
someOtherProjection :: IORef a -> IORef x -> IO ()
View SomeTemplate.elm
itemView : Item -> Html Msg
itemView item =
tr []
[ td [ class "item-id" ] [ text ("#" ++ item.id) ]
, td [ class "item-name" ] [ text item.name ]
]
You can’t perform that action at this time.