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
@micimize
micimize / graphql_flutter_google_sign_in.dart
Created April 6, 2020 15:47
Some `graphql_flutter` auth code for use with `google_sign_in`
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show Clipboard, ClipboardData;
import 'package:google_sign_in/google_sign_in.dart';
import 'package:graphql_flutter/graphql_flutter.dart' show AuthLink;
/// Our `google_sign_in` client
GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: <String>['email', 'profile'],
);
@micimize
micimize / postgres_macros.sh
Created April 4, 2020 22:48
example postgres macros I've used
#!/bin/sh
# Plugins handle upsert${table} and upsert${table}Batch functions
# Add a `create${table}Batch` function to the schema
# for the given $table, allowing for bulk creates
function batch_create {
table=$1
inputName=$2
echo "
@micimize
micimize / bolton_comments.ts
Created April 3, 2020 23:48
add comments to sql table definitions
function removeUpTo(
s: string | undefined,
prefix: RegExp
){
if (s === undefined){
return undefined
}
s = s.trim()
const i = s.search(prefix)
if (i == -1){
@micimize
micimize / stupid_number.py
Created April 2, 2020 20:30
why did I bother
class StupidNumber:
"""A stupid viral facebook arithmetic puzzle with overridden operators
"""
_number: int
def __init__(self, number: int):
self._number = number
def __add__(self, other):
return StupidNumber(self._number * (other._number + 1))
void printKwargs({
String string = 'default',
bool boolean = false,
int integer = 1,
}) {
print([string, boolean, integer]);
}
Map<Symbol, dynamic> symbolizeKeys(Map<String, dynamic> map) =>
map.map((key, value) => MapEntry(Symbol(key), value));
/*
FULL cheaters_global_key.dart example,
contents:
* first defines the cheaters_global_key,
* then a few helpers
* then at the bottom a usage example
BEGIN cheaters_global_keys.dart
*/
@micimize
micimize / form_pop_example.dart
Last active February 6, 2020 03:23
'package:flutter/src/widgets/will_pop_scope.dart': Failed assertion: line 59 pos 12: '_route == ModalRoute.of(context)': is not true.
import 'package:flutter/material.dart';
void main() => runApp(FormPopExample());
class FormPopExample extends StatefulWidget {
@override
_FormPopExampleState createState() => _FormPopExampleState();
}
class _FormPopExampleState extends State<FormPopExample> {
@micimize
micimize / animated_offset_builder.dart
Last active April 7, 2022 04:59
animated offset and a AnimatedCompositedTransformFollower based on flutter's internal slide animation
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@immutable
class AnimationOptions {
AnimationOptions({
this.curve = Curves.linear,
@required this.duration,
this.onEnd,
});
@micimize
micimize / asymmetry.dart
Last active January 10, 2020 17:49
== asymmetry demo
class ThisClass {
int bar;
ThisClass(this.bar);
@override
bool operator ==(other) => other is ThisClass && other.bar == bar;
}
class ThatClass extends ThisClass {
ThatClass(int bar, this.bob) : super(bar);
int bob;
@micimize
micimize / ideas.dart
Created January 8, 2020 14:00
type ideas in dart
/// Extensible enum that has `instance.asKnown` for good switch tooling
enum KnownReleaseType {
ALPHA,
BETA,
GAMMA,
}
class ReleaseType {
ReleaseType(String value) : value = _parseValue(value);