Skip to content

Instantly share code, notes, and snippets.

View mmichaelis's full-sized avatar

Mark Michaelis mmichaelis

View GitHub Profile
@mmichaelis
mmichaelis / .gitignore
Created September 1, 2011 20:08
Monitoring System Load on Linux System with vmstat and generating graphs from it
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
# idea:
*.iml
*.ipr
*.iws
.idea/
# maven:
target/
@mmichaelis
mmichaelis / settitle.sh
Created October 24, 2011 08:30
Function to change Linux Terminal Tab Title (e. g. for gnome terminal)
#!/bin/bash
function title() {
local s="${1}"
echo -ne "\033]0;${s}\007"
}
title "${1}"
@mmichaelis
mmichaelis / BusyWaitingExamples.java
Created November 1, 2011 21:37
Examples of JBehave Stories
@Then("I see the main page")
public void seeMainPage() {
selenium.waitForCondition("selenium.browserbot.getCurrentWindow().someJavaScript",10000);
[...]
)
@Then("I see the main page")
public void seeMainPage() {
(new WebDriverWait(webDriver, 1000))
.until(new ExpectedCondition<Object>() {
@mmichaelis
mmichaelis / FullstopStory.java
Created November 7, 2011 18:29
BDD: Given, When, Then - Emergency Break (Related to http://jira.codehaus.org/browse/JBEHAVE-615)
@Then("the delete button will be enabled")
public void deleteButtonEnabled() {
// ...
}
@mmichaelis
mmichaelis / AmbiguousSteps.java
Created November 8, 2011 13:55
BDD: Ambiguous Step Definitions
@When("I log in as user $user with password $password")
public void login1(String user, String password) {
...
}
[...]
@When("I log in as user named $user with password $password")
public void login2(String user, String password) {
...
}
@mmichaelis
mmichaelis / RomanNumberTest.java
Created November 10, 2011 22:50
Coding Kata: Roman Numerals DDT JUnit Test
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.List;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
@mmichaelis
mmichaelis / AbstractReferenceTracker.java
Created November 22, 2011 10:48
BDD Design Pattern: Reference Tracker
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/**
* <p>
* Tracks references between BDD steps. Typically you need some global variables or something alike to remember
@mmichaelis
mmichaelis / BadStory.story
Created November 25, 2011 08:21
BDD: Stories which really matter
Scenario: Edit String Property Field
!--
Given I am logged in
When I create document A of type Article
And I enter some text T into property Title
Then the preview will update to contain text T
@mmichaelis
mmichaelis / bash_script_template.sh
Last active February 13, 2017 13:56
Template with some convenience settings for bash scripts.
#!/usr/bin/env bash
set -o nounset
set -o pipefail
set -o errexit
### Uncomment to enable debugging
#set -o verbose
#set -o xtrace
declare -r BOLD="$(tput bold)"
@mmichaelis
mmichaelis / .git-prune-orphaned-tracking-branches.ps1
Last active April 3, 2019 08:44
Based on Erik Aybar's 'Git Tip: Deleting Old Local Branches', this snippet will delete all local branches which are tracking remote branches which are gone meanwhile, for example because they already got merged.
git branch -vv|select-string "\[origin/(.*): gone\]"|%{$_.matches.groups[1].value}|%{git branch -D $_}