Skip to content

Instantly share code, notes, and snippets.

View ItGumby's full-sized avatar

Brian Street ItGumby

View GitHub Profile
var docWidth = document.documentElement.offsetWidth;
[].forEach.call(
document.querySelectorAll('*'),
function(el) {
if (el.offsetWidth > docWidth) {
console.log(el);
}
}
);
@ItGumby
ItGumby / WebServer.groovy
Created December 21, 2017 18:54
WebServer.groovy
#! /usr/bin/env groovy
import com.sun.net.httpserver.HttpServer
/**
* http://localhost:8080/hello
*/
HttpServer.create(new InetSocketAddress(8080), 0).with {
createContext("/hello") { http ->
http.responseHeaders.add("Content-type", "text/plain")
http.sendResponseHeaders(200, 0)
@ItGumby
ItGumby / JcrQueryLibrary.md
Created November 16, 2017 22:38 — forked from floriankraft/JcrQueryLibrary.md
Some useful JCR queries (XPATH, SQL2) for AEM/CQ development.

SQL2

All nodes with a specific name

SELECT * FROM [nt:unstructured] AS node
WHERE ISDESCENDANTNODE(node, "/search/in/path")
AND NAME() = "nodeName"

All pages below content path

@ItGumby
ItGumby / spinner.groovy
Created October 13, 2016 03:16
groovy example of displaying a spinner in CLI apps/scripts
// based on http://groovyconsole.appspot.com/script/277001 from melix
def spinner = '|/-\\'
print ' ' // need to print something so it can be deleted
(0..100).each { i ->
print "\u0008${spinner[i%4]}"
Thread.sleep(100) // replace with whatever operation you want ;)
}
@ItGumby
ItGumby / java8-time.groovy
Last active August 13, 2016 04:55
Scanning odd timezones via java.time.* (Java8)
// inspired by https://kousenit.org/2016/07/16/fun-with-time-zones-in-java-8/
import java.time.*
import java.time.format.*
final boolean shouldIncludeHourOffsets = false
LocalDateTime now = LocalDateTime.now()
List<ZonedDateTime> zdts = ZoneId.availableZoneIds
.collect { now.atZone(ZoneId.of(it)) }
.findAll { shouldIncludeHourOffsets || it.offset.totalSeconds % (60*60) != 0 }
.sort { it.offset.totalSeconds }
@ItGumby
ItGumby / SimpleSoap.groovy
Created October 24, 2014 02:33
Simple SOAP Example (without JAXB) using groovy and Spring WebServices. Based on http://spring.io/guides/gs/consuming-web-service/, but as a single-file script
@Grab('org.springframework.ws:spring-ws-core:2.2.0.RELEASE')
@Grab('org.springframework.ws:spring-xml:2.2.0.RELEASE')
import org.springframework.ws.client.core.WebServiceTemplate
import org.springframework.ws.soap.client.core.SoapActionCallback
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory
import org.springframework.xml.transform.StringSource
import groovy.util.slurpersupport.GPathResult
import groovy.util.XmlSlurper
@ItGumby
ItGumby / build.gradle
Last active October 11, 2017 07:28 — forked from ysb33r/gist:0c534d165863628a07cc
gradle build file for presentations from asciidoctor and deck.js
// You will need the VFS plugin
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.0'
classpath 'org.ysb33r.gradle:vfs-gradle-plugin:0.5'
classpath 'commons-httpclient:commons-httpclient:3.1'