Skip to content

Instantly share code, notes, and snippets.

View mikeholler's full-sized avatar

Michael Holler mikeholler

View GitHub Profile
@mikeholler
mikeholler / MatlabTimeHelper.java
Created February 7, 2014 15:37
Convert from MATLAB serial date time to Unix UTC milliseconds.
public class MatlabTimeHelper {
public static final int UNIX_EPOCH_START_MATLAB_DAYS = 719529;
public static long matlabToMillis(double matlab) {
return (long) (matlab - UNIX_EPOCH_START_MATLAB_DAYS) * 24 * 3600 * 1000;
}
public static double millisToMatlab(long millis) {
return millis / (24.0 * 3600 * 1000) + UNIX_EPOCH_START_MATLAB_DAYS;
@mikeholler
mikeholler / build.gradle
Created February 3, 2014 22:31
Task to print project version. Run using `./gradlew -q version`.
// Task to get current version of the project.
task version(type: VersionTask)
class VersionTask extends DefaultTask {
@TaskAction
def version() {
println project.version
}
}
@mikeholler
mikeholler / build.gradle
Created February 3, 2014 22:29
Publish binary, source, and javadoc jars to maven repository requiring username/password credentials.
apply plugin: 'java'
apply plugin: 'maven-publish'
task sourceJar(type: Jar) {
// Specifies a JAR that contains source code from the library.
from sourceSets.main.allJava
}
task fatJar(type: Jar, dependsOn: build) {
// Creates a JAR that contains all dependencies in addition to the library.
@mikeholler
mikeholler / build.gradle
Created February 3, 2014 22:27
Create javadoc jar build artifact.
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}
@mikeholler
mikeholler / build.gradle
Created February 3, 2014 22:27
Create source jar build artifact.
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
@mikeholler
mikeholler / build.gradle
Created February 3, 2014 22:26
Create "fat" jar containing dependencies.
jar {
// from http://fw-geekycoder.blogspot.com/2011/11/how-to-create-jar-with-dependencies-in.html
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest { attributes 'Main-Class': 'test.Main' }
}
@mikeholler
mikeholler / settings.gradle
Created February 3, 2014 22:21
Change project artifact name.
rootProject.name = "artifact-name"
@mikeholler
mikeholler / build.gradle
Created February 3, 2014 22:04
Examples of different remote Maven repositories: Maven Central, public, and a password protected Sonatype Nexus repository. Make sure to ignore gradle.properties and version control gradle.properties.example.
repositories {
mavenCentral()
maven {
// via https://support.sonatype.com/entries/21596297.html
url "http://www.sonatypenexus.com/maven/"
credentials {
username mavenUser
password mavenPass
}
}