Skip to content

Instantly share code, notes, and snippets.

View MisterJimson's full-sized avatar

Jason Rai MisterJimson

View GitHub Profile
@MisterJimson
MisterJimson / local-date.tsx
Created September 24, 2024 20:24
local-date.tsx
'use client';
import { format as dateFnsFormat } from 'date-fns/format';
import dynamic from 'next/dynamic';
import { Skeleton } from '~/components/ui/skeleton';
export const DisplayLocalDate = dynamic(
() => import('./DisplayLocalDate').then((res) => res.DisplayLocalDateClient),
{ ssr: false, loading: () => <Skeleton className="mx-1 h-4 w-20" /> }
);
@MisterJimson
MisterJimson / macos-dock-dont-move.sh
Created March 19, 2024 18:21
macos-dock-dont-move.sh
defaults write com.apple.Dock autohide-delay -float 1000 && killall cfprefsd && killall Dock
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@MisterJimson
MisterJimson / main.dart
Created April 23, 2022 02:00
CachedIterable
void main() {
final inputs = ['a', 'b', 'c', 'd', 'e', 'f'];
final map = inputs.map((e) {
print(e);
return e;
});
final cachedIterable = inputs.mapCached((e) {
print(e);
return e;
launch_as() {
local cmd_name=$1
shift
(time $@ || echo $cmd_name >> fail.txt) 2>&1 > $cmd_name.txt
}
time npm ci
launch_as lint npm run lint &
time npm run build
launch_as build1 npm run build:build1 &
for f in $(find ./ -name '*.dart')
do
(echo "// @dart=2.9" && cat $f) > filename1 && mv filename1 $f
done
@MisterJimson
MisterJimson / error_report.txt
Created April 29, 2021 14:14
error_report.txt
at ? (/_next/static/chunks/10b6e365ec26fe7cfe781d1400fb39e500cbc9dd.8ddfae01087d9249678b.js:1:140675)
at ? (/_next/static/chunks/10b6e365ec26fe7cfe781d1400fb39e500cbc9dd.8ddfae01087d9249678b.js:1:139168)
at a(/_next/static/chunks/10b6e365ec26fe7cfe781d1400fb39e500cbc9dd.8ddfae01087d9249678b.js:1:137986)
@MisterJimson
MisterJimson / README.md
Last active March 28, 2021 02:54 — forked from GroovinChip/README.md
My "Vintage bloc" usage style

My use of the classic (or "vintage") BLoC pattern (not to be confused with Felix Angelov's great bloc library) has evolved over the years. I do no use dedicated sinks for input and dedicated streams for output. Rather, I directly use rxdart's excellent BehaviorSubject directly. BehaviorSubject implements ValueStream, which itself implements Stream, so I found that I could reduce boilerplate a lot by doing this. Values can be directly added to, and read from, a BehaviorSubject. I then use provider to pass my services (I don't really think of them as "bloc"s any more) through my app. This gist provides a real example of how I currently use this pattern.

  • prefs_service.dart is where the service is defined.
  • main.dart shows how to initialize the service.
  • app.dart shows how I use MultiProvider to pass down my service. I always use MultiProvider rather than one single provider to allow for more services. I listen to the BehaviorSubject in my service to set the ThemeMode of my `Ma
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: TwoPageLayout(
child: Center(
child: MultiScreenInfo(builder: (info) {
return Column(
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: TwoPageLayout(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,