Skip to content

Instantly share code, notes, and snippets.

@OscarL
OscarL / gist:44dff94b7d7eb11c2ba61a03ab874a17
Created October 23, 2025 21:21
Basic bash function (place it on profile or bashrc) to quickly squash the N last commits.
squash_last_n_commits()
{
if [ $# -ne 1 ] || [ "$1" -lt 2 ]; then
echo 'squash_last_n_commits() requires a number (>1) as the only argument ("HEAD~$1")'
else
echo "Creating '__pre_squash__state__' tag, just in case."
git tag "__pre_squash__state__"
git reset --soft HEAD~$1 &&
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
if [ $? -ne 0 ]; then
@OscarL
OscarL / VirtualBox-graphics-howto.md
Created December 20, 2024 18:08
How to have decent video on VirtualBox.

How to have decent video on VirtualBox.

  • Make sure VM's OS type is set to Linux 64 bits.
  • On the VM's Settings -> Display, make sure "Graphics Controller" is "VMSVGA". 32 MB of "Video Memory" should be enough.
  • On Haiku, run "pkgman install vmware_addons", reboot.
  • Change resolution as you wish from the Screen preflet.

You should now be able to change modes as you like.

To make sure VirtualBox starts in the resolution you want:

`time git status` for Haiku/Haikuports trees.
=============================================
HDD, Haiku 64 bits (VBox, Win10 host, unless otherwise noted)
Haiku tree
----------
hrev58287 | hrev58344 | hrev58344 (Host on PowerSaving mode) | hrev58344 (bare metal) | hrev58287 (bare metal)
@OscarL
OscarL / Updating-Patchsets-101.md
Last active May 13, 2025 18:57
How to update .patchset files for HaikuPorter recipes, when they do not apply cleanly.

Updating HaikuPorter .recipes (and what to do when applying the .patchset fails).

An example-based, step-by-step guide.

TL;DR

# Let's start! (from the git repo on the work-dir for "package_name-1.2.3"):
> git am ../../../patches/<package_name-1.2.3.patchset>
@OscarL
OscarL / QueryTimings.txt
Created November 2, 2023 09:38
Timings of some queries on Haiku beta4 (indexed vs non-indexed attributes, first, vs repeated runs, exact vs "glob" queries, BFS vs PackageFS.
///////////////////////////////////////////////////////////////////////////////
// Beta4, 64 bits, SATA HDD 5400 RPM:
///////////////////////////////////////////////////////////////////////////////
[~/Desktop ]
> df
Mount Type Total Free Flags Device
----------------- --------- --------- --------- ------- ------------------------
/boot bfs 20.0 GiB 9.7 GiB QAM-P-W /dev/disk/ata/1/master/2_1
/boot/system packagefs 4.0 KiB 4.0 KiB QAM-P--
@OscarL
OscarL / compare_package.py
Last active November 2, 2025 13:56
Compare .hpkg locally built with haikuporter, with the one you have installed under /system/packages/
#!python3
"""
Compares the contents (disregarding files' sizes and timestamps) of Haiku packages (.hpkg).
Useful to see, at first glance, if our newly built package looks more or less like the older ones.
Usage:
> compare_packages.py <package_name>
> compare_packages.py <package1.hpkg> <package2.hpkg>
@OscarL
OscarL / pkgman_list_not_required.py
Created May 5, 2023 12:56
Proof of Concept for `pkgman search --not-required`
#!python3
"""
Proof of concept for `pkgman search --not-required`.
The idea is *very* simple.
- Get the list of installed packages.
- From that, builds a list of all unique requirements.
- Print the list of packages that do not provide any of those requirements.
@OscarL
OscarL / patchset_split.py
Created December 20, 2022 23:07
Split Haikuporter's .patchset files ("git am" mailboxes).
#! python3
"""
patchset_split.py
Based on Paolo Bonzini's mbox_split.py:
https://gist.github.com/bonzini/d5bc1946475487167c529f9699e39512
"""
import argparse
@OscarL
OscarL / test_pidof.py
Last active September 2, 2022 20:01
A script to test Haiku's pidof command.
"""
Test bench for Haiku's `pidof` command.
Requires at least Python 3.5 (for subprocess.run()).
Usage:
python3 test_pidof.py [path_to_pidof]
If no "path_to_pidof" is given, the one in $PATH, if any, will be used.
"""
@OscarL
OscarL / pidof.sh
Last active August 28, 2022 08:49
A pidof shell implementation for Haiku
#!/bin/sh
# Poor-man's pidof replacement for Haiku
#
# Usage: > pidof <ProcessName>
if [ "$#" -eq "1" ] ; then
ps -o Id Team | grep $1 | grep -v 'grep' | grep -v 'pidof' | grep -o '[0-9]*'
fi