Skip to content

Instantly share code, notes, and snippets.

@AvnerCohen
AvnerCohen / delete_branches_older_than.sh
Last active March 7, 2025 11:50 — forked from antonio/delete_branches_older_than.sh
Script to delete branches older than 6 months old, ignore local vs remote errors.
#!/bin/sh
ECHO='echo '
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
if [[ "$(git log $branch --since "6 months ago" | wc -l)" -eq 0 ]]; then
if [[ "$DRY_RUN" = "false" ]]; then
ECHO=""
fi
local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///')
$ECHO git branch -d "${local_branch_name}"
@PatelUtkarsh
PatelUtkarsh / index.js
Created February 19, 2020 13:25
Refresh WordPress media library images - useful when editors are uploading image via 3rd party tool using REST API - Example: Mediawires so editor do not need to reload page to get new images on existing article.
jQuery( document ).ready( function () {
// Refresh media library each time on click of add media.
if ( wp.media ) {
wp.media.view.Modal.prototype.on( 'open', function () {
if ( wp.media.frame.content.get() !== null ) {
// this forces a refresh of the content.
wp.media.frame.content.get().collection._requery( true );
}
} );
}
@matipojo
matipojo / merge-git-repos.sh
Last active August 3, 2025 15:23
Merge two git repositories while saving both commit histories
#!/bin/bash
# Parse named arguments
while [ $# -gt 0 ]; do
case "$1" in
--source-a=*)
REPO_A="${1#*=}"
;;
--source-b=*)
REPO_B="${1#*=}"