Skip to content

Instantly share code, notes, and snippets.

View turesheim's full-sized avatar

Torkild U. Resheim turesheim

View GitHub Profile
@turesheim
turesheim / EPUBFileUtil.java
Created March 15, 2012 09:12
Various file utilities originally written for the EPUB utilities in Mylyn Docs, but contains useful bits that can be taken elsewhere.
/*******************************************************************************
* Copyright (c) 2011,2012 Torkild U. Resheim.
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Torkild U. Resheim - initial API and implementation
*******************************************************************************/
@turesheim
turesheim / bashrc.sh
Created September 27, 2011 07:25 — forked from dogmatic69/bashrc.sh
make git prompt more useful
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
@turesheim
turesheim / Data.java
Created May 6, 2011 17:49
Animated GIF in JFace TableViewer
public class Data {
boolean busy;
String firstName;
String lastName;
public Data(String firstName, String lastName, boolean busy) {
this.firstName = firstName;
this.lastName = lastName;
this.busy = busy;
}
@turesheim
turesheim / pixma2pdf.sh
Created May 5, 2011 06:51
Bash script to create PDF files using Canon Pixma scanner on Linux
#!/bin/bash
#-----------------------------------------------------------------------------
# pixma2pdf.sh version 2.0
#
# Copyright (c) 2009 Torkild U. Resheim - torkildr@gmail.com
# Released under the Eclipse Public License version 1.0
#-----------------------------------------------------------------------------
title="Canon Pixma - Scan to PDF"
dialog --title "$title" --checklist "Scan options" 10 50 10 \
@turesheim
turesheim / gist:956648
Created May 5, 2011 06:47
Invoking Eclipse Wizard programmatically
public void openWizard(String id) {
// First see if this is a "new wizard".
IWizardDescriptor descriptor = PlatformUI.getWorkbench()
.getNewWizardRegistry().findWizard(id);
// If not check if it is an "import wizard".
if (descriptor == null) {
descriptor = PlatformUI.getWorkbench().getImportWizardRegistry()
.findWizard(id);
}
// Or maybe an export wizard
@turesheim
turesheim / gist:956647
Created May 5, 2011 06:44
Decorating Eclipse icons with status indicators
private static final Point size = new Point(16, 16);
private Image getDecoratedImage(ImageRegistry registry,
String baseImageId,
IStatus status){
ImageDescriptor overlay = null;
Image baseImage = registry.get(baseImageId);
switch (status.getSeverity()) {
case IStatus.ERROR:
overlay = PlatformUI.getWorkbench().getSharedImages()