Skip to content

Instantly share code, notes, and snippets.

@ben-xD
ben-xD / embedded.mobileprovision
Created August 28, 2021 07:29
`embedded.mobileprovision` generated from a fresh Xcode project + push notifications capability added
0�P *�H��
��P0�P 1 0 +0�@� *�H��
��@��@�<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AppIDName</key>
<string>XC com example app</string>
<key>ApplicationIdentifierPrefix</key>
<array>
@ben-xD
ben-xD / direct_apns.sh
Created September 22, 2021 04:10
Direct APNs Push Notifications
#!/usr/bin/env bash
# your team id located in the developer portal
TEAMID="replace"
import 'package:flutter/material.dart';
import 'package:listenos/session.dart';
class SessionsScreen extends StatelessWidget {
SessionsScreen({Key? key}) : super(key: key);
final session = Session(author: "Ben Butterworth", createdAt: DateTime.now(), id: "flutter-festival", questions: [
Question(id: "some question", answers: [], createdAt: DateTime.now(), author: "Human being", text: "Some question"
)
@ben-xD
ben-xD / main.dart
Last active November 20, 2022 16:02
AlertDialog with StatelessWidget
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
showAppDialog(BuildContext context) {
print("Showing app dialog");
showDialog(context: context,
builder: (context) {
return AlertDialog(
@ben-xD
ben-xD / main.dart
Last active November 20, 2022 16:07
Widget-testing `showDialog`/`AlertDialog` in Flutter
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
const buttonKey = Key("button");
const alertDialogKey = Key("alertDialog");
class MyApp extends StatelessWidget {
showAppDialog(BuildContext context) async {
print("Showing app dialog");
await showDialog(
@ben-xD
ben-xD / main.dart
Last active November 22, 2022 17:25
#dart #math Rotating by -90 degrees using quaternions
import "dart:math";
import "package:vector_math/vector_math.dart";
class Orientation {
// radians
final double yaw;
final double pitch;
final double roll;
Orientation({required this.yaw, required this.pitch, required this.roll});
}
@ben-xD
ben-xD / main.dart
Last active November 28, 2022 11:36
Debug: PageView, inside ListView, inside Column
// Doesn't actually use the PageView, because it doesn't current work.
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
@ben-xD
ben-xD / main.dart
Last active December 1, 2022 18:06
Example problem needing FutureOr<> in Dart
import 'dart:async';
import 'package:http/http.dart' as Http;
String callbackOne() => "hello";
Future<String> callbackTwo() async => (await Future.delayed(Duration(seconds: 1),() => "This is a sentence"));
Future<int> getLengthOfResult2(String Function() callback) async {
return callback().length;
@ben-xD
ben-xD / main.dart
Last active December 1, 2022 18:05
Solution: Example problem needing FutureOr<> in Dart
import 'dart:async';
String callbackOne() => "hello";
Future<String> callbackTwo() async => (await Future.delayed(Duration(seconds: 1),() => "This is a sentence"));
Future<int> getLengthOfResult(FutureOr<String> Function() callback) async {
// I can await on callbackOne, even though it returns a String.
final result = await callback();
return result.length;
@ben-xD
ben-xD / .gitconfig
Created January 12, 2023 08:57
Git aliases
...
# Aliases adapted from https://snyk.io/blog/10-git-aliases-for-faster-and-productive-git-workflow/ and http://blog.kfish.org/2010/04/git-lola.html
[alias]
# Logging
s = status
l = log --pretty=format:\"%C(magenta)%h%Creset -%C(red)%d%Creset %s %C(dim green)(%cr) [%an]\" --abbrev-commit -30
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
new = log origin/main@{1}..origin/main@{0}