Skip to content

Instantly share code, notes, and snippets.

@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 / 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
@eddiemoya
eddiemoya / git-ffable.sh
Created April 23, 2014 17:37
Bash script that checks if a branch is fast-forwardable, and it its not offers to rebase it for you. Once rebased, the script asks before ff merging.
#!/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
@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.
@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'
##
# 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"
@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
@xentek
xentek / wp-unit-tests.md
Created August 26, 2012 19:06
WordPress Unit Tests Quick Start

WordPress Unit Tests Quick Start Guide

This quick start guide is geared towards installing PHPUnit on OSX in order to run the WordPress unit tests. It uses homebrew to install PHP using homebrew-php. You can likely skip this step if you've already got php and pear installed properly.

If you use MAMP, then try these instructions to use MAMP's php and pear to install PHPUnit.

install homebrew

ruby &lt;(curl -fsSkL raw.github.com/mxcl/homebrew/go)