Skip to content

Instantly share code, notes, and snippets.

View saw303's full-sized avatar

Silvio Wangler saw303

View GitHub Profile
@saw303
saw303 / cwebp
Created January 27, 2014 14:33
Iterate on files using bash (template to convert PNGs and JPEGs to WebPs)
#!/bin/bash
for f in /tmp/*.{JPG,jpg,PNG,png};
do
FILE="$f.webp"
if [ ! -f $FILE ]
then
echo "Converting image $f to $(basename $f).webp";
else
echo "WebP image $(basename $f).webp does exist";
@saw303
saw303 / Spring Security SHA-512 hasing
Last active August 29, 2015 13:57
A script to generate a valid SHA-512 HEX-ified hashes to reset a users password
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
import java.security.SecureRandom
def password = 'my pwd'
def username = 'a users name'
def passwordToHash = "${password}{${username}}"
MessageDigest md = MessageDigest.getInstance 'SHA-512'
byte[] bytes = md.digest passwordToHash.getBytes()
@saw303
saw303 / dbSize.sql
Created April 22, 2014 13:57
Retrieve MySQL Database size
SELECT table_schema "DB Name",
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables
GROUP BY table_schema;
@ContextConfiguration("classpath:applicationContextRestIntegrationTest.xml")
@ActiveProfiles(['local', 'compliance'])
@TestExecutionListeners([DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class])
class RestSpec extends Specification implements JaxrsInterceptorRegistryListener {
@Autowired
ApplicationContext applicationContext
@Autowired
KsdApiSchemaRequestFilter filter
@saw303
saw303 / clean-gradle-cache
Created December 1, 2014 07:22
This script deletes all folders in the local Gradle cache that version is lower than a specific one
def baseName = '3.05.BUILD-'
def version = '161'
def composedName = "${baseName}${version}"
def rootDir = new File('/home/saw/.gradle/caches/artifacts-24/filestore/com.adcubum.syrius')
assert rootDir.exists() && rootDir.canWrite()
def killList = []
@saw303
saw303 / Proxy.groovy
Created December 3, 2014 20:26
Vert.x proxy verticle
/**
* @author Silvio Wangler
*/
def logger = container.logger
def server = vertx.createHttpServer().requestHandler { req ->
logger.info "Proxying request: ${req.uri}. Going to url ${req.params.url}"
def icalA()
{
def start = new Date(114,11,22,19,10,0)
def end = new Date(114,11,22,20,0,0)
render( contentType: params.format == 'ics' ? 'text/calendar' : 'text/plain', filename: "ical-a.ics") {
calendar {
events {
event(
start: start,
end: end,