Skip to content

Instantly share code, notes, and snippets.

View mlliarm's full-sized avatar

Michail Liarmako. mlliarm

  • 23:37 (UTC +02:00)
View GitHub Profile
@mlliarm
mlliarm / goodcode.cpp
Created February 11, 2022 18:17 — forked from Maltysen/goodcode.cpp
Good Code
//header
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
@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 / 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 / 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

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