Skip to content

Instantly share code, notes, and snippets.


Jamie Birch shirakaba

View GitHub Profile
shirakaba / How to install pip and six on macOS with Nix and
Created January 25, 2023 08:45
How to install pip and six on macOS with Nix and home-manager
View How to install pip and six on macOS with Nix and

Given the following Nix packages (you may be able to install six manually rather than managing it by Nix, but anyway, this was my setup):


I would very often run into this situation:

/usr/local/bin/pip: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory

shirakaba / clang ast
Last active January 18, 2023 09:44
How dump the ASTs for an Obj-C file using the clang CLI tool
View clang ast

For example, for the NSString.h header:

clang \
  -Xclang \
  -ast-dump \
  -fsyntax-only \
  -x objective-c \
  -I/Applications/ \
 -F/Applications/ \
shirakaba / Building and running the NativeScript metadata
Last active January 28, 2023 07:37
Building and running the NativeScript metadata generator
View Building and running the NativeScript metadata
shirakaba / How NativeScript's JS->native bindings
Last active June 4, 2022 10:17
How NativeScript's JS->native bindings work
View How NativeScript's JS->native bindings

[Draft] Deep-dive: How NativeScript's JS->native bindings work

What is NativeScript?

NativeScript is a JavaScript runtime that allows you to write an iOS or Android app entirely in TypeScript or JavaScript with no compromises. That is to say, it provides you with the same level of native access that writing the app in Obj-C/Swift (for iOS) or Java/Kotlin (for Android) does. Not just JSON-serialisable data types like NSString, but all data types are supported. To illustrate what it's all about, here's how you would get the battery level using NativeScript (the below snippet is entirely JS code!):

import { isIOS, isAndroid, Application } from "@nativescript/core";

shirakaba / ModalView.svelte
Last active April 21, 2022 20:47
Scroll-trapping view (modal overlay)
View ModalView.svelte
<script lang="ts">
import Popover from "./Popover.svelte";
import InputView from "./InputView.svelte";
import { onMount } from "svelte";
import type { InputViewProps } from "./InputInterfaces";
import { InputParser } from "./InputParser";
import Loader from "./Loader.svelte";
export let inputModel: InputViewProps|undefined = void 0;
export const inputParser: InputParser = new InputParser();
shirakaba / ViewController.swift
Last active March 26, 2022 16:32
Injecting a stylesheet into a WKWebView
View ViewController.swift
import WebKit
import UIKit
class ViewController: UIViewController {
let webView: WKWebView = WKWebView(frame: self.view.frame, configuration: WKWebViewConfiguration())
override func loadView() {
self.view = webView
shirakaba /
Created January 1, 2022 17:35
The many UI renderers of NativeScript

The many UI Renderers of NativeScript


In this article, we'll learn how NativeScript was adapted into so many different flavours (Angular, Vue, React, Svelte, and more). We'll cover what makes it such a good target for adapting, but also lift the curtain on some of the technical challenges involved in the process. And through the article, you should gain a sense of what's involved in creating a new flavour for NativeScript (or indeed any other host!).


NativeScript's cross-platform UI modules (broadly everything under the ui directory in the @nativescript/core npm package) can be described as a "UI runtime". In other words, a library that allows you to manipulate the user interface for your app while it is running.

shirakaba /
Last active February 3, 2023 19:54
Setting up Nix and Home Manager on a new M1 Mac (circa Dec 2021)


I have a brand new M1 MacBook Pro. I have a long list of complaints with homebrew, so I want to try Nix as my package manager instead, along with Home Manager to control my setup on a per-user basis. Once I've set this all up, theoretically, I should be able to reuse the same configuration on any other Macs I own.

What is Nix?

A reproducible, declarative package manager.

More info:

shirakaba /
Last active September 28, 2022 21:25
How to configure Vite from svelte.config.js in SvelteKit projects


In SvelteKit projects, SvelteKit wraps around Vite.

This example is for configuring path aliases, but you get the idea. There's a kit.vite property in svelte.config.js, and you'd configure vite through there.

Vite's plugins should be API-compatible with Rollup, to my understanding.

shirakaba / AndroidManifest.xml
Created September 26, 2021 15:35
NativeScript Android generated files
View AndroidManifest.xml
// example/android/app/src/main/AndroidManifest.xml
<manifest xmlns:android=""
<uses-permission android:name="android.permission.INTERNET" />