Skip to content

Instantly share code, notes, and snippets.

@Jonas-Sander
Jonas-Sander / main.dart
Created December 21, 2019 22:58
Dart async throwing
/*Will print:
Uncaught Error: Instance of 'SomeException'
will catch this
bye bye
*/
void main() {
test();
}
Future<void> test() async {
@Jonas-Sander
Jonas-Sander / main.tf
Created March 16, 2020 13:47
google-beta provider credentials problem
jonassander@MacBook-Pro test % terraform apply
2020/03/16 14:45:46 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
Use TF_LOG=TRACE to see Terraform's internal logs.
----
2020/03/16 14:45:46 [INFO] Terraform version: 0.12.23
2020/03/16 14:45:46 [INFO] Go runtime version: go1.13.8
2020/03/16 14:45:46 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2020/03/16 14:45:46 [DEBUG] Attempting to open CLI config file: /Users/jonassander/.terraformrc
2020/03/16 14:45:46 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/03/16 14:45:46 [INFO] CLI command args: []string{"apply"}
@Jonas-Sander
Jonas-Sander / glowing_overscroll_color_changer.dart
Created April 20, 2020 14:07
Flutter GlowingOverscrollColorChanger
/// Overrides the [GlowingOverscrollIndicator] color used by descendant widgets.
class GlowingOverscrollColorChanger extends StatelessWidget {
final Widget child;
final Color color;
const GlowingOverscrollColorChanger({Key key, this.child, this.color})
: super(key: key);
@override
Widget build(BuildContext context) {
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
// Pressing SHIFT + N (first SHIFT, then N) works on Web but not Mac
void main() {
runApp(KeyboardShortcut());
}
class KeyboardShortcut extends StatefulWidget {
@Jonas-Sander
Jonas-Sander / main.dart
Created November 20, 2020 17:01
Add dart language comment "// @Dart=2.10" to top of dart files.
// @dart = 2.10
import 'dart:io';
import 'package:glob/glob.dart';
Future<void> main() async {
final replacements =
Glob('**.dart').list().asyncMap((fileSystemEntity) async {
if (fileSystemEntity is File) {
final content = await fileSystemEntity.readAsString();
await fileSystemEntity.writeAsString('// @dart = 2.10\n$content');
@Jonas-Sander
Jonas-Sander / main.dart
Created November 23, 2020 22:47
Fixed googleapis Firestore Query
import 'dart:convert';
// ignore: import_of_legacy_library_into_null_safe
import 'package:googleapis/firestore/v1.dart';
// ignore: import_of_legacy_library_into_null_safe
import 'package:http/http.dart' as http;
extension FirestoreRunQueryFixedExtension
on ProjectsDatabasesDocumentsResourceApi {
/// Runs a query.
blueprint:
name: Awtrix current playing song
description: Shows the title and artist of your current playing song on Awtrix.
domain: automation
author: N1c093
input:
awtrix_light:
name: Awtrix Display
description: Select the target Awtrix display.
selector:
@Jonas-Sander
Jonas-Sander / awtrix_spotify_nowPlaying.yaml
Last active May 22, 2024 04:22
awtrix_spotify_nowPlaying.yaml
alias: Awtrix Spotify NowPlaying 🎹
description:
trigger:
- platform: state
entity_id: media_player.spotify
action:
- choose:
- conditions:
- condition: state
entity_id: media_player.spotify