Skip to content

Instantly share code, notes, and snippets.

View johari's full-sized avatar
💭
🔮

Nima Johari johari

💭
🔮
View GitHub Profile
@johari
johari / README.md
Last active January 31, 2025 18:25
Nima's Legion notes

Legion is task graph. So is llbuild2fx.

(Task-based system) The task model heavily resemble's llbuild2fx's FXKey, computeValue and fi.request mechanism.

(Memmory model) llbuild2fx has a closer relationship with CAS for storage/memory. Legion's emphasis is on logical region (as an abstraction over memory) and Rect (to express the shape/dimensions of the computation).

(Decoupling the task from underbelly of compute) Legion has the following API

  • Runtime::preregister_task_variant<int, sum_task>(registrar, "sum", AUTO_GENERATE_ID); and
  • registrar.add_constraint(ProcessorConstraint(Processor::LOC_PROC));
import CoreMIDI
import SwiftUI
struct MIDIEvent: Identifiable, Hashable {
var id: String {
"Status: \(status), Data1: \(data1), Data2: \(data2)"
}
let status: UInt8
let data1: UInt8
nix-shell -E "with import <nixpkgs> {}; pkgs.mkShell.override { inherit (pkgs.swift) stdenv; } { buildInputs = [ swift swiftPackages.Foundation ]; }" --run "swiftc -" <<< 'import Foundation; print("hello")'
@johari
johari / Common.swift
Created November 28, 2023 19:49
Pipes and Tuples (SignalFunctions, `>>>` and `&&&` operators)
public struct Pair<A: Equatable, B: Equatable>: Equatable {
public static func == (lhs: Pair<A, B>, rhs: Pair<A, B>) -> Bool {
lhs.fst == rhs.fst && lhs.snd == rhs.snd
}
public let fst: A
public let snd: B
public init(_ fst: A, _ snd: B) {
self.fst = fst
@johari
johari / larkspur-36.xml
Created August 14, 2019 03:47
Google Maps sample API call result
<?xml version="1.0" encoding="UTF-8"?>
<DirectionsResponse>
<status>OK</status>
<route>
<summary></summary>
<leg>
<step>
<travel_mode>WALKING</travel_mode>
<start_location>
<lat>47.5754010</lat>
@johari
johari / .xmobarrc
Last active November 6, 2019 15:33
x{monad,mobar}
Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
, borderColor = "black"
, border = TopB
, bgColor = "black"
, fgColor = "grey"
, position = TopW L 100
, commands = [ Run Weather "CYVR" ["-t","<tempC>C","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 36000
, Run Network "eth0" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Network "eth1" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
@johari
johari / 0262162091.xml
Created September 14, 2018 16:32
Goodreads and TAPL
<?xml version="1.0" encoding="UTF-8"?>
<GoodreadsResponse>
<Request>
<authentication>true</authentication>
<key><![CDATA[JLKmEsBoPY8EDdanenpiw]]></key>
<method><![CDATA[book_isbn]]></method>
</Request>
<book>
<id>112252</id>
<title><![CDATA[Types and Programming Languages]]></title>
Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
, borderColor = "black"
, border = TopB
, bgColor = "black"
, fgColor = "grey"
, position = TopW L 100
, commands = [ Run Weather "CYVR" ["-t","<tempC>C","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 36000
, Run Network "eth0" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Network "eth1" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
Naval Fate.

Usage:
  naval_fate.py ship new <name>...
  naval_fate.py ship <name> move <x> <y> [--speed=<kn>]
  naval_fate.py [fake] ship shoot <x> <y>
  naval_fate.py mine (set|remove) <x> <y> [--moored|--drifting]
  naval_fate.py mine list [<region>...]
 naval_fate.py mine [-r ...]