Skip to content

Instantly share code, notes, and snippets.

View RaffaeleSgarro's full-sized avatar

Raffaele Sgarro RaffaeleSgarro

View GitHub Profile
@RaffaeleSgarro
RaffaeleSgarro / EnsureAllFieldsAreRead.java
Created January 13, 2016 22:13
Test library to assert that all getters of a bean are called using Javassist proxies
package com.stackoverflow;
import javassist.util.proxy.MethodHandler;
import javassist.util.proxy.ProxyFactory;
import javassist.util.proxy.ProxyObject;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.beans.*;
import java.lang.reflect.Method;
package com.stackoverflow;
import org.apache.commons.io.IOUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.*;
import java.nio.file.Files;
import static org.testng.Assert.assertEquals;
@RaffaeleSgarro
RaffaeleSgarro / ConvolutionTest.java
Last active March 25, 2023 05:33
Image processing: convolution matrices in Java
package stackoverflow;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
public class ConvolutionTest {
@RaffaeleSgarro
RaffaeleSgarro / RhinoHowToReadJavascriptNumbersFromJavaMethod.java
Created May 12, 2015 21:36
Rhino: read Javascript numbers returned from Java method
package stackoverflow;
import sun.org.mozilla.javascript.internal.Context;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.util.Date;
/*
* See question at http://stackoverflow.com/q/30185079/315306
@RaffaeleSgarro
RaffaeleSgarro / add_to_whitelist.py
Created April 15, 2015 09:27
Add user to whitelist
#!/usr/bin/env python
# Usage add_to_whitelist.py $FILENAME $USERNAME
import sys
def eval_line(line):
if line.startswith('#'):
return line
if '=' in line:
key, val = line.split('=')
if key == 'app.store.access.list':
@RaffaeleSgarro
RaffaeleSgarro / App.java
Created March 31, 2015 17:58
Demo JOOX program
package app;
import org.joox.JOOX;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
package stackoverflow;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@RaffaeleSgarro
RaffaeleSgarro / Acceptable.java
Created November 23, 2014 09:02
Java LazyIterator
package stackoverflow;
public interface Acceptable {
boolean accept();
}
@RaffaeleSgarro
RaffaeleSgarro / PlotBandCalculator.java
Created July 14, 2014 19:35
GWT/Highchart highlight a plot band
package stackoverflow;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class PlotBandCalculator {
private int hourStart, lengthInHours;
@RaffaeleSgarro
RaffaeleSgarro / .htaccess
Last active August 29, 2015 13:56
Simple breadcrumb for PHP scripts apps deployed by mapping request paths to the server's filesystem
RewriteEngine On
RewriteRule index.php index.php [END]
RewriteRule (.*) index.php?request=$1 [END]