Skip to content

Instantly share code, notes, and snippets.

View amitaibu's full-sized avatar

Amitai Burstein amitaibu

View GitHub Profile
instance ToJSON Html where
toJSON html = String (TL.toStrict $ Renderer.renderHtml html)
data-tree={encode someJsonValue}
<div class="flex flex-row justify-between">
<div>Name</div>
<div class="flex flex-row items-center gap-x-4 divide-x">
<div>Edit</div>
<div>Delete</div>
</div>
</div>
let
# Execute:
# nix-shell --run 'make build/ihp-lib's
ihp = builtins.fetchGit {
url = "https://github.com/digitallyinduced/ihp.git";
# ref = "refs/tags/v0.19.0";
rev = "05f1eafbe897dfdbf8a77e5bd0673b1857f4e8c2";
};
haskellEnv = import "${ihp}/NixSupport/default.nix" {
curl --silent https://raw.githubusercontent.com/digitallyinduced/ihp/master/Troubleshoot/ihp-troubleshoot | python3
Checking that the current directory is an IHP project:
+ Found Main.hs
+ Found start script
+ Nix installed
Checking direnv:
+ Found .envrc
+ direnv loads .envrc
+ direnv allows .envrc
DEBUG=1 ./start
direnv: loading ~/Sites/Haskell/ihp/ihp-simple-seat-reservation/.envrc
direnv: export ~PATH
IHP Version: 0.20.0
Opening in existing browser session.
GET /
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Status: 302 Found 0.002388625s
[("ihpVersion","0.20.0"),("os","linux"),("arch","x86_64"),("projectId","02f68fafb04ff896261af0ac082ec9f688c950e1d1b6612e3a5f304a5cfc91c6dc7e6cd27c08d0aea4c5dba559bc041e98ee90fdfce8c83d69208692adef74b7")]
[
    {
        "key": "1",
        "tree": [
            {
                "key": "1.1",
                "tree": {
                    "key": "1.1.1"
 }
module Radix exposing (..)
import List.Extra
import Tree
import Tree.Zipper as TreeZipper
empty : Tree.Tree (List a)
empty =
Tree.singleton []

I'd like to convert the List (List Int) to a Tree, where it will group similar items together.

So imagine the following:

[
  [ 1 , 2, 3, 4]
  [ 1 , 2, 5, 6]
  [ 1 , 2, 3, 7]
]
@amitaibu
amitaibu / example.hs
Last active September 30, 2021 12:40
action CreateBidAction = do
let bid = newRecord @Bid
bid
|> buildBid
>>= ifValid \case
Left bid -> render NewView { .. }
Right bid -> do
bid <- bid |> createRecord
_ <- forkIO $ do
# https://ddev.readthedocs.io/en/stable/users/cli-usage/#drupal-8-quickstart
mkdir my-drupal8-site
cd my-drupal8-site
ddev config --project-type=drupal8 --docroot=web --create-docroot
ddev start
ddev composer create "drupal/recommended-project:^8"
ddev composer require drush/drush
ddev launch