Instantly share code, notes, and snippets.

View PostRequestHelper.cs
public class PostRequestHelper
public static HttpRequestMessage Create(String path, Dictionary<string, string> formPostBodyData)
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, path)
Content = new FormUrlEncodedContent(ToFormPostData(formPostBodyData))
return httpRequestMessage;
View AntiForgeryHelper.cs
public class AntiForgeryHelper
public static string ExtractAntiForgeryToken(string htmlResponseText)
if (htmlResponseText == null) throw new ArgumentNullException("htmlResponseText");
System.Text.RegularExpressions.Match match = Regex.Match(htmlResponseText, @"\<input name=""__RequestVerificationToken"" type=""hidden"" value=""([^""]+)"" \/\>");
return match.Success ? match.Groups[1].Captures[0].Value : null;
View cookieshelper.cs
public class CookiesHelper
// Inspired from:
public static IDictionary<string, string> ExtractCookiesFromResponse(HttpResponseMessage response)
IDictionary<string, string> result = new Dictionary<string, string>();
IEnumerable<string> values;

When running maven you might see a different JAVA_HOME version than when you're running java -version

In general sense this means when you run mvn a new shell is opened and your JAVA_HOME is (re)set. This means, especially if you need to work with different Java versions, that you must be sure you don't override the version you're working on.

First thing you need to make sure is that you only set JAVA_HOME once.

In relation to Maven you might have something set in :

  • ~/.mavenrc
  • /etc/mavenrc
View git_current_branch_term
Add this to .profile (if not exist, create it):
# This shows the git branch of the current directory
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
View vimrc
call pathogen#infect()
syntax on
filetype plugin indent on
"Add mapping for opening NERDTree
nmap <silent> <C-D> :NERDTreeToggle<CR>
colorscheme distinguished
" set default height and width for gvim
View gist:3875680
public void nastyBug() {
game.roll(10); // spare
rollMany(14, 0);
Assert.assertEquals(32, game.score());
View gist:3696795
Possible improvements:
- put display numbers into one dimensional array
Possible additions:
- make it possible to use different character sets (your own numbers)