Skip to content

Instantly share code, notes, and snippets.

@jifalops
jifalops / main.dart
Last active October 26, 2018 20:26
Random binary tree
import 'dart:math';
const maxNodes = 10;
void main() {
final rng = Random();
final nodes = List.generate(maxNodes, (index) => Node(index + 1));
final openNodes = [nodes[0]];
nodes.skip(1).forEach((node) {
node.parent = openNodes[rng.nextInt(openNodes.length)];
@jifalops
jifalops / main.dart
Last active November 27, 2018 18:56
Reversing a linked list
class Node<T> {
Node(this.value, [this.next]);
T value;
Node next;
@override String toString() => '$value $next';
}
Node reverse(Node n) {
Node curr = n.next;
n.next = null; // `n` is the new tail.
@jifalops
jifalops / _README.md
Last active June 30, 2019 18:53
Headless Crostini quick setup script for Flutter, VS Code, Node/npm (via nvm), Firebase tools, and pip for Python3

Headless Crostini quick setup script for Flutter, VS Code, Node/npm (via nvm), Firebase tools, and pip for Python3

Modify lines 20 and 21 with your gist and token for the VS Code settings-sync extension.

The script adds a symbolic link to the ChromeOS Downloads folder at ~/Downloads. For it to work, share your Downloads folder with Linux by right-clicking it in the Files app.

WARNING

  • The script appends to the PATH environment variable each time it runs (at the end).
  • settings.json for VS Code will be overwritten if it exists! (The default settings are empty and it was easier to do it this way than to use jq.)