Skip to content

Instantly share code, notes, and snippets.

@kascote
kascote / bid.sh
Created January 2, 2025 17:09
Get bundle identifier
/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /Applications/Visual\ Studio\ Code.app/Contents/Info.plist
@kascote
kascote / txt_handler.sh
Created January 2, 2025 17:08
Setup app to use to load specific mime types
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{
LSHandlerContentType = "public.plain-text";
LSHandlerRoleAll = "com.neovide.neovide";
}'
@kascote
kascote / perf.md
Created November 22, 2024 23:56
dart performance review

dart compile aot-snapshot dartfile.dart
perf record -g dartaotruntime dartfile.aot parameterfile.json
perf report

@kascote
kascote / buffering_iosink.dart
Created November 7, 2024 22:59
BufferedOutputStream for Dart -
// example code, take care
// https://github.com/dart-lang/sdk/issues/32874#issuecomment-1467905810
class BufferingIOSink implements IOSink {
static const int _defaultBufferSize = 2048;
final Sink<List<int>> _sink;
Uint8List _buffer;
// Current live bytes in buffer.
int _start = 0;
int _end = 0;
@kascote
kascote / schemes_registered.sh
Created May 23, 2024 15:53
Check urls schemes registered on MacOS
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep -B3 "bindings:.*:"
@kascote
kascote / list_path.dart
Created February 17, 2024 22:01
simple array path traversal
/// Traverse the list by the given path.
/// ex: listPath<int>([1, 2, [3, 4]], '2.1') => 4
T? listPath<T>(Object list, String path) {
if (path.isEmpty) return null;
var result = list;
for (final part in path.split('.')) {
if (result is! List) return null;
final idx = int.tryParse(part);
if (idx == null || idx < 0 || result.length <= idx) return null;
#!/bin/bash
brew deps --installed --dot --graph | pbcopy
# And paste it in https://dreampuf.github.io/GraphvizOnline
# https://twitter.com/kevmoo/status/1612939071982297089
@kascote
kascote / json_sqlite.md
Last active May 22, 2022 22:03
SQlite JSON queries

JSON and virtual columns in SQLite

reference: https://antonz.org/json-virtual-columns/

select value from events;

{"timestamp":"2022-05-15T09:31:00Z","object":"user","object_id":11,"action":"login","details":{"ip":"192.168.0.1"}}
{"timestamp":"2022-05-15T09:32:00Z","object":"account","object_id":12,"action":"deposit","details":{"amount":"1000","currency":"USD"}}
{"timestamp":"2022-05-15T09:33:00Z","object":"company","object_id":13,"action":"edit","details":{"fields":["address","phone"]}}
@kascote
kascote / spinner.dart
Created July 11, 2019 16:45
flutter icon spinner
//
// https://stackoverflow.com/questions/55431496/font-awesome-spinners-icons-not-spinning-in-flutter
//
// Usage:
// Spinner(
// icon: FontAwesomeIcons.spinner,
// )
//
class Spinner extends StatefulWidget {
final IconData icon;
@kascote
kascote / blob_authenticatable.rb
Created September 4, 2018 15:53 — forked from dommmel/blob_authenticatable.rb
Devise authentication for Rails' ActiveStorage
# Rails controller concern to enable Devise authentication for ActiveStorage.
# Put it in +app/controllers/concerns/blob_authenticatable.rb+ and include it when overriding
# +ActiveStorage::BlobsController+ and +ActiveStorage::RepresentationsController+.
#
# Optional configuration:
#
# Set the model that includes devise's database_authenticatable.
# Defaults to Devise.default_scope which defaults to the first
# devise role declared in your routes (usually :user)
#