Skip to content

Instantly share code, notes, and snippets.

Avatar

Ulric Wilfred shamansir

View GitHub Profile
@shamansir
shamansir / purs-typeclasses.cue
Last active May 15, 2021
PureScript typeclasses in CUE -> JSON, for https://imgur.com/a/ESOR7
View purs-typeclasses.cue
plus: {
name: "Plus"
info: "Left and Right identity for Alt"
parent: "alt"
"package": "Control*"
members:
[
{ name: "empty"
, def: "f a"
, laws : // FIXME: laws are incorrect
@shamansir
shamansir / FromHex.elm
Last active May 3, 2021
Color from Hex in Elm
View FromHex.elm
module FromHex exposing (..)
import Color exposing (Color)
hexToColor : String -> Result String Color
hexToColor str =
let
digitToInt digit =
case digit of
@shamansir
shamansir / backloggery_load_games.js
Last active Aug 16, 2021
Load games list as JSON From Backloggery page
View backloggery_load_games.js
let games = Array.from(document.getElementsByClassName('gamebox'));
function loadTitle(gamebox) {
if (!gamebox) return null;
return gamebox.querySelector('h2 b') ? gamebox.querySelector('h2 b').textContent.trim() : null;
}
function isNowPlaying(gamebox) {
return gamebox.classList.contains('nowplaying');
}
@shamansir
shamansir / macOSVideoScreenSaver.md
Last active Oct 2, 2020
Installing video file as a screensaver on macOS
View macOSVideoScreenSaver.md

Based on this article: https://workspacevita.com/how-to-use-own-videos-screensavers-mac-catalina/

The difference is that the Aerial Configuration screens shown there are outdated.

First, you need to prepare the video file so it would be visible to Aerial. Due to security.

  1. Create /Users/Shared/screensavers folder.
  2. Put a copy of your video file to /Users/Shared/screensavers.
  3. That should be enough.
@shamansir
shamansir / BinPack.elm
Created Aug 26, 2020
Elm 2D Bin Packing
View BinPack.elm
module BinPack exposing (..)
import Browser
import Html exposing (Html, button, div, text, input)
import Html.Attributes as H exposing (..)
import Html.Events exposing (onClick)
import Random
import Svg exposing (..)
import Svg.Attributes as S exposing (..)
@shamansir
shamansir / Main.elm
Last active Aug 14, 2020
Elm program quick template
View Main.elm
module Main exposing (..)
import Browser
import Html exposing (Html)
import Html as H
type alias Flags = ()
@shamansir
shamansir / Main.elm
Last active Jun 25, 2020
Elm parser loop example
View Main.elm
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, h2, input, text)
import Html.Attributes exposing (class, placeholder, value)
import Html.Events exposing (onClick, onInput)
import Parser exposing (..)
import Parser as P exposing (..)
View Component.hs
module ComonadicUI.Component where
import Control.Comonad (Comonad(..))
import ComonadicUI.Pairing
import ComonadicUI.UI
type Component base w m a = w (UI base m a)
@shamansir
shamansir / prepare.sh
Created Mar 10, 2020
Image Magick MacOS X Preparation
View prepare.sh
# magick: set the correct path to libMagickCore.dylib
install_name_tool -change \
/ImageMagick-7.0.9/lib/libMagickCore-7.Q16HDRI.7.dylib \
@executable_path/../lib/libMagickCore-7.Q16HDRI.7.dylib \
/Users/shamansir/ImageMagick-7.0.9/bin/magick
# magick: set the correct path to libMagickWand.dylib
install_name_tool -change \
/ImageMagick-7.0.9/lib/libMagickWand-7.Q16HDRI.7.dylib \
@executable_path/../lib/libMagickWand-7.Q16HDRI.7.dylib \
View Errors.hs
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE FlexibleInstances #-}
module Errors2 where
import Prelude
import Control.Monad.Identity