Skip to content

Instantly share code, notes, and snippets.

View mlliarm's full-sized avatar

Michail Liarmako. mlliarm

  • 08:16 (UTC +02:00)
View GitHub Profile
@4hg
4hg / tca.ijs
Created May 4, 2022 15:02
1D Totalistic Cellular Automata code written for my writeup on the subject.
require 'viewmat'
NB. rules are base-4, but the base is dependent on the number of states
NB. output is 500x500
NB. colors are encoded as hex
NB. r - 0 for custom rule, 1 for random rule
NB. s - 0 for single 1-cell start, 1 for random start
NB. c - 0 for custom colors, 1 for random colors
NB. g - iter function
NB. edit these to change modes
@steveAllen0112
steveAllen0112 / oldtimer_APL_code.md
Last active February 26, 2022 08:47 — forked from mlliarm/oldtimer_APL_code.md
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,

@aarroyoc
aarroyoc / alien.pl
Created January 27, 2022 12:43
Alien Puzzle
:- use_module(library(dcgs)).
:- use_module(library(clpz)).
hex_number(N) -->
hex(A),
hex(B),
{
N #= B + A*16
}.
@mlliarm
mlliarm / gists.md
Last active November 8, 2022 02:50
Gists
∇ solvePart1 {
⍝ Construct a 2-column array with the first column being the command
⍝ and the second being the distance.
list ← ⊃ {(d n) ← ⍵ ⊂⍨ ⍵≠↑" " ◊ d (⍎n)}¨ io:read "/home/elias/prog/advent-of-code2021/part02.txt"
⍝ Convert each direction instruction into a vector (up, down or right)
directions ← { ⊃ ((0 1) (¯1 0) (1 0))[(⊂¨ "forward" "up" "down") ⍳ ⊂⍵] }¨ list[;0]
⍝ Multiply each direction with the distance and sum the results
⍝ and finally multiply the individual values
@Maltysen
Maltysen / geo.cpp
Last active February 11, 2022 18:18
2D geometry template
//Geometry
#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;
typedef complex<ld> pt;
@pmoura
pmoura / particles.lgt
Last active March 17, 2020 00:48
Logtalk version of particles.pl
:- object(particle).
% common properties to all particles
:- public([
boson/0, fermion/0,
mass/1, spin/1, lifetime/1, charge/1
]).
:- end_object.
@Maltysen
Maltysen / goodcode.cpp
Last active November 2, 2023 07:57
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;

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 6, 2024 20:05
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).