Skip to content

Instantly share code, notes, and snippets.

View ivan-pi's full-sized avatar

Ivan Pribec ivan-pi

View GitHub Profile
@fnky
fnky / ANSI.md
Last active April 26, 2024 16:45
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 25, 2024 06:23
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@kconner
kconner / macOS Internals.md
Last active April 22, 2024 21:28
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

# IDA (disassembler) and Hex-Rays (decompiler) plugin for Apple AMX
#
# WIP research. (This was edited to add more info after someone posted it to
# Hacker News. Click "Revisions" to see full changes.)
#
# Copyright (c) 2020 dougallj
# Based on Python port of VMX intrinsics plugin:
# Copyright (c) 2019 w4kfu - Synacktiv
@dblalock
dblalock / align.c
Created August 30, 2017 22:11
C / C++ portable aligned memory allocation
/* Allocate aligned memory in a portable way.
*
* Memory allocated with aligned alloc *MUST* be freed using aligned_free.
*
* @param alignment The number of bytes to which memory must be aligned. This
* value *must* be <= 255.
* @param bytes The number of bytes to allocate.
* @param zero If true, the returned memory will be zeroed. If false, the
* contents of the returned memory are undefined.
* @returns A pointer to `size` bytes of memory, aligned to an `alignment`-byte

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone git@gist.github.com:<hash>.git     # or with ssh
@max-mapper
max-mapper / bibtex.png
Last active March 10, 2024 21:53
How to make a scientific looking PDF from markdown (with bibliography)
bibtex.png

Two schools

There are two schools how to write numerical code, which in this document we will call the IEEE school and the Fortran school.

One end of the spectrum: no changes in floating point by the compiler, the developer must express exact intent. This is the IEEE school.

On the other end of the spectrum: Developer specifies math, the compiler is

@leverich
leverich / tide_fac.f
Created November 27, 2015 19:02
tide_fac.f modified to compute node factors and equilibrium arguments for all 37 NOS/NOAA tidal constituents
C PROGRAM TO COMPUTE NODAL FACTORS AND EQUILIBRIUM ARGUEMENTS
C
C
PARAMETER(NCNST=37)
CHARACTER CNAME(NCNST)*8
COMMON /CNSNAM/ CNAME
REAL NODFAC,MONTH
DIMENSION NCON(NCNST)
COMMON /CNST/ NODFAC(NCNST),GRTERM(NCNST),SPEED(NCNST),P(NCNST)
@ivan-pi
ivan-pi / bisect.cxx
Last active August 25, 2022 07:42
Passing a C Function Callback to the Boost Math Toolkit Root Finding Library
// compile with g++ -o bisect.cxx poly.o -I<path/to/boost>
#include <cmath>
#include <iostream>
#include <boost/math/tools/roots.hpp>
// Functor providing termination condition
// Determines convergence in x based on if the relative or absolute tolerance are satisfied
template<class T>