Skip to content

Instantly share code, notes, and snippets.

View dpbackes's full-sized avatar

Dan Backes dpbackes

  • Articulate
  • Madison, WI
View GitHub Profile

Using Git Command Line for Feature Dev

Here's an example of what I do with git on the command line during the course of developing a feature. At the start I am on the main branch with no local modifications

First, create a named branch for the feature

git checkout -b MyFeature

Then, I begin to write the feature. As I'm going, I'll make commits to save state in case I want to go back.

@dpbackes
dpbackes / StateTransitions.cs
Created October 10, 2017 13:39
A set of classes and interfaces to build a functional state transition machine using a nice syntax
internal sealed class StateTransitionPoolFactory<TState, TObject>
{
private readonly Dictionary<Tuple<TState, TState>, Action<TObject>> transitions = new Dictionary<Tuple<TState, TState>, Action<TObject>>();
private readonly List<TState> toStates = new List<TState>();
private TState fromState;
private bool fromDefined;
private bool readyForNewInitialState = true;
public StateTransitionPoolFactory<TState, TObject> From(TState state)
@dpbackes
dpbackes / DeliverSelected.js
Last active June 28, 2017 16:17
A bookmarklet to format selected pivotal stories for delivering. Demo: https://jsfiddle.net/7zmn735f/1/
var func = function() {
var list = {};
$(".selected").each(function(){
list[$(this).parent().parent().attr('class').replace(/.*story_(\d+).*/,"$1")] = $(this).parent().parent().find('.story_name').text();
});
var result = Object.keys(list).map(key => "[Delivers #" + key + "] " + list[key]).join("<br>");
window.open("data:text/html,"+result);
};
func()
function Review-PullRequest {
param(
[Parameter(Mandatory=$false)]
[string]$Number
)
Invoke-Expression "git fetch origin"
Invoke-Expression "git fetch origin refs/pull/$Number/head --"
$commits = Invoke-Expression "git rev-list origin/master..FETCH_HEAD --"
git branch --merged master | ? { $_ -notmatch '(^\*)|(^. master$)' } | % { git branch -d $_.Substring(2) }
@dpbackes
dpbackes / gist:1638592178f3d20d3042
Created September 5, 2014 14:58
Change all relative references to common to point to solutiondir instead
(Get-ChildItem -Recurse -Filter *.csproj | Where-Object { Select-String '(\.\.\\)+[cC]ommon' $_ -Quiet }) | Foreach-Object {$file = $_.FullName; (Get-Content $_.FullName) | Foreach-Object {$_ -replace '(\.\.\\)+[Cc]ommon', '$(SolutionDir)\Common'} | Set-Content $file}
@dpbackes
dpbackes / Makefile
Created March 11, 2014 03:16
Wisconsin Population Density
GENERATED_FILES = \
wi.json
all: $(GENERATED_FILES)
.PHONY: clean all
clean:
rm -rf -- $(GENERATED_FILES) build
@dpbackes
dpbackes / Makefile
Last active August 29, 2015 13:57
Wisconsin Census Tracts
GENERATED_FILES = \
wi.json
all: $(GENERATED_FILES)
.PHONY: clean all
clean:
rm -rf -- $(GENERATED_FILES) build
@dpbackes
dpbackes / MergeSort.js
Last active December 15, 2015 01:49
A Javascript implementation of the merge sort algorithm
/*
Runs the mege sort algorithm on the passed in list using the specified compare function
The compare function should take two parameters. It should return -1 if the first parameter
is less than the second parameter, 0 if they are equal, and 1 if the second parameter is
less than the first
see http://en.wikipedia.org/wiki/Merge_sort for more detail
*/
function MergeSort(list, compareFunc)
@dpbackes
dpbackes / MultiplicationTableTweet
Created February 28, 2013 23:04
a javascript multiplication table that fits in a tweet.
var o=" ";for(var i=0;i<10;i++){o+=i+" "}o+='\n';for(var i=0;i<10;i++){o+=i+" ";for(var j=0;j<10;j++){o+=i*j+" "}o+="\n"}console.log(o);