Skip to content

Instantly share code, notes, and snippets.

@emmanuelrosa
emmanuelrosa / main.dart
Created October 23, 2025 18:08
Rive Mars Landing
import 'package:flutter/material.dart';
// NOTICE!
// The rive package as an Image class, which conflicts with the Flutter Image class.
// Thus, import rive such that it uses its own namespace to avoid this conflict.
import 'package:rive/rive.dart' as rive;
void main() {
runApp(const MyApp());
}
@emmanuelrosa
emmanuelrosa / main.dart
Created October 23, 2025 14:58
ZTM CustomPainter lesson, with fixed mouth
import 'dart:math' as math;
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@emmanuelrosa
emmanuelrosa / main.dart
Created October 11, 2025 16:55
Changes I made to get app to match what is shown in the Flutter theme lesson.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@emmanuelrosa
emmanuelrosa / ami4linux.bash
Created October 5, 2025 17:04
Amazin Maya Installer 4 Linux
#!/usr/bin/env bash
# ami4linux.bash - Awesome Maya Installer 4 Linux
set -e
FEDORA_RELEASE="42"
CONFIG_DIR_PATH="$HOME/.config/ami4linux"
CONFIG_FILE="ami4linux.env"
CONFIG_FILE_PATH="$CONFIG_DIR_PATH/$CONFIG_FILE"
CHECKPOINT_FILE_PATH="$CONFIG_DIR_PATH/checkpoint"
@emmanuelrosa
emmanuelrosa / main.dart
Created September 26, 2025 18:14
Exercise: Restaurant ratings (a weird outcome)
void main() {
var restaurants = [
{
'name': 'Pizza Mario',
'cuisine': 'Italian',
'ratings': [5.0, 3.5, 4.5],
},
{
'name': 'Chez Anne',
'cuisine': 'French',
@emmanuelrosa
emmanuelrosa / sparrow.nix
Created September 23, 2025 08:14
A Nix package for sparrow using bundled JDK with buildFHSenv
{
stdenvNoCC,
stdenv,
lib,
fetchurl,
makeDesktopItem,
copyDesktopItems,
buildFHSEnv,
# temurin JDK dependencies
@emmanuelrosa
emmanuelrosa / xor-shift-lfsr.cpp
Created May 19, 2025 21:23
A 32-bit XOR Shift LFSR (Linear Feedback Shift Register).
unsigned int XORShiftLinearFeedbackShiftRegister(unsigned int state, unsigned int seed, int index) {
/* A 32-bit XOR Shift LFSR.
* The lower 16 bits can be used as a pseudo random number generator.
* Based on the XORShift LFSR source code example at https://stackoverflow.com/questions/65661856/how-to-do-an-8-bit-16-bit-and-32-bit-linear-feedback-shift-register-prng-in-ja";
* IMPORTANT: The seed must NEVER be zero, otherwise the LFSR will get stuck.
*/
unsigned int lfsr = index == 0 ? seed : state;
lfsr ^= (lfsr & 0x0007ffff) << 13;
lfsr ^= lfsr >> 17;
@emmanuelrosa
emmanuelrosa / sparrow.nix
Created April 8, 2025 11:52
Nix package for Sparrow 2.1.3
{
stdenv,
stdenvNoCC,
lib,
makeWrapper,
fetchurl,
makeDesktopItem,
copyDesktopItems,
autoPatchelfHook,
writeText,
@emmanuelrosa
emmanuelrosa / bspwmrc
Created November 18, 2021 15:09
bspwmrc and sxhkdrc
#! /run/current-system/sw/bin/sh
. "${HOME}/.cache/wal/colors.sh"
pgrep -x sxhkd > /dev/null || sxhkd &
pgrep -x udiskie > /dev/null || udiskie &
pgrep -x picom > /dev/null || picom &
pgrep -x dunst > /dev/null || dunst &
killall xmobar > /dev/null ; (bspc subscribe report | awk -v ulcolor="$color4" -v tcolor="$color7" -v fcolor="$color2" -f $HOME/.config/bspwm/desktops.awk | xmobar -B $color0 -F $color7 $HOME/.config/bspwm/xmobarrc) &
@emmanuelrosa
emmanuelrosa / pomodoro.sh
Created April 7, 2021 22:47
A custom rofi mode which provides 20 and 5 minute timers.
#! /run/current-system/sw/bin/env bash
# POMODORO: A custom rofi mode which provides 20 and 5 minute timers.
# USAGE: rofi -combi-modi window,drun,pomo -show combi -modi combi,pomo:$HOME/bin/pomodoro
OPT_START_TASK="20 minute timer"
OPT_START_BREAK="5 minute timer"
SLEEP_TASK=1200
SLEEP_BREAK=300