Skip to content

Instantly share code, notes, and snippets.

@moonlightdrive
moonlightdrive / xmonad.hs
Created April 2, 2017 00:35
xmonad+xfce4
import XMonad
import XMonad.Config.Xfce
import XMonad.Hooks.EwmhDesktops
import XMonad.Util.Replace(replace)
main = do
replace
xmonad $ ewmh xfceConfig
{ terminal = "xfce4-terminal --hide-menubar"
, manageHook = myManageHook <+> manageHook xfceConfig
@moonlightdrive
moonlightdrive / mouse_position.elm
Created July 26, 2016 16:52
Print Left or Right when mouse on left or right side of window respectively
-- Prints Left or Right when mouse on left or right side of window respectively
{-
"dependencies": {
"elm-lang/core": "4.0.3 <= v < 5.0.0",
"elm-lang/html": "1.1.0 <= v < 2.0.0",
"elm-lang/mouse": "1.0.0 <= v < 2.0.0",
"elm-lang/window": "1.0.0 <= v < 2.0.0"
},
"elm-version": "0.17.1 <= v < 0.18.0"
-}
@moonlightdrive
moonlightdrive / password.elm
Created July 22, 2016 17:06
Password Validation Exercises from the Elm Architecture Tutorial
{- Implementation of the Exercises for the Forms section of the Elm Architecture Tut
- http://guide.elm-lang.org/architecture/user_input/forms.html
-
- Elm Platform 0.17.1
-}
import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing (onInput, onClick)
@moonlightdrive
moonlightdrive / mutable_stack_queue.ml
Created June 23, 2016 23:52
mutable stack with queue implemented as two stacks
(** Mutable stack and queue.
** Queue implemented as two stacks. This is all the rage. *)
module type STACK = sig
type 'a t
val create : unit -> 'a t
val peek : 'a t -> 'a option
@moonlightdrive
moonlightdrive / type_constructor_escape_scope.ml
Created March 14, 2015 17:05
The type constructor would escape its scope (or, what on earth is this error?)
type _ value = Bool : bool -> bool value
| Int : int -> int value
type _ atom = Abool : bool -> bool atom
| Aint : int -> int atom
type _ sexp = Sexp_atom : 'a atom -> 'b atom sexp
let val_of_atom : type t. t atom -> t value =
function
@moonlightdrive
moonlightdrive / xen2img.sh
Created August 17, 2014 04:30
Create image from unikernel
#!/usr/bin/env bash
# Create an image from a unikernel.
# Props to Mirage for this script, which was derived from
# https://raw.githubusercontent.com/mirage/mirage/master/scripts/ec2.sh
while getopts "hn:k:" arg; do
case $arg in
h)
echo "usage: $0 [-h] [-n <name>] [-r <region>] -k <unikernel> "
echo ""
@moonlightdrive
moonlightdrive / sig4.ml
Last active August 29, 2015 14:02
AWS Signature 4 Signing Process
(* See http://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html
# signature;;
- : string = "ced6826de92d2bdeed8f846f0bf508e8559e98e4b0199114b84c54174deb456c"
*)
#require "cryptokit";;
open Cryptokit;;
let secret = "AWS4" ^ "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY";;