Skip to content

Instantly share code, notes, and snippets.

View suhr's full-sized avatar
😐
Trying to fix the world

Сухарик suhr

😐
Trying to fix the world
View GitHub Profile

Why so slow? Creating a flamegraph of your program with perf

Flamegraphs can help to optimize the program a lot. So let's create one!

  • Install perf with use flag unwind enabled
  • Download flamegraph.pl and stackcolllapse-perf.pl
  • Run perf record -F 99 --call-graph dwarf -- ‹your program›
  • Do all the things that make your program slow
  • Close your program
  • Run perf script | stackcollapse-perf.pl > out.folded
@suhr
suhr / task.cue
Last active November 23, 2019 02:20
{
PendingTask | EndedTask | WaitingTask | RecurringParrentTask | RecurringChildTask
...
}
Task :: {
status: Status
uuid: Uuid
entry: Date
description: string
# APL keyboard
<Multi_key> <space> <z> : "⊂"
<Multi_key> <space> <Z> : "⊆"
<Multi_key> <space> <x> : "⊃"
<Multi_key> <space> <c> : "∩"
<Multi_key> <space> <v> : "∪"
<Multi_key> <space> <b> : "⊥"
<Multi_key> <space> <n> : "⊤"
<Multi_key> <space> <less> : "⍝"
<Multi_key> <space> <comma> : "⍪"
@suhr
suhr / sse.bqn
Last active August 16, 2021 09:46
# SSE to BQN dictonary
# This is an implementation of SSE SIMD intristics in BQN. The purpose of it
# is understanding: it's a look at SIMD instructions from an array programmer POV.
# There are limit of what you can can represent in a programming language without
# losing clarity. Bit hackery is one of such features. So instead of converting
# from floats to bits and back, we just assume that the data *already* is
# represented the way we need.
@suhr
suhr / proofs.md
Last active December 8, 2022 13:05

Упражнения по формальным доказательствам

Нет времени объяснять, переходим сразу к делу.

Инструменты

Доказывать теоремы мы будем, используя интерактивные пруверы Isabelle или Lean 3. Примеры приводятся для каждого прувера, для решения задач же можно использовать любой из них.

@suhr
suhr / apl.sed
Last active December 15, 2021 11:06
s:∘.: outerProduct_ :g
s:+: ConjugatePlus :g
s:-: NegateMinus :g
s:×: DirectionTimes :g
s:÷: ReciprocalDivide :g
s:⌊: FloorMinimum :g
s:⌈: CeilingMaximum :g
s:|: MagnitudeResidue :g
s:*: ExponentialPower :g
s:⍟: NatualLogarithmLogarithm :g
@suhr
suhr / bqn.sed
Created December 14, 2021 16:38
s:+: ConjugateAdd :g
s:-: NegateSubtract :g
s:×: SignMultiply :g
s:÷: ReciprocalDivide :g
s:⋆: ExponentialPower :g
s:√: SquareRootRoot :g
s:⌊: FloorMinimum :g
s:⌈: CeilingMaximum :g
s:∧: SortUpAnd :g
s:∨: SortDownOr :g
@suhr
suhr / k.sed
Last active December 15, 2021 14:05
s:+: FlipAdd :g
s:-: NegateSubtract :g
s:*: FirstMultiply :g
s:%: SquareRootDivide :g
s:!: EnumerateOdometerDictonaryKeysDivideModulo :g
s:&: WhereDeepWhereAndMinimum :g
s:|: ReverseOrMax :g
s:<: OpenAscendLess :g
s:>: CloseDescendMore :g
s:=: GroupUnitMatrixEqual :g

Array algebra stripped down

Let's reduce the operations on rank-1 arrays (lists) down to very basic functions.

Two views on lists:

  • A list is a function from indices to values
  • A list is a free monoid

The first view gives ↕n, i⊑x and x⊏y, which correspond to the identity function, application and composition, and also gives f¨x and x f¨ y.