Skip to content

Instantly share code, notes, and snippets.

@Wizek
Wizek / bookmarklet.js
Created April 14, 2016 07:39
Bookmarklet to search for website alternatives most easily
// Author: https://github.com/Wizek
javascript:open(`http://alternativeto.net/browse/search?q=${((a)=>a[a.length-2])(window.location.host.split('.'))}`)
@Wizek
Wizek / code.hs
Created April 1, 2016 21:37
Quick & Dirty & Simple promises with Haskell (similar to JavaScript)
-- #! /usr/bin/env nix-shell
-- #! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (p: [p.interpolatedstring-perl6 p.regex-tdfa p.dump p.hspec p.shelly])"
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
-- {-# OPTIONS_GHC -fdefer-type-errors #-}
import Data.IORef
{ pkgs, stdenv, callPackage }: {
packageOverrides = super: let self = super.pkgs; in with self; rec {
"optparse-generic" = callPackage
({ mkDerivation, base, bytestring, optparse-applicative
, system-filepath, text, time, transformers, void
}:
mkDerivation {
pname = "optparse-generic";
split-objs: True
<command line>: can't load .so/.DLL for: /home/wizek/sandbox/exp-proj/exp-proj/dist/build/libHSexp-proj-0.0.0-8sib1y4kizm0SYHSLrPEV8-ghc7.10.3.so (/home/wizek/sandbox/exp-proj/exp-proj/dist/build/libHSexp-proj-0.0.0-8sib1y4kizm0SYHSLrPEV8-ghc7.10.3.so: undefined symbol: firstzu8sib1y4kizzm0SYHSLrPEV8_Test_zdfPersistFieldNotificationType_closure)
@Wizek
Wizek / file.hs
Last active March 10, 2016 19:04
data NotificationType = NotifTypeRequest | NotifTypeAccept
deriving (Read, Show, Eq, Enum)
derivePersistField "NotificationType"
[makeEnum|Type
Employee EE
Employer ER
Company CO
Unknown UN
|]
@Wizek
Wizek / dependency-injection.hs
Last active February 20, 2016 22:22
Thinking about how Dependency Injection could work in Haskell similar to Angular.js, to allow for mocking in unit tests, therefore most easily testing even IO code or complex pure code.
fns =
[ ("a", ["print", "b"], \print b -> print b)
, ("b", [], 12)
, ("print", [], print)
]
main = assemble fns `lookup` "a"
spec = do
b' =? 3
@Wizek
Wizek / versions side-by-side.md
Last active February 10, 2016 13:14
How to have different versions of local libraries and binaries side-by-side?

Hello. I have a somewhat advanced workflow related question. I use Linux and mainly develop in Haskell (sometimes also JavaScript), and sometimes when I have some functionality that I want to reuse, I put them in libraries or binaries. So far so good, but here comes my annoyance: when I develop these shared tools further, sometimes regressions/incompatibilities arise, and then I wish to use an earlier version (which usually has had fewer features, but more stable).

Right now, I have no easy way of doing this other than going into the appropriate project folder, checking out a version with git and building/replacing the newer version with the older. And even if I do that, I am changing the global version of that utility.

Could I somehow have the versions of these tools/libs exist side by side? I am thinking I could maybe do this with either apt-get, nix (the package manager), Cabal or haskell-stack, but I am not sure how I could do that with either of these.

Does anyone of you have a workflow that a

@Wizek
Wizek / shell-session.sh
Last active February 10, 2016 02:36
Installing reactive-banana-wx with stack
➜ exp-frp cabal get reactive-banana-wx
Warning: The package list for 'hackage.haskell.org' is 23.5 days old.
Run 'cabal update' to get the latest list of available packages.
Downloading reactive-banana-wx-1.1.0.0...
Unpacking to reactive-banana-wx-1.1.0.0/