Skip to content

Instantly share code, notes, and snippets.

View svenefftinge's full-sized avatar

Sven Efftinge svenefftinge

View GitHub Profile
const fs = require('fs');
const path = require('path');
const ignored = ['.git', 'migrate.js'];
const encoding = 'latin1';
function allFiles(rootPath, action) {
const files = fs.readdirSync(rootPath);
for (const e of files) {
@svenefftinge
svenefftinge / theia-dep-licenses.txt
Last active February 5, 2019 15:46
Licenses of theia dependencies. Output of `yarn licenses list`
yarn licenses v1.12.3
info fsevents@1.2.4: The platform "linux" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
├─ (BSD-2-Clause OR MIT OR Apache-2.0)
│ └─ rc@1.2.8
│ ├─ URL: https://github.com/dominictarr/rc.git
│ ├─ VendorName: Dominic Tarr
│ └─ VendorUrl: dominictarr.com
├─ (GPL-2.0 OR MIT)
│ └─ ua-parser-js@0.7.18
// Part 1
org.xtext.homeautomation
// To Be Parsed
Device Window can be OPEN, CLOSED
Device Heating can be ON, OFF
Rule 'Close Window, when heating turned on'
var char character;
while ((character = buffer.get) != PacketConstants.STRING_TERMINATOR) {
// do stuff
}
@svenefftinge
svenefftinge / Super.xtend
Created August 29, 2013 07:00
An active annotation that declares constructors delegating to super constructors.
package superConstr
import org.eclipse.xtend.lib.macro.AbstractClassProcessor
import org.eclipse.xtend.lib.macro.Active
import org.eclipse.xtend.lib.macro.TransformationContext
import org.eclipse.xtend.lib.macro.declaration.ClassDeclaration
import org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration
import org.eclipse.xtend.lib.macro.declaration.Visibility
@Active(SuperProcessor)
@svenefftinge
svenefftinge / I18Processor.xtend
Created August 9, 2013 06:04
An annotation processor for localization using Java Resource Bundle
@Active(ExternalizedProcessor)
annotation Externalized {}
class ExternalizedProcessor extends AbstractClassProcessor implements CodeGenerationParticipant<ClassDeclaration> {
override doTransform(MutableClassDeclaration annotatedClass, extension TransformationContext context) {
for (field : annotatedClass.declaredFields) {
val initializer = field.initializerAsString
val msgFormat = try {
new MessageFormat(initializer)
@svenefftinge
svenefftinge / gist:3621045
Created September 4, 2012 13:14
AST construction with data typed in Xtend
package basepack.exmaple2
import java.util.Map
import org.eclipse.xtend.lib.Data
class Eval {
def static void main(String...args) { new Eval().run } // run inside an instance instead of statically so we can operator overloading (and use extensions)
def evaluate(Map<String,Integer> it, Expression exp) {
import com.google.inject.Inject;
import com.google.inject.Provider;
public class MrsH {
@Inject
private DoorService door;
@Inject
private PanelService panel;
@svenefftinge
svenefftinge / gist:1506285
Created December 21, 2011 14:49
This one prints : "Took : 31 ms, number of elements : 3000000"
public static void main(String[] args) {
int iterations = 1000000;
List<?> items = newArrayList("foo", 23, true);
List<Object> absoluteResult = new ArrayList<Object>(iterations*items.size());
long before = System.currentTimeMillis();
for (int i=0; i < iterations; i++) {
for (int j=0 ; j< items.size(); j++) {
absoluteResult.add(foo(items.get(j)));
}