Skip to content

Instantly share code, notes, and snippets.

View thehapax's full-sized avatar

The Hapax thehapax

  • the universe
View GitHub Profile
@jhidding
jhidding / pi.py
Created January 16, 2020 11:54
Compute Pi using Numba and Dask
# requirements: python3, numba, dask
import random
import numba
import dask
@dask.delayed
@numba.jit(nopython=True, nogil=True)
def calc_pi(N):
@maxtaco
maxtaco / bot-signup-flow.md
Last active May 5, 2023 16:47
New bot signup flow

Get a Bot Token

As your keybase user run:

$ keybase bot token create > /tmp/bot-token

You'll get back a base64 token, like: 6C37sjCBgMNf06Z6oTgixIxHJpja8G-Qp. This is your bot token that allows you to sign up bots.

@painor
painor / FastTelethon.py
Last active July 13, 2024 13:27
This will increase the download/upload speed when using telethon
# copied from https://github.com/tulir/mautrix-telegram/blob/master/mautrix_telegram/util/parallel_file_transfer.py
# Copyright (C) 2021 Tulir Asokan
import asyncio
import hashlib
import inspect
import logging
import math
import os
from collections import defaultdict
from typing import Optional, List, AsyncGenerator, Union, Awaitable, DefaultDict, Tuple, BinaryIO
@rockstardev
rockstardev / btcpayserver_install_env.sh
Last active October 25, 2023 23:10
Setting up BTCPayServer development environment on Linux (Ubuntu)
# Installing prerequisites for BTCPayServer development on Ubuntu
# Install .NET Core SDK 2.2
# https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install?initial-os=linux
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo add-apt-repository universe
@Rich-Harris
Rich-Harris / what-is-svelte.md
Last active March 27, 2024 06:09
The truth about Svelte

I've been deceiving you all. I had you believe that Svelte was a UI framework — unlike React and Vue etc, because it shifts work out of the client and into the compiler, but a framework nonetheless.

But that's not exactly accurate. In my defense, I didn't realise it myself until very recently. But with Svelte 3 around the corner, it's time to come clean about what Svelte really is.

Svelte is a language.

Specifically, Svelte is an attempt to answer a question that many people have asked, and a few have answered: what would it look like if we had a language for describing reactive user interfaces?

A few projects that have answered this question:

@gaearon
gaearon / modern_js.md
Last active July 18, 2024 10:37
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@HarshaVardhanBabu
HarshaVardhanBabu / Instructions_UML_Python.rst
Last active July 16, 2024 11:34
Generating UML diagrams in python using pyreverse

Requirements

  1. Install Pylint from Install. If you have anaconda already installed use pip install -U pylint to update the Pylint so that pyreverse is added to the scripts folder.

  2. You need to install Graphviz as the pyreverse generates the UML diagrams in dot format and needs the dot.exe provided by Graphviz. Once Graphviz is installed make sure the bin folder is added to the PATH variable so that pyreverse can find it at run time. "the command pyreverse generates the diagrams in all formats that graphviz/dot knows." (Reference

  3. Now add the path of python modules for which you want to generate the documentation to PYTHONPATH.

  4. Use pyreverse -S <modulename> to generate dot files in the current folder

    Usage:

# See official docs at https://dash.plotly.com
# pip install dash pandas
from dash import Dash, dcc, html, Input, Output
import plotly.express as px
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv')
@subfuzion
subfuzion / curl.md
Last active July 25, 2024 08:53
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

Distributed Currency Exchange on OpenBazaar

Introduction

OpenBazaar allows for the decentralised exchange of types of currencies using the flexible Ricardian contract system. Currency exchanges are not limited trades between crypto-currencies, but can also facilitate exchanges with fiat currencies using reverisble and non-reversible payment systems.

Currency Exchanges

Fundamentally, currency exchanges require a matching of buy and sell orders at a certain price for a given volume. Firstly, buy and sell orders will be created and issued as a Ricardian contract, formatted according to a specialised 'currency' template in OpenBazaar. Secondly, matching buy and sell orders theoretically will be mediated over exchange nodes, which may also function as arbiters for each exchange. Alternative, buy and sell orders may be matched over the OpenBazaar distributed hash table. Finally, private exchanges can be made bet