Skip to content

Instantly share code, notes, and snippets.

@Aetet
Aetet / config-deb-i386.json
Created January 23, 2022 19:25 — forked from lyshie/config-deb-i386.json
Scratch Desktop (Scratch 3.0 Offline Editor) on GNU/Linux
{
"src": "/tmp/scratch-desktop/",
"dest": "/tmp/",
"arch": "i386",
"icon": "/tmp/scratch-desktop/resources/Icon.png",
"categories": [
"Education"
]
}
@Aetet
Aetet / main.dart
Created August 23, 2021 06:01
accumulate stream
void main() {
var counterStream =
Stream<int>.periodic(const Duration(seconds: 1), (x) => x).take(15);
var mas = <int>[];
counterStream.listen((num) {
mas.add(num);
print("mas: ${mas}");
});
}
@Aetet
Aetet / main.dart
Last active October 6, 2019 19:51
void main() {
final a = 10;
final inside = a.clamp(1, 11);
final outsideMax = a.clamp(1, 9);
final outsideMin = a.clamp(11, 20);
print('inside: $inside, min: $outsideMin, max: $outsideMax');
}
@Aetet
Aetet / gist:026f78becd6743000ed39a32767255fa
Last active July 7, 2019 13:14
Async stream vs broadcast
import 'dart:async';
void main() {
final controller = new StreamController<int>();
controller.add(10);
controller.stream.listen((a) => print('receive: $a'));
final contrtoller2 = new StreamController<int>.broadcast();
@Aetet
Aetet / gist.dart
Last active December 12, 2018 20:21
void main() {
int i, b = 1, n = 11;
final mas = new List(n);
mas[0] = 1;
for (i = 1; i < n; i++) {
mas[i] = b;
b = mas[i-1] + b;
}
for (i = 0; i < n; i++) {
https://seanlin0800.gitbooks.io/async-performance/content/source/ch4/breaking_run_to_completion.html
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = tab
[*.{dart,less}]
end_of_line = lf
@Aetet
Aetet / gist:1fc43accb7fba19ccfa4
Created February 1, 2016 15:41
Battle tested regexps
"url\\([\"'\s]*([^'\"()]+?)[\"'\s]*\\)(\s+(-?\d+)(?:px)?\s+(-?\d+)(?:px)?)?"
Matching url() at css rule
@Aetet
Aetet / hacker-radiio
Created October 1, 2015 17:36 — forked from jars/hacker-radiio
Music For Hackers
Music For Hackers
==
To a hacker, there's something distracting about booting up a GUI to listen to your tunes. You live your life in the terminal, you treat the mouse like a high voltage tap.
So give these commands a run in the terminal, and toss on your headphones.
sudo apt-get install mplayer
echo "alias defcon-start='nohup mplayer http://sfstream1.somafm.com:6200 > /dev/null 1>&2 &'" >> ~/.bashrc
echo "alias defcon-stop='killall -9 mplayer'" >> ~/.bashrc
@Aetet
Aetet / gist:2be9ff0745b3b4eb4ab3
Created September 16, 2015 21:31
capslock language switch with autohotkey
LOCALE_EN := 0x4090409
LOCALE_RU := 0x4190419
CapsLock::
if WinActive("ahk_class ConsoleWindowClass") {
PostMessage, 0x50, 0x02, 0,, A
}
else {
SetFormat, Integer, H
WinGet, WinID,, A
ThreadID := DllCall("GetWindowThreadProcessId", "UInt", WinID, "UInt", 0)