Skip to content

Instantly share code, notes, and snippets.

@Wizek
Wizek / main.js
Created October 24, 2020 17:28
Chrome Extensions Manager utility functions
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
@Wizek
Wizek / stress-memory-1.js
Last active August 19, 2020 14:23 — forked from Eomm/stress-memory.js
Check when your server goes out of memory
/**
node --max-old-space-size=4048 --initial-old-space-size=4048 --max-heap-size=4048 stress-memory-1.js
x64
rss 7.62 GB
heapTotal 3.74 GB
heapUsed 3.73 GB
*/
@Wizek
Wizek / EvilList.hs
Created October 8, 2018 12:19 — forked from ion1/0readme.md
Emulating the elegance of JavaScript's `new Array` in Haskell
{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, TypeApplications, TypeFamilies #-}
module EvilList where
import Data.Typeable
type family EvilListContent a where
EvilListContent Int = ()
EvilListContent a = a
$ stack install stack-run
terminfo-0.4.1.0: configure
hslogger-1.2.10: configure
hslogger-1.2.10: build
hslogger-1.2.10: copy/register
Progress 2/5
-- While building custom Setup.hs for package terminfo-0.4.1.0 using:
/tmp/stack19043/terminfo-0.4.1.0/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/setup --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0 configure --with-ghc=/home/wizek/.stack/programs/x86_64-linux/ghc-8.0.2/bin/ghc --with-ghc-pkg=/home/wizek/.stack/programs/x86_64-linux/ghc-8.0.2/bin/ghc-pkg --user --package-db=clear --package-db=global --package-db=/home/wizek/.stack/snapshots/x86_64-linux/lts-9.14/8.0.2/pkgdb --libdir=/home/wizek/.stack/snapshots/x86_64-linux/lts-9.14/8.0.2/lib --bindir=/home/wizek/.stack/snapshots/x86_64-linux/lts-9.14/8.0.2/bin --datadir=/home/wizek/.stack/snapshots/x86_64-linux/lts-9.14/8.0.2/share --libexecdir=/home/wizek/.stack/snapshots/x86_64-linux/lts-9.14/8.0.2/libexec --sysconfdir=/home/wizek/.stack/snapshots/x86_64-linux/lts-9.14/8.0.2/etc --docdi
@Wizek
Wizek / Bag.purs
Created May 3, 2018 10:06 — forked from i-am-tom/Bag.purs
PureScript port of Will Jones' type-indexed config "bag".
module Main where
import Control.Alternative ((<|>))
import Control.Apply (lift2)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, logShow)
import Data.Argonaut.Core (Json)
import Data.Argonaut.Decode (class DecodeJson, decodeJson)
import Data.Argonaut.Encode (class EncodeJson, encodeJson)
import Data.Either (hush)
@Wizek
Wizek / NamedDefaults.hs
Created April 24, 2018 06:16 — forked from int-index/NamedDefaults.hs
named-defaults
{-# LANGUAGE KindSignatures, DataKinds, FlexibleInstances, FlexibleContexts,
FunctionalDependencies, TypeFamilies, TypeOperators,
PatternSynonyms, UndecidableInstances, ConstraintKinds,
TypeApplications, ScopedTypeVariables, CPP #-}
module NamedDefaults (FillDefaults, fillDefaults, (!.)) where
import Prelude (Maybe(..), id)
import Data.Kind (Type)
@Wizek
Wizek / nix-package-search
Created December 3, 2017 04:07 — forked from olejorgenb/nix-package-search
nix-package-search

Try commenting out line 21 in ./test-suite/HsDiExample/MainSpec.hs

21:      & override "logger"         [qc| \a -> modifyIORef logs (++ [a]) |]

Run it with stack test, and you'll get [an error like the following][error]:

• Ambiguous type variable ‘m0’
@Wizek
Wizek / 1-readme.md
Last active September 12, 2017 16:48
GivenWhenThen

v0.3.0 of a Given-When-Then implementation for Haskell's HSpec. In similar vein to Ruby's rspec-given and Javascript's (Node's) jasmine-given.

I guess we could call it hspec-given.

If there is some interest I could package it up for Hackage. Ideas on improvements and contributions are also welcome, as I suspect I've only found a local optimum while implementing, e.g. in terms of syntax.

See here for a usage example.

@Wizek
Wizek / backblaze b2 backup script
Created August 29, 2017 23:10 — forked from scottlinux/backblaze b2 backup script
Backup script for backblaze b2
#!/usr/bin/env bash
#
# Backup selected directories to a Backblaze B2 bucket
#
# Example daily cron:
# @daily /usr/local/bin/b2backup >/dev/null
#
# Account creds
id=xxxxxxxxxx