Skip to content

Instantly share code, notes, and snippets.

View adlai's full-sized avatar
☠️
"My happiness should not be your concern"

Adlai adlai

☠️
"My happiness should not be your concern"
View GitHub Profile
@nowl
nowl / k-means.lisp
Created April 13, 2011 23:08
k-means clustering in Common Lisp
(defun classify (means data dist-func)
(let ((sets (loop for m in means collect '())))
(loop for d in data do
(let ((min 0)
(dist (funcall dist-func d (car means))))
(loop for m in (cdr means) for n from 1 do
(when (< (funcall dist-func d m) dist)
(setf min n
dist (funcall dist-func d m))))
(push d (nth min sets))))
@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active May 19, 2024 19:25
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@gavinandresen
gavinandresen / BlockPropagation.md
Last active June 28, 2024 08:17
O(1) block propagation

O(1) Block Propagation

The problem

Bitcoin miners want their newly-found blocks to propagate across the network as quickly as possible, because every millisecond of delay increases the chances that another block, found at about the same time, wins the "block race."

@petertodd
petertodd / gist:8e87c782bdf342ef18fb
Last active December 13, 2020 05:33
What the CoinWallet.eu tx-flood stress-test means for you and how to deal with it
standard rules:
1. # unique input scripts == # unique output scripts
2. all output scripts unique
3. at least one pair of outputs has equal value
alternate rules (replace standard rule 1):
1A. # unique inputs > 1
1B. # of unique input scripts > # unique output scripts / 2
tx 01 (standard form):
@fukamachi
fukamachi / quicklisp-badges.markdown
Last active July 19, 2021 21:26
Quicklisp badge

Quicklisp badge

Quickdocs.org now provides project badges for Quicklisp projects. It shows Quicklisp dist version when the project was updated last.

Once the project owner adds this badge to their README file, it will inform the project is ready for Quicklisp and its documentation is available on Quickdocs.org.

Stability

It's available, however it was just added in this morning at whim and it may still have issues. Please try it and tell @nitro_idiot if you encountered any issues.

@fukamachi
fukamachi / using-travis-ci-with-roswell.md
Last active May 28, 2021 03:36
Using Travis CI with Roswell

Using Travis CI with Roswell

Travis CI is the most prevalent cloud CI service. Though it has no Common Lisp support officially, by using Roswell, you can test your Common Lisp product with a few efforts.

WARNING: This document is based on Roswell v0.0.3.42 (not released yet) or above.

Enabling Travis CI

To use Travis CI, you must sign up and enable testing for your repository at your profile page.

This document is a summary of the line of reasoning leading to an idea I had about secret messaging which is referred to here as 'TLSTweet' (not sure about the name..).

What is "self-evident" about modern crypto.

There are several "truisms" in modern day cryptology (= cryptography + cryptanalysis). One of them is "don't roll your own crypto", which is meant to convey the extraordinary difficulty in creating ciphers and cryptosystems that are genuinely resistant to cryptanalysis, and the tremendous ease with which it's possible for the non-specialist, or even the specialist, to convince themselves that the cipher or system they've created is resistant to cryptanalysis, when it isn't.

Another, related but distinct, actually has a name - Kerckhoff's Principle - which briefly stated means that not only should you not hide the algorithm, but you should endeavour to make it as publically known as possible, because genuine security comes from the sec

@AdamISZ
AdamISZ / JMsnoopmitigation.md
Last active April 3, 2023 20:22
Snooping attacks on joinmarket - mitigation ideas.

Username (herafter "nick") construction for message channel:

nick = one "type" byte (currently "J") + one version byte (current jm_version protocol value) + Base58 (not Base58Check) of: first joinmarket.message_channel.NICK_HASH_LEN bytes of sha256 of : ephemeral per-bot-process public key.

If length(X) < joinmarket.message_channel.NICK_MAX_ENCODED, right pad with 'O' char to that length.

Definitions: