Skip to content

Instantly share code, notes, and snippets.

@pissang
pissang / echarts-svg.js
Last active August 23, 2024 03:34
Server side SVG rendering of ECharts
const echarts = require("echarts");
const Canvas = require('canvas');
const {JSDOM} = require('jsdom');
const fs = require('fs');
echarts.setCanvasCreator(() => {
return new Canvas(100, 100);
});
const {window} = new JSDOM();
global.window = window;
@chris-belcher
chris-belcher / sorted-merkle-tree-issue693.md
Last active February 2, 2025 13:01
Sorted merkle tree as solution to issue #693

The Problem

JoinMarket has a problem where it assumes different nicknames have different bitcoin wallets. This can be exploited by people running multiple yield generator bots from the same wallet, so they get a higher rate of profit at the expense of de-legitimizing the system for privacy.

Crypto primitive 1: Merkle Tree

A merkle tree is a way of producing a commitment to a set, which can later can prove that elements are contained within the set using only O(logN) data, and only revealing one other element in the set.

For example here is a merkle tree commiting to a set of numbers {6, 3, 9, 0, 8, 4, 7, 2}

@Icelandjack
Icelandjack / Constraints.org
Last active April 2, 2024 20:22
Type Classes and Constraints

Reddit discussion.

Disclaimer 1: Type classes are great but they are not the right tool for every job. Enjoy some balance and balance to your balance.

Disclaimer 2: I should tidy this up but probably won’t.

Disclaimer 3: Yeah called it, better to be realistic.

Type classes are a language of their own, this is an attempt to document features and give a name to them.

function docker-compose() {
if ($pwd.Path.StartsWith('C:\Users')) {
$projectName = Split-Path "$pwd" -leaf
$dockerPath = "/c" + $($($pwd -replace "^[a-z]:(.*)$",'$1') -replace "\\","/")
$dockerCmd = "docker run -v $dockerPath" + ":/$dockerPath -w $dockerPath -v /var/run/docker.sock:/var/run/docker.sock -e COMPOSE_PROJECT_NAME=$projectName -ti --rm dduportal/docker-compose:latest $args"
Write-Host $dockerCmd
Invoke-Expression $dockerCmd
} else {
Write-Error 'You must be under C:\Users, otherwise fileshare to boot2docker will not work!'
}
@nkpart
nkpart / Err.hs
Last active August 20, 2022 01:20
Lens, Prisms, and Errors.
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fwarn-missing-methods #-}
module Err where
import Control.Lens
import Control.Monad.Error
import Control.Monad.Error.Lens
-- Here is a fairly typical situation, where we have low level errors in certain
@folone
folone / gist:6089236
Last active January 4, 2025 10:32
Table of unicode operators in scalaz 6.0.x
@sebastiaanvisser
sebastiaanvisser / g1.hs
Created May 29, 2013 08:36
Composing algebras using Arrow and Applicative.
{-# LANGUAGE GADTs, TypeOperators, TupleSections #-}
module Generics.Algebra where
import Control.Category
import Control.Arrow
import Control.Applicative
import Prelude hiding ((.), id)
import Generics.Combinator