Skip to content

Instantly share code, notes, and snippets.

View andhikayuana's full-sized avatar
🌏
bertapa

Andhika Yuana andhikayuana

🌏
bertapa
View GitHub Profile

Kotlin Flow Cheat Sheet

Flow Types

Flow Type Purpose Key Features Use Case
flow {} Creates a cold flow that emits values lazily. Emits values only when collected.
Supports suspending functions.
Creating custom flows to emit data on demand.
flowOf() Creates a flow from a fixed set of values. Emits provided values sequentially.
Cold by nature.
Emit predefined values (e.g., configuration settings).
asFlow() Converts collections, sequences, arrays, or ranges to flows. Supports many standard types.
Cold by nature.
Convert lists or arrays into flows for processing.
`c
@trvswgnr
trvswgnr / compress_video
Last active February 5, 2025 20:37
portable shell script to compress videos with ffmpeg
#!/bin/sh
print_usage() {
echo "usage: compress_video <input_file>"
echo "supported formats: mp4, webm, mkv, mov, avi, flv"
}
get_extension() {
f="${1##*/}"
case "$f" in
@Spikeysanju
Spikeysanju / ffmpeg-cheatsheet.md
Last active August 27, 2024 03:26
A comprehensive cheatsheet of FFmpeg commands with descriptions and examples, covering video and audio processing tasks such as format conversion, resizing, trimming, extracting audio, and adding effects.

FFmpeg Cheatsheet

Common FFmpeg Options

Option Description Example
-i Input file ffmpeg -i input.mp4
-vf Video filters (apply effects to video) ffmpeg -i input.mp4 -vf "scale=1280:720" output.mp4
-c:v Video codec (specify video compression method) ffmpeg -i input.mp4 -c:v libx264 output.mp4
-c:a Audio codec (specify audio compression method) ffmpeg -i input.mp4 -c:a aac output.mp4
@ahmadrosid
ahmadrosid / write-fixer.py
Created April 17, 2024 10:02
Fixed typos, spelling mistakes, and grammar while maintaining clarity and a concise tone using Claude.
import sys
import anthropic
from dotenv import load_dotenv
load_dotenv()
client = anthropic.Anthropic()
prompt_template = """
Please review and edit the following text to ensure it is grammatically correct, clear, and concise. Aim to maintain a casual tone without being overly informal. Provide suggestions for improvement and explain any changes you make. Do not add double quotes in you rewrite answer. Answer in direct response.
@kamilogorek
kamilogorek / _screenshot.md
Last active September 18, 2024 03:05
Clutter-free VS Code Setup
image
@lewdev
lewdev / worksheet-generators.md
Last active September 25, 2024 04:46
🏫📄 Worksheet Generators List
@andrimuhyidin
andrimuhyidin / gcr-cleaner.sh
Last active June 8, 2022 13:50
Deleting unused image tags from Google Container Registry, leaving x number left
#!/bin/bash
IFS=$'\n\t'
set -eou pipefail
if [[ "$#" -ne 3 || "${1}" == '-h' || "${1}" == '--help' ]]; then
cat >&2 <<"EOF"
gcr-cleaner.sh will cleans up the gcr tags or untaged images pushed in a repository (image name with the specific tag)
and except the given number most recent images.
@colinrtwhite
colinrtwhite / complex_forwarding_painter.kt
Last active October 26, 2024 09:03
A painter that wraps another painter to overwrite its color filter, alpha, and/or onDraw.
/**
* Create and return a new [Painter] that wraps [painter] with its [alpha], [colorFilter], or [onDraw] overwritten.
*/
fun forwardingPainter(
painter: Painter,
alpha: Float = DefaultAlpha,
colorFilter: ColorFilter? = null,
onDraw: DrawScope.(ForwardingDrawInfo) -> Unit = DefaultOnDraw,
): Painter = ForwardingPainter(painter, alpha, colorFilter, onDraw)
@mxalbert1996
mxalbert1996 / Scrollbar.kt
Last active March 5, 2025 00:36
Modifiers to draw scrollbars in Jetpack Compose
/*
* MIT License
*
* Copyright (c) 2022 Albert Chang
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@ak4bento
ak4bento / how-to-setup-verified-commits.md
Last active November 29, 2024 17:36
Setup Verified Commits