Skip to content

Instantly share code, notes, and snippets.

View mostalive's full-sized avatar

Willem van den Ende mostalive

View GitHub Profile
@mostalive
mostalive / Main.purs
Last active July 1, 2020 10:34
Bucket constraint example from the Domain-Driven Design book, in purescript with hopefully a twist (work in progress)
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (logShow)
import TryPureScript (render, withConsole)
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
@mostalive
mostalive / gist:54dbbf388f6ca58795d6ae37fef22890
Created May 24, 2017 14:02
Bash script to create package description to include in purescript 'package-set'. Automatically retrieves git repository url and latest tag. Doesn't do formatting yet, and generates one trailing
#!/bin/bash
echo 'usage: purescript-package2set.sh <packagename>'
set -euo pipefail
PACKAGENAME=$1
REPO=`git remote get-url origin`
VERSION=`git tag | tail -n 1`
echo "\"$1\": {"
@mostalive
mostalive / Loadable.purs
Last active May 22, 2017 13:24
Loadable state of an object in my pux application (under construction - sketch)
-- Loadable
-- Thanks to @karls - full implementation would probably be... https://github.com/krisajenkins/purescript-remotedata/blob/v2.1.0/src/Network/RemoteData.purs#L30-L34
-- i stands for identifier, e.g. a schema or a number, or whatever else is needed to load or index it
-- kind of a 'maybe'.
-- o is for object. Only in the Loaded state is the object available
-- example ```
-- showLoaded Loaded id object = show object
-- showLoaded _ = "Object not loaded"
-- ```
Fri Mar 24 12:38:56 UTC 2017
module Client where
import Prelude (bind, return)
import Pux (App, Config, CoreEffects, start, renderToDOM)
import Control.Bind ((=<<))
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
@mostalive
mostalive / Main.purs
Last active June 15, 2016 12:24
Purescript - remove exception in Aff
module Main where
import Prelude (($), bind,id, pure)
import Control.Monad.Eff.Exception (Error, EXCEPTION, catchException, message)
import Control.Monad.Aff (Aff, attempt)
import Control.Monad.Aff.Unsafe (unsafeInterleaveAff)
import Data.Either (either)
catchException' :: forall e a. (Error -> a) -> Aff (err :: EXCEPTION | e ) a -> Aff e a
catchException' handler f = do
@mostalive
mostalive / Calc.hs
Last active August 29, 2015 14:23
Form validation with Reflex FRP in haskell
{- Based on https://github.com/ryantrinkle/try-reflex/README.md .
This is the try Reflex calculator example modified
to collect the two numbers and an operator into a Maybe Calculation.
So we use the validation for each field to validate the form as a hole.
This could be useful to build forms for e.g. an admin interface. -}
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE GADTs #-}
@mostalive
mostalive / Enemyhorde.lua
Created March 7, 2012 18:34 — forked from anonymous/Enemyhorde.lua
Enemy horde
ENEMY_SPAWN_EASY = 0
ENEMY_SPAWN_HARD = 1
EnemyHorde = class()
function EnemyHorde:init()
    -- you can accept and set parameters here
    self.frame = 0
    self.units = {} -- enemy units
    self.heroBullets = {} -- hero's bullets
@mostalive
mostalive / Main.lua
Created March 7, 2012 18:34 — forked from anonymous/Main.lua
Space invaders main file
hero = nil
enemies = nil
bgLines = nil
explosion = nil
killCount=0
GAME_PLAYING = 0
GAME_DEAD = 1
GAME_WON = 2
@mostalive
mostalive / default.vcl
Created December 17, 2010 07:57
varnish cache server configuration file, used with drupal 6 and apache
#varnish cache server configuration file, used with drupal 6 and apache
#inspiration from https://wiki.fourkitchens.com/display/PF/Configure+Varnish+for+Pressflow
#with change from obj to beresp of
#http://www.mail-archive.com/varnish-misc@projects.linpro.no/msg02911.html
#and cache HIT or MISS header from somewhere else
backend default {
.host = "127.0.0.1";
.port = "80";
.connect_timeout = 600s;
.first_byte_timeout = 600s;