Skip to content

Instantly share code, notes, and snippets.

@kwannoel
kwannoel / and-hides-errors.sh
Created July 25, 2023 06:07
`./and-hides-errors.sh` then `echo $?` it should be 0.
#!/usr/bin/env bash
set -euo pipefail
throw_error() {
cat ahjwkbhw
}
throw_error && echo "1"
@kwannoel
kwannoel / agda.nix
Created July 6, 2020 15:52
Nix shell for agda
# Adapted from @ryanorendorff's gist: https://gist.github.com/ryanorendorff/f5c96d9f363a0e390425c2d9588bbb9d
{ pkgs ? import <nixos> {} }:
let
# The standard library in nixpkgs does not come with a *.agda-lib file, so we
# generate it here.
standard-library-agda-lib = pkgs.writeText "standard-library.agda-lib" ''
name: standard-library
include: ${pkgs.AgdaStdlib}/share/agda
@kwannoel
kwannoel / mutex.go
Created May 1, 2022 08:02
Mutex using channels and goroutines
import (
"fmt"
"sync"
)
type Mutex struct {
lockCh chan struct {}
unlockCh chan struct {}
doneCh chan struct {}
}
@kwannoel
kwannoel / Dockerfile
Created April 13, 2022 08:33
Ubuntu dockerfile
#Create ubuntu as base image
FROM ubuntu
#Install packages
RUN apt-get -y update
RUN apt-get -y install python3
RUN apt-get -y install gdb
RUN apt-get -y install gcc
@kwannoel
kwannoel / multicall.c
Created September 10, 2021 18:00
Try out multicall binaries
#include <stdio.h>
#include <string.h>
// Try it out:
// gcc multicall.c -o multi
// chmod +x multi
// ln -s multi hello
// ./hello
// ln -s multi bye
// ./bye
>>> compiling gerbil core
*** WARNING -- Variable "macro-readtable-brace-keyword-set!" used in module "gx-gambc1" is undefined
*** WARNING -- Variable "macro-readtable-bracket-keyword-set!" used in module "gx-gambc1" is undefined
build.sh: line 107: 12092 Segmentation fault (core dumped) "${GERBIL_STAGE0}/bin/gxi" "${GERBIL_BUILD}/build1.ss"
*** ERROR; build failed
builder for '/nix/store/qvhfwb9r400dmxwxgckdfidasxhxcydl-gerbil-unstable-2021-06-08.drv' failed with exit code 1
error: build of '/nix/store/fs655cfzsbq0yx87639c3ff9r9847brr-gerbil-crypto-unstable-2021-05-10.drv', '/nix/store/h3ahfn7imahhaxfahgn9xsykq79wdgsv-gerbil-utils-unstable-2021-05-10.drv', '/nix/store/hf7llw081hsdyvyajciq6cmas3a4glav-gerbil-persist-unstable-2021-03-15.drv', '/nix/store/j8zmqkdny97bwq08fx7gkbgbi8h6ac4x-gerbil-poo-unstable-2021-05-21.drv', '/nix/store/k4yb4jgjx8rjizqh9k9ipvkm0akxam1l-smug-gerbil-unstable-2020-12-12.drv', '/nix/store/m0nh7d37qvk1zzq2067pl6yp6j6g98yn-glow-lang-unstable-2021-06-18.drv', '/nix/store/nq5vq4r4b
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Arrow((>>>), (&&&))
import Data.Maybe (catMaybes)
import qualified Data.Text as T
import Data.Text (Text)
import Data.List.NonEmpty (NonEmpty, nonEmpty)
> ./scripts/run-ethereum-test-net.ss
Running: (echo geth --datadir /home/noel/.local/share/glow/geth --identity GlowPrivateEthereumTestNet --verbosity 4 --miner.etherbase 0x25c0bb1A5203AF87869951AEf7cF3FEdD8E330fC --nodiscover --maxpeers 0 --nousb --networkid 17 --nat any --vmdebug --unlock 0x25c0bb1A5203AF87869951AEf7cF3FEdD8E330fC account import --password /dev/null /tmp/croesus-tmp-WYZhrO.prv ; geth --datadir /home/noel/.local/share/glow/geth --identity GlowPrivateEthereumTestNet --verbosity 4 --miner.etherbase 0x25c0bb1A5203AF87869951AEf7cF3FEdD8E330fC --nodiscover --maxpeers 0 --nousb --networkid 17 --nat any --vmdebug --unlock 0x25c0bb1A5203AF87869951AEf7cF3FEdD8E330fC account import --password /dev/null /tmp/croesus-tmp-WYZhrO.prv) < /dev/null >> /home/noel/.local/share/glow//log/geth/geth.log 2>&1
Gerbil-ethereum v0.0-260-gb151403 on Gerbil-persist v0.0-19-g75d4c45, Gerbil-crypto ef0ef55, Gerbil-poo 5b2290f, Gerbil-utils v0.0-316-g3c748ed, Gerbil v0.16-178-g17fbcb95, Gambit v4.9.3-1389-g55b21ed9
In th
@kwannoel
kwannoel / haskeller_competency_matrix.md
Created December 18, 2020 05:27 — forked from graninas/haskeller_competency_matrix.md
Haskeller competency matrix

Haskeller Competency Matrix

See also List of materials about Software Design in Haskell

Junior Middle Senior Architect
Haskell level Basic Haskell Intermediate Haskell Advanced Haskell Language-agnostic
Haskell knowledge scope Learn you a Haskell Get programming with Haskell Haskell in Depth Knows several languages from different categories
Get programming with Haskell Haskell in Depth Functional Design and Architecture
[Other books on Software Engineering in Haskell](https://github.com/graninas/software-design-in-haskell#Books-on-So
@kwannoel
kwannoel / buffer.c
Created April 11, 2021 10:11
Increment trigger until you see output upon program crash.
#include <stdio.h>
int main()
{
int *ip = NULL; //just a convenient way to crash a program :-)
int i, trigger;
printf("Trigger at (positive int): ");
scanf("%d", &trigger);