Skip to content

Instantly share code, notes, and snippets.

View lukepighetti's full-sized avatar
🦞

Luke Pighetti lukepighetti

🦞
View GitHub Profile
import 'dart:async';
import 'dart:convert';
import 'dart:math';
import 'dart:ui';
import 'package:app/components/lifecycle_builder.dart';
import 'package:app/components/button.dart';
import 'package:app/components/cancelling_builder.dart';
import 'package:app/components/keep_any_alive.dart';
import 'package:app/components/listenables_builder.dart';
@lukepighetti
lukepighetti / 1-setup-digital-ocean.sh
Last active August 1, 2024 13:08
Setting up digital ocean to run a dart shelf server
# install dart
sudo apt-get update && sudo apt-get install apt-transport-https
wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub \
| sudo gpg --dearmor -o /usr/share/keyrings/dart.gpg
echo 'deb [signed-by=/usr/share/keyrings/dart.gpg arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main' \
| sudo tee /etc/apt/sources.list.d/dart_stable.list
sudo apt-get update && sudo apt-get install dart
# install sqlite3
sudo apt install libsqlite3-dev
@lukepighetti
lukepighetti / README.md
Last active August 26, 2024 19:25
pocketbase systemd
vim /lib/systemd/system/pocketbase.service
systemctl enable pocketbase
systemctl start pocketbase
systemctl status pocketbase
systemctl stop pocketbase
systemctl restart pocketbase
@lukepighetti
lukepighetti / try_or_null.dart
Created May 18, 2024 15:02
Errors as values in dart
import 'dart:io';
Future<void> main(List<String> arguments) async {
final x1 = tryOrNull(() => throwing());
print(x1);
final (v1, e1) = tryTuple(() => throwing());
print("$v1, $e1");
final (v2, e2) = tryTuple(() => nonThrowing());
@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/'