Skip to content

Instantly share code, notes, and snippets.

View reedom's full-sized avatar

reedom -- HANAI Tohru reedom

  • Fukuoka, Japan
  • 11:14 (UTC +09:00)
View GitHub Profile
@reedom
reedom / gauth.go
Last active April 17, 2023 02:34
Go Echo middleware that extract user info from Google Auth Token found in Authorization: Bearer header field
package echomw
import (
"encoding/json"
"io/ioutil"
"net/http"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/reedom/…/pkg/log"
@reedom
reedom / main.dart
Created August 4, 2022 08:00
[Flutter] See what makes widgets' rebuilding(1)
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(ProviderScope(child: _MyApp()));
}
@reedom
reedom / optimized_indexed_stack.dart
Created March 4, 2021 10:50
An improved IndexStack, suppress flickering on switching to another widget.
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
class OptimizedIndexedStack extends HookWidget {
const OptimizedIndexedStack({
Key key,
@required this.pages,
this.index = 0,
}) : super(key: key);
@reedom
reedom / Makefile
Created January 23, 2021 08:16
[Flutter/Freezed] faster code generation for projects having filename convention
# In convention, our project names `xxx_state.dart` for StateNotifier's state files
# and we only use Freezed in them. So, we can:
gen:
flutter pub run build_runner build --delete-conflicting-outputs \
--build-filter="lib/**/*_state.freezed.dart"
@reedom
reedom / main.dart
Last active January 22, 2021 10:51
Flutter v1.22 optimization bug: a widget rebuild does not happen
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
open class CircleShapeView: UIView {
override open var backgroundColor: UIColor? {
get {
guard
let layer = layer as? CAShapeLayer,
let cgColor = layer.fillColor
else { return super.backgroundColor }
return UIColor(cgColor: cgColor)
}
set {
@reedom
reedom / TSTextRectangleDetector.m
Created December 9, 2018 14:17
iOS11+Flutter Objective-C Text Rectangle Detection
#import "TSTextRectangleDetector.h"
#import <CoreML/CoreML.h>
#import <Vision/Vision.h>
@implementation TSTextRectangleDetector {
FlutterEventSink _eventSink;
BOOL _running;
BOOL _wasEmpty;
}