Skip to content

Instantly share code, notes, and snippets.

View espresso3389's full-sized avatar

Takashi Kawasaki espresso3389

View GitHub Profile
@espresso3389
espresso3389 / wsl2-rootless-docker.md
Last active April 18, 2024 16:06
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-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;
@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 / parsejpeg.cpp
Last active July 15, 2022 03:24
JPEG parser
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#define APP(n) (0xe0 + n)
struct HUFF_ENTRY
{
unsigned char len;
/*
* The MIT License
*
* Further resources on the MIT License
* Copyright 2018 Cuminas Corporation/@espresso3389
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
@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);
void main() {
print('''Multiline
String
can be
directly embedded on the code!''');
}
@espresso3389
espresso3389 / coroutine_test.cpp
Created December 16, 2017 15:02
Evaluating coroutine performance on Visual C++
#include <cstdio>
#include <random>
#include <experimental/generator>
auto random()
{
std::mt19937 r;
for (;;)
co_yield r();
}

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 -