Skip to content

Instantly share code, notes, and snippets.

@chexxor
chexxor / ServiceRequestTrigger.java
Created June 4, 2012 00:08
pcon Trigger Template - automated VSC insertion
public class ServiceRequestTrigger {
private final Map<Id, Service_Request__c> oldMap;
private final Map<Id, Service_Request__c> newMap;
private final List<Service_Request__c> newObjs;
private final Boolean isInsert;
private final Boolean isUpdate;
private final Boolean isDelete;
private final Boolean isBulk;
/**
@chexxor
chexxor / DF12SessionOpenSeats.js
Created August 30, 2012 02:24
Show Open Seats for DF12 Sessions Scriptlet
/*
Curious about how many people are attending your session?
Use this JS scriptlet to find out how many people will be attending your session!
Open the DF12 Agenda Builder web app. Open the developer tools for your browser,
copy this entire gist into the JS command line, and run it.
A list of all sessions for which you are registered will be shown with
@chexxor
chexxor / DishwasherAlgo.java
Created March 18, 2013 18:00
An algorithm for our company's dishwasher. Because people need instructions.
public class Dishwasher {
public enum StatusCode { READY_TO_WASH, WASHING, READY_TO_EMPTY }
public enum Reason { OK, FULL, MUST_REMOVE_DISHES, MUST_EXECUTE_WASH_CYCLE }
public Integer capacity {get; set;} // 0 - 100
public StatusCode status {get; set;}
public hasSoap {get; set;}
public Dishwasher() {
@chexxor
chexxor / Main.purs
Last active February 17, 2016 01:25
Basic Example of Rock-Paper-Scissors in PureScript
module Main where
import Prelude
import Control.Monad.Eff.Console (log)
-- Define the types of data used by the game.
-- `Rock`, a data type, is better than `"Rock"`, a String,
-- because the compiler can help us. The number of possible
-- values of a String is huuuuuge, but the number of possible
-- values of a RpsChoice is only three. Well-defined choices
@chexxor
chexxor / Dockerfile
Created February 1, 2017 17:07
cloudsql-proxy Dockerfile
FROM ubuntu
RUN apt-get update && apt-get -y install wget \
&& wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 \
&& mv cloud_sql_proxy.linux.amd64 cloud_sql_proxy \
&& chmod +x cloud_sql_proxy \
&& mkdir /cloudsql;
# Expects cred-file.json to be in working directory.
# This isn't good, but I haven't had time to improve yet.
@chexxor
chexxor / Main.purs
Last active September 14, 2017 22:33
SQL query row types
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (logShow, CONSOLE)
import Data.Foldable (class Foldable, foldl, intercalate)
import Data.Maybe (Maybe(..), maybe)
import Data.Monoid (class Monoid, mempty)
import Data.StrMap (StrMap, lookup)
@chexxor
chexxor / WithPipeline.purs
Created April 20, 2018 18:19
WithPipeline
newtype WithPipeline a = WithPipeline (NEL.NonEmptyList (a -> a)) a
-- or --
newtype WithPipeline a = WithPipeline (a -> a)) a
instance profunctorWithPipeline :: Profunctor (WithPipeline a) where
dimap :: forall a b c d. (a -> b) -> (c -> d) -> p b c -> p a d
dimap a2b c2d (WithPipeline f a) = WithPipeline (a2b >>> f >>> c2d) a
instance contraWithPipeline :: Contravariant (WithPipeline a) where
cmap :: forall a b. (b -> a) -> f a -> f b
@chexxor
chexxor / Main.purs
Created April 25, 2018 21:34
HomoHKTRow.purs
module Main where
import Prelude
import Control.Monad.Eff.Console (log)
import TryPureScript (render, withConsole)
import Type.Row
class HomoHKTRow (rs :: RowList) (f :: Type -> Type)
@chexxor
chexxor / TEA_Wrong_For_Web.md
Last active March 21, 2024 19:55
The Elm Architecture is the wrong abstraction for the web

The Elm Architecture is the wrong abstraction for the web

In this article, I'd like to explain why I think The Elm Architecture is fine for small components, but quite harmful for websites based on pages.

Definition and Pros/Cons

First, let's clarify what I mean by "The Elm Architecture".

The Elm Architecture's webpage describes it pretty well.

module Main where
import Prelude
import Control.Monad.Eff.Console (log, logShow)
import TryPureScript (render, withConsole)
import Control.Lazy (fix)
-- From https://github.com/awkure/purescript-birds/blob/v1.0.4/src/Aviary/Birds.purs#L38-L38
fixB :: forall a. (a -> a) -> a