Skip to content

Instantly share code, notes, and snippets.

View edofic's full-sized avatar

Andraž Bajt edofic

View GitHub Profile
@edofic
edofic / index.html
Created May 6, 2023 19:26
htmx + mock requests = SPA?
<!DOCTYPE html>
<html>
<head>
<title>Hello Page</title>
<script src="https://unpkg.com/htmx.org@1.9.2"></script>
<script src="https://unpkg.com/mock-requests@1.3.2/index.js"></script>
<script language="javascript">
MockRequests.setDynamicMockUrlResponse('/ui/button',
{
@edofic
edofic / index.html
Created May 6, 2023 19:06
htmx with a "backend" in service worker
<!DOCTYPE html>
<html>
<head>
<title>Hello Page</title>
<script src="https://unpkg.com/htmx.org@1.9.2"></script>
</head>
<body>
<h1>Hello</h1>
@edofic
edofic / _ go pub sub systems comparison
Last active September 4, 2022 14:38
redis pub sub vs redis streams vs grpc streams
.
@edofic
edofic / parser.py
Created December 9, 2019 16:36
generator based recursive descent parsers
import doctest
from collections import namedtuple
import sys
def parse_string(target):
"""
>>> list(parse_string('foo')('foobar'))
[('foo', 'bar')]
>>> list(parse_string('foo')('bar'))
@edofic
edofic / fizzbuzz.hs
Last active November 5, 2017 09:35
fizzbuzz in haskell using a simple control structure
module Main where
main :: IO ()
main = print $ fb <$> [0..15]
fb :: Int -> String
fb n = fallthrough (show n) concat [ (n `mod` 3 == 0, "Fizz")
, (n `mod` 5 == 0, "Buzz")
]
@edofic
edofic / parser.hs
Last active November 2, 2017 09:42
Parser combinators from scratch in Haskell
import Control.Applicative
import Data.List
newtype Parser a = Parser { runParser :: String -> [(a, String)] }
parseConst :: a -> Parser a
parseConst a = Parser $ \s -> [(a, s)]
parseString :: String -> Parser String
parseString target = Parser p where
@edofic
edofic / parser.py
Created November 2, 2017 09:05
parser combinators in python
from collections import namedtuple
Lazy = namedtuple('Lazy', 'force')
def parseConst(a):
"""
>>> parseConst(1)('')
[(1, '')]
"""
@edofic
edofic / git_commands.wiki
Created October 10, 2017 12:17
Git commands notes

Ask for help

    git --help
    git <command> --help

Commiting

  git commit -am wip
  git commit -m "Initial commit" --allow-empty
  git commit --amend --allow-empty --no-edit

@edofic
edofic / tuple_get.scala
Last active August 31, 2017 15:37
Tuple apply method in scala
object App {
// this integer references can be avoided when/if SIP-23 - Literal-based
// singleton types is implemented
val _1 = 1: Integer
val _2 = 2: Integer
val _3 = 3: Integer
// ... up to 22
trait TupleGet[T, A, N <: Integer] {
@edofic
edofic / modulo.hs
Created July 15, 2017 07:20
type parametrized modulo arithmetic
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Main where
import Data.Proxy
import GHC.TypeLits