Skip to content

Instantly share code, notes, and snippets.

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

Jamie Birch shirakaba

💭
🧙‍♂️
View GitHub Profile
@shirakaba
shirakaba / guard.ts
Created May 14, 2021 13:53
TypeScript guard function for type-checking records by index signatures
type Check<T> = {
[K in keyof T]: K extends `dull.${string}`
? T[K] extends string
? T[K]
: never
: K extends `rich.${string}`
? T[K]
: never
}
@shirakaba
shirakaba / custom store.js
Last active May 6, 2021 20:12
Svelte custom store example
import { writable, derived } from 'svelte/store';
function createCountries() {
const { subscribe, update } = writable([
{
name: "United Kingdom",
weather: "Cold",
description: "Nice tea",
},
{
@shirakaba
shirakaba / MWE.svelte
Last active April 28, 2021 16:40
Svelte store contract for all APIs of a class
<script>
import { writable } from "svelte/store";
class TransactionManager {
constructor(){
this.transactionCount = -1;
this.transactionQueue = [];
this._transactionIsInFlight = writable(this);
}
@shirakaba
shirakaba / MWE.svelte
Last active April 28, 2021 16:40
Svelte store contract for one API of a class
<script>
import { writable } from 'svelte/store';
class TransactionManager {
constructor(){
this.transactionCount = -1;
this.transactionQueue = [];
this._transactionIsInFlight = writable(false);
}
startTransaction(){
@shirakaba
shirakaba / react-native-in-nativescript-dump.md
Created February 11, 2021 22:55
react-native:0.63.4.aar selector dump

Here's what I ran:

declare var com: any;
const visitedValues = new Set();

function eachRecursive(path, value){
    if(visitedValues.has(value)){
        // Crude protection against following circular references in an infinite loop
        console.log(`${path} [Already visited, so won't recurse]`);
@shirakaba
shirakaba / README.md
Last active May 10, 2021 21:04
Running NativeScript on Apple Silicon via Rosetta (x86 emulation)

This guide will show you how to provision an Apple Silicon machine to run a NativeScript app via Rosetta (x86 emulation). It may soon become possible to run it natively, but I believe that's pending this PR, so I had to go with Rosetta for the time being.

I did this setup on a borrowed M1 Mac Mini, so a few things had been provisioned already, but I'll do my best to retrace setup steps below.

I referenced the iOS-related setup steps in the NativeScript Advanced Setup: macOS docs. They're still up-to-date, except for referring to an older version of Node.js. Specifically, what I did was:

1) Install Homebrew:

x86 Homebrew was provisioned already on the machine, like so:

@shirakaba
shirakaba / es_cookbook.md
Last active November 13, 2020 22:28
ElasticSearch cookbook

List the indices

curl -XGET 'localhost:9200/_all/_settings'
{
  "logstash-my-project-2020.04.16": {
    "settings": {
@shirakaba
shirakaba / react_native_firebase_dynamic_links_notes.md
Last active June 4, 2020 00:11
Strategy for fixing React Native Firebase Dynamic Links
@shirakaba
shirakaba / AppDelegate.swift
Last active May 24, 2020 15:08
LinguaBrowse Mac (React Native macOS + iOS Swift app) old AppDelegate
//
// AppDelegate.swift
// LinguaBrowse
//
// Created by jamie on 07/06/2018.
// Copyright © 2018 Facebook. All rights reserved.
//
import Foundation
import StoreKit
@shirakaba
shirakaba / .babelrc
Created May 21, 2020 21:41
Babelrc file for getting React Native Web to work with react-scripts
{
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
["@babel/plugin-proposal-numeric-separator", {}]
]
}