Skip to content

Instantly share code, notes, and snippets.

Andrew Fray tenpn

Block or report user

Report or block tenpn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tenpn
tenpn / unusedgitremotebranches.sh
Created Oct 8, 2012
a bash script to list unused remote branches
View unusedgitremotebranches.sh
for branch in `git branch -r --merged develop`; do
echo $branch `git log $branch -1 --pretty=format:%ct`
done | sort -k2
@tenpn
tenpn / MapValue.cs
Created Jul 26, 2012
MapValue() takes an input in one range and remaps it to another. Very useful for AI and scripting.
View MapValue.cs
public static float MapValue(float inVal, float inFrom, float inTo, float outFrom, float outTo)
{
float inScale = (inFrom != inTo)
? ( ( inVal - inFrom ) / ( inTo - inFrom ) )
: 0.0f;
float outVal = outFrom + ( inScale * ( outTo - outFrom ) );
outVal = (outFrom < outTo )
? SomeClampFunction( outVal, outFrom, outTo )
: SomeClampFunction( outVal, outTo, outFrom );
return outVal;
@tenpn
tenpn / execute-shell-command-on-buffer
Created Apr 12, 2012
emacs function to execute a shell command with the current buffer filename as an argument
View execute-shell-command-on-buffer
;; eg when in a text file, (execute-shell-command-on-buffer "p4 edit %s") will check out the file in perforce
(defun execute-shell-command-on-buffer (shell-command-text)
(interactive "MShell command:")
(shell-command (format shell-command-text (shell-quote-argument buffer-file-name)))
)
View gist:1216696
#include <algorithm>
#include <vector>
#include <stdio>
int main()
{
typedef std::pair<int,int> Pos;
typedef std::pair<Pos, unsigned char> PosChar;
typedef vector<PosChar> list;
View Move all files from a pending changelist to a selected branch, leaves in default changelist
param([int]$changelistNum, [string]$destBranch)
$regex = "^\s+//[^/]+(/\S+)\s"
$sourceFiles = p4 change -o $changelistNum | select-string $regex | %{$_.matches[0]}
$sourceFiles | %{
$sourcePath = (p4 where $_.groups[0].value.trim()).split(' ')[2];
$destPath = (p4 where ($destBranch + $_.groups[1].value)).split(' ')[2];
p4 edit $destPath;
copy $sourcePath $destPath;
You can’t perform that action at this time.