Skip to content

Instantly share code, notes, and snippets.

@digulla
digulla / OrphanNodesTool.groovy
Created October 24, 2014 10:20
Groovy tool to count, list or delete orphaned nodes in a database with proper FK relations
import groovy.sql.Sql
class OrphanNodesTool {
Sql sql;
String schema;
Set<String> tablesTargetedByForeignKeys() {
def query = '''\
@digulla
digulla / c't_Inhaltsverzeichnis_sortieren.user.js
Last active August 29, 2015 14:12
Sortiert das Inhaltsverzeichnis der c't nach Seitenzahl, wenn man auf "aktuell" klickt
// ==UserScript==
// @name c't Inhaltsverzeichnis sortieren
// @namespace http://www.pdark.de/
// @version 1.0
// @description Sortiert das Inhaltsverzeichnis der c't nach Seitenzahl, wenn man auf "aktuell" klickt
// @match https://www.heise.de/artikel-archiv/ct/*
// @copyright 2014+, Aaron Digulla
// @grant unsafeWindow
// ==/UserScript==
@digulla
digulla / LineNumberTest.java
Created September 1, 2011 12:02
Demo for SimpleXml line number problem
package net.sf.simple.test;
import static org.junit.Assert.*;
import java.io.StringReader;
import org.junit.Test;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
@digulla
digulla / SDL-1.2.14-x11modes.patch
Created December 4, 2011 11:43
Patch to force a certain window/screen size in SDL games
--- SDL-1.2.14/src/video/x11/SDL_x11modes.c 2009-10-13 01:07:15.000000000 +0200
+++ SDL-1.2.14/src/video/x11/SDL_x11modes.c 2011-12-04 12:34:55.000000000 +0100
@@ -33,7 +33,7 @@
#include "SDL_x11modes_c.h"
#include "SDL_x11image_c.h"
-/*#define X11MODES_DEBUG*/
+#define X11MODES_DEBUG
#define MAX(a, b) (a > b ? a : b)
@digulla
digulla / diffFolders.py
Created March 22, 2012 11:15
Small script to copy the difference between two folders to a new folder
#!/usr/bin/env python
import os
import os.path
import sys
import shutil
# Bugfixed version of makedirs
def makedirs(name, mode=0777):
"""makedirs(path [, mode=0777])
@digulla
digulla / AbstractRebuildingPreferencePage.java
Created April 10, 2012 13:49
Refactored org.cloudsmith.geppetto.pp.dsl.ui.preferences.AbstractRebuildingPreferencePage
/**
* Copyright (c) 2011 Cloudsmith Inc. and other contributors, as listed below.
* 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:
* Cloudsmith
* Aaron Digulla
@digulla
digulla / XmlModelFactory.java
Created July 27, 2012 16:55
Xml model factory for Wro4j which can reference imports (see https://code.google.com/p/wro4j/issues/detail?id=423)
/*
* Copyright (c) 2008. All rights reserved.
*/
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.lang3.StringUtils;
@digulla
digulla / FastXtextResourceSetProvider.java
Created September 20, 2012 07:11
Faster implementation of XtextResourceSetProvider.
import org.apache.log4j.Logger;
import org.eclipse.core.resources.IProject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
import org.eclipse.xtext.ui.resource.XtextResourceSetProvider;
import org.eclipse.xtext.ui.util.JdtClasspathUriResolver;
@digulla
digulla / TypeAndImportUriGlobalScopeProvider.java
Created September 21, 2012 11:50
A global scope provider that is both able to process the importURI attributes to establish cross links with other EMF models, and to handle references to JVM types.
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.common.types.TypesPackage;
import org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider;
import org.eclipse.xtext.common.types.xtext.ClasspathBasedTypeScopeProvider;
import org.eclipse.xtext.common.types.xtext.TypesAwareDefaultGlobalScopeProvider;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.scoping.IScope;
@digulla
digulla / IntRange.java
Created October 2, 2012 08:33
IntRange for Xtend which works as Java developers expect
/*
Copyright (c) 2012, Aaron Digulla
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.