Skip to content

Instantly share code, notes, and snippets.

View micimize's full-sized avatar

Michael Joseph Rosenthal micimize

  • San Francisco, CA
View GitHub Profile
import 'package:flutter/material.dart';
class OverlayContainer extends StatefulWidget {
/// The child to render in the regular document flow (defaults to Container())
final Widget child;
/// The widget to render inside the [OverlayEntry].
final Widget overlay;
/// Offset to apply to the [CompositedTransformFollower]

Two Dreidel

Two Dreidel is a poker-like dreidel variant that combines elements from one poker and dominion in an attempt to create a stategic, high stakes gambling game that still feels conceptually like dreidel.

High Level Overview

  • Each player has their own small deck of cards, from which they draw two-card hands in a semi-controlled way, and which slowly dwindles to 0 before replenishing (Similar to dominion)
  • There are no pairs - גה beats הה.
  • There are 3 rounds of betting, 2 of which are informed by a dreidel spin
  • Dreidel spins set a buy-in bet (called simultaneously by everyone)
  • After the dreidel is called, betting proceeds as in no-limit poker from the right of the button
@micimize
micimize / scirm.dart
Created December 25, 2019 17:58
Simple flutter scrim/overlay widget
class Scrim extends StatelessWidget {
final bool applied;
final Widget child;
final double opacity;
final Duration speed;
final Color color;
const Scrim({
Key key,
@micimize
micimize / npm-publish-dist-scripts.json
Last active February 3, 2024 02:32
Scripts to streamline/enforce the copy and publish subdir method (https://stackoverflow.com/a/39946795/2234013). idk if copying package.json is necessary
{
"prepublishOnly": "if [[ ! $PWD =~ dist$ ]]; then npm run _dist:nopublish; fi",
"_dist:nopublish": "echo 'Use `npm run dist` instead of `npm publish`!' && exit 1",
"_dist:prep": "yarn build && cp package.json dist && cp README.md dist",
"_dist:post": "rm -f dist/package.json && rm -f dist/README.md",
"dist": "npm run _dist:prep && npm publish dist && npm run _dist:post"
}
// 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';
enum _Side { top, right, bottom, left }
extension SpreadBorder on Border {
Iterable<MapEntry<_Side, BorderSide>> get sides {
@micimize
micimize / interpolate_template.ts
Last active December 11, 2019 23:08
simple template interoplation with 1-level ternary parsing based on https://stackoverflow.com/a/1408373/2234013
/* mini template parser helpers */
const INTEROPLATE_TEMPLATE_PATTERN = /\${\s*([^}]*)\s*}/g;
const SINGLE_QUOTE = '\'';
const DOUBLE_QUOTE = '"';
function normalize(value: string) {
if (value.startsWith(SINGLE_QUOTE) && value.endsWith(SINGLE_QUOTE)) {
const raw = value.slice(1, value.length - 1);
@micimize
micimize / cheaters_global_keys.dart
Last active February 7, 2020 15:53
working around the various constraints of flutter GlobalKeys + Navigators + complex pages. Fully functioning example can be seen at https://gist.github.com/micimize/5191af05191c027713a9cd1def3528db
import 'package:flutter/material.dart';
// TODO maybe GlobalObjectKeys would be better
class CheatersGlobalKey extends InheritedWidget {
CheatersGlobalKey._({
this.cheatersKeys = const {},
Key key,
Widget child,
}) : super(key: key, child: child);
@micimize
micimize / tab_bar_example.dart
Created December 2, 2019 16:36
tab bar example with tabs overrriden
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'dart:ui' show lerpDouble;
class TabBarExample extends StatefulWidget {
const TabBarExample({
Key key,
List<HSLColor> hslTetrad(Color color) {
final hsl = HSLColor.fromColor(color);
final baseHue = hsl.hue;
return [
hsl,
hsl.withHue((baseHue + 90) % 360),
hsl.withHue((baseHue + 180) % 360),
hsl.withHue((baseHue + 270) % 360),
];
}
@micimize
micimize / graphql_fragments_in_dart.dart
Last active November 10, 2019 19:54
An approach for sane graphql-style fragment inheritence in dart https://dartpad.dartlang.org/ec9df3c1df23f415621fd3da7e81209e
// base type
class Foo {
String _foo;
int _bar;
}
//fragment exposing foo
class FooFragment extends Foo {
String get foo => _foo;
set foo(String value) => _foo = value;