Skip to content

Instantly share code, notes, and snippets.

View cristobal's full-sized avatar
💭
¯\_(ツ)_/¯

Cristobal Dabed cristobal

💭
¯\_(ツ)_/¯
View GitHub Profile
@cristobal
cristobal / podman-manifest-table.sh
Created February 20, 2026 21:08
Podman Manifest Table
#!/usr/bin/env sh
#
# podman-manifest-table - List platform digests from a multi-arch container image
#
# Usage: podman-manifest-table <image>
# podman-manifest-table -h|--help
#
# Example: podman-manifest-table node:24.13.1-alpine3.23
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
@cristobal
cristobal / podman-cleanup.sh
Last active November 13, 2025 09:41
Podman System Cleanup Script
#!/usr/bin/env sh
#####
# Podman System Cleanup
#
# This script performs a comprehensive cleanup of all unused Podman resources
# including networks, volumes, images, containers, pods, and system cache.
# It uses the prune commands to remove dangling and unused resources, then
# displays the final disk usage statistics.
#####
@cristobal
cristobal / machine-diskutil.sh
Last active November 2, 2024 08:05
Machine Diskutil to mount/unmont external volumes inside docker machines running on Virtualbox
#!/usr/bin/env sh
# @see http://stackoverflow.com/questions/30040708/how-to-mount-local-volumes-in-docker-machine
# @see https://github.com/boot2docker/boot2docker/blob/master/doc/FAQ.md
################################################################################
# Dependency Section #
# #
################################################################################
check_deps() {
## Make sure commands are available
@cristobal
cristobal / package_json_find_when_introduced.sh
Created April 11, 2022 12:09
Find git commit when a package was introduced in the package.json file in a git repo.
prev_cmt=""
for cmt in $(git lg package.json | awk '{print $2}');
do
git co $cmt >/dev/null 2>&1
cat package.json | grep 'package-name' >/dev/null 2>&1
# will fail if does not find the package-name in the current commit
if [ $? -ne 0 ] ; then
echo "cmt: $cmt"
echo "prev_cmt: $prev_cmt"
git co main
@cristobal
cristobal / script.ps1
Created April 11, 2021 21:41
Setting custom NPM_USER_CONFIG with readonly NPM_TOKEN via Powershell (Tested in TeamCity)
# Write NPM_TOKEN registry without BOM @see https://stackoverflow.com/a/32951824
[IO.File]::WriteAllLines("$(Get-Location)\.npmrc", "//registry.npmjs.org/:_authToken=$env:NPM_TOKEN")
# Set Custom NPM_CONFIG_USERCONFIG Environment variable
$env:NPM_CONFIG_USERCONFIG="$(Get-Location)\.npmrc"
# debug who you are
# npm whoami
# replace * with the npm script you want to run.
@cristobal
cristobal / bashrc_ccze.sh
Created August 26, 2014 12:27
Colorize with CCZE
# CCZE Colourize Config for Centos
# http://lintut.com/colorize-log-files-on-linux-using-ccze-tool/
# http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/
CCZE=`which ccze`
if [ "$TERM" != dumb ] && [ -n "$CCZE" ]
then
function colourify { `$@` | $CCZE -A }
alias colourify=colourify
alias configure='colourify ./configure'
@cristobal
cristobal / LUA unserialize
Created September 5, 2012 23:39
Lua php unserialize port
--[[
LUA variant of the php unserialize function
Port of http://phpjs.org/functions/unserialize
]]--
local function unserialize (data)
local function utf8Overhead (chr)
local code = chr:byte()
if (code < 0x0080) then
return 0
@cristobal
cristobal / 01_validate_orgnr.php
Last active July 10, 2020 11:13
Validate Norwegian Organization Number
<?php
/**
* Validate orgnr
* Validates an string number according to the brreg spec
* https://www.brreg.no/om-oss/oppgavene-vare/alle-registrene-vare/om-enhetsregisteret/organisasjonsnummeret/
*
* Test case: https://repl.it/repls/TechnicalForcefulBsddaemon
*
* @param <string> $value
const pattern =
new RegExp(
// starts with PT
'^PT' +
// one or more digits followed by the hours designator H
'((\\d+)H){0,1}' +
// one or more digits followed by the minutes designator M
'((\\d+)M){0,1}' +
// one or more digits with precission followed by the seconds designator S
'((\\d+(\\.\\d+){0,1})S){0,1}' +
function parseDesignators (duration) {
return [
{
name: 'hours',
designator: 'H'
},
{
name: 'minutes',
designator: 'M'
},