Skip to content

Instantly share code, notes, and snippets.

View mlliarm's full-sized avatar

Michail Liarmako. mlliarm

  • 17:14 (UTC +02:00)
View GitHub Profile
@mlliarm
mlliarm / rat2dec_with_PARI-GP.gp
Last active November 25, 2021 04:39
Rat to dec with PARI/GP
\\ So we have a rational number with nominator called 'p' and denom called 'q'.
\\ The person that gave us these numbers claims that the rational approximates Pi.
\\ We want to test this hypothesis.
\\
\\ Using the following version of PARI/GP:
\\ GP/PARI CALCULATOR Version 2.9.4 (released)
\\ amd64 running linux (x86-64/GMP-6.1.2 kernel) 64-bit version
\\ compiled: Dec 19 2017, gcc version 7.3.0 (Ubuntu 7.3.0-1ubuntu1)
\\ threading engine: pthread
\\ (readline v7.0 disabled, extended help enabled)

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 / terminal_notification.md
Last active December 6, 2021 10:19 — forked from wojteklu/terminal_notification.md
Show macOS notification when long running command finishes and your terminal is not in focus.

ATTENTION READER

BEWARE/ACHTUNG: The Bash script below doesn't work as-is on a GNU/Linux system, as GNU/Linux doesn't have the osascript OSX binary, as this is a native binary in OSX (see: OS X man page of osascript, how to use osascript binary within an OS X system). Please monitor the ticket at the repo of the python osascript binary. This is our best shot.

What and how

What

  • "Show macOS notification when long running command finishes and your terminal is not in focus." (from the title).
  • So it seems that the suggestion script is meant to run on OSX only (hence the osascript call).
  • I was able to find this (osascript) python package that seems to do that same thing. I'll test this.
  • Well, the previously found interesting looking PyPy solution, osascript is failing to work with my o
@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:

@mlliarm
mlliarm / rat2dec_with_J.md
Last active December 22, 2021 10:22
rat 2 dec with J

Rational to decimal with J

What

  • Dividing huge integers in J.
  • In Dyalog APL it's possible too, but the results are not that good as J's.

The integers

p = 16962152159971500827621917151258764064784109544245606900232064418226686845961761975388912289865516218340413697394718075218735990590275326042551305054822946743251386241642489494245471398546527893252932843180182809680192088776599427113501123269274458132892561314308941636933276592382091484436687241649828631070978202384933597627563631774076483559190382875656090731209010145477051774728710861905881838500566319597750401148880792875025501426320603030847800878985836558193868500592585719084381509349937697564242219824113650349394653098453745985221583126086570936265816829394955776190673850520166101913279272565966512735281261749675616850652392628593497225933539232795974920911990400849911804397411838424388970866361825595247265843120599991831757560765774023664956799721430767199386488989539383914103950616200296703209785010432936063062003719983999914228385
@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 / 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 / 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 / clean_code.md
Last active December 23, 2021 06:20 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.

Bob Martin's book in Amazon.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid (KISS). Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.
@mlliarm
mlliarm / particles.lgt
Last active December 23, 2021 06:22 — forked from pmoura/particles.lgt
Logtalk version of particles.pl
% Source of the particles.pl: https://github.com/mlliarm/particleslogic/blob/master/src/particles.pl
:- object(particle).
% common properties to all particles
:- public([
boson/0, fermion/0,
mass/1, spin/1, lifetime/1, charge/1
]).