Skip to content

Instantly share code, notes, and snippets.

@Engelberg
Engelberg / Poor man's hardware wallet
Last active June 5, 2019 23:53
"Poor man's hardware wallet"
For those who cannot afford a hardware wallet, the next best thing is to use Electrum
to create a 2-of-2 multisig wallet with one key on your phone and one on your desktop.
To use, create the transaction on your desktop client, and then display the QR code
for the partially signed transaction. Scan the QR code in your phone's Electrum,
sign it, and broadcast with a few taps.
Given the added difficulty of a hacker accessing both your desktop and your phone,
you get significantly better security and the process of using the wallet remains
relatively straightforward.
@Engelberg
Engelberg / electrs on dojo
Last active October 5, 2022 18:26
Installing local electrum server that relies on the bitcoin daemon inside of Samourai Dojo for its data
I am successfully running a local electrum server, getting its data from dojo. This is useful for private use of hardware wallets.
Step 1: As Laurent MT suggested in the Samourai telegram group, you need to edit the docker-compose.yaml file, adding to the bitcoind section the following two lines
ports:
- "127.0.0.1:28256:28256"
Step 2: Follow install directions for electrs, an electrum server written in rust.
electrs install directions can be found here: https://github.com/romanz/electrs/blob/master/doc/usage.md
@Engelberg
Engelberg / core_subset.clj
Created August 2, 2018 23:06
Comparison Clojure to Java
public class CoreSubsetObjective implements Objective<SubsetSolution, CoreSubsetData>{
/**
* Evaluates the given subset solution using the underlying data, by computing the average
* distance between all pairs of selected items. If less than two items are selected,
* the evaluation is defined to have a value of 0.0.
*
* @param solution subset solution
* @param data core subset data
* @return evaluation with a value set to the average distance between all pairs of selected items;
@Engelberg
Engelberg / cond-example.clj
Created April 3, 2017 06:07
refactoring with better-cond
; The sample to refactor
(if-let [x (foo)]
(if-let [y (bar x)]
(if-let [z (goo x y)]
(do
(qux x y z)
(log "it worked")
true)
(do
(log "goo failed")
@Engelberg
Engelberg / wordlist.txt
Created February 21, 2017 07:30
Esperanto wordlist from Baza Radikaro with unique 3-letter prefixes
abelo
abio
abomeno
abrikoto
absoluta
abunda
acida
adapti
adicii
adjektivo
@Engelberg
Engelberg / core.clj
Last active January 5, 2017 09:30
Twenty four using partitions
(ns twentyfour.core
(:use clojure.math.combinatorics))
(def ops ['+ '- '* '/])
(def commutative #{'+ '*})
;; We can generate all the possible expressions efficiently with combinatorics' partitions
;; partitions automatically handles duplicates for us, which keeps the process efficient
(defn expressions [nums]

Keybase proof

I hereby claim:

  • I am engelberg on github.
  • I am markengelberg (https://keybase.io/markengelberg) on keybase.
  • I have a public key whose fingerprint is C3F3 DE10 2B2E DEDA 4613 AC36 530A 864D 3A1B A35E

To claim this, I am signing this object:

(ns utils.cond
"A collection of variations on Clojure's core macros. Let's see which features
end up being useful."
{:author "Christophe Grand"}
(:refer-clojure :exclude [cond when-let if-let]))
(defmacro if-let
"A variation on if-let where all the exprs in the bindings vector must be true.
Also supports :let."
([bindings then]
@Engelberg
Engelberg / bowling.clj
Created May 18, 2016 12:33
Bowling kata in 11 lines of clojure
(defn- sum [s] (reduce + s))
(defn score
([gs] (let [s (clojure.string/replace gs #"\d/" #(str (nth % 0) (char (- 106 (int (nth % 0)))))),
g (map #(case % \X 10 \- 0 (- (int %) 48)) s)]
(score g 1)))
([game frame]
(cond
(= frame 10) (sum game)
(= (first game) 10) (+ (sum (take 3 game)) (score (drop 1 game) (inc frame))),
(= (sum (take 2 game)) 10) (+ (sum (take 3 game)) (score (drop 2 game) (inc frame))),
@Engelberg
Engelberg / teamsplit.clj
Created October 7, 2015 04:03
Loco model for splitting a sequence of numbers into two equally-sized parts, minimizing the disparity of their sums
(ns mark.teamsplit
(:require [loco.core :as l]
[loco.constraints :refer :all]))
; Although this problem was stated in terms of a group of players
; with multiple attributes, we can just represent each player by
; a single number, so this function just takes the list of numbers.
(defn find-teams
"Players is a list of player strengths, timeout is in milliseconds"