Skip to content

Instantly share code, notes, and snippets.

View mlliarm's full-sized avatar

Michail Liarmako. mlliarm

  • 14:24 (UTC +02:00)
View GitHub Profile
@mlliarm
mlliarm / Installing Python 3.7 from source on Ubuntu 18.04.md
Created January 12, 2022 23:56
Installing Python 3.7 from source on Ubuntu 18.04

Installing Python 3.7 from source on Ubuntu 18.04

# update system
sudo apt update && sudo apt upgrade -y

# install build tools and python prerequisites
sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev

# download and extract python
@mlliarm
mlliarm / gists.md
Last active November 8, 2022 02:50
Gists
@mlliarm
mlliarm / whitney.c
Last active December 23, 2021 16:45 — forked from anonymous/gist:f72e5c4a432492abce59
Arthur Whitney's J interpreter, decompressed
// Link to the original: http://www.jsoftware.com/jwiki/Essays/Incunabulum
// Found at https://news.ycombinator.com/item?id=8533843
typedef char C;
typedef long I;
typedef struct a {
I t,r,d[3],p[2];
}* A;
@mlliarm
mlliarm / gist:261037e635c0b8942fd6b939e2608922
Created December 23, 2021 06:24 — forked from psayre23/gist:c30a821239f4818b0709
Runtime Complexity of Java Collections
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@mlliarm
mlliarm / combinators_for_logic.hs
Created December 23, 2021 04:47
Combinators for logic programming (Haskell98)
-- Authors: Mike Spivey and Silvija Seres
-- Taken from: https://www.cs.ox.ac.uk/publications/books/fop/dist/fop/chapters/9/Logic.hs,
-- "The fun of programming book", https://www.cs.ox.ac.uk/publications/books/fop/,
-- Chapter 9, Combinators for logic programming
-- Haskell 98 compliant.
module Logic where
import List
-- Section 9.2
@mlliarm
mlliarm / sympy-test.md
Last active December 22, 2021 22:10
Testing SymPy

Testing SymPy

What

I've been a great fan of Mathematica since the first time I've used it back in 2000.

After a couple discussions of one of the creators of SymPy over Twitter, I decided to look deeper in this interesting project.

Tests

This is the Python version:

@mlliarm
mlliarm / gist:e2d50b9b9f820376a17e0d89da67c8e6
Last active December 22, 2021 12:37 — forked from ademar/gist:1016874
Combinators for logic programming
// Based on the article 'Combinators for logic programming' by Michael Spivey and Silvija Seres.
// Original author's blog post: http://ademar.name/blog/2011/06/combinators-for-logic-programm.html
// More info about this language: https://en.wikipedia.org/wiki/F_Sharp_(programming_language)
let rec inf_seq n = seq { yield n; yield! inf_seq (n+1) }
let rec lzw f l1 l2 =
LazyList.delayed ( fun () ->
match l1,l2 with
|LazyList.Nil, _ -> l2
@mlliarm
mlliarm / oldtimer_APL_code.md
Last active February 25, 2022 23:01
An oldtimer's APL code

An oldtimer's APL code

What

Some pretty cool code from the 70s'-80s' that a Reddit user shared at this question.

Here's what u/snarkuzoid wrote:

5x5 Knight's Tour in APL

It puts an A in the middle, then randomly does a knight's tour,

Problem

A lot of GitHub projects need to have pretty math formulas in READMEs, wikis or other markdown pages. The desired approach would be to just write inline LaTeX-style formulas like this:

$e^{i \pi} = -1$

Unfortunately, GitHub does not support inline formulas. The issue is tracked here.

Investigation

@mlliarm
mlliarm / rat_pi.md
Last active December 6, 2021 10:49
Rational Approximation of pi

Rational Approximation of pi

What

Sometime ago, a user of r/math posted this outreageous result and claimed that this fraction approximates pi.

I confirmed this result of his, using J and using PARI/GP.

But today, I was reading the lemma on tacit programming over aplwiki.com and saw this amazing result: