Skip to content

Instantly share code, notes, and snippets.

View shirakaba's full-sized avatar
💭
🧙‍♂️

Jamie Birch shirakaba

💭
🧙‍♂️
View GitHub Profile
@shirakaba
shirakaba / Creating an Expo app in 2023.md
Created July 12, 2023 08:08
Creating an Expo app in 2023

Creating an Expo app in 2023

12th July, 2023. I'm going to try creating an iOS app called Paranovel, using Expo. My environment for mobile app dev (Xcode, Ruby, etc.) should be in reasonably good shape already as I frequently develop with React Native and NativeScript.

Creating the app

Go to https://docs.expo.dev, and see the Quick Start: npx create-expo-app paranovel

This runs with no problem, then I get this macOS system popup:

@shirakaba
shirakaba / How to install pip and six on macOS with Nix and home-manager.md
Created January 25, 2023 08:45
How to install pip and six on macOS with Nix and home-manager

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):

pkgs.python310Full
pkgs.python310Packages.six

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
shirakaba / clang ast dumping.md
Last active January 18, 2023 09:44
How dump the ASTs for an Obj-C file using the clang CLI tool

For example, for the NSString.h header:

clang \
  -Xclang \
  -ast-dump \
  -fsyntax-only \
  -x objective-c \
  -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers \
 -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks \
@shirakaba
shirakaba / Building and running the NativeScript metadata generator.md
Last active January 28, 2023 07:37
Building and running the NativeScript metadata generator
@shirakaba
shirakaba / How NativeScript's JS->native bindings work.md
Last active August 22, 2023 10:44
How NativeScript's JS->native bindings work

[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
shirakaba / ModalView.svelte
Last active April 21, 2022 20:47
Scroll-trapping view (modal overlay)
<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
shirakaba / ViewController.swift
Last active March 26, 2022 16:32
Injecting a stylesheet into a WKWebView
import WebKit
import UIKit
class ViewController: UIViewController {
let webView: WKWebView = WKWebView(frame: self.view.frame, configuration: WKWebViewConfiguration())
override func loadView() {
super.loadView()
self.view = webView
@shirakaba
shirakaba / renderers.md
Created January 1, 2022 17:35
The many UI renderers of NativeScript

The many UI Renderers of NativeScript

Introduction

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!).

Background

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
shirakaba / nix.md
Last active December 26, 2024 21:01
Setting up Nix and Home Manager on a new M1 Mac (circa Dec 2021)

Background

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
shirakaba / vite-configuration.md
Last active November 18, 2024 03:50
How to configure Vite from svelte.config.js in SvelteKit projects

SvelteKit

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.

https://kit.svelte.dev/faq#aliases

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