Skip to content

Instantly share code, notes, and snippets.

View emiloberg's full-sized avatar
🦄

Emil Öberg emiloberg

🦄
View GitHub Profile
@emiloberg
emiloberg / gist:de1b3f2b92257b8afc366575772681a7
Last active April 10, 2026 17:09
Claude sandbox with Apple Container

Running Claude in a lightweigh VM on Mac.

container is Apple's tool that you can use to create and run Linux containers as lightweight virtual machines on your Mac. Requires Apple Silicon and macOS 26+.

This guides you through running Claude in a container.

There is a single catalog that can be written by both host and guest. No other access from guest to host is allowed.

Step 1 — Install Apple Container

@emiloberg
emiloberg / promise.ts
Last active March 23, 2025 09:30
Type-safe promise.allSettled where a promise may or may not be required
type PromiseObject<T> = {
promise: Promise<T>;
required: boolean;
};
type PromiseResult<T> = T extends Promise<infer U> ? U : never;
type PromiseResults<T extends readonly PromiseObject<unknown>[]> = {
[K in keyof T]: T[K]['required'] extends true
? PromiseResult<T[K]['promise']>
@emiloberg
emiloberg / extract-translations.ts
Created April 14, 2021 20:59
Extract translations from Typescript
/*
* Finds and prints all usage of t()
* Use to extract translations
* Save as file and run:
* ts-node extract-translations.ts
*
* Change ROOT_PATH in this file if needed.
*/
import { readFileSync, readdirSync, statSync } from 'fs';
@emiloberg
emiloberg / cloudSettings
Last active September 3, 2020 15:47
VSCode Settings
{"lastUpload":"2020-09-03T15:47:18.938Z","extensionVersion":"v3.4.3"}
@emiloberg
emiloberg / GaugeChart.js
Last active February 13, 2024 14:30
Gauge Chart with React Recharts (http://recharts.org)
import React from 'react';
import { Sector, Cell, PieChart, Pie } from 'recharts';
const GaugeChart = () => {
const width = 500;
const chartValue = 180;
const colorData = [{
value: 40, // Meaning span is 0 to 40
color: '#663399'
}, {
@emiloberg
emiloberg / gist:81271ba2427278aa4262
Created October 30, 2015 12:16
NativeScript Crash Report Android
java.lang.RuntimeException: Unable to start activity ComponentInfo{se.vgregion.rekapp/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
Calling js method onCreate failed
Error: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.tns.gen.android.app.Fragment_frnal_prepareExtend_l60_c37__PageFragmentBody: make sure class name exists, is public, and has an empty constructor that is public
android.app.Fragment.instantiate(Fragment.java:597)
android.app.FragmentState.instantiate(Fragment.java:98)
android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1762)
android.app.Activity.onCreate(Activity.java:904)
com.tns.Platform.callJSMethodNative(Native Method)
com.tns.Platform.dispatchCallJSMethodNative(Platform.java:821)
com.tns.Platform.callJSMethod(Platform.java:708)
@emiloberg
emiloberg / crashreport.txt
Created October 23, 2015 14:02
nativescript-email crash
Process: MailCompositionService [20544]
Path: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 8.1.simruntime/Contents/Resources/RuntimeRoot/Applications/MailCompositionService.app/MailCompositionService
Identifier: MailCompositionService
Version: 1.0 (1.0)
Code Type: X86-64 (Native)
Parent Process: launchd_sim [20491]
Responsible: launchd_sim [20491]
User ID: 501
Date/Time: 2015-10-23 16:01:13.073 +0200
@emiloberg
emiloberg / article.json
Created October 18, 2015 15:30
Sample, DDM Tool article
{
"articleId": "1715401",
"classNameId": 0,
"classPK": 0,
"companyId": 1712101,
"content": "<?xml version=\"1.0\"?>\n\n<root available-locales=\"en_US,sv_SE\" default-locale=\"sv_SE\">\n\t<dynamic-element name=\"heading\" index=\"0\" type=\"text\" index-type=\"keyword\">\n\t\t<dynamic-element name=\"body\" index=\"0\" type=\"text_area\" index-type=\"keyword\">\n\t\t\t<dynamic-element name=\"type\" index=\"0\" type=\"list\" index-type=\"keyword\">\n\t\t\t\t<dynamic-content language-id=\"en_US\"><![CDATA[normal]]></dynamic-content>\n\t\t\t\t<dynamic-content language-id=\"sv_SE\"><![CDATA[normal]]></dynamic-content>\n\t\t\t</dynamic-element>\n\t\t\t<dynamic-element name=\"subheading\" index=\"0\" type=\"text\" index-type=\"keyword\">\n\t\t\t\t<dynamic-content language-id=\"en_US\"><![CDATA[]]></dynamic-content>\n\t\t\t\t<dynamic-content language-id=\"sv_SE\"><![CDATA[]]></dynamic-content>\n\t\t\t</dynamic-element>\n\t\t\t<dynamic-element name=\"image\" index=\"0\" type=\"document_library\" in
@emiloberg
emiloberg / Snippets.txt
Created October 15, 2015 10:46
Snippets for Uppsala JS
DEMO 1
<StackLayout orientation="vertical">
<Button text="one"/>
<Button text="two"/>
<Button text="three"/>
<Button text="four"/>
<Button text="five"/>
</StackLayout>
@emiloberg
emiloberg / Gulpfile.js
Last active February 28, 2021 14:34
Restart node.js and reload Chrome tab(s) when files change
/**
* This Gulpfile will monitor files and restart node.js
* and reload the Chrome browser tab(s) when files changes.
*
* Dependencies:
* gulp npm install -g gulp (obviously as this is a gulp script)
* gulp-nodemon npm install gulp-nodemon
* chrome-cli brew install chrome-cli (https://github.com/prasmussen/chrome-cli)
*
* Installation