Skip to content

Instantly share code, notes, and snippets.

View lukepighetti's full-sized avatar
🦞

Luke Pighetti lukepighetti

🦞
View GitHub Profile
@lukepighetti
lukepighetti / paywall_showing_schedule.dart
Created March 4, 2024 02:08
My way of showing a paywall every day for a few days, then every week, then every two weeks. Good for about a year.
import 'package:collection/collection.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '/architecture/let.dart';
import '/membership/membership_state.dart';
import '/membership/membership_tasks.dart';
import '/telemetry/analytics.dart';
Future<void> appOpenAction() async {
$analytics.vglAppOpenActionRequested();
@lukepighetti
lukepighetti / markers.dart
Created January 30, 2024 15:15
Extracting markers for YouTube channels in Dart
import 'dart:io';
import 'package:xml/xml.dart';
Future<void> main() async {
final str = File('./markers.fcpxmld/Info.fcpxml').readAsStringSync();
final xml = XmlDocument.parse(str);
final markers = xml.findAllElements('marker');
for (final x in markers) {
import '/features/architecture/logging.dart';
class CachedQuery<T> {
final Duration invalidation;
final Future<T> Function(String key) fn;
CachedQuery(
this.fn,
this.invalidation,
);
import 'package:flutter/material.dart';
class Tappable extends StatefulWidget {
const Tappable({
super.key,
required this.onPressed,
required this.child,
});
final VoidCallback? onPressed;
@lukepighetti
lukepighetti / example.dart
Last active December 7, 2023 14:09
Another logger
class MyService {
final _log = Logger('MyService');
void init() {
try {
// operation
_log("initialized");
} catch(e, stackTrace){
_log.e("init() error", e, stackTrace);
}
@lukepighetti
lukepighetti / signing-google-sign-in.md
Last active October 29, 2023 01:51
Finally figured out how to get Google Sign In working. I needed to add my debug keys to Firebase https://twitter.com/luke_pighetti/status/1677328491216359434?s=20

Figured it out! You need to add:

  1. Debug signing keys
  2. Release signing keys
  3. PlayStore signing keys

Use JDK from Android Studio

  • export JAVA_HOME='/Applications/Android Studio.app/Contents/jbr/Contents/Home/'
@lukepighetti
lukepighetti / Fastfile
Created July 6, 2023 13:39
Release Flutter app with environment variables to TestFlight every night with GitHub Actions
# ios/Fastlane/Fastfile
default_platform(:ios)
APPLE_ISSUER_ID = ENV["APPLE_ISSUER_ID"]
APPLE_KEY_CONTENT = ENV["APPLE_KEY_CONTENT"]
APPLE_KEY_ID = ENV["APPLE_KEY_ID"]
DEVELOPER_APP_ID = ENV["DEVELOPER_APP_ID"]
DEVELOPER_APP_IDENTIFIER = ENV["DEVELOPER_APP_IDENTIFIER"]
GIT_AUTHORIZATION = ENV["GIT_AUTHORIZATION"]
GITHUB_RUN_NUMBER = ENV["GITHUB_RUN_NUMBER"]
import 'package:flutter/material.dart';
class TextInputComponent extends StatefulWidget {
const TextInputComponent({super.key});
@override
State<TextInputComponent> createState() => _TextInputComponentState();
}
class _TextInputComponentState extends State<TextInputComponent> {
@lukepighetti
lukepighetti / device_service.dart
Last active June 28, 2023 00:49
All the basic data you need to roll your own analytics payloads
import 'dart:convert';
import 'dart:io';
import 'package:app/extensions.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_timezone/flutter_timezone.dart';
import 'package:get_it/get_it.dart';
import 'package:package_info_plus/package_info_plus.dart';
// we need this in core dart so all these serialization packages can use it
// this enables generalized solutions for storage, messaging, tasks, etc
abstract interface class JsonCoder<T> {
String toJson(T payload);
T fromJson(String payload);
}
// then we can create generalized packages for things like storage
/// ```dart