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: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 / 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 / _ 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 / 0690ms.js
Last active March 29, 2019 12:24
testing lambda lifting in javascript
function test() {
var total = 0;
for(i = 0; i< 100000000; i++) {
total = total ^ ((i * i + i + 4 * i + 1) / i);
}
return total;
}
console.log(test());
@edofic
edofic / indirect.py
Created May 15, 2017 06:42
Indirect parametrization in pytest
import pytest
@pytest.fixture()
def user(request):
user = 'mock user'
if hasattr(request, 'param'):
user += ': {}'.format(request.param)
return user
@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