Skip to content

Instantly share code, notes, and snippets.

View michalmela's full-sized avatar
🍈

Michał Mela michalmela

🍈
View GitHub Profile
@tomwhoiscontrary
tomwhoiscontrary / Main.java
Last active June 25, 2024 16:37
A simple Java web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
import com.sun.net.httpserver.Filter;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.List;
@lyhcode
lyhcode / pdftrim
Created March 8, 2015 07:21
Remove text layer from PDF using Apache PDFBox in a Groovy script
#!/usr/bin/env groovy
@Grab('org.apache.pdfbox:pdfbox:1.8.8')
import org.apache.pdfbox.cos.COSArray
import org.apache.pdfbox.cos.COSString
import org.apache.pdfbox.pdfparser.PDFStreamParser
import org.apache.pdfbox.pdfwriter.ContentStreamWriter
import org.apache.pdfbox.pdmodel.PDDocument
import org.apache.pdfbox.pdmodel.PDPage
import org.apache.pdfbox.pdmodel.common.PDStream
import org.apache.pdfbox.util.PDFOperator
@sadikovi
sadikovi / LoginSimulation.scala
Created February 25, 2015 09:26
Another example of Gatling scenario with complex authentication/response processing and number of simple requests that have been used as a test.
package mobilepackage
import io.gatling.core.Predef._
import io.gatling.core.session._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import scala.util.parsing.json._
import general._
class LoginSimulation extends Simulation {
@melix
melix / body.tpl
Last active August 12, 2019 01:04
An example of improved template composition using fragments and the MarkupTemplateEngine
html {
head {
title(title)
}
body {
content()
}
}
/**
* HttpBuilder Testing
*/
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.2' )
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
def http = new HTTPBuilder( 'http://localhost:8080' )
@lyhcode
lyhcode / selenium_screenshot.groovy
Created December 30, 2012 14:35
Groovy + Selenium for Web ScreenShot Capturing
@Grapes([
@Grab('org.seleniumhq.selenium.client-drivers:selenium-java-client-driver:1.0.2'),
@Grab('org.seleniumhq.selenium:selenium-server:2.25.0'),
@GrabConfig(systemClassLoader=false, initContextClassLoader=true)
])
import com.thoughtworks.selenium.*
import org.openqa.selenium.server.*
seleniumServer = new SeleniumServer()
@lyhcode
lyhcode / jsoup_demo.groovy
Created December 30, 2012 13:34
Groovy + Jsoup
@Grab('org.jsoup:jsoup:1.7.1')
def doc = org.jsoup.Jsoup.connect("https://news.google.com/nwshp?hl=zh-TW&tab=wn").get()
doc.select("#s_POPULAR .titletext").each {
node->
println "title=${node.text()}"
}