Skip to content

Instantly share code, notes, and snippets.

@MarkDana
MarkDana / m1-max-numpy-setup.md
Last active May 8, 2026 23:22
Install NumPy on M1 Max

How to install numpy on M1 Max, with the most accelerated performance (Apple's vecLib)? Here's the answer as of Dec 6 2021.


Steps

I. Install miniforge

So that your Python is run natively on arm64, not translated via Rosseta.

  1. Download Miniforge3-MacOSX-arm64.sh, then
  2. Run the script, then open another shell
$ bash Miniforge3-MacOSX-arm64.sh
@mlabbe
mlabbe / build.sh
Created December 11, 2020 23:08
MacOS M1 cross compile and build a fat binary with aarch64/arm64 and x86_64/amd64
#!/bin/bash
clang hello.c -target arm64-apple-darwin20.1.0 -o hello.arm64
echo -n "hello.arm64 is architecture " && lipo -archs ./hello.arm64
clang hello.c -target x86_64-apple-darwin-macho -o hello.x86_64
echo -n "hello.x86_64 is architecture " && lipo -archs ./hello.x86_64
lipo hello.arm64 hello.x86_64 -create -output hello
echo -n "final output binary has archs " && lipo -archs ./hello
@creativcoder
creativcoder / main.rs
Last active November 5, 2023 13:23
Merge k sorted arrays in Rust
// Blog post: https://creativcoder.dev/merge-k-sorted-arrays-rust
// Merge 2 sorted arrays
fn merge_2(a: &[i32], b: &[i32]) -> Vec<i32> {
let (mut i, mut j) = (0, 0);
let mut sorted = vec![];
let remaining;
let remaining_idx;
loop {
if a[i] < b[j] {
@chriseidhof
chriseidhof / boilerplate.swift
Last active September 27, 2025 12:39
QuickMacApp
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
@TheCherno
TheCherno / Instrumentor.h
Last active April 3, 2026 08:43
Basic Instrumentation Profiler
//
// Basic instrumentation profiler by Cherno
// Usage: include this header file somewhere in your code (eg. precompiled header), and then use like:
//
// Instrumentor::Get().BeginSession("Session Name"); // Begin session
// {
// InstrumentationTimer timer("Profiled Scope Name"); // Place code like this in scopes you'd like to include in profiling
// // Code
// }
@CMCDragonkai
CMCDragonkai / TrueColour.md
Created August 30, 2018 14:05 — forked from XVilka/TrueColour.md
True Colour (16 million colours) support in various terminal applications and terminals

Colours in terminal

It's a common confusion about terminal colours... Actually we have this:

  • plain ascii
  • ansi escape codes (16 colour codes with bold/italic and background)
  • 256 colour palette (216 colours + 16 ansi + 24 gray) (colors are 24bit)
  • 24bit true colour ("888" colours (aka 16 milion))
printf "\x1b[${bg};2;${red};${green};${blue}m\n"
@ming4883
ming4883 / install_vboxsf.sh
Last active November 8, 2024 01:53
Alpine Virtual Box shared folder setup
apk update
apk add virtualbox-guest-additions virtualbox-guest-modules-virthardened
# auto load vboxsf kernel module
echo vboxsf > /etc/modules-load.d/vboxsf.conf
reboot
#include <unistd.h>
#include <assert.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
char *c;
sigjmp_buf jbuf;
@egmontkob
egmontkob / Hyperlinks_in_Terminal_Emulators.md
Last active May 9, 2026 23:11
Hyperlinks in Terminal Emulators

Стоимость OpenGL команд

http://www.gamedev.ru/code/articles/opengl_overhead

Автор: Анатолий Герлиц

В современных проектах для получения красивой картинки отрисовываются тысячи различных объектов: персонажи, строения, ландшафт, природа, эффекты и т.д.
Разумеется есть разные способы отобразить на экране геометрию. В этой статье мы рассмотрим как сделать это эффективно, посчитаем и сравним стоимость различных API вызовов для отрисовки геометрии.
Рассмотрим стоимость API вызовов:
    - смену различных стейтов по отдельности (фрейм буферов, вершинных буферов, шейдеров, констант, текстур)