Skip to content

Instantly share code, notes, and snippets.

View benjaminaaron's full-sized avatar

Benjamin Degenhart benjaminaaron

View GitHub Profile
@benjaminaaron
benjaminaaron / Simple.java
Created May 9, 2015 16:49
Trying to achieve a simple Tree-Layout with graphstream
import org.graphstream.graph.Graph;
import org.graphstream.graph.implementations.SingleGraph;
import org.graphstream.ui.layout.HierarchicalLayout;
import org.graphstream.ui.view.Viewer;
public class Simple {
public static void main(String[] args) {
Graph graph = new SingleGraph("Test");
import org.graphstream.graph.Graph;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import org.graphstream.ui.layout.HierarchicalLayout;
import org.graphstream.ui.view.Viewer;
public class graphstreamHierarchicalLayoutTesting {
public static void main(String[] args) {
Graph graph = new SingleGraph("Test");
@benjaminaaron
benjaminaaron / script.py
Created November 18, 2015 21:47
subgroups and permutations in python
Set = ['A', 'B', 'C', 'D']
Subsets = []
n = len(Set)
for i in xrange(pow(2, n)):
binaryDigits = (bin(i)[2:]).zfill(n)
subset = ''
j = 0
for digit in binaryDigits:
if(digit == '1'):
@benjaminaaron
benjaminaaron / GetStreamingAssetsPath.cs
Created March 11, 2016 18:39 — forked from amowu/GetStreamingAssetsPath.cs
Get Unity StreamingAssets file path with Android and iOS.
// Put your file to "YOUR_UNITY_PROJ/Assets/StreamingAssets"
// example: "YOUR_UNITY_PROJ/Assets/StreamingAssets/db.bytes"
string dbPath = "";
if (Application.platform == RuntimePlatform.Android)
{
// Android
string oriPath = System.IO.Path.Combine(Application.streamingAssetsPath, "db.bytes");
@benjaminaaron
benjaminaaron / AttributesExample.java
Created May 31, 2016 21:07
gson.fromJson + JsonBooleanDeserializer + allFieldsNotNull()
public class AttributesExample {
private String str;
private Double dbl;
private Boolean bool;
public boolean allFieldsNotNull() {
return str != null && dbl != null && bool != null;
}
}
@benjaminaaron
benjaminaaron / AttributesExample.java
Last active April 14, 2022 09:10
validate json by reflection before using gson
public class AttributesExample {
private String str = "foo";
private double dbl = 0.8;
private boolean bool = false;
}
@benjaminaaron
benjaminaaron / AttributesExample.java
Last active June 6, 2016 17:09
using jackson for json to object
public class AttributesExample {
private String str = "foo";
private double dbl = 0.8;
private boolean bool = false;
public String toString() { return str + ", " + dbl + ", " + bool; }
}
@benjaminaaron
benjaminaaron / Main.java
Created June 6, 2016 22:45
WIP validating parsedTree against constructedTree (Jackson)
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import java.util.Iterator;
public class Main {
public static void main(String[] args) throws IOException {
ObjectMapper mapper = new ObjectMapper();
@benjaminaaron
benjaminaaron / Attributes.java
Last active June 17, 2016 09:10
Jackson: strict parsing of json-string into Map<ModelType, Attributes>
public abstract class Attributes {}
@benjaminaaron
benjaminaaron / old_scenario_format.json
Created June 29, 2016 08:16
the .scenario format as it currently is
{
"release": "not a release",
"topographyhash": "d439ba0f5e95a65942da5d53374e3fb1372c2020",
"name": "New_scenario",
"processWriters": [],
"attributeshash": "bf1f2ba3b13f6b61e215e57743c81a3de5973418",
"vadere": {
"attributesModel": {
"OPTIMAL_STEPS_MODEL": {
"stepCircleResolution": 18.0,