Skip to content

Instantly share code, notes, and snippets.

View maciejwalkowiak's full-sized avatar

Maciej Walkowiak maciejwalkowiak

View GitHub Profile
@eeichinger
eeichinger / ConcordionSpringJunit4ClassRunner.java
Created May 17, 2012 15:56
Spring Test / Concordion integration - integrate Concordion with Spring's test runner
package testsupport;
import org.concordion.api.ResultSummary;
import org.concordion.internal.FixtureRunner;
import org.junit.runner.Description;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ogavrisevs
ogavrisevs / gist:2881356
Created June 6, 2012 11:25
Create pdf using iText 2.1.7 (manual add styles + unicode font )
InputStreamReader reader = new InputStreamReader(inputStream);
ByteArrayOutputStream outputStream = null;
try {
Document document = new Document();
outputStream = new ByteArrayOutputStream();
PdfWriter.getInstance(document, outputStream);
Map<String, String> pc2 = new HashMap<String, String>();
pc2.put("line-height", "115%");
@Riduidel
Riduidel / pom.xml
Created June 21, 2012 15:52
Full configuration for buildnumber-maven-plugin with SVN 1.7 and svnjava/javasvn
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
@madan712
madan712 / ImageCropper.java
Created September 2, 2012 17:46
Java - Simple image cropping example
/* ImageCropper.java */
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class ImageCropper {
@chbaranowski
chbaranowski / JUnitEnclosedParameterizedTest.java
Created October 2, 2012 07:15
JUnitEnclosedParameterizedTest Demo
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@agentgt
agentgt / ExampleController.java
Last active December 27, 2022 00:37
Spring Immutable Object Web Data Binding
public class ExampleController {
@RequestMapping(value = {"/blah", ""})
public @ResponseBody Map<String, Object> blah(@Valid Blah blah, BindingResult errors, ModelMap model) {
if (errors.hasErrors()) {
return ModelUtils.mapBuilder().put("status", "errors").build();
}
return ModelUtils.mapBuilder().put("status", blah.getFirst() + " " + blah.getLast()).build();
}
public static class Blah {
@conorbranagan
conorbranagan / gist:4513828
Last active August 16, 2024 14:06
Linux System Metrics

Linux System Metrics

CPU

  • system.cpu.idle: % Idle CPU
  • system.cpu.system: % System CPU
  • system.cpu.user: % User CPU

Disk

@jkuipers
jkuipers / formMacros.ftl
Last active June 21, 2022 13:43
FreeMarker macros for rendering Bootstrap horizontal form inputs in Spring-MVC applications
<#ftl strip_whitespace=true>
<#import "spring.ftl" as spring />
<#-- This file contains form-related macros for use in the other Freemarker template files.
The generated HTML is intended for use with Twitter Bootstrap based forms. -->
<#--
* radioButtons
*
* @param path the name of the field to bind to
@Daniel15
Daniel15 / 1_README.md
Last active March 22, 2025 04:24
Complete Google Drive File Picker example

Google Drive File Picker Example

This is an example of how to use the Google Drive file picker and Google Drive API to retrieve files from Google Drive using pure JavaScript. At the time of writing (14th July 2013), Google have good examples for using these two APIs separately, but no documentation on using them together.

Note that this is just sample code, designed to be concise to demonstrate the API. In a production environment, you should include more error handling.

See a demo at http://stuff.dan.cx/js/filepicker/google/

@esycat
esycat / PrettyPrinter.groovy
Last active November 5, 2024 13:54
A simple way to pretty print nested lists and maps in Groovy.
import static groovy.json.JsonOutput.*
def config = ['test': 'lalala']
println prettyPrint(toJson(config))