Skip to content

Instantly share code, notes, and snippets.

Stefan Hendriks stefanhendriks

Block or report user

Report or block stefanhendriks

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
stefanhendriks / PostRequestHelper.cs
Last active May 11, 2016
Helper class to construct a HttpRequest message for easily POSTing data ( Core)
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;
stefanhendriks / AntiForgeryHelper.cs
Created May 11, 2016
AntiForgeryHelper class to read token from request (Asp.Net core)
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;
stefanhendriks / cookieshelper.cs
Last active May 11, 2019
A cookies helper class to easily read and set cookies on HttpRequest (Asp.Net Core)
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
stefanhendriks / git_current_branch_term
Created Dec 7, 2012
Show git branch in terminal (macOSX) of current directory
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
stefanhendriks / gist:3875680
Created Oct 11, 2012
Bowling game kata test - ultimate test for nasty bug
View gist:3875680
public void nastyBug() {
game.roll(10); // spare
rollMany(14, 0);
Assert.assertEquals(32, game.score());
stefanhendriks / gist:3696795
Created Sep 11, 2012
LEDDisplayKataJava thoughts
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)
You can’t perform that action at this time.