Skip to content

Instantly share code, notes, and snippets.

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

Jamie Birch shirakaba

💭
🧙‍♂️
View GitHub Profile
@shirakaba
shirakaba / I hate pip.md
Last active December 29, 2023 08:27
Fixing pip when even `pip --version` fails

A very common failure pattern of pip is the following:

> pip --version
/usr/local/bin/pip:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import load_entry_point
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/pkg_resources/__init__.py", line 631, in _build_master
    ws.require(__requires__)
  File "/opt/homebrew/lib/python3.11/site-packages/pkg_resources/__init__.py", line 968, in require
    needed = self.resolve(parse_requirements(requirements))
@shirakaba
shirakaba / gist:85297b286c7c4fd6097c2e2c49d8ff1e
Last active December 27, 2023 11:43
Setting up deDRM with Calibre

Go to apprenticeharper/DeDRM_tools and download the latest release.

Follow the plugin's installation instructions:

Open calibre's Preferences dialog. Click on the "Plugins" button. Next, click on the button, "Load plugin from file". Navigate to the unzipped DeDRM_tools folder, find the file "DeDRM_plugin.zip". Click to select the file and select "Open". Click "Yes" in the "Are you sure?" dialog box. Click the "OK" button in the "Success" dialog box.

Once the DeDRM plugin appears in the Calibre plugins menu, double-click it to get the Customise DeDRM popup. From there, click "eInk Kindle ebooks".

Add the serial number for your preferred Kindle (the one you intend to download files for) via the Manage Your Content and Devices section of the Amazon site (instructions here).

@shirakaba
shirakaba / react-native-jsi-bridge-2+1.0.0.patch
Last active September 29, 2023 23:11
react-native-webview jsi patch
diff --git a/node_modules/react-native-jsi-bridge-2/ios/JsiBridgeEmitter.h b/node_modules/react-native-jsi-bridge-2/ios/JsiBridgeEmitter.h
index 62da923..cae7aee 100644
--- a/node_modules/react-native-jsi-bridge-2/ios/JsiBridgeEmitter.h
+++ b/node_modules/react-native-jsi-bridge-2/ios/JsiBridgeEmitter.h
@@ -9,16 +9,16 @@
#import <Foundation/Foundation.h>
#import "_JsiBridge.h"
-typedef void (^JsiBridgeCallback)(id data);
+typedef void (^CustomJsiBridgeCallback)(id data);
@shirakaba
shirakaba / Bun exiting without debug.md
Created September 24, 2023 02:46
Bun exiting without debug

We're going to be calling into Python from Bun, so ensure that you have Python 3 and Pip and install these packages for Python:

# https://github.com/polm/fugashi
pip install fugashi

# https://github.com/polm/unidic-py
pip install unidic
@shirakaba
shirakaba / UniDic Licence.txt
Last active August 9, 2023 01:42
UniDic fields
Copyright (c) 2011-2021, The UniDic Consortium
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
@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";

/**