Skip to content

Instantly share code, notes, and snippets.

Avatar
🦊
🦊🦊🦊🦊🦊

Plague Fox PlugFox

🦊
🦊🦊🦊🦊🦊
View GitHub Profile
@PlugFox
PlugFox / main.dart
Last active Jan 27, 2023
Format input date
View main.dart
/*
* Format input date
* https://gist.github.com/PlugFox/9364d6a88d0baf1284e4cdc0581957e7
* https://dartpad.dev/9364d6a88d0baf1284e4cdc0581957e7
* Matiunin Mikhail <plugfox@gmail.com>, 27 January 2023
*/
void main() => [
'',
'.',
@PlugFox
PlugFox / tasks.json
Created Jan 25, 2023
VS Code tasks for flutter
View tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "flutter",
"command": "flutter",
"options": {
"cwd": "packages/sd_market/"
},
"args": [
@PlugFox
PlugFox / shortcuts.json
Created Jan 20, 2023
VSCode Keyboard Shortcuts
View shortcuts.json
[
{
"key": "shift+alt+`",
"command": "workbench.action.showCommands"
},
{
"key": "shift+cmd+p",
"command": "-workbench.action.showCommands"
},
{
@PlugFox
PlugFox / chunker.dart
Last active Dec 29, 2022
Dart & Flutter AES Encryption
View chunker.dart
import 'dart:async';
import 'dart:math' as math;
import 'dart:typed_data' as td;
import 'package:meta/meta.dart';
/// {@template chunker}
/// Chunker stream transformer
/// {@endtemplate}
@immutable
@PlugFox
PlugFox / main.dart
Last active Dec 29, 2022
Chunker : Chunk Stream Transformer
View main.dart
import 'dart:async';
import 'dart:math' as math;
import 'dart:typed_data' as td;
import 'package:meta/meta.dart';
/// {@template chunker}
/// Chunker stream transformer
/// {@endtemplate}
@immutable
@PlugFox
PlugFox / cbz.sh
Last active Dec 27, 2022
cbz.sh is a simple command line shell script (bash) to take a folder and turn it into a comic book zip archive (a zip archive with a cbz file name extension instead of zip).
View cbz.sh
#! /bin/zsh
# Usage: Zips given directories into .cbz (Comic Book ZIP) archives of the smame name (eg "folder name.cbz").
# How to make public:
# 1. chmod +x cbz.sh
# 2. mv cbz.sh /usr/local/bin/cbz
# 3. cbz -h
complete="/System/Applications/Music.app/Contents/Resources/complete.aif"
remove_flag="m"
@PlugFox
PlugFox / qbittorrent.sh
Last active Dec 27, 2022
Docker QBitTorrents client
View qbittorrent.sh
#! /bin/zsh
docker stop qbittorrent
docker rm qbittorrent
mkdir -p $PWD/qbittorrent/{config,torrents,downloads}
# --rm --net=host --restart unless-stopped --user $UID:$GID \
docker run -d \
--name qbittorrent \
@PlugFox
PlugFox / api.dart
Last active Dec 23, 2022
Lazy local storage, shared preferences
View api.dart
/* ... */
mixin _LocalStorageAPI on _LocalStorageCache {
Future<String?> getString(String key) => _eval<String?>((db) => db.getString(key));
Future<void> setString(String key, String value) => _eval<void>((db) => db.setString(key, value));
}
@PlugFox
PlugFox / stateless.dart
Last active Jan 27, 2023
StatelessWidget & StatelessElement as a StatefulWidget
View stateless.dart
import 'package:flutter/widgets.dart';
class Example extends StatelessWidget {
const Example({super.key});
@override
StatelessElement createElement() => ExampleElement(this);
@override
Widget build(BuildContext context) => const Placeholder();
@PlugFox
PlugFox / database.dart
Last active Jan 26, 2023
Key Value extension for SQLite (Drift)
View database.dart
/// Key-value storage interface for SQLite database
abstract class IKeyValueStorage {
Future<void> refresh();
String? getKey(String key);
void addKey(String key, String value);
void removeKey(String key);