Skip to content

Instantly share code, notes, and snippets.

View jamesmorgan's full-sized avatar

James Morgan jamesmorgan

View GitHub Profile
@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 / logging_aspect_example.java
Created August 4, 2011 12:38
Sample Logging Aspect
@Aspect
public class LoggingAspect {
private ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
@Before("execution(@com.morgan.design.demo.annotation.LogMe(com.morgan.design.demo.annotation.LoggingLevel.WARN) * *(..))")
public void loggerWarn(final JoinPoint jp) throws Throwable {
final Logger logger = getLoggerForClass(jp);
logger.warn(buildLogging(jp));
}
@jamesmorgan
jamesmorgan / sample_logging_annotation_example.java
Created August 4, 2011 12:23
Deomstration using the Loggin annotation
package com.morgan.design.demo;
import org.springframework.stereotype.Component;
import com.morgan.design.demo.annotation.LogMe;
import com.morgan.design.demo.annotation.LoggingLevel;
@Component
public class LoggingExample {
@jamesmorgan
jamesmorgan / itext_qrcode_snippet.java
Created September 14, 2011 07:35
Sample iText QRCode creation snippet
PushbuttonField barcodeButton = acroFields.getNewPushbuttonFromField("barcode_button");
if(barcodeButton){
// These settings are optional, null can be passed in as the four argument to BarcodeQRCode
Map<EncodeHintType, Object> hints = Maps.newHashMap();
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
hints.put(EncodeHintType.CHARACTER_SET, "ISO-8859-1");
BarcodeQRCode qrcode = new BarcodeQRCode("SomeBarcodeData_123456789", 0, 0, hints);
barcodeButton.setLayout(PushbuttonField.LAYOUT_ICON_ONLY);
@jamesmorgan
jamesmorgan / ObjectArrayMatcher.java
Created September 20, 2011 19:51
Simple List Object Array Matcher with usage
/**
* An expected call to my matcher
*/
this.context.checking(new Expectations() {
{
one(someMockedService).save(with(args), with(def), with(thisObjectArray(batch)));
}
});
this.seviceUnderTest.source(args);
@jamesmorgan
jamesmorgan / InitialSqlBuilkder.java
Created November 2, 2011 08:33
Initial implementation of a SQL creation builder used for generating SQL migration queries.
String rawSql = new AlterTableBuild()
.alterTable(Person.class)
.addColumn(Person.FOO_ID)
.after(Person.NAME)
.migrate()
.from("old_column")
.to(Person.FOO_ID)
.build();
this.db.executeRaw(rawSql);
@jamesmorgan
jamesmorgan / UpgradeHelper.java
Created November 10, 2011 08:25
Utility class for loading migration files in Android assets directory
/**
* Used as a aid in the migration process for, loading required SQL files as specified by a given version
*
* @author James Edward Morgan
*/
public class UpgradeHelper {
private static final String LOG_TAG = "UpgradeHelper";
protected static final Set<Integer> VERSION;
@jamesmorgan
jamesmorgan / TODO.java
Created January 8, 2012 15:05
TODO.java - My version of a roadmap...
package com.morgan.design;
public class TODO {
private TODO() {
}
//@formatter:off
// ////////////////////////
// Build / Configuration //
@jamesmorgan
jamesmorgan / DynamicAssetsLoader.as
Created February 9, 2012 19:34
Loads a given image asset in ActionScript, setting the source on the given image
public class DynamicAssetsLoader {
public static function loadImage(image:Image, assetUri:String):void
{
// if not
if(!assetUri){
image.includeInLayout = false;
image.visible = false;
image.source = null;
return;
@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()