Skip to content

Instantly share code, notes, and snippets.

View mlliarm's full-sized avatar

Michail Liarmakopoulos mlliarm

View GitHub Profile
@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
]).
@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 / 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)
@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 / 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 / weather.md
Last active January 10, 2022 23:21
A simple CLI script that tells the weather of any given location

Weather CLI app

What

A simple CLI script that tells the weather of any given location.

It uses the https://wttr.in/ service along with a curl.

Why

I love CLI GNU/Linux apps.

@mlliarm
mlliarm / pealog.md
Last active November 26, 2022 10:35
Peano Axioms and Prolog

Pealog

What

Playing around with the Peano Axioms and Prolog.

I'd used one of the implementations of the multiplication and addition operations as defined in the Peano system, found in this StackOverflow question or this one. For some reason I haven't kept the source code, since it must have been like 4 LOC.

This gist is simply to store the results, but feel free to explore the solutions provided in the previous links to do your own experiments.

Why

@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:

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 / 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,