Skip to content

Instantly share code, notes, and snippets.

View aslakhellesoy's full-sized avatar
🤠
typing...

Aslak Hellesøy aslakhellesoy

🤠
typing...
View GitHub Profile
@aslakhellesoy
aslakhellesoy / github-issues-milestones-bookmarklet.js
Last active December 18, 2015 05:49
This bookmarklet shows what milestone each issue is assigned to. Very handy when moving a bunch of issues into different milestones. Github - can you make this default behaviour on Github?
javascript:$('.issue-list-item').each(function(n, dom_issue) {
var id = dom_issue.id.match(/issue_(\d+)/)[1];
/* Create your own here: https://github.com/settings/applications */
var token = 'SECRET';
$.get('https://api.github.com/repos' + window.location.pathname + '/' + id + '?access_token=' + token).success(function(issue) {
if(issue.milestone && issue.milestone.title) {
var $issue_number = $(dom_issue).find('.list-group-item-number');
$issue_number.text('(' + issue.milestone.title + ') ' + $issue_number.text());
}
}).error(function(e) {
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running CucumberTest
log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager).
log4j:WARN Please initialize the log4j system properly.
@selenium @browse
Feature: Browse Tests
As a user
@aslakhellesoy
aslakhellesoy / cucumber.json
Last active December 15, 2015 19:19
Cucumber configuration
{
"options": {
"glue": "classpath:com/company/app/stepdefs",
"format": ["pretty", "json:target/cucumber.json"]
},
"environments": {
"firefox": {"driver": "org.openqa.selenium.firefox.FirefoxDriver"},
"chrome": {"driver": "org.openqa.selenium.chrome.ChromeDriver"}
}
}
@aslakhellesoy
aslakhellesoy / gfm.sh
Last active November 23, 2016 09:57
Compile and show GFM docs in your browser.https://help.github.com/articles/github-flavored-markdown
#!/bin/sh
# Compile and show [GFM](https://help.github.com/articles/github-flavored-markdown) docs in your browser.
# Before this works you need to `gem install bcat`
#
# Usage: gfm.sh FILE.md
#
curl --silent --data-binary @- https://api.github.com/markdown/raw -H "Content-Type: text/plain" | bcat
#!/bin/bash
# Usage: flac16.sh SOURCEDIR DESTDIR
# DESTDIR should have no spaces since sox chokes on it.
set -e
SOURCEDIR=$1
DESTDIR=$(cd $(dirname "$2"); pwd)/$(basename "$2")
cd "$SOURCEDIR"
rm -f tmp_flac16_source.flac
for file in *.flac
do
@aslakhellesoy
aslakhellesoy / MyStepdefs.java
Created November 14, 2012 16:01
How to embed text into your cucumber-jvm report with Java
import cucumber.api.Scenario;
public class MyStepdefs {
private Scenario scenario;
@Before
public void before(Scenario scenario) {
this.scenario = scenario;
}
Scenario Outline: Create comments using supported media types
Given I have an existing default incident
And I know the ID for the default incident as "defaultIncidentId"
And my payload type is "<type>" and I am accepting "<type>"
When I POST my payload to "/v1/incidents/{defaultIncidentId}/comments"
Then a response of 201 (CREATED) is returned
Examples:
| type |
| application/json |
@aslakhellesoy
aslakhellesoy / usejava6
Created October 24, 2012 19:11
Switch between java 6 and 7 versions after Apple removed Java Jreferences
#!/bin/sh
cd /System/Library/Frameworks/JavaVM.framework/Versions && sudo mv Current Current.bak && sudo ln -s CurrentJDK Current
java -version
function the_x(x, cb) {
console.log('x', x);
cb();
}
Given(/x is (.*)/, the_x);
Given(/i decide x/, function(cb) {
foo(97, cb);
});
@aslakhellesoy
aslakhellesoy / deepMerge.java
Created October 9, 2012 13:28
Merge two maps in Java
// This is fancier than Map.putAll(Map)
public Map deepMerge(Map original, Map newMap) {
for (Object key : newMap.keySet()) {
if (newMap.get(key) instanceof Map && original.get(key) instanceof Map) {
Map originalChild = (Map) original.get(key);
Map newChild = (Map) newMap.get(key);
original.put(key, deepMerge(originalChild, newChild));
} else {
original.put(key, newMap.get(key));
}