Skip to content

Instantly share code, notes, and snippets.

##
# Creates an alias called "git hist" that outputs a nicely formatted git log.
# Usage is just like "git log"
# Examples:
# git hist
# git hist -5
# git hist <branch_name>
# git hist <tag_name> -10
##
git config --global alias.hist "log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){{%an}}%C(reset) %C(blue)%d%C(reset)' --graph --date=short"
@fcamblor
fcamblor / git-flip-last.sh
Last active August 5, 2022 16:00 — forked from eddiemoya/git-flip-last.sh
Flip the last two commits in a branch using git-cherry-pick, git-update-ref and git-rev-parse. Interesting exercise using quite a bit of plumbing commands.
#!/bin/bash
flip_last_branch_name=ongoing-flip-last;
git rev-parse --verify $flip_last_branch_name > /dev/null 2>&1;
res=$?;
if [ "$res" = "0" ]; then
echo "An ongoing flip-last is already in progress ($res) ... execute following command to remove it : git branch -D $flip_last_branch_name";
exit -1;
fi;
@eddiemoya
eddiemoya / wp-query-since.php
Last active August 5, 2022 15:59
Allows WP_Query to use a 'since' argument to query for relative date queries using `strtotime()`
<?php
/**
* Allows WP_Query to use a 'since' argument to query for
* relative date queries.
*
* Usage: Query posts from last 30 days
* $query = new WP_Query('since' => '-30 days');
*
* @uses strtotime()
* @author Eddie Moya
@eddiemoya
eddiemoya / git-unrm.sh
Last active August 5, 2022 15:59
Restores file that was deleted in a previous commit based on its last known state before it was removed.
### Git Unremove ##
# Adds an alias called "unrm" to retrieve a pile or path deleted at any point in the repositories history.
# Usage:
# git unrm [path]
# git unrm path/to/file
git config --global alias.unrm '!COMMIT=$(git log -1 --pretty=%h -- "$1"); git checkout $COMMIT^ -- "$1"; echo "File: $1, was restored from commit $COMMIT"; git show -s $COMMIT'
@eddiemoya
eddiemoya / git-rebase.sh
Last active August 5, 2022 15:58
Checks to see if the given branch is fast-forward-mergable with the given base. If not, it attempts to rebase the branch. If any conflicts arise, the rebase is aborted and the script exists with non-zero status.
#!/bin/bash
underline=$(tput sgr 0 1) # Underline
bold=$(tput bold) # Bold
normal=$(tput rmso) # Normal
# Dims
red=$(tput setaf 1) # red
green=$(tput setaf 2) # magenta
blue=$(tput setaf 4) # blue
@barraponto
barraponto / git-submodule-rm.sh
Created April 25, 2012 16:36
git submodule-rm
#!/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
}
@seamusabshere
seamusabshere / excelwebservice.vb
Created September 28, 2012 15:44
Excel VB for accessing http://carbon.brighterplanet.com/flights.txt as a web service (early 2011)
Option Explicit
Function GetBrighterPlanetApiKey()
GetBrighterPlanetApiKey = ActiveWorkbook.Worksheets("Setup").Range("C2").Value
End Function
Function IsEmissionEstimateServiceOnline()
If LCase(ActiveWorkbook.Worksheets("Setup").Range("C3").Value) = "online" And ThisWorkbook.HasFinishedWorkbookOpen() = True Then
IsEmissionEstimateServiceOnline = True
Else
@eddiemoya
eddiemoya / boilerplate-widget.php
Last active March 4, 2020 16:36
WordPress Boilerplate Widget
<?php /*
Plugin Name: Boilerplate Widget
Description: Starting point for building widgets quickly and easier
Version: 1.0
Author: Eddie Moya
/**
* IMPORTANT: Change the class name for each widget
*/
class Boilerplate_Widget extends WP_Widget {
@svebal
svebal / iitc-export-import-draw.js
Last active June 11, 2019 10:55
Plugin for IITC - let you im- / export your sketches from drawing tools
// ==UserScript==
// @id iitc-export-import-draw@skamander
// @name IITC plugin: export and import data from draw tools
// @version 0.0.1
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @description Import/Export Data from draw tools
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
@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.