Skip to content

Instantly share code, notes, and snippets.

@joefiorini
joefiorini / undo.elm
Last active Aug 29, 2015
An example of a genericized undo/redo in Elm
View undo.elm
import List
import List ((::))
import Signal
import Signal ((<~), (~))
import Html
import Html (div, text, button, ul, input, li, p, label)
import Html.Attributes (disabled, type', name, id, value, checked)
import Html.Events (onClick, on, targetValue)
@joefiorini
joefiorini / toggle.elm
Created Jan 9, 2015
Signal.toggle for Elm
View toggle.elm
import Signal
import Html
import Html (div, text, button)
import Html.Events (onClick)
toggle s1 s2 s =
Signal.foldp
(\prev curr ->
if prev == s1 then s2 else s1) s1 s
View xmbarrc.hs
Config { font = "xft:Source Code Pro:size=24:bold:antialias=true"
, bgColor = "#002b36"
, fgColor = "#657b83"
, position = TopP 0 150
, lowerOnStart = True
, commands = [ Run Cpu ["-L", "3", "-H", "50", "-n", "#719e07", "-h", "#dc322f"] 10
, Run Battery ["-t", "<left>% (<timeleft>)", "-L", "25", "-H", "75", "-h", "#719e07", "-n", "#b58900", "-l", "#dc322f"] 10
, Run ThermalZone 0 ["-t", "<temp> C", "-L", "40", "-H", "79", "-h", "#dc322f", "-n", "#b58900", "-l", "#719e07"] 10
, Run Memory ["-t","<usedratio>%"] 10
, Run Date "%a %_d/%m %H:%M" "date" 10
@joefiorini
joefiorini / main.elm
Created Jan 8, 2015
String Calculator Kata in Elm
View main.elm
import Graphics.Element (..)
import Graphics.Input.Field (Content, Selection, Direction(..))
import Graphics.Input.Field as Field
import Signal
import Time
import String
import List
import Result
import Text (plainText)
import Debug
View main.js
var Elm = Elm || { Native: {} };
Elm.Array = Elm.Array || {};
Elm.Array.make = function (_elm) {
"use strict";
_elm.Array = _elm.Array || {};
if (_elm.Array.values)
return _elm.Array.values;
var _op = {},
_N = Elm.Native,
_U = _N.Utils.make(_elm),
View keter.service
[Unit]
Description=Keter Deployment Tool
[Service]
ExecStart=/opt/keter/bin/keter /opt/keter/etc/keter-config.yaml
[Install]
WantedBy=multi-user.target
View compiler-output.txt
Main.hs:47:3:
Couldn't match type ‘WhebT WhebShort () IO HandlerResponse’
with ‘HandlerResponse’
Expected type: LoggingT (WhebT WhebShort () IO) HandlerResponse
Actual type: LoggingT (WhebT WhebShort () IO) ShortHandler
In a stmt of a 'do' block:
return
$ renderHtml
$ layout
$ do { ((Control.Monad.Logger.monadLoggerLog
@joefiorini
joefiorini / rails.nix
Created Sep 18, 2014
Nix Expression for Running Rails Apps
View rails.nix
with (import <nixpkgs> {});
stdenv.mkDerivation {
name = "717-app";
buildInputs = [ libiconv openssl ruby21 postgresql git nodejs ];
src = "/src/717";
builder = builtins.toFile "builder.sh" ''
set -e
source $stdenv/setup
View error.log
test-hsp.hs:27:8:
Couldn't match type `XMLType (ServerPartT IO)' with `XML'
Expected type: XMLGenT (ServerPartT IO) XML
Actual type: XMLGenT (ServerPartT IO) (XMLType (ServerPartT IO))
In the return type of a call of `genElement'
In the first argument of `unXMLGenT', namely
`(genElement
(Nothing, fromStringLit "html")
[]