Skip to content

Instantly share code, notes, and snippets.

@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.)
@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 / 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 5, 2018 19:13
SimpleObserver & Debouncer demo
import 'dart:async';
import 'dart:math';
void main() {
/// Use of the SimpleObservable base class.
final observable = SimpleObservable<String>(printCallback);
observable.values.listen(printStream);
/// Recursively listens to [nextValue] and prints changes.
printFuture(observable);
import 'package:flutter/material.dart';
class ABCModel extends InheritedModel<String> {
ABCModel({
Key key,
this.a,
this.b,
this.c,
Widget child,
}) : super(key: key, child: child);
@jifalops
jifalops / shared_theme_howto_screenshots.md
Created September 28, 2018 01:45
shared_theme how-to screenshots
Mobile light Mobile dark
mobile-light mobile-dark
Web light Web dark
![web-light][22] ![web-dark][23]
@jifalops
jifalops / shared_theme_howto_table.md
Last active September 28, 2018 01:42
shared_theme how-to table
File Description
[bin/build_themes.dart][8] Script to generate lib/src/_themes.g.scss.
[web/index.html][9] Add small script to load saved theme.
[web/styles.scss][10] Global styles for the web app.
[lib/app_component.dart][11] The main component of the app.
[lib/app_component.html][12] The main component of the app.
[lib/app_component.scss][13] The main component of the app.
[lib/src/example_list/example_list.dart][14] Demo of current theme.
[lib/src/example_list/example_list.html][15] Demo of current theme.
@jifalops
jifalops / main.dart
Created September 28, 2018 00:12
Example main.dart for Flutter using shared_theme.
import 'package:flutter/material.dart';
import 'package:<project_name>/config.dart';
import 'package:<project_name>/themes.dart';
import 'package:shared_theme_flutter/shared_theme_flutter.dart' as themer;
import 'package:shared_preferences/shared_preferences.dart';
void main() => runApp(App());
class App extends StatefulWidget {
_AppState createState() => _AppState();
@jifalops
jifalops / bin--build_themes.dart
Last active October 5, 2018 02:42
First run prep for web package using shared_theme.
import 'dart:io';
import 'package:<project_name>/themes.dart';
void main() async {
await File('lib/src/_themes.g.scss').writeAsString(themeset.toString(), flush: true);
}
@jifalops
jifalops / Example_usage.dart
Last active June 30, 2021 21:14
Creating a BLoC for formatted currency, and using it in Flutter.
...
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
title: 'My App',
home: CurrencyProviderRoot(
child: MyHomePage(),
));
}