Skip to content

Instantly share code, notes, and snippets.

@goofyahead
goofyahead / Jenkinsfile
Created May 27, 2019 09:40 — forked from jonico/Jenkinsfile
Example for a full blown Jenkins pipeline script with multiple stages, kubernetes templates, shared volumes, input steps, injected credentials, heroku deploy, sonarqube and artifactory integration, Docker containers, multiple Git commit statuses, PR merge vs branch build detection, REST API calls to GitHub deployment API, stage timeouts, stage c…
#!groovy
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label, yaml: """
spec:
containers:
- name: mvn
image: maven:3.3.9-jdk-8-alpine
@goofyahead
goofyahead / Jenkinsfile.groovy
Created April 15, 2019 06:29 — forked from aerobless/Jenkinsfile.groovy
An example Jenkinsfile for a build pipeline using gradle, junit, selenium, checkstyle
pipeline {
agent {
label 'agentId' //The id of the slave/agent where the build should be executed, if it doesn't matter use "agent any" instead.
}
triggers {
cron('H */8 * * *') //regular builds
pollSCM('* * * * *') //polling for changes, here once a minute
}
@goofyahead
goofyahead / testrunner.html
Created December 19, 2017 14:06 — forked from jonnyreeves/testrunner.html
Unit Testing Promises with Sinon.js
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen" />
<!-- when.js Promises implementation -->
<script src="https://raw.github.com/cujojs/when/master/when.js"></script>
<!-- Unit testing and mocking framework -->
<script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>
@goofyahead
goofyahead / Interceptor.java
Created June 7, 2017 04:08 — forked from alex-shpak/Interceptor.java
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON
@goofyahead
goofyahead / Place.js
Created September 15, 2016 14:53 — forked from PascalAnimateur/Place.js
Geospatial example in Sails.js using native MongoDB query
/* Place model */
module.exports = {
attributes: {
name: {
type: 'string',
required: true
},
@goofyahead
goofyahead / BitmapScaler.java
Last active September 7, 2016 12:12 — forked from nesquena/BitmapScaler.java
Easy utility for scaling bitmaps
public class BitmapScaler
{
// scale and keep aspect ratio
public static Bitmap scaleToFitWidth(Bitmap b, int width)
{
float factor = width / (float) b.getWidth();
return Bitmap.createScaledBitmap(b, width, (int) (b.getHeight() * factor), true);
}
android.libraryVariants.all { variant ->
def name = variant.buildType.name
if (name.equals(com.android.builder.BuilderConstants.DEBUG)) {
return; // Skip debug builds.
}
def task = project.tasks.create "jar${name.capitalize()}", Jar
task.dependsOn variant.javaCompile
//Include Java classes
task.from variant.javaCompile.destinationDir
//Include dependent jars with some exceptions
import java.util.ArrayList;
import java.util.List;
/**
* Generic enabled Object Oriented Switch/Case construct
* @param <T> type to switch on
*/
public class Switch<T extends Comparable<T>>
{
private final List<Case<T>> cases;