Skip to content

Instantly share code, notes, and snippets.

20 million digits of pi in under a minute with Julia

I recently discovered a relatively obscure algorithm for calculating the digits of pi: https://en.wikipedia.org/wiki/Gauss–Legendre_algorithm. Well, at least obscure compared to Chudnovsky's. Wikipedia notes that it is "memory-intensive" but is it really? Let's compare to the MPFR pi function:

function gauss_legendre(prec)
    setprecision(BigFloat, prec, base=10)
    GC.enable(false)
@etherx-dev
etherx-dev / requires python binanace api
Last active April 9, 2024 23:26
Crypto Currency address Regular Expressions - extracted from the binance api on 31/03/2022
from binance.client import Client
from binance.exceptions import BinanceAPIException, BinanceRequestException
#incomplete but i just need a useful regex
client = Client("apikey", "secret")
coininfo = client.get_all_coins_info()
for coin in coininfo:
for network in (coin['networkList']):
print(coin['name'],network['addressRegex'])
@etherx-dev
etherx-dev / balanced_merkle_path_update.md
Created November 14, 2021 19:03 — forked from gavinandresen/balanced_merkle_path_update.md
Updating old paths (witnesses) for a balanced merkle forest accumulator

Introduction

It would be spiffy to use the balanced merkle forest idea for ethereum tokens or to store unspent transaction outputs.

Tadge Dryja has been working on 'utreexo' (presentation) for storing unspent transaction outputs in log(n) space; this gist is inspired by, and is very similar to, that work.

So my previous gist describes really simple algorithms for adding and removing items from a balanced merkle forest. This gist extends those operations to create

@jhoelzel
jhoelzel / gist:1c015e667c162fc8f3f3712b1c6417c5
Created September 28, 2021 15:49
iptables / ip6tables allow only cloudflare IPs to acces our server
# https://www.cloudflare.com/ips
# https://support.cloudflare.com/hc/en-us/articles/200169166-How-do-I-whitelist-CloudFlare-s-IP-addresses-in-iptables-
for i in `curl https://www.cloudflare.com/ips-v4`; do iptables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
for i in `curl https://www.cloudflare.com/ips-v6`; do ip6tables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
@patricklodder
patricklodder / 2021-Dogecoin-fee-policy-proposal.md
Created June 27, 2021 20:12
2021 Dogecoin Fee Policy Proposal

DOGECOIN FEE POLICY CHANGE PROPOSAL

This document proposes a new fee structure and policy for Dogecoin Core, to be gradually deployed to the network over multiple software releases.

Historical fee policy

Meaningful fees were introduced for Dogecoin in 2014 to reduce on-chain spam. With a 1 DOGE fee per kilobyte, rounded up, the Dogecoin chain provided

@etherx-dev
etherx-dev / messages.c
Last active April 3, 2021 06:18 — forked from taviso/messages.c
Enumerating Windows Messages ( PROOF OF CONCEPT) - (i guess, this is so weired)... https://googleprojectzero.blogspot.com/2019/08/down-rabbit-hole.html#ftnt1 <-- "plain text" file RCE exploit in windows.
#include <windows.h>
#include <stdio.h>
#include <stdint.h>
#pragma comment(lib, "USER32")
FARPROC NtUserPostMessage;
BOOL CALLBACK QueryWindowMessageProc(HWND Window, LPARAM Param)
{

Hal Finney's explanation of secp256k1 "efficiently computable endomorphism" parameters used secp256k1 libraries, archived from source.

The same optimization could be applied to any Koblitz curve (e.g. Short Weistrass curve with a=0).


I implemented an optimized ECDSA verify for the secp256k1 curve, based on pages 125-129 of the Guide to Elliptic Curve Cryptography, by Hankerson, Menezes and Vanstone. I own the book but I also found a PDF on a Russian site which is more convenient.

secp256k1 uses the following prime for its x and y coordinates:

@jpmcb
jpmcb / hacker.md
Created November 25, 2020 18:09
To Catch a Hacker - NPM Event Stream

To Catch a Hacker - NPM Event Stream

(Note: this post is from a legacy blog dated 12/14/2018 and some content or links may have changed)

A few weeks ago, this issue was opened on a popular Node NPM package called Event Stream. This package enables Node streams to be simpler and streamlines many I/O operations within Node. Regardless, this package is a key dependency for many other Node packages and has over 1 million downloads per week from NPM. The newly opened issue initially questioned a new, suspicious dependency that was pushed by a new, unknown maintainer. I was lucky enough to follow the community's investigation into this issue and now, I hope to present the findings here. My goal with this piece is to hopefully shed some light on how easy it is for somebody to inject malicious code into NPM packages, the responsibility of open source maintainers, and the responsibility of the community.

The Malicious Code

A Github user noticed that

@iahuang
iahuang / apfs_crack.py
Last active May 30, 2024 16:04
A command line tool for Kali Linux that uses apfs-fuse to crack encrypted MacOS drives. Run with -h to see usage
from subprocess import Popen, PIPE, STDOUT
from multiprocessing import Process, Queue
import queue
import os
import re
from termcolor import colored
import argparse
import time
from datetime import datetime
from dataclasses import dataclass
@bmatcuk
bmatcuk / create-usb.sh
Created May 30, 2019 04:38
Creating a Bootable Windows USB from ISO on a Mac
# First, we need to find our device. BEFORE inserting your USB drive, run the
# following:
diskutil list
# This will output a bunch of info about all of the disk drives connected to
# your Mac. Each entry will have a header in the form "/dev/diskX", where X is
# some number starting at 0. Now, insert your USB drive and run the command
# again. You should see a new entry. Make note of the name (ie, /dev/diskX).
diskutil list