Skip to content

Instantly share code, notes, and snippets.

View JarJak's full-sized avatar

Jarek Jakubowski JarJak

View GitHub Profile
@JarJak
JarJak / git_delete_stale_branches.sh
Last active August 6, 2025 13:14
Bash script to delete all remote git branches older than provided days (runs in dry mode by default)
#!/bin/bash
# This script identifies and suggests deletion of remote Git branches
# that haven't been updated in a specified number of days.
usage() {
echo "Usage: $0 <stale_days> [--force] [--path=<repo_path>]"
echo " <stale_days>: REQUIRED. The number of days after which a branch is considered stale."
echo " --force: Optional. Execute the deletion commands. By default, a dry run is performed."
echo " --path=<repo_path>: Optional. Specify the path to the local Git repository (defaults to current directory)."
@JarJak
JarJak / OptionalProperties.php
Created June 17, 2024 07:56
Optional properties php trait that distinguish from unset and null properties, useful tin DTOs
<?php
trait OptionalProperties
{
public static function fromArray(array $args = [], bool $strict = true): self
{
$obj = (new ReflectionClass(self::class))->newInstanceWithoutConstructor();
foreach ($args as $prop => $value) {
if (!property_exists($obj, $prop)) {
if ($strict) {
@JarJak
JarJak / .bashrc
Last active June 1, 2022 09:26
Useful GIT bash aliases
eval $(docker-machine env)
SSH_ENV=$HOME/.ssh/environment
force_color_prompt=yes
source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh
PS1="\[\033[1;36m\]\u\[\033[1;35m\]@\[\033[1;34m\]#:\[\033[1;33m\]\w\[\033[1;32m\]\$(__git_ps1) \[\033[1;31m\]\$ \[\033[00m\]"
alias ls='ls --color=auto'
@JarJak
JarJak / lol.php
Last active March 15, 2017 21:02
php > if (!1 instanceof DumbClass) echo 'lolphp';
PHP Fatal error: instanceof expects an object instance, constant given in php shell code on line 1
php > $a = 1; if (!($a instanceof DumbClass)) echo 'lolphp'; // DumbClass has not been declared but not even a notice is thrown
lolphp