Skip to content

Instantly share code, notes, and snippets.

@muvaf
muvaf / build.sh
Created November 17, 2024 09:53
How to build standalone binary of scrcpy for macOS that does not need any dependencies like ffmpeg
#!/usr/bin/env bash
set -e
# Configuration
FFMPEG_VERSION="7.1"
SDL_VERSION="2.30.9"
LIBUSB_VERSION="1.0.27"
BUILD_DIR="build-macos-static"
DEPS_DIR="deps-static"
@muvaf
muvaf / multiple-app-logs-single-terminal.md
Last active November 16, 2023 17:05
How to browse log lines from multiple apps in single terminal

Browsing log lines in single terminal

You have a pipeline that builds multiple apps in parallel and the logs of every build drops into the same terminal window or you run multiple apps with a single command and one app has too many log lines that it clutters the terminal window.

Install lnav command. It's website is here.

brew install lnav

Run the command and pipe its output:

@muvaf
muvaf / retool.js
Last active October 13, 2023 16:52
Show file size in human readable format in a Retool table
// Replace "item" with your variable name.
{{ (item / Math.pow(1024, Math.floor(Math.log(item) / Math.log(1024)))).toFixed(2) }} {{ Array.from(['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'])[Math.floor(Math.log(item) / Math.log(1024))] }}
/* It'll show like the following:
* 42.00 Bytes
* 1.09 MB
* 2.89 GB
*/
// Credit to https://stackoverflow.com/a/34210131/5233252

A control plane composite (the internal one) will be created with this. We can add more configs over time.

apiVersion: controlplane.spaces.upbound.io
kind: Instance
metadata:
  name: myctp
spec:
  forProvider:
    initialRestorationFrom:
@muvaf
muvaf / xrd-first.yaml
Created July 18, 2023 08:53
Example YAMLs to reproduce
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: eks.example.org
spec:
group: example.org
names:
kind: EKS
plural: eks
versions:
export COMMENT='olala omama /test-examples="provider-aws/examples/acm/*.yaml,provider-aws/examples/ec2/*.yaml"'
export PROVIDER_NAME=$(echo $COMMENT | sed 's/^.*\/test-examples="//g' | cut -d '/' -f 1)
echo "Provider: ${PROVIDER_NAME}"
# Create an array from the test statement. This expands the * signs as well.
PATHS=$(echo $COMMENT | sed 's/^.*\/test-examples="//g' | cut -d '"' -f 1 | sed 's/,/ /g')
EXAMPLE_LIST=""
for PATH in $PATHS
do
@muvaf
muvaf / claim.yaml
Last active January 12, 2022 14:24
jetlag-is-so-nice
# Represented with nice boxes in the UI.
apiVersion: java.application.acme.org/v1alpha1
kind: SpringBoot
metadata:
name: dope-app
namespace: purple-squad
spec:
location: us-central1
package main
import (
"fmt"
"strings"
)
func main() {
lines := strings.Split(list, "\n")
@muvaf
muvaf / groups.go
Last active March 9, 2024 03:39
A small script to get all package-based groupings from TF AWS Provider
package main
import (
"fmt"
"sort"
"strings"
)
func main() {
lines := strings.Split(resources, "\n")
{
"typeName": "AWS::ACMPCA::Certificate",
"description": "A certificate issued via a private certificate authority",
"sourceUrl": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ACMPCA.html",
"definitions": {
"ApiPassthrough": {
"description": "Structure that specifies fields to be overridden in a certificate at the time of issuance. These requires an API Passthrough template be used or they will be ignored.",
"type": "object",
"additionalProperties": false,
"properties": {