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
  • 16:25 (UTC +10:00)
View GitHub Profile
@hacker1024
hacker1024 / segmented_control_form_field.dart
Created March 5, 2019 07:39
A simple segmented control form field for flutter.
import 'package:flutter/material.dart';
class SegmentedControlFormField extends FormField<int> {
final List<String> options;
final double textScaleFactor;
SegmentedControlFormField({
this.options,
this.textScaleFactor,
FormFieldSetter<int> onSaved,
#!/usr/bin/env python2
#This script finds the compressed data embedded in a Dell BIOS update program
#and decompresses it to an apparent HDR file. The main data seems to start
#at offset 0x58 in the HDR FWIW
import zlib
import sys
import re
check if exist
/dev/anbox-binder
if it doesn't, anbox-binder don't work
sudo apt install anbox-ubuntu-touch
sudo wget -q --show-progress -O /home/phablet/anbox-data/android.img http://cdimage.ubports.com/anbox-images/android-armhf-64binder.img
touch /home/phablet/anbox-data/.enable
chmod -R o+wrx /home/phablet/anbox-data/data
check if exist
/dev/anbox-binder
if it doesn't, anbox-binder don't work
sudo apt install anbox-ubuntu-touch
sudo wget -q --show-progress -O /home/phablet/anbox-data/android.img http://cdimage.ubports.com/anbox-images/android-armhf-64binder.img
touch /home/phablet/anbox-data/.enable
chmod -R o+wrx /home/phablet/anbox-data/data
@hacker1024
hacker1024 / custom_context_menu.dart
Created August 24, 2020 05:51
A mixin to provide convenience methods to record a tap position and show a popup menu - based on https://stackoverflow.com/a/63555370/13458266
import 'package:flutter/material.dart' hide showMenu;
import 'package:flutter/material.dart' as material show showMenu;
/// A mixin to provide convenience methods to record a tap position and show a popup menu.
mixin CustomPopupMenu<T extends StatefulWidget> on State<T> {
Offset _tapPosition;
/// Pass this method to an onTapDown parameter to record the tap position.
void storePosition(TapDownDetails details) => _tapPosition = details.globalPosition;
@hacker1024
hacker1024 / caddy_json_systemd_override.conf
Last active October 1, 2020 05:41
Caddy 2 systemd service override to load a JSON configuration file
[Service]
ExecStart=
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile.json
ExecReload=
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile.json
@hacker1024
hacker1024 / aaatest.dart
Created October 11, 2020 12:17
An IntelliJ IDEA live template for Dart testing implementing Reso Coder's "Arrange, Act, Assert" structure
test(
'should $TITLE$',
() async {
// Arrange
$ARRANGE$
// Act
$ACT$
// Assert
@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',