Skip to content

Instantly share code, notes, and snippets.

@sveinungkb
sveinungkb / AdnroidFieldNamingPolicy.java
Last active April 18, 2020 17:02
GSON Field naming policy taking Android m-prefix into account (e.g. mField and mHomeAddress).
package co.sveinung.utils;
import com.google.gson.FieldNamingStrategy;
import java.lang.reflect.Field;
import java.util.regex.Pattern;
/**
* Created by sveinung on 21.02.15.
*/
@sveinungkb
sveinungkb / record-history.sh
Created March 2, 2015 15:24
Simple bash script to compact and add markdown links to any jira issues or git PR references
#!/bin/sh
# Use this script to create markdowned release notes based on a previous point in git history, e.g. for HockeyApp uploads from Jenkins/Team City
# Store current reference with git log --pretty=format:'%H' -n 1 > git-reference and pass as first parameter to this script
# Usage: record-history <git sha in the past>
PREVIOUS=$1
CURRENT=$(git log --pretty=format:'%H' -n 1)
JIRA_BASE='https:\/\/your.jira.com\/browse\/'
@sveinungkb
sveinungkb / SystemProperties.java
Created March 18, 2015 14:25
Provides access to Android's system properties (read only)
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@sveinungkb
sveinungkb / generate-report.py
Last active October 28, 2020 06:42
HP Unified Functional Testing report to ANT JUnit XML
# By Sveinung Kval Bakken @ iHeartRadio
# http://tech.iheart.com
#
# This script will parse any HP Unified Functional Testing reports and generate ANT JUnit XML reports
# for use with Team City / Jenkins
import sys
from xml.dom import minidom
from xml.dom.minidom import Document, Element
@sveinungkb
sveinungkb / tc-grep-set-parameter.py
Created March 24, 2015 22:58
This python script will look for a regexp pattern in whatever is piped to it, and echo back a Team City service message to set this as a build time variable using a service message.
import fileinput
import sys
import re
valuePair = sys.argv[1]
name = valuePair.split("=")[0]
valuePattern = valuePair.split("=")[1]
if not (name and valuePattern):
print("Call like this 'echo \"Lorem ipsum doler sit\" | python tc-grep-set-parameter.py 'jibberish=(ipsum)'")
@sveinungkb
sveinungkb / android-screen-gif.sh
Last active May 23, 2017 14:41
Bash script to record screenshots on Android until interrupted, then assemble all screenshots to an animated GIF. Useful for demos etc. Requires ImageMagick's (convert) to be on your path.
#!/bin/sh
PREFIX="Screenshot-$(date +%Y%m%d-%H%M%S)"
BASE="/sdcard/$PREFIX"
DELAY=300
trap ctrl_c INT
function clean_up() {
rm -f $PREFIX*.png
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@sveinungkb
sveinungkb / github-history.py
Last active October 22, 2015 17:34
Simple script that will use Github's API to read a number of repo's commit history into .csv so it can be processed in other tools (Excel, R, Matlab)
import requests
import re
import os
import datetime
OAUTH_TOKEN = 'YOUR-TOKEN
ORGANIZATION = "org"
REPOS = ["repo1", "repo2"]
# Uncomment to get all repos for org
# REPOS = []
@sveinungkb
sveinungkb / AutomationTest.java
Created May 12, 2016 18:10
Convenient parent class for UI automation tests to ensure successful runs. Will wake screen, unlock if necessary and optionally show the home screen.
import android.app.Activity;
import android.app.Application;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;