Skip to content

Instantly share code, notes, and snippets.

Haskell at Work - Web API

(from Haskell training)


git checkout chapter2

Haskell Cheatsheet

(from Haskell Training)

declarations and types

When we declare a value f, we usually first write the type of f and then, on a separate line, its actual value. For example

fortytwo :: Int
@palutz
palutz / Bitcoin Privacy Intro.org
Created November 10, 2022 15:06 — forked from nothingmuch/Bitcoin Privacy Intro.org
Notes for a presentation on Bitcoin privacy for the Des Femmes mentorship progarm

Bitcoin Privacy Introduction

Why privacy matters in Bitcoin

Celsius recent court filings provided a terrible and arguably avoidable loss of privacy for many of its customers, and will likely have chilling ripple effects for a long time to come. The goal of this presentation-turned-writeup is to give some context so that the reader can understand the consequences of such incidents and where to find more detailed information in order to mitigate such risks, and the tradeoffs that entails.

@palutz
palutz / helloWorkd.sol
Created September 25, 2022 15:47
Playing with Solidity and pure
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract HelloWorld { // capital letter for contract name
string text_ = "Hello World";
function helloworld() public view returns (string memory) {
//return text_;
bytes memory bm = helloTest(text_, "!!!");
return string(bm);
@palutz
palutz / testBitcoin.py
Last active August 10, 2022 13:55
Try to test the bitcoin core code with python
#!/usr/bin/env python3
# Copyright (c) 2017-2021 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""An example functional test
The module-level docstring should include a high-level description of
what the test is doing. It's the first thing people see when they open
the file and should give the reader information about *what* the test
import Data.Char (intToDigit, digitToInt)
-- Ading 2 binary int with reminder
addB :: Int -> Int -> Int -> (Int, Int)
addB x y r = if z >= 2 then (1, z - 2) else (0, z)
where
z = x + y + r
-- recursive adder combining the 2 streams of Char and return the reversed combination
-- (Char -> Int) = convert Char to Int. It can be customise to add custom logic
// Scala Bridge - Code to show how to declare type classes in Scala (from Scala with Cats)
sealed trait Json
final case class JsObject(get: Map[String, Json]) extends Json
final case class JsString(get: String) extends Json
final case class JsNumber(get: Double) extends Json
final case object JsNull extends Json
trait JsonWriter[A] {
def write(value: A): Json
@palutz
palutz / latency.txt
Created August 13, 2020 13:04 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@palutz
palutz / Tree.scala
Created June 25, 2020 13:42 — forked from dholbrook/Tree.scala
Scala binary tree
/**
* D Holbrook
*
* Code Club: PO1
*
* (*) Define a binary tree data structure and related fundamental operations.
*
* Use whichever language features are the best fit (this will depend on the language you have selected). The following operations should be supported:
*
* Constructors