Skip to content

Instantly share code, notes, and snippets.

View espresso3389's full-sized avatar

Takashi Kawasaki espresso3389

View GitHub Profile
@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;
void main() {
print('''Multiline
String
can be
directly embedded on the code!''');
}

M5Stack Motor Module/Cable

PIN Cable Color RJ12 PIN Description
M+ Black 2 motor +
G Green 4 encoder Vcc (3.3V - 5V)
A Yellow 5 encoder A
B Blue 6 encoder B
V Red 3 encoder GND
1 White 1 motor -
@espresso3389
espresso3389 / mobileprovision.sh
Last active December 25, 2020 09:32
Installing provisioning profile
#/bin/sh
#
# Installing provisioning profile
# Set $PROVISIONING_PROFILE_BASE64 and $CERT_SERIAL_NUMBER before invoking the script.
PROVPROF_TMP=$GITHUB_WORKSPACE/tmp.mobileprovision
echo "$PROVISIONING_PROFILE_BASE64" | openssl base64 -d -A -out $PROVPROF_TMP
UUID=`grep UUID -A1 -a $PROVPROF_TMP | grep -io "[-A-Z0-9]\{36\}"`
echo "Provisioning profile UUID: $UUID"
@espresso3389
espresso3389 / keychain_init.sh
Created December 1, 2020 14:39
Installing p12 certificate (public-key/private-key combination) to keychain accessible on ssh connection
#!/bin/sh
#
# Install our provisioning certificates on the runner machine
#
# Reference: https://apple.stackexchange.com/a/285320
#
# Set $P12_BASE64 and $P12_PASSWORD before invoking the script
MY_KEYCHAIN="temp.keychain"