Skip to content

Instantly share code, notes, and snippets.

View maks's full-sized avatar

Maksim Lin maks

View GitHub Profile
@maks
maks / main.dart
Created September 25, 2023 06:29
reverberating-oak-9145
// Example of using Dart 3 switch expression
void main() {
print("code: ${process('ok')}");
}
Code process(String res) {
return switch(res) {
"ok" => Code.ok,
"error" => Code.ok,
_ => Code.undefined
@maks
maks / main.dart
Created September 25, 2023 06:11
reverberating-oak-9145
import "dart:math";
// Example of use Dart's "late final" lazily initialised cached async value
void main() async {
late final Future<int> magicNumber = Future.value(Random().nextInt(100));
print("1. magic number:${await magicNumber}");
print("2. magic number:${await magicNumber}");
print("3. magic number:${await magicNumber}");
}
@maks
maks / main.dart
Created September 25, 2023 06:05
reverberating-oak-9145
import "dart:math";
// Example of use Dart's "late final" lazily initialised cached value
void main() {
late final int magicNumber = Random().nextInt(100);
print("1. magic number:$magicNumber");
print("2. magic number:$magicNumber");
print("3. magic number:$magicNumber");
}
@maks
maks / main.dart
Created September 21, 2023 06:32
lively-osmium-3954
typedef Callback = Object Function();
void main() async {
final res = request(false);
final mesg = switch (res) {
OkResponse() => "houston we are ok",
ErrResponse() => "houston we have a problem"
};
@maks
maks / adaptive_scaffold.dart
Last active November 8, 2022 06:16 — forked from rodydavis/adaptive_scaffold.dart
Flutter Adaptive Scaffold
import 'package:flutter/material.dart';
// Updated to Flutter 3 by @maks
// original from: https://gist.github.com/rodydavis/5c7b3365ba9c4b010cace84ca20c2bcc
const kTabletBreakpoint = 720.0;
const kDesktopBreakpoint = 1200.0;
const kSideMenuWidth = 250.0;
class AdaptiveScaffold extends StatelessWidget {
@maks
maks / armasm.dart
Created October 18, 2022 08:59 — forked from pingbird/armasm.dart
Little ARM assembler in dart
// By PixelToast
var src =
"mov r0, #69\n"
"bx lr\n"
"ldmedeq ip!, {a3-sp}\n"
"strbhi r13, [v2, lr, asr #3]!\n"
"ldrls a3, [sb], sp, asr #0x14\n";
main() {
@maks
maks / main.dart
Last active September 26, 2022 03:51
popup menu example
import 'package:flutter/material.dart';
// example code from: https://stackoverflow.com/a/70236525/85472
// This is the type used by the popup menu below.
enum Menu { itemOne, itemTwo, itemThree, itemFour }
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
@maks
maks / config.ini
Last active May 26, 2022 23:59
config for m8c on Odroid go super to use more ergonomic buttons for start and select
[graphics]
fullscreen=false
use_gpu=true
idle_ms=20
[keyboard]
key_up=82
key_left=80
key_down=81
key_right=79
key_select=225
@maks
maks / firetron.sh
Last active February 23, 2022 23:51
**VERY BASIC AND LIMITED** pwa workaround for firefox from script found on: https://www.reddit.com/r/linuxquestions/comments/omsgqd/alternative_to_nativefier/
#!/bin/bash
## Usage:
# ./firetron <name> <url>
# ./firetron hulu hulu.com
firefox -CreateProfile "$1"
cd "$HOME/.local/share/icons/hicolor/32x32/apps/" || exit
wget -O $1.png $2/favicon.ico
touch "$HOME/.local/share/applications/$1.desktop"
import 'dart:async';
import 'dart:isolate';
import 'dart:typed_data';
import 'package:libao/libao.dart';
void playbackWorker(SendPort replyPort) {
final requestsPort = ReceivePort();
final player = AudioPlayer();
player.play();