Skip to content

Instantly share code, notes, and snippets.

@MarkDana
MarkDana / m1-max-numpy-setup.md
Last active October 28, 2023 11:42
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] {
// 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 June 25, 2024 18:39
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 June 22, 2024 03:08
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;
@miekg
miekg / udpserv.c
Created May 10, 2017 10:33
udp server in C
/*
* udpserver.c - A simple UDP echo server
* usage: udpserver <port>
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
@egmontkob
egmontkob / Hyperlinks_in_Terminal_Emulators.md
Last active July 4, 2024 01:11
Hyperlinks in Terminal Emulators