Skip to content

Instantly share code, notes, and snippets.

View xarvh's full-sized avatar

Francesco Orsenigo xarvh

View GitHub Profile
@xarvh
xarvh / elm-format-hack
Created June 1, 2021 12:15
A wrapper for elm-format to nicely indent chained `andThen`s (ie, pseudo do-notation)
#!/usr/bin/env node
// A work around to https://github.com/avh4/elm-format/issues/352
// * Use it in place of elm-format (only some flags are supported)
// * Run it from a directory containing node_modules/elm-format/bin/elm-format (but you can change it below)
function extractFirstRegexMatch(regex, elmCode) {
@xarvh
xarvh / README.md
Last active December 18, 2019 09:44
Proposal: transpile Elm to GLSL

Proposal: transpiling Elm code to GLSL

The main problem that this proposal wants to solve is the inability to reuse code when writing shaders: if I declare a function in a shader, the only way I can reuse it in a different shader is to cut and paste the function code.

This prevents us from writing generic code that can be reused and shared in libraries.

@xarvh
xarvh / Main.elm
Last active December 1, 2019 11:24
findDuplicatesBy benchmark
module Main exposing (main)
import Benchmark exposing (Benchmark, benchmark, describe)
import Benchmark.Runner exposing (BenchmarkProgram, program)
import Browser
import Dict exposing (Dict)
import List.Extra
onn : (a -> comparable) -> List a -> Maybe ( a, a )
[Unit]
Description=xboxdrv daemon
[Service]
ExecStart=/usr/bin/xboxdrv --daemon --quiet --dbus disabled
Type=simple
[Install]
WantedBy=multi-user.target
@xarvh
xarvh / MyGame.elm
Last active July 28, 2017 22:53
API options comparison for elm-gamepad
{-
As a game developer, I want to allow the player to remap the game controls, to allow them using non-recognised pads and suit their personal comfort.
As a game developer, I want to access specific gamepad inputs with consistent naming that does not depend on hardware or user preferences.
-}
-- Option A
@xarvh
xarvh / Label.elm
Created May 30, 2017 01:36
Floating label for a cartesian chart
type alias Label =
{ content : String
, mainColor : String
, textColor : String
-- origin point, in data coordinates
, dataX : Float
, dataY : Float
-- origin point Y, in svg coordinates
module Counter where
import Html exposing (..)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
import Effects
import Task
@xarvh
xarvh / rotate-screen.sh
Created December 29, 2015 08:27 — forked from rubo77/rotate-screen.sh
This script rotates the screen and touchscreen input, disables or enbles the touchpad, and dis- or enables the virtual keyboard on a Lenovo Yoga 13 or Yoga 2 Pro (source: http://askubuntu.com/q/405628/34298)
#!/bin/bash
# This script rotates the screen and touchscreen input 90 degrees each time it is called,
# also disables the touchpad, and enables the virtual keyboard accordingly
# by Ruben Barkow: https://gist.github.com/rubo77/daa262e0229f6e398766
#### configuration
# find your Touchscreen and Touchpad device with `xinput`
TouchscreenDevice='ELAN Touchscreen'
TouchpadDevice='SynPS/2 Synaptics TouchPad'