Skip to content

Instantly share code, notes, and snippets.

View espresso3389's full-sized avatar

Takashi Kawasaki espresso3389

View GitHub Profile
@espresso3389
espresso3389 / genesis-wsl2.md
Last active January 24, 2025 13:10
Run Hello, Genesis on WSL2 (Ubuntu 24.04)

Run Hello, Genesis on WSL2 (Ubuntu 24.04)

image

Install Python and venv

sudo apt install python python3-venv
@espresso3389
espresso3389 / find_cert.rb
Created December 10, 2024 18:42
Find a signing certificate of serial number from keychain
#!/usr/bin/env ruby
require 'openssl'
def print_usage
puts "Usage: #{File.basename($0)} [-s|-S|-C component] <serial_number> [keychain]"
puts "Options:"
puts " -s Show only certificate subject (single line)"
puts " -S Show only certificate subject (one parameter per line)"
puts " -C component Show only specified component (e.g., -C CN for Common Name)"
@espresso3389
espresso3389 / provprof.rb
Created December 10, 2024 18:41
Get info. such as signing certificate's serial number from provisioning profile
#!/usr/bin/env ruby
require 'openssl'
def print_usage
puts "Usage: #{File.basename($0)} <provisioning_profile_path>"
puts "Example: #{File.basename($0)} /path/to/profile.mobileprovision"
exit 1
end
@espresso3389
espresso3389 / winrt_formatters.h
Created December 9, 2024 03:08
C++23 std::formatter implementations for WinRT classes
#ifndef WINRT_FORMATTERS_H
#define WINRT_FORMATTERS_H
#include <windows.h>
#include <winrt/base.h>
#include <string>
#include <format>
@espresso3389
espresso3389 / html_image_embed.js
Created October 1, 2024 16:06
Node.js program that converts HTML with img files to a single HTML that uses embedded image data using data protocol
const fs = require('fs').promises;
const path = require('path');
const cheerio = require('cheerio');
const sharp = require('sharp');
const zlib = require('zlib');
const util = require('util');
const gzip = util.promisify(zlib.gzip);
async function optimizeAndConvertToDataURI(imagePath, baseDir, useLossless) {
@espresso3389
espresso3389 / flutter-build-env.ps1
Last active February 2, 2024 12:21
Create Flutter Android build environment on Windows
# Need to enable scripting before executing the file
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
cd ~
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
scoop install git
scoop bucket add java
@espresso3389
espresso3389 / nfkc.dart
Last active October 30, 2023 08:23
Using icu from Dart/Flutter
import 'dart:ffi';
import 'dart:io';
import 'package:ffi/ffi.dart';
import 'package:unorm_dart/unorm_dart.dart' as unorm_dart; // fallback
String _getLibicuModuleName() {
if (Platform.isAndroid) {
return 'libicu.so';
} else if (Platform.isWindows) {
@espresso3389
espresso3389 / wsl2-rootless-docker.md
Last active October 5, 2024 17:49
WSL2 configuration for developing using rootless docker

NOTE: WORK IN PROGRESS

WSL2 configuration for developing using rootless docker

This document assumes Windows Insider Preview Dev.

Install Ubuntu 22.04

Installing Ubuntu 22.04.1 LTS from Microsoft Store.

@espresso3389
espresso3389 / flutter-#93615.dart
Created November 19, 2021 07:28
Sample repro for flutter #93615
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@espresso3389
espresso3389 / flutter-ffi-async-nativeport.md
Last active April 5, 2024 11:30
Async messaging between Flutter and C++ using Dart ffi NativePort

C++

  • Copy Dart SDK (${FLUTTER_DIR}/bin/cache/dart-sdk/include) to your project, e.g. ios/Classes/
  • Add your own code like the following fragment
#include "dart_api_dl.h"

// Receives NativePort ID from Flutter code
static Dart_Port_DL dart_port = 0;