Skip to content

Instantly share code, notes, and snippets.

View Desdaemon's full-sized avatar

Viet Dinh Desdaemon

View GitHub Profile
@Desdaemon
Desdaemon / main.dart
Last active August 31, 2020 04:56
Reactive State in Flutter with BehaviorSubject and StreamProvider
// =========
// main.dart
// =========
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:rxdart/subjects.dart';
import 'package:table_sticky_headers/table_sticky_headers.dart';
void main() => runApp(ProviderScope(child: MainPage()));
@Desdaemon
Desdaemon / hw1.ts
Last active September 23, 2020 03:04
CSDS 338 HW1
import {
MAX_BATCH, MAX_BURST,
MAX_DELAY, MIN_BURST,
MIN_DELAY, MIN_PRIORITY,
TASKS_COUNT, MAX_PRIORITY,
Stopwatch, Task,
randomInt, TaskAggregate
} from './util'
export default async function () {
@Desdaemon
Desdaemon / CardDemo.vue
Last active January 9, 2021 03:51
Inline Markup Table using Quasar
<template>
<div class="q-pa-md">
<q-card class="my-card">
<q-card-section>
<div class="text-h6">
Inline Markup Table
</div>
</q-card-section>
<q-markup-table dense>
<thead>
@Desdaemon
Desdaemon / dark.dart
Last active March 15, 2021 13:52
Yet Another Flutter Todo (Null-safe + Animations + Dark Theme/List State via Riverpod + State Persistence via Hive)
/* lib/state/dark.dart */
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:hive/hive.dart';
final darkTheme = StateNotifierProvider((_) => Dark());
class Dark extends StateNotifier<bool> {
final String boxname;
bool firstrun = true;
Dark({this.boxname = 'todo'}) : super(false);
@Desdaemon
Desdaemon / .vimrc
Last active December 13, 2021 01:51
Typescript vimrc
if !has('nvim')
source $VIMRUNTIME/defaults.vim
endif
set number
set hlsearch
set incsearch
let &t_ut='' " fixes display bug on kitty
call plug#begin('~/.vim/plugged')
@Desdaemon
Desdaemon / Ayu Dark.tmTheme
Created January 9, 2022 22:30
Ayu Dark TextMate color scheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>name</key>
<string>Ayu Dark</string>
#!/usr/bin/python3
# Source: https://support.particle.io/hc/en-us/articles/360045547634-How-can-I-set-up-my-Argon-or-Boron-via-USB-
from shutil import which
from urllib.request import urlopen
from sys import exit as bail
from subprocess import run
from os import remove
from re import compile as regex
@Desdaemon
Desdaemon / init.lua
Last active February 1, 2022 03:11
NVIM config file
-- Full list at https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
local servers = {
'pyright', 'rust_analyzer', 'tsserver', 'dartls', 'clangd',
-- Provided by vscode-langservers-extracted
'html', 'eslint', 'cssls', 'jsonls',
}
local use = require('packer').use
require('packer').startup(function()
use 'wbthomason/packer.nvim' -- Self-management
@Desdaemon
Desdaemon / api.rs
Created February 18, 2022 00:51
Long-running StreamSink
use anyhow::Result;
use std::{thread::sleep, time::Duration};
use flutter_rust_bridge::StreamSink;
const ONE_SECOND: Duration = Duration::from_secs(1);
// can't omit the return type yet, this is a bug
pub fn tick(sink: StreamSink<i32>) -> Result<()> {
let mut ticks = 0;
@Desdaemon
Desdaemon / gen-stub.py
Last active June 17, 2022 01:39
Create Python Stubs
#!/usr/bin/env python
# pyright: basic
import re
import sys
import os
import ast as a
from typing import Callable, Generic, Iterable, Iterator, TypeVar
from multiprocessing import Pool
from pathlib import Path