Skip to content

Instantly share code, notes, and snippets.

Avatar

Florian Beeres cideM

View GitHub Profile
View wai_auth.hs
getSessionFromDb :: SQLite.Connection -> ByteString -> IO (Maybe Session)
getSessionFromDb conn id =
SQLite.query conn "SELECT expires,userid FROM sessions WHERE id = ?" [id]
>>= \dbResult -> case dbResult of
[s :: Session] -> return $ Just s
[] -> return Nothing
other -> throwString $ "unexpected DB result: " <> show other
getRolesFromDb :: SQLite.Connection -> Int -> IO (Maybe [Role])
getRolesFromDb conn userId =
View issue2.sh
echo '[{"name":"v1.22.10","zipball_url":"https://api.github.com/repos/yarnpkg/yarn/zipball/v1.22.10","tarball_url":"https://api.github.com/repos/yarnpkg/yarn/tarball/v1.22.10","commit":{"sha":"785cda8020aa5f513d6f60b8349bca8dab9dd79b","url":"https://api.github.com/repos/yarnpkg/yarn/commits/785cda8020aa5f513d6f60b8349bca8dab9dd79b"},"node_id":"MDM6UmVmNDk5NzA2NDI6cmVmcy90YWdzL3YxLjIyLjEw"}]' | tr ',' '\n' | awk -F'":"' '{ version; gsub(/"/, "", $2); if ($1 ~ /name/ ) { version = $2; } if ($1 ~ /tarball/) { gsub(/v/, "", version); print version, $2; } }'
View issue.sh
echo '[{"name":"v1.22.10","zipball_url":"https://api.github.com/repos/yarnpkg/yarn/zipball/v1.22.10","tarball_url":"https://api.github.com/repos/yarnpkg/yarn/tarball/v1.22.10","commit":{"sha":"785cda8020aa5f513d6f60b8349bca8dab9dd79b","url":"https://api.github.com/repos/yarnpkg/yarn/commits/785cda8020aa5f513d6f60b8349bca8dab9dd79b"},"node_id":"MDM6UmVmNDk5NzA2NDI6cmVmcy90YWdzL3YxLjIyLjEw"}]' | tr ',' '\n' | awk -F'":"' '{ version;
gsub(/"/, "", $2)
if ($1 ~ /name/ ) { version = $2 }
if ($1 ~ /tarball/) { gsub(/v/, "", version); print version, $2 } }'
View foo.js
const vanillaFn = (notes) => {
const grouped = {};
notes.forEach((note) => {
const {
author: { id: currentId },
content,
section,
} = note;
if (!grouped[section]) grouped[section] = { len: 0, data: {} };
@cideM
cideM / foo
Created Jan 7, 2021
Nix Shell With Specific GHC Version
View foo
$ nix-env -f "<nixpkgs>" -qaP -A haskell.compiler
haskell.compiler.ghc8101 ghc-8.10.1
haskell.compiler.integer-simple.ghc8101 ghc-8.10.1
haskell.compiler.ghc8102 ghc-8.10.2
haskell.compiler.integer-simple.ghc8102 ghc-8.10.2
haskell.compiler.ghc8102Binary ghc-8.10.2-binary
haskell.compiler.ghc8102BinaryMinimal ghc-8.10.2-binary
haskell.compiler.integer-simple.ghc8103 ghc-8.10.3
haskell.compiler.ghc8103 ghc-8.10.3
haskell.compiler.native-bignum.ghcHEAD ghc-8.11.20200824
View example.hs
#! /usr/bin/env nix-shell
#! nix-shell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [scotty text relude co-log])" -i "runghc -Wall"
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PatternSynonyms #-}
@cideM
cideM / example.hs
Created Dec 7, 2020
Problem with `fgl` in Haskell
View example.hs
#! /usr/bin/env nix-shell
#! nix-shell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [fgl])" -i "runghc -Wall"
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.Graph.Inductive.Graph as G
import qualified Data.Graph.Inductive.NodeMap as GM
import Data.Graph.Inductive.PatriciaTree (Gr)
type Graph = Gr String Integer
View Main.purs
module Main where
import Prelude
import Effect (Effect)
import Control.Monad.Except.Trans (throwError)
import Effect.Console (log)
import Control.Alt ((<|>))
import Data.Generic.Rep as GR
import Foreign (Foreign, ForeignError(..), fail)
import Foreign as Foreign
View configuration.nix
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
View flake.nix
{
description = "Nix. All. The. Things.";
inputs = {
home-manager = {
url = "github:rycee/home-manager";
inputs.nixpkgs.follows = "/unstable";
};
nixpkgs = {