Skip to content

Instantly share code, notes, and snippets.

@ion1
ion1 / shellquote.sh
Created November 29, 2018 04:50
shellquote
shellquote() {
local space=
for arg; do
printf '%s' "$space"
printf '%s' "$arg" | sed -e "s/'/'\\\\''/g; s/^/'/; s/\$/'/;"
space=' '
done
printf '\n'
}
@ion1
ion1 / SPJ Discord.user.js
Last active October 24, 2018 06:14
SPJ Discord
// ==UserScript==
// @name SPJ Discord
// @namespace https://example.net/
// @version 0.1
// @description SPJ Discord
// @author ion
// @match *://discordapp.com/*
// @grant none
// ==/UserScript==
@ion1
ion1 / 0readme.md
Last active October 22, 2018 18:52
Emulating the elegance of JavaScript's `new Array` in Haskell

Emulating the elegance of JavaScript's new Array in Haskell

What does new Array(x) do? Trick question. It does different things depending on whether x is an integer or something else.

I wanted to replicate this elegant functionality in Haskell: behold.

SWTOR Resource Gathering Nodes
Archaeology / Artifact Fragment:
? Prehistoric Archaeological Find
1 Lost Artifact Fragment Lost Archaeological Find
2 Sacred Artifact Fragment Sacred Archaeological Find
3 Ancient Artifact Fragment Ancient Archaeological Find
4 Galactic Artifact Fragment Galactic Archaeological Find
5 Hypertech Artifact Fragment Alien Archaeological Find, Hypertech Archaeological Find
6 Primeval Artifact Fragment Primeval Archaeological Find
@ion1
ion1 / ghci.lhs
Last active February 9, 2017 23:57
Would it be possible for this type to be inferred?
> :set -XGADTs -XDataKinds
> data Nat = Z | S Nat
> data Vect n a where { Nil :: Vect 'Z a; (:-) :: a -> Vect n a -> Vect ('S n) a }
> :t () :- Nil
() :- Nil :: Vect ('S 'Z) ()
> :t \(a :- Nil) -> a
<interactive>:1:16:
Couldn't match expected type `r' with actual type `t1'
`r' is untouchable
@ion1
ion1 / biquad.hs
Last active October 10, 2016 21:10
Biquad
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad.State
import Test.QuickCheck
main = do
print $ runBiquad' 1 0 0 (-1) (-1) [1,0,0,0,0,0,0,0,0,0,0,0]
quickCheck $ \xs -> (dif . int) xs == xs
&& (int . dif) xs == xs
import Data.Functor.Contravariant
data Foo a = Foo (a -> Integer)
data Bar a = Bar ((a -> Integer) -> Integer)
data Baz a = Baz (((a -> Integer) -> Integer) -> Integer)
foo :: (b -> a) -> (a -> Integer) -> (b -> Integer)
foo f g = _
@ion1
ion1 / google-android-apps.md
Last active February 4, 2016 19:30
Google apps for your non-Nexus phone
@ion1
ion1 / e.md
Last active August 29, 2015 14:27
Trying to derive an equation for e from df(x)/dx = f(x)

Trying to derive an equation for e from df(x)/dx = f(x)

Exists f.

df(x)/dx = f(x)

lim{y→0} (f(x+y) − f(x)) / y = f(x)

lim{y→0} f(x+y) − f(x) − y f(x) = 0