Skip to content

Instantly share code, notes, and snippets.

Avatar
🌿

Marco Z ocramz

🌿
View GitHub Profile
@ocramz
ocramz / URIDecoding.hs
Created April 23, 2023 12:26
decoding URI-encoded strings in Haskell
View URIDecoding.hs
import Data.Bits ((.|.),(.&.),shiftL)
import Data.Char (chr, isHexDigit, digitToInt)
import Data.Text (Text, pack, unpack)
{-
sources :
uri-encode (https://hackage.haskell.org/package/uri-encode-1.5.0.7/docs/src/Network.URI.Encode.html#decodeText)
network-uri (https://hackage.haskell.org/package/network-uri-2.6.4.2/docs/src/Network.URI.html#unEscapeString)
@ocramz
ocramz / get_highlighted_text.html
Last active November 3, 2022 21:05
Get highlighted text (Firefox, Chrome but not on IE)
View get_highlighted_text.html
<!DOCTYPE html>
<html>
<body>
Select some text below and then click the button:<br/>
<textarea id="myText" rows="5" cols="60" onselect="alert(getTextSelection())">
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
</textarea>
View server-sent-events.html
<!DOCTYPE html>
<html>
<head>
{{>head}}
{{#user}}
<title>Back {{name}} checkout | satsbacker</title>
{{/user}}
</head>
<body>
{{>header}}
View server-sent-events.hs
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
module Invoicing
( invoiceRoutes
, newInvoice
, waitInvoices
) where
@ocramz
ocramz / histograms-vega.json
Created March 1, 2019 15:54
Multiple histograms in `vega`, colour-coded by a feature
View histograms-vega.json
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 200,
"height": 200,
"padding": 5,
"data": [
{
"name": "d1",
"values": [
{"a": 0, "c": "2.5", "z": 0},
@ocramz
ocramz / scatterplot-over-heatmap-vega.json
Last active January 13, 2020 08:41
Overlay a scatterplot on top of a heatmap in `vega`
View scatterplot-over-heatmap-vega.json
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 200,
"height": 200,
"padding": 5,
"data": [
{
"name": "d1",
"values": [
{"a": 0, "b": 0, "c": "36.5"},
View records-to-lists.hs
import qualified GHC.Generics as G
-- | generics-sop
import Generics.SOP
import Generics.SOP.NP (collapse_NP)
-- | Python in Haskell yay!
--
-- Example :
View comonad-graph.md
layout title date comments author categories commentIssueId
post
A comonad of graph decompositions
2016-04-02 13:02:54 -0400
true
Rúnar
scala comonads
22
@ocramz
ocramz / existential-constraint.hs
Last active June 16, 2016 13:27 — forked from phadej/existential-constraint.hs
This is short gist about problem I run today into, and its solution. It feels that probably I'm over engineering stuff, so: please comment!
View existential-constraint.hs
#!/usr/bin/env stack
-- stack --resolver=lts-6.0 runghc --package constraints --package mtl --package lens --package text --package time
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, ConstraintKinds, UndecidableInstances, ScopedTypeVariables, InstanceSigs, OverloadedStrings, TemplateHaskell #-}
-- This is short gist about problem I run today into,
@ocramz
ocramz / gist:56bb62e139321a204df2
Created November 6, 2015 13:31 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
View gist:56bb62e139321a204df2
  1. General Background and Overview