Follow the steps below to setup a local development environment:
Recommended to download latest XQuartz
Follow the steps below to setup a local development environment:
Recommended to download latest XQuartz
{-# LANGUAGE MagicHash, UnboxedTuples #-} | |
module Main(main) where | |
import GHC.Exts ( addrToAny# ) | |
import GHC.Ptr ( Ptr(..) ) | |
import System.Info ( os, arch ) | |
import Encoding | |
import ObjLink | |
main :: IO () |
{-# LANGUAGE TypeFamilies, TypeOperators, FlexibleContexts, | |
TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses | |
#-} | |
import Data.List.NonEmpty (NonEmpty(..)) | |
import Data.Maybe (maybeToList) | |
import Data.Ratio (numerator, denominator) | |
import Data.IORef (IORef) | |
import SubType |
/* | |
Assuming you have an enum type like this. | |
You want to rename 'pending' to 'lodged' | |
*/ | |
CREATE TYPE dispute_status AS ENUM('pending', 'resolved', 'open', 'cancelled'); | |
BEGIN; | |
ALTER TYPE dispute_status ADD VALUE 'lodged'; | |
UPDATE dispute SET status = 'lodged' WHERE status = 'pending'; |
function worker() { | |
setInterval(function() { | |
postMessage({foo: "bar"}); | |
}, 1000); | |
} | |
var code = worker.toString(); | |
code = code.substring(code.indexOf("{")+1, code.lastIndexOf("}")); | |
var blob = new Blob([code], {type: "application/javascript"}); |
Have you ever had to write code that made a complex series of succesive modifications to a single piece of mutable state? (Almost certainly yes.)
Did you ever wish you could make the compiler tell you if a particular operation on the state was illegal at a given point in the modifications? (If you're a fan of static typing, probably yes.)
If that's the case, the indexed state monad can help!
Motivation
#!/bin/bash | |
# Usage: slackpost <token> <channel> <message> | |
# Enter the name of your slack host here - the thing that appears in your URL: | |
# https://slackhost.slack.com/ | |
slackhost=PUT_YOUR_HOST_HERE | |
token=$1 |
var questions = [ | |
{ id:'fname', text:'First Name', answerType:'str' }, | |
{ id:'lname', text:'Last Name', answerType:'str' }, | |
{ id:'age', text:'Age', answerType:'int' }, | |
{ id:'weight', text:'Weight', answerType:'float' } | |
] | |
function ask(question, callback) { | |
var stdin = process.stdin, stdout = process.stdout; |
gifify() { | |
if [[ -n "$1" ]]; then | |
if [[ $2 == '--good' ]]; then | |
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png | |
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif | |
rm out-static*.png | |
else | |
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif | |
fi | |
else |
# webm | |
ffmpeg -i IN -f webm -vcodec libvpx -acodec libvorbis -ab 128000 -crf 22 -s 640x360 OUT.webm | |
# mp4 | |
ffmpeg -i IN -acodec aac -strict experimental -ac 2 -ab 128k -vcodec libx264 -vpre slow -f mp4 -crf 22 -s 640x360 OUT.mp4 | |
# ogg (if you want to support older Firefox) | |
ffmpeg2theora IN -o OUT.ogv -x 640 -y 360 --videoquality 5 --audioquality 0 --frontend |