Skip to content

Instantly share code, notes, and snippets.

View jmackie's full-sized avatar
🕺

Jordan Mackie jmackie

🕺
View GitHub Profile
@jmackie
jmackie / fancy-editor.R
Created August 6, 2023 17:26
Showing how to get the Shiny to properly handle image uploads
library(shiny)
# The browser will send files inserted into the editor here
upload_path <- "/upload-image"
# Only accept PNGs for now
supported_file_types <- c("png")
shiny_editor_options <- paste(
"plugins: 'image'",
@jmackie
jmackie / build.sh
Created December 13, 2019 16:29
Bash build script starter
#!/usr/bin/env bash
# Enable bash "strict mode"
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
# Some nice colour functions, you might want to add more...
# https://gist.github.com/daytonn/8677243
let
pkgs = import <nixpkgs> { };
reasonml = import ../reasonml.nix { inherit pkgs; };
libs = p: with p; [ gtk3-x11.dev pango.dev glib.dev cairo.dev gdk-pixbuf.dev atk.dev ];
pkg-config = p: p.stdenv.mkDerivation {
# revery looks for gtk headers via...
# pkg-config --cflags gtk+-x11-3.0
name = "pkg-config-wrapped";
buildInputs = [ p.makeWrapper ] ++ libs p;
@jmackie
jmackie / README.md
Last active August 30, 2021 14:29
Basic example of file upload with progress in PureScript

Build the purescript bundle:

spago init
spago install aff console effect web-file web-xhr
spago build && spago bundle-module -m Upload -t index.cjs && browserify index.cjs -s Upload -o index.js

Spin up a dumb server to accept the POST request

{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Dope (main) where
import Prelude
@jmackie
jmackie / Config.hs
Last active October 19, 2018 17:34
Haskell App Configuration
#!/usr/bin/env stack
-- stack --resolver lts-12.12 script --package aeson --package mtl
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
@jmackie
jmackie / Main.hs
Last active June 10, 2018 20:50
Dev.to post
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Aeson ((.:))
import qualified Data.Aeson as Aeson
import qualified Data.ByteString.Lazy.Char8 as ByteString
import qualified Network.HTTP as HTTP
import qualified System.IO as IO
@jmackie
jmackie / .ghci
Last active December 5, 2022 06:37
Running a background process alongside a Wai Application
:set -fwarn-unused-binds -fwarn-unused-imports
:load Server.hs
@jmackie
jmackie / .ghci
Last active November 17, 2020 13:03
Writing haskell scripts with a nix-shell shebang line
:set -fwarn-unused-binds -fwarn-unused-imports
:set -i.
:load Request
@jmackie
jmackie / elm-compilation-notes.md
Last active March 27, 2018 16:58
99 Elm compilation problems

Rebuild all the things (worse case scenario):

[ReallyBigProject](master)$ find client/elm -type f -exec touch {} +
[ReallyBigProject](master)$ elm-make +RTS -N4 -s -RTS client/elm/Main.elm --output $(mktemp --suffix .js)

Here's the output (with some overhead from profiling stuff in the build):