A Future represents a single value that might end up as data, error, or
incomplete. For each of these states we wire up different handlers. For data
we use the then method on the Future, which takes a function (data) {},
where data is the input that enters the event loop asynchronously.
Future.value(5).then((data){print(data);})
Pay special attention here.
Incase it wasn't a regular data like 5, but an error, we could setup the
handler like this:
Here, even though .catchError was invoked on the .then of the Future,
both are meant to handle the same Future. But if instead of .catchError
we used a .then we are working on a different Future: the one returned by
the handler of the previous Future. For example:
The second then is a handler for a new Future (value 10) while the
first catchError worked on the First future had the value been an error.
The event loop really runs the show. All streams let the data in into the event
loop, where handlers are set to work with it synchronously (unless Isolates are
explictly used). Note: What's asynchronous here is just delivery of events
originating from other threads into the event loop thread/the main thread. So its
asynchronous delivery and synchronous handling.
Let's start with the basic stdin. stdin (like stdout and stderr) is managed by
the kernel. You don't get the typical .close() method for this stream. The
closing of this stream is done by the kernel when the process finishes.
import'dart:convert';import'dart:io';voidmain(){List<int>input=[];stdin.lineMode=false;stdin.echoMode=false;varsubscription;subscription=stdin.listen((List<int>data){if(data[0]==4){// Reset terminal modes before exitingstdin.lineMode=true;stdin.echoMode=true;subscription.cancel();print("Input:");print(utf8.decode(input));}// if (!ListEquality().equals(data, [127])) {if(data[0]!=127){// Add the character to our input bufferinput.addAll(data);// Display the characterstdout.write(utf8.decode(data));}else{// Handle backspaceif(input.isNotEmpty){// Remove last character from bufferinput.removeLast();// Move cursor back, print space to overwrite, move cursor back againstdout.write('\b\b');}}});}
//# was changed to //# + #//, flanking the critic markup so that it
doesn't consume the whole line like the regex in screenshots does. For the
latest version look up: https://github.com/vectorspacexyz/pymdown-lexers
The Problem
The Solution
Here in the markdown tab note that I'm trying to highlight widget.count++ by
surrounding it in critic
markup .
The issue I encounter is highlighted in the result tab. I also noted while
trying to debug the problem that if the critic markup is inside a comment, it
renders correctly. This gave me a high degree of certainty that it was
something that was happening with pygment syntax highlighting that was
interfering with critic.
The solution i went with is creating a new lexer dart-critic, where a new
syntax is added //# is used. This dart-critic is built on top of the
existing dart lexer in pygments.
To develop the solution I first played around with the file that contained
the original Dart lexer directly, I found out that the dart lexer was in javascript.py
by searching for "dart" in repo in https://github.com/pygments/pygments. Since I used
arch:
Get all lexers
You can get all the pygment lexers installed on your system with:
Just had to add a single loc at the javascript.py file (this is just for testing, please note any pacman
upgrade might rewrite this file back to its old state):
This solution isn't perfect as there are more lexers with this same issue, or
maybe lexers are not the real issue at all the critic implementation is.
I also need to find some way to edit system python install on the fly: pacman
the SOURCE in PKGBUILDs to be a directory. As such, I was committing and pushing
to the repo and redoing makepkg -Si over and over again before reaching a state
that works. This also made me reflect on whether mkdocs and material-theme should
be a system install at all, should I have used venv instead?
They call it a bridge, but I like to call it a virtual switch: Linux bridges
are a really interesting concept I've come across recently.
Here was the use case: Through wifi interface wlp3s0 my laptop (archlinux
btw) was connected to a network that had internet access. Had I
enabled the default network interface in virt-manager the guest windows machine
would get access to the internet: you all know what happens when windows gets
internet access; it downloads updates and forces you to update. So I didn't
want the guest windows vm to access the internet, but I did want it to access
my IP camera network which wasn't connected to the internet. My laptop was
connected to this network via ethernet —this means my laptop ethernet interface
enp5s0 had a LAN IP address assigned to it just like the other client cameras
in the network. I wanted the windows guest vm to access this network so I could
install the software that could initialize my IP cameras (SmartPSS, SmartPSS
Lite, and ODM: Onvif Device Manager): 3 of the cameras needed this software for
configuration but the other 3 had a convenient web interface. Still, I'm not
complaining because when there is good old Linux on your side you can always
find a way .
The solution here is to use a Linux bridge (or a "virtual switch"). This setup
turns our ethernet interface into an ethernet port on a switch. The ethernet
port on a switch doesn't have its own ip address like the ethernet interface
does, the port just links you to the things connected on other port.
In this case the connection to the ethernet port just puts two more devices
in the network: br0 and the VM's virtual interface.
┌─────────────────────────────────────┐
│ br0 (Virtual Switch) │
│ ┌─────────────────────────────────┐│
│ │ Port 1: enp5s0 (Physical) ││ ← Connected to 10.0.0.0/24 network
│ │ Port 2: VM's virtual interface ││ ← Your Windows VM will connect here
│ │ Port 3: Host's br0 interface ││ ← Your host's network access
│ └─────────────────────────────────┘│
└─────────────────────────────────────┘
The config files that make it happen (if you've ever worked with systemd before you'd be
familiar with the /etc/systemd/system directory where you usually place .service files)
With all this in place, once you execute sudo systemctl restart systemd-networkd you should
see a new br0 interface in the output of ip addr command. However, you might also see
that enp5s0 interfaces gets an IP address too —this isn't what we expected since enp5s0 is
now just a "port" or replaced by a new br0 interface. When enp5s0 has an ip address
you might find that you can't ping other devices on the IP camera network.
I found out that it was dhcpcd.service that was assigning an IP address to enp5s0. To prevent
it from getting an address I did:
sudo nvim /etc/dhcpcd.conf
Add this line at the top or bottom of the file:
denyinterfaces enp5s0
Restart dhcpcd:
sudo systemctl restart dhcpcd
Flush the Current IP and Restart systemd-networkd:
# Remove the current IP from enp5s0
sudo ip addr flush dev enp5s0
# Restart systemd-networkd to properly configure the bridge
sudo systemctl restart systemd-networkd
Now enp5s0 has no IP address and now it no longer interferes with
connecting to other devices on the network.
unrar x Warcraft.III.Complete.Edition.MULTi6.rar
cd Warcraft.III.Complete.Edition.MULTi6
sudo mount -o loop IGG-Warcraft.III.Complete.Edition.MULTi6.iso /mnt
I went with proton-ge-custom because of the recommendation that appeared in lutris. But system
wine had better performance and significantly faster startup time. You can skip this section if
you go with.
If you're on wayland you might want to configure chrome to use xorg/xwayland. There seems to be some issue switching
between Lutris (that uses xorg backend) and chrome on wayland.
Google colab provides powerful GPUs with 12G of VRAM even at free tier. I foud
this very useful to first generate srt files of chinese youtube videos and then
translate the chinese srt files into english srt files.
Sample yt-dlp command to download video
# proxy, cookies, format and output name are not compulsory.yt-dlp--proxysocks5://localhost:1080/--cookies/tmp/cookies.txt-f"bestvideo[height=720]+bestaudio"'https://www.youtube.com/watch?v=XlmWtg4ksaw'-o'藏南的诅咒:困死在喜马拉雅南坡的印度'
Select python3 as interpreter and t4 gpu as hardware accelator
Each code bock below is inserted by pressing the +Code button in the UI first
and then entering the text. Lines that beings with ! is run in the os shell
environment, while the rest are run in the selected interpreter (here python3).
After typing in each code blocks, press the run button:
I believe this is a better way to manage your config files than uploading them to
github. With this approach all you need to do is sync your configs file into the
config folder within the root of your mkdocs site. They can easily be embedded
as snippets in markdown files with appropriate syntax highlighting and contents
of these config files also turn up in site search.
# Welcome to MkDocsFor full documentation visit [mkdocs.org](https://www.mkdocs.org).
## Commands*`mkdocs new [dir-name]` - Create a new project.
*`mkdocs serve` - Start the live-reloading docs server.
*`mkdocs build` - Build the documentation site.
*`mkdocs -h` - Print help message and exit.
## Project layout mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.
```zsh--8<--"configs/.zshrc"```
Here I've just added:
```zsh
--8<-- "configs/.zshrc"
```
... to the end of the autogenerated docs/index.md file when you first create a site. Check the
results of this by:
# Inside the directory that contains the mkdocs.yml file
mkdocs serve -a 127.0.0.1:9000