Skip to content

Instantly share code, notes, and snippets.

@Wizek
Wizek / Run.hs
Created August 19, 2017 16:48 — forked from dalaing/Run.hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
module Run (
runner
) where
import Control.Monad.Reader (ReaderT, runReaderT)
import Data.Foldable (traverse_)
@Wizek
Wizek / .ghci
Created August 19, 2017 16:46 — forked from 3noch/.ghci
Reflex-DOM Auto Reload Development with ghcid
:set prompt "> "
:set -isrc
:load Main
@Wizek
Wizek / a.txt
Created August 19, 2017 10:56 — forked from lspitzner/a.txt
sublime3+ghcid setup for quick haskell coding feedback
sublime3 and ghcid setup for quick haskell coding feedback
tested on sublime 3
(you can omit the SublimeOnSaveBuild steps, as the result is not
completely reliable anyways. i still find it useful, though.)
steps:
- install https://github.com/lspitzner/SublimeOnSaveBuild
(original from alexnj; in his/her version the build-window gets closed
@Wizek
Wizek / somesquares.hs
Created August 15, 2017 14:52 — forked from ali-abrar/somesquares.hs
Simple Canvas Example
{-# LANGUAGE ScopedTypeVariables #-}
import Reflex.Dom
import GHCJS.DOM.CanvasRenderingContext2D (putImageData, setFillStyle, fillRect)
import GHCJS.DOM.HTMLCanvasElement (getContext)
import GHCJS.DOM.ImageData (newImageData')
import Control.Monad.IO.Class (liftIO)
import GHCJS.DOM.Types (CanvasStyle(..), CanvasRenderingContext2D(..), toJSString, castToHTMLCanvasElement)
import GHCJS.Marshal (toJSVal)
import Data.Time (getCurrentTime)
# test
- list
\begin{code}
main = print 1
\end{code}
1. num
2. bers
@Wizek
Wizek / ManualKey.hs
Created May 2, 2017 23:58 — forked from carymrobbins/ManualKey.hs
Yesod - manually creating a Key
-- Good
import Database.Persist.Sql
toSqlKey 1 :: UserId
-- Bad
Prelude.read "UserKey {unUserKey = SqlBackendKey {unSqlBackendKey = 1}}" :: UserId
@Wizek
Wizek / Printed.hs
Last active February 21, 2017 17:55
Printed datatype for Haskell: custom format deep within a data structure
import Text.Printf
import ComposeLTR
main = do
print ls
print lsd
-- [26,56,114,222,398,628,857,1033,1141,1199,1229,1243]
-- [26,30,58,108,176,230,229,176,108,58,30,14]
ln
@Wizek
Wizek / 1-hmAt.hs
Last active January 29, 2017 02:40
import qualified Data.HashMap as HM
hmAt :: (Functor f, Ord t, Hashable t) => t -> (Maybe a -> f b) -> HM.Map t a -> f t1
hmAt k = lens g s
where
s v = HM.insert k v
g = HM.lookup k
import Data.IORef
import System.Exit (exitSuccess, ExitCode(ExitSuccess))
import Control.Concurrent
import System.Posix.Signals -- (installHandler, Handler(Catch), sigINT, sigTERM)
import Control.Concurrent.Lock ( Lock )
import qualified Control.Concurrent.Lock as Lock
forkIOInterruptible io = do
ctid <- forkIO io
tid <- myThreadId
@Wizek
Wizek / gist:a23d3ee6b79e57dfb17f8e5b5a88f43b
Last active December 15, 2016 17:19 — forked from jturcotte/gist:3912465
Terminator plugin to open paths in Sublime Text
import re
import terminatorlib.plugin as plugin
import subprocess
# Every plugin you want Terminator to load *must* be listed in 'AVAILABLE'
AVAILABLE = ['FileURLHandler']
class FileURLHandler(plugin.URLHandler):
capabilities = ['url_handler']
handler_name = 'file_path'