Skip to content

Instantly share code, notes, and snippets.

View fab1an's full-sized avatar

Fabian Zeindl fab1an

View GitHub Profile
@fab1an
fab1an / CreateRMapping.xml
Created April 12, 2014 12:41
Builder for Android/Eclipse that generates references to Views
<?xml version="1.0"?>
<project name="createRMapping" default="main">
<property name="package" value="org.somecompany.somepackage" />
<target name="main">
<script language="javascript">
<classpath>
<fileset dir="libs" includes="guava*.jar" />
</classpath>
@fab1an
fab1an / SWTLoader.java
Last active August 29, 2015 14:14
Capsule/Caplet for multi-platform SWT
import static com.google.common.base.Preconditions.checkState;
import java.nio.file.Path;
import java.util.Iterator;
import java.util.List;
public final class SWTLoader extends Capsule {
// ~ Constructors ----------------------------------------------------------------------------------------------
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.*;
public class TableListenerTest
{
public static void main(String[] args) {
new TableListenerTest();
--- ../gl-1.8.0-source/extensions/swt/source/ca/odell/glazedlists/swt/EventTableViewer.java 2008-12-14 05:49:50.000000000 +0100
+++ gl-patches/patched/EventTableViewer.java 2009-10-11 20:55:26.000000000 +0200
@@ -231,7 +231,8 @@
* {@link TableFormat}. This method is not yet implemented for SWT.
*/
public void setTableFormat(TableFormat<E> tableFormat) {
- throw new UnsupportedOperationException();
+ this.tableFormat = tableFormat;
+ this.tableHandler.redraw();
}
$app->view = new \Slim\Views\Twig();
$app->view->setTemplatesDirectory(__DIR__."/templates/");
$app->view->parserOptions = ['debug' => $config['debug']];
$app->view->parserExtensions = [new \Slim\Views\TwigExtension()];
$app->get('/(:page)', function ($page = "intro") use ($app, $config) {
try {
$app->render('wrapper.html', [
'page' => $page,
'debugEnabled' => ($config['debug'] ? "true" : "false")
@fab1an
fab1an / gist:7532478
Created November 18, 2013 18:08
Bug in GSON: DeserializationHandler changes Serialization of Abstract classes
import static org.junit.Assert.*;
import java.lang.reflect.Type;
import org.junit.Test;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
@fab1an
fab1an / sample.js
Created April 8, 2016 12:59
simple 'shouldComponentUpdate'
class ReactBase extends React.Component {
shouldComponentUpdate(nextProps) {
/* function from lodash */
return !_.isEqual(this.props, nextProps);
/* if we use immutableJS we could also just do an equality check */
// return this.props !== nextProps;
}
}
@fab1an
fab1an / BoxExample.js
Last active April 8, 2016 13:10
react state
/* my state */
state = {
box1: {data: "Box 1", top: 0, left: 0},
box2: {data: "Box 2", top: 0, left: 100},
otherData: {}
}
class App extends React.Component {
render() {
const $ = this.props
class App extends React.Component {
static makeProps($) {
return {
box1: $.box1,
box2: $.box2,
otherData: $.otherData || "Default Value"
}
}
render() {
/* App.makeProps */
static makeProps($) {
return {
/* call Box.makeProps to construct the substate */
box1: [Box, "1"],
box2: [Box, "2"],
/* call OtherData.makeProps to get the substate */
OtherData
}
}