Skip to content

Instantly share code, notes, and snippets.

View hacker1024's full-sized avatar
🎵
Working on my music app, Epimetheus.

hacker1024

🎵
Working on my music app, Epimetheus.
  • Melbourne, Australia
  • 12:36 (UTC +10:00)
View GitHub Profile
@hacker1024
hacker1024 / scroll_detector_example.dart
Last active February 19, 2021 05:52
A Flutter scroll detector example.
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@hacker1024
hacker1024 / lovelace-transmission-card.yaml
Created December 19, 2020 13:58
A Transmission control card for Home Assistant's Lovelace interface
type: entities
title: Transmission
show_header_toggle: false
entities:
- entity: switch.transmission_switch
icon: 'hass:power'
name: Enabled
secondary_info: last-changed
- entity: switch.transmission_turtle_mode
icon: 'hass:turtle'
@hacker1024
hacker1024 / pkcs5.dart
Created January 17, 2021 06:32
PKCS #5 padding in Dart
import 'dart:typed_data';
Uint8List padPKCS5(List<int> input) {
final inputLength = input.length;
final paddingValue = 8 - (inputLength % 8);
final outputLength = inputLength + paddingValue;
final output = Uint8List(outputLength);
for (var i = 0; i < inputLength; ++i) {
output[i] = input[i];
@hacker1024
hacker1024 / keywords.dart
Created January 20, 2021 12:46
A Dart list of Dart keywords (as of 2.12.0)
const keywords = [
'abstract',
'else',
'import',
'super',
'as',
'enum',
'in',
'switch',
'assert',
@hacker1024
hacker1024 / replay_stream_extension.dart
Created January 29, 2021 06:22
A Dart extension function to convert a regular Stream into an RxDart ReplayStream.
import 'package:rxdart/streams.dart';
import 'package:rxdart/subjects.dart';
extension StreamUtils<T> on Stream<T> {
ReplayStream<T> replay() {
final subject = ReplaySubject<T>();
pipe(subject);
return subject;
}
}
@hacker1024
hacker1024 / 10.dart
Created March 22, 2021 02:43
The most efficient way to initialize an integer with a value of 10 in Dart.
import 'dart:math';
/// Thanks to https://www.reddit.com/r/ProgrammerHumor/comments/m9r3vz/efficiency/ for the inspiration
void main() {
final random = Random();
final stopwatch = Stopwatch()..start();
int x;
do {
@hacker1024
hacker1024 / redux_state_tree_live_template.dart
Last active March 24, 2021 01:31
A live template for IntelliJ to create a new Redux state object. Objects can be nested.
import 'package:meta/meta.dart';
@immutable
class $NAME$State {
const $NAME$State();
const $NAME$State.initial() : this();
$NAME$State copyWith() => $NAME$State();
@hacker1024
hacker1024 / value_animation.dart
Created April 11, 2021 07:43
A Flutter Animation implementation that wraps a mutable value.
import 'package:flutter/widgets.dart';
abstract class ValueAnimation<T> extends Animation<T>
with
AnimationEagerListenerMixin,
AnimationLocalListenersMixin,
AnimationLocalStatusListenersMixin {
T _value;
@override
@hacker1024
hacker1024 / mygov_totp_storage.md
Last active August 16, 2023 18:01
Information about TOTP token storage in the myGov Code Generator app, as well as token extraction instructions.

This gist contains information about TOTP token storage in the myGov Code Generator app, along with instructions on how to extract tokens.

App data

Structure

/data/user/0/au.gov.dhs.centrelink.mygovauthenticator:
├───files
│ myGov.ks
@hacker1024
hacker1024 / keyboard_effects.md
Created May 10, 2021 03:53
Some of my favourite RGB keyboard settings

Thunderstorm

Effect: Ripple
Background color: #16191C
Foreground color: #FEFF67