Skip to content

Instantly share code, notes, and snippets.

View donn's full-sized avatar

Mohamed Gaber donn

View GitHub Profile
@donn
donn / Readme.md
Last active December 5, 2023 21:29
Lima with Rosetta 2 and Nix
  1. Install lima. Counterintuitively, the Nix version of Lima does not support the vz engine, so you will want to grab the binary from https://github.com/lima-vm/lima/releases/latest
  2. Before starting the VM for the first time, limactl edit default: Make sure the following entries are set to these values:
vmType: "vz"
rosetta:
  # Hint: try `softwareupdate --install-rosetta` if Lima gets stuck at `Installing rosetta...`
  enabled: true
  binfmt: true
@donn
donn / or-tools.log
Created December 4, 2023 23:51
Log for build failure on `or-tools`
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/lx1pw59wacirmr5mm8lwfdx4piif1g2b-source
source root is source
setting SOURCE_DATE_EPOCH to timestamp 315619200 of file source/tools/win/zip.exe
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
applying patch /nix/store/5xpjwlnv7mw62dihnzrqcj3k3b37jp85-7072ae92ec204afcbfce17d5360a5884c136ce90.patch
patching file examples/cpp/CMakeLists.txt
applying patch /nix/store/xbhc4633ci0zdxhb4y86fdkxvakd1f7a-a26602f24781e7bfcc39612568aa9f4010bb9736.patch
@donn
donn / eea.swift
Created October 20, 2023 12:16
Extended Euclidean Algorithm
struct Row: CustomStringConvertible {
var a: Int
var b: Int
var t1: Int
var t2: Int
var s1: Int
var s2: Int
var r: Int {
return self.a % self.b
@donn
donn / cnf_to_xnf.ipynb
Last active November 28, 2022 13:57
Conjunctive Normal Form to Conjunctive XOR-based form
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@donn
donn / opendbpy.py
Created December 24, 2021 12:57
opendbpy for reference
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info as _swig_python_version_info
if _swig_python_version_info < (2, 7, 0):
raise RuntimeError("Python 2.7 or later required")
@donn
donn / graph.swift
Last active November 2, 2021 14:20
Swift Uniform Cost Search
#!/usr/bin/env quips
/*
Requires quips - github.com/donn/quips
yeet
Swift
--
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
@donn
donn / iPhone Region Codes.md
Last active April 18, 2024 11:06
iPhone Region/Country Codes

iPhone Country Codes

Why I made this

The model regions on Apple wikis are missing some entries- and the entries are lacking some information that I would be critical for international buyers: there are some extreme differences between features in some regions: FaceTime support, Dual SIM support, etc.

What's worse is some regions have multiple codes, and sometimes even imported devices from other regions.

Unfortunately, Apple does not seem to acknowledge these region numbers exist and all and resort to nebulous claims about the feature differences, and it doesnt help that there are some conflicting reports on the internet.

So I'm going to try my best to maintain an up-to-date list. Any and all confirmations, additions and denials here would be extremely helpful. Please just leave a comment.

@donn
donn / cthreadpoolfuture.swift
Created November 17, 2019 15:08
c thread pool future swift
// attempted to replace GCD but it turns out GCD was not in fact broken so uh Linux
import Foundation
import CThreadPool
var pool: threadpool?
public class Future {
private var semaphore: DispatchSemaphore
private var store: Any?
private var executor: () -> Any
@donn
donn / tm4c_mac_setup.rb
Last active October 28, 2019 22:43
TM4C123GH6PM Environment Mac Setup
#!/usr/bin/env ruby
# TM4C123GH6PM Environment Mac Setup
#
# This is what I do when I procrastinate.
#
# I recommend you have homebrew pre-installed for this, but the script
# will try to install it anyway.
#
# (To get STM32 working on Mac instead, try
@donn
donn / ALU.scala
Created October 12, 2019 12:13
RiscBEE ALU in Chisel
/*
The RiscBEE ALU in Chisel
I rewrote the ALU for github.io/donn/RiscBEE in Chisel in the initial research phase for Phi…
I uh. Wasn't a fan.
Scala
--
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or