Skip to content

Instantly share code, notes, and snippets.

@eddiemoya
eddiemoya / git-smarter-example-git-log-path.sh
Last active August 29, 2015 13:57
Example of using "git log" with a specified file -- for oembed use on http://eddiemoya.com
# Show specifically only the last commit to affect the path/to/file -
# this will be the commit where the file as deleted.
git log -1 -- path/to/file
#!/bin/bash
##
# Name: wp-gitify
# Description: Turns the subversion repositories of wordpress
# plugins and themes into github read-only repositories.
# Author: Brian Greenacre <bgreenacre42@gmail.com>
# Requirements: git, svn, git-svn, svn2git, curl
##
@eddiemoya
eddiemoya / git-merge-rebase-first.sh
Created September 26, 2013 19:02
Simplifies the workflow of having to ... * Check if a branch can be fast-forward merged * If it is not, checking that branch out * Rebasing that branch into the branch you were originally on. * Ensuring that if you were kicked into a headless state after the rebase, that your actual branch ref points to the new rebased commits. * Checking out th…
#!/bin/bash
function get_merge_revs {
MERGE=$(git rev-parse --abbrev-ref $REV);
MERGE_REV=$(git rev-parse $REV);
SHORT_MERGE_REV=$(echo $MERGE_REV | cut -c 1-7);
}
function get_orig_merge_revs {
ORIG_MERGE=$(git rev-parse --abbrev-ref $REV);
@eddiemoya
eddiemoya / git-find-merge-base.sh
Last active March 30, 2021 09:57
Finds the most recent common ancestor (the "merge-base") of two given revisions using 'git merge-base', and shows it highlighted in a list of every commit since then using 'git log' and 'git rev-list'.
##
# Get the first 7 characters of the SHA1 of the most common ancestor of the given revs
##
BASE_FULL_SHA1=$(git merge-base "$1" "$2");
BASE=$(cut -c 1-7 <<< $BASE_FULL_SHA1);
##
# Get (roughly) the number of commits between the given revs.
# Add one for safety padding so the actual commit in question is included.
##
#!/bin/bash
# readlink -f resolves symlinks but doesnt work on OSX or BSD.
# SYNC_BIN_PATH=`dirname $(readlink -f $0)`
# pwd is lazy, doesnt resolve symlinks, but works everywhere.
SYNC_BIN_PATH=$(pwd)
TMP_PATH="$SYNC_BIN_PATH/tmp"
REPO_PLUGINS="$SYNC_BIN_PATH/uxwpress/plugins/"
NEW_REPO_PLUGINS="$SYNC_BIN_PATH/plugins"
#!/bin/bash
function actual_path() {
if [ [ -z "$1" ] -a [ -d $1 ] ]; then
echo $(cd $1 && test `pwd` = `pwd -P`)
return 0
else
return 1
fi
}
appliances vacuums-floor-care 20018
appliances refrigerators 20021
appliances small-kitchen-appliances 20024
baby baby-health-safety 20027
baby baby-gear 20028
baby baby-diapering 20029
baby baby-feeding 20030
jewelry bracelets 20060
jewelry jewelry-boxes-jewelry-care 20061
jewelry earrings 20063
appliances disposers-compactors 1020015
appliances dishwashers 1020017
appliances vacuums-floor-care 1020018
appliances freezers-ice-makers 1020019
appliances microwaves 1020021
appliances refrigerators 1020022
appliances small-kitchen-appliances 1020025
appliances water-heaters 1020026
baby baby-health-safety 1020029
baby baby-gear 1020030
@eddiemoya
eddiemoya / example-body-class-filter.php
Created May 1, 2013 15:06
Example body class filter
<?php
/**
* Do not call this function directly, add it to the body_class filter
*
* Conditionally adds classes to the body class of a page for styling purposes.
* These examples are from the Kmart Fashion and BirthdayClub themes.
*
* @author Eddie Moya
*
* @param type $classes
@eddiemoya
eddiemoya / git-flip-last.sh
Last active September 6, 2018 08:55
Flip the last two commits in a branch using git-rebase, git-cherry-pick, git-update-ref, git-name-rev, and git-rev-parse. Interesting exercise using quite a bit of plumbing commands.
#!/bin/bash
branch=$(git name-rev --name-only HEAD)
git rebase --onto HEAD~2 HEAD~1 HEAD
git cherry-pick ORIG_HEAD~1
git update-ref refs/heads/$branch $(git rev-parse HEAD)
git checkout --quiet $branch
# Instead of creating an independant bash script with the code above,
# consider simply creating a git alias using the command below.