Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Shipping it

Moritz Schmale narrowtux

:shipit:
Shipping it
View GitHub Profile
View LJVehicleListener.java
package com.narrowtux.longjourney;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.event.vehicle.VehicleListener;
import org.bukkit.event.vehicle.VehicleMoveEvent;
import org.bukkit.util.Vector;
public class LJVehicleListener extends VehicleListener {
View Code where I create it.java
p.addPoint(0, 0, new Color(0xffffffff));
p.addPoint(0, 10, new Color(0xffffffff));
p.addPoint(10, 10, new Color(0xffffffff));
p.addPoint(10, 0, new Color(0xffffffff));
View gist:1486905
Contianer c = new GenericContainer();
c.setLayout(new VerticalLayout());
c.setGeometry(5,5,width - 10, height - 10);
c.attachWidget(addon, new GenericLabel("Title")); //Same as c.getLayout().addItem(new WidgetItem(widget));
c.getLayout().addItem(new SpacerItem(0, 25, 0, Integer.INFINITY)); //minWidth, minHeight, maxWidth, maxHeight
Button b = new GenericButton("Done");
b.setMaxWidth(200);
c.attachWidget(addon, b);
c.getLayout().setAlign(WidgetAnchor.TOP_CENTER);
screen.attachWidget(addon, c);
@narrowtux
narrowtux / ComponentHolder.java
Created Sep 24, 2012
Endless event-style methods for Components
View ComponentHolder.java
public class ComponentHolder {
// ...
public void onEvent(String methodName) {
for (Component c:getComponents()) {
if (c.getClass().hasMethod(methodName)) {
c.getClass().getMethod(methodName).execute(c);
}
}
}
// ...
View AssociationUtils.java
package de.hs.settlers.util;
import java.lang.reflect.Field;
import javafx.beans.property.Property;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableSet;
import javafx.collections.SetChangeListener;
View range.ex
defmodule Range
def range(num, min_value, max_value) do
num
|> min(max_value)
|> max(min_value)
end
end
@narrowtux
narrowtux / collection.ex
Last active Nov 15, 2016
remove and difference functions for Enum
View collection.ex
defmodule Coll do
@doc """
Removes all values from the subject
iex> Coll.remove([1, 2, 3], [2, 3])
[1]
iex> Coll.remove([1, 2], [2, 3, 4])
[1]
"""
View lol.ex
def descendants(organization_id, truncation, filter \\ from o in __MODULE__) do
sub = from os in filter, where: os.organization_id == ^organization_id and os.truncation == ^truncation, select: [os.organization_id, os.parent_organization_id, os.id, ^1, os.datetime, os.truncation]
query = from outer in __MODULE__,
join: t in fragment("""
WITH RECURSIVE search_orgs(organization_id, parent_organization_id, id, depth, datetime, truncation) AS (
?
UNION ALL
SELECT
o.organization_id,
View lol.ex
def descendants(organization_id, truncation, filter \\ from o in __MODULE__) do
sub = from os in filter, where: os.organization_id == ^organization_id and os.truncation == ^truncation, select: [os.organization_id, os.parent_organization_id, os.id, ^1, os.datetime, os.truncation]
query = from outer in __MODULE__,
join: t in fragment("""
WITH RECURSIVE search_orgs(organization_id, parent_organization_id, id, depth, datetime, truncation) AS (
?
UNION ALL
SELECT
o.organization_id,
View lol.ex
def descendants(organization_id, truncation, filter \\ from o in __MODULE__) do
sub = from os in filter, where: os.organization_id == ^organization_id and os.truncation == ^truncation, select: [os.organization_id, os.parent_organization_id, os.id, ^1, os.datetime, os.truncation]
query = from outer in __MODULE__,
join: t in fragment("""
WITH RECURSIVE search_orgs(organization_id, parent_organization_id, id, depth, datetime, truncation) AS (
?
UNION ALL
SELECT
o.organization_id,