Skip to content

Instantly share code, notes, and snippets.

View turesheim's full-sized avatar

Torkild U. Resheim turesheim

View GitHub Profile
@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()
@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 / 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 - [email protected]
# 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 / 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 / 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 / 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
*******************************************************************************/
#! /usr/bin/env python
'''
Register a mDNS/DNS-SD alias name for your computer using the Avahi daemon
This script will register an alternate CNAME alias besides your hostname,
which could be useful for ex. when serving several http virtual hosts to
your ffriends on the local network and you don't want to make them configure
their /etc/hosts.
Why a CNAME? You could also publish your current address with avahi-publish-address
@turesheim
turesheim / close-issues.sh
Last active December 14, 2015 12:48
Bash script for closing issues 50-5000 that were inadvertently created using Zapier synchronization.
#!/bin/sh
for issue in {50..5000}
do
echo "Closing issue #$issue"
curl --progress-bar --user "<github-user>:<github-password>" -X PATCH \
--data '{"state":"closed","title":"Inadvertently created by Zapier sync","body":""}' \
https://api.github.com/repos/<github-user>/<github-repo>/issues/$issue > /dev/null
done
@turesheim
turesheim / derby
Created July 17, 2013 09:19
Apache Derby startup script.
#!/bin/bash
#
# Startup script for Derby
#
# chkconfig: 345 94 16
# description: Derby startup script
# to enable on bootup on redhat "chkconfig --level 35 derby on"
# to enable on bootup on debian "update-rc.d derby defaults" or the
# slightly longer (but better run levels) "update-rc.d derby start 91 2 3 4 5 . stop 20 0 1 6 ."
@turesheim
turesheim / pixma2pdf.sh
Last active December 27, 2015 08:09
Bash script to scan documents to PDF.
#!/bin/bash
#-----------------------------------------------------------------------------
# pixma2pdf.sh version 3.0
#
# Copyright (c) 2009, 2013 Torkild U. Resheim - [email protected]
# Released under the Eclipse Public License version 1.0
#-----------------------------------------------------------------------------
t=$(tempfile) || exit
trap "rm -f -- '$t'" EXIT