Skip to content

Instantly share code, notes, and snippets.

@luismoramedina
luismoramedina / pom-fragment-build-plugins.xml
Created December 2, 2015 12:02
Tomcat 7 on pom.xml, run with mvn tomcat7:run and tomcat7:run-war
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
@luismoramedina
luismoramedina / gmavenplugin pom.xml
Created February 4, 2016 17:55
groovy maven plugin
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
@luismoramedina
luismoramedina / curl soap
Created February 4, 2016 17:58
curl command soap request
curl -i --header "content-type: text/xml" -d @src/test/resources/bks-b64-corporatetoken-request.xml http://localhost:8080/phoenix-sample-soapcorptoken/public/soap
@luismoramedina
luismoramedina / string 2 SOAPMessage
Created February 4, 2016 18:26
create SOAPMessage from string
/**
* Util to get a soapmessage from a string.
*/
private SOAPMessage getSoapMessageFromString(String xml) throws SOAPException, IOException {
MessageFactory factory = MessageFactory.newInstance()
factory.createMessage(new MimeHeaders(), new ByteArrayInputStream(xml.getBytes('UTF-8')))
}
@luismoramedina
luismoramedina / junit5 build.gradle
Created April 20, 2016 12:39
simple junit5 gradle configuration
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.junit:junit-gradle:5.0.0-ALPHA'
}
}
apply plugin: 'java'
@luismoramedina
luismoramedina / heavy_services.js
Created June 14, 2016 11:30
Emulates a heavy nodejs delayed rest service
http = require("http");
function sleep(milliSeconds, callback) {
var startTime = new Date().getTime();
while (new Date().getTime() < startTime + milliSeconds);
}
server = http.createServer(function (request, response) {
console.log(request);
console.log('a request');
@luismoramedina
luismoramedina / cli.groovy
Last active July 22, 2016 16:28
Groovy argument parse
#!/usr/bin/env groovy
def cli = new CliBuilder(usage: 'cli', stopAtNonOption: false)
cli.n('Force numeric on property set')
cli.h(longOpt: 'help', 'Show usage information')
cli.c(longOpt: 'config-server', args:1, argName:'server', 'Config server url')
cli.p(longOpt: 'profile', args:1, argName:'profile', 'Profile')
cli.l(longOpt: 'label', args:1, argName:'label', 'Label')
cli.u(longOpt: 'credentials', args:1, argName:'user:pass', 'Basic credentials')
@luismoramedina
luismoramedina / args.go
Created July 22, 2016 21:58
go command line
package main
import (
"flag"
"fmt"
)
func main() {
var cmd string
var i bool
@luismoramedina
luismoramedina / httpget.go
Created July 22, 2016 21:58
http connection in go
package main
import "fmt"
import "net/http"
func main() {
resp, error := http.Get("https://www.google.com/")
fmt.Println(resp)
fmt.Println(error)
}
@luismoramedina
luismoramedina / setbackground.groovy
Created August 10, 2016 14:44
set background gopro photo of the day ubuntu
#!/usr/bin/env groovy
def proxyParams = ""
def jsonUri = "https://api.gopro.com/v2/channels/feed/playlists/photo-of-the-day.json?platform=web"
//def data = get(jsonUri)
def commandJson = "wget -q -O - " + jsonUri + proxyParams
def data = commandJson.execute().text
json = new groovy.json.JsonSlurper().parseText(data)