Skip to content

Instantly share code, notes, and snippets.

View jamesmorgan's full-sized avatar

James Morgan jamesmorgan

View GitHub Profile
@jamesmorgan
jamesmorgan / AdobeReaderPrinting.java
Created March 15, 2012 18:35
How to manually print through Adobe Reader on Windows
public class AdobeReaderPrinting {
public static void main(final String[] args) {
final File file = new File("src/test/resources/tests/Sample_Printing.pdf");
final Runtime r = Runtime.getRuntime();
Process p = null;
try {
// Information about command line printing flags can be foud at http://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Acrobat10_SDK_HTMLHelp&file=DevFAQ_UnderstandingSDK.22.31.html
final String printing =
"C:\\Program Files (x86)\\Adobe\\Reader 10.0\\Reader\\AcroRd32.exe /s /h /t " + file.getCanonicalPath()
@jamesmorgan
jamesmorgan / PdfRendererPrinting.java
Created April 15, 2012 15:58
Printing PDFs through PdfRenderer library
public class PdfRendererPrinting {
public static void main(final String[] args) {
PrintingHelper.lookupAllPrinters();
final PrintService[] printers = PrintingHelper.findPrinterOutputLocation("\\\\My_Remote_Or_Locally_Installed_Printer");
if (0 == printers.length || 1 < printers.length) {
// Handle
}
final PrintService printService = printers[0];
PrintingHelper.listsPrinterAttributes(printService);
@jamesmorgan
jamesmorgan / JPdfPrinting.java
Created April 15, 2012 16:02
Printing PDFs through JPDF library
public class JPdfPrinting {
public static void main(final String[] args) {
PrintingHelper.lookupAllPrinters();
final PrintService[] printers = PrintingHelper.findPrinterOutputLocation("\\\\My_Remote_Or_Locally_Installed_Printer");
if (0 == printers.length || 1 < printers.length) {
// Handle
}
final PrintService printService = printers[0];
PrintingHelper.listsPrinterAttributes(printService);
@jamesmorgan
jamesmorgan / IcePdfPrinting.java
Created April 15, 2012 16:03
Printing PDFs through IcePDF library
public class IcePdfPrinting {
public static void main(final String[] args) {
PrintingHelper.lookupAllPrinters();
final PrintService[] printers = PrintingHelper.findPrinterOutputLocation("\\\\My_Remote_Or_Locally_Installed_Printer");
if (0 == printers.length || 1 < printers.length) {
// Handle
}
final PrintService printService = printers[0];
PrintingHelper.listsPrinterAttributes(printService);
@jamesmorgan
jamesmorgan / spring-reloadableProperties.xml
Created August 8, 2012 09:42
Example Spring Reloadable Properties Configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
">
<import resource="classpath:/spring/spring-defaultConfiguration.xml" />
@jamesmorgan
jamesmorgan / AutowiredPropertyBean.java
Created August 8, 2012 09:44
Sample Annotated Bean
@Component
public class AutowiredPropertyBean {
private String notAnnotated = "Original value";
@ReloadableProperty("not.in.the.file")
private String withDefaultValue = "Default Value";
@ReloadableProperty("not.in.the.file")
private int primitiveWithDefaultValue = 55;
@jamesmorgan
jamesmorgan / application.properties
Created August 8, 2012 09:50
Sample Application Properties
dynamicProperty.longValue=12345
dynamicProperty.substitutionProperty=${dynamicProperty.substitutionValue}
dynamicProperty.doubleValue=12345.67
dynamicProperty.localTimeValue=12:22:45
dynamicProperty.stringValue=Injected String Value
dynamicProperty.substitutionValue=elephant
dynamicProperty.bigDecimalValue=20012.56
dynamicProperty.intValue=42
dynamicProperty.localDateValue=2009-06-12
dynamicProperty.periodValue=00:12:22
@jamesmorgan
jamesmorgan / pom.xml
Created October 13, 2012 11:36
MavenEnforcer Plugin Example
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
@jamesmorgan
jamesmorgan / applet.js
Last active August 29, 2015 14:02
Cut down version of applet.js with scrollview popup submenus
/** Allows import of other files e.g. const GitHub=imports.github; = github.js */
imports.searchPath.push(imports.ui.appletManager.appletMeta["github-projects@morgan-design.com"].path);
/** Imports START **/
const Mainloop = imports.mainloop;
const Lang = imports.lang;
const Gettext = imports.gettext.domain('cinnamon-applets');
const _ = Gettext.gettext;
const Cinnamon = imports.gi.Cinnamon;
const St = imports.gi.St;
@jamesmorgan
jamesmorgan / example-event-emitter-competition-service.ts
Last active March 19, 2016 09:21
Example Angular2 EventEmitter in TypeScript
export class CompetitionsService {
/** Create a EventEmitter - constructing with true to make async */
onCompetitionsChanged = new EventEmitter<>(true);
constructor(private _http:Http) {
_http.get('competitions.json')
.subscribe(
data => {
//Broadcast the event to anyone who is listening