Skip to content

Instantly share code, notes, and snippets.

@ben-xD
ben-xD / macOS_SytemPrefs.md
Created December 3, 2023 22:29 — forked from rmcdongit/macOS_SytemPrefs.md
Apple System Preferences URL Schemes

macOS 10.15 System Preference Panes

Below are a list of System Preference pane URLs and paths that can be accessed with scripting to assist users with enabling macOS security settings without having to walk them through launching System Preferences, finding panes, and scrolling to settings. Not all panes have an accessible anchor and some are OS specific.

To find the Pane ID of a specific pane, open the System Preferences app and select the desired Preference Pane. With the pane selected, open the ScriptEditor.app and run the following script to copy the current Pane ID to your clipboard and display any available anchors:

tell application "System Preferences"
	set CurrentPane to the id of the current pane
	set the clipboard to CurrentPane
@ben-xD
ben-xD / gist:99ad5494e322942c8f5d7c90323933da
Created October 19, 2023 07:58
Download current ChatGPT chat as markdown file. Just paste it into the dev tools console and it will download.
// Inspired by https://www.reddit.com/r/ChatGPT/comments/zm237o/save_your_chatgpt_conversation_as_a_markdown_file/ + my own customisations
function h(html) {
return html.replace(/<p>/g, '\n\n').replace(/<\/p>/g, '').replace(/<b>/g, '**').replace(/<\/b>/g, '**').replace(/<i>/g, '_').replace(/<\/i>/g, '_').replace(/<code[^>]*>/g, (match) => { const lm = match.match(/class="[^"]*language-([^"]*)"/); return lm ? '\n```' + lm[1] + '\n' : '```'; }).replace(/<\/code[^>]*>/g, '```').replace(/<[^>]*>/g, '').replace(/Copy code/g, '').replace(/This content may violate our content policy. If you believe this to be in error, please submit your feedback — your input will aid our research in this area./g, '').trim();
}
(() => {
const title = document.querySelector("a.dark\\:bg-gray-800 div")?.textContent || "Chat";
const filename = `${title}.md`;
let t = `# ${title}\n`;
@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}
@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 / 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 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 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 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 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(
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"
)