Skip to content

Instantly share code, notes, and snippets.

@fstanis
fstanis / ViewModelScope.kt
Created August 6, 2023 12:43
Hilt inject a CoroutineScope into anything @ViewModelScoped
// Copyright 2023 Google LLC.
// SPDX-License-Identifier: Apache-2.0
import dagger.hilt.android.ViewModelLifecycle
import dagger.hilt.android.scopes.ViewModelScoped
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import javax.inject.Inject
@fstanis
fstanis / audio2waveform.html
Last active March 7, 2023 01:42
Demo on creating SVG waveforms from an audio file.
<!--
Copyright 2018 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@fstanis
fstanis / simple.go
Created September 22, 2022 11:04
libmpv/simple/simple.c rewritten in Go
package main
/*
#include <stdlib.h>
#include <mpv/client.h>
#cgo pkg-config: mpv
const char* INPUT_DEFAULT_BINDING = "input-default-bindings";
const char* INPUT_VO_KEYBOARD = "input-vo-keyboard";
const char* YES = "yes";
@fstanis
fstanis / pi-sound-guide.md
Created February 28, 2018 00:30
Setting up Speaker pHAT or pHAT DAC with pulseaudio

Setting up Speaker pHAT or pHAT DAC with pulseaudio

Overview

The purpose of this document if to provide a simple method of getting pulseaudio to work on Raspberry Pi with either Speaker pHAT or pHAT DAC.

Please see Software installer for Speaker pHAT or Setting up pHAT DAC for the more official guide / installer. The idea behind this guide is to provide you with a more manual alternative that lets you have a minimal setup.

Installation

@fstanis
fstanis / ffgif.sh
Last active July 5, 2021 12:05
Simple shell script for creating HQ gifs from videos using ffmpeg
#!/bin/bash
# Based on: https://medium.com/@colten_jackson/doing-the-gif-thing-on-debian-82b9760a8483
# Command line arguments:
# -i <input file> (required)
# -o <output file> (required)
# -s <start time>
# -t <duration in seconds>
# -f <output FPS>
@fstanis
fstanis / pacmdx
Last active April 30, 2021 14:06
pacmd with extensions
#!/bin/bash
# Copyright 2021 Google LLC.
# SPDX-License-Identifier: Apache-2.0
# This script provides a few extensions to pacmd, the tool used to reconfigure
# a running PulseAudio sound server during runtime.
# Added commands:
# exists-card Checks if card exists (args: name)
@fstanis
fstanis / upspin-drive-guide.md
Last active March 29, 2021 21:06
Upspin server backed by Google Drive on a Raspberry Pi

Set up an Upspin server backed by Google Drive

Overview

The purpose of this document is to explain how to deploy an Upspin server on a Debian or Ubuntu based machine - which can be a Raspberry Pi - and, optionally, use Google Drive to back the data.

Effectively, this will give you all the nifty advantages Upspin gives you in terms of file sharing without requiring a costly server.

Requirements

@fstanis
fstanis / notes.html
Created March 19, 2020 17:32
AMP for Email - dynamic notes
<!--
Copyright 2020 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@fstanis
fstanis / server.js
Created March 19, 2020 15:48
Simple AMP for Email compatible server for notes
/*
Copyright 2020 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@fstanis
fstanis / index.html
Last active March 16, 2020 03:15
Webpack HTML entry
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="./style.css">
</head>
<body>