Skip to content

Instantly share code, notes, and snippets.

public static final <T> T bestMatch(String search, Collection<T> options, double threshold) {
T bestObj = null;
double bestScore = 0.0D;
for (T obj : options) {
double score = LiquidMetal.score(obj.toString(), search);
if (score > bestScore) {
bestObj = obj;
bestScore = score;
} else if (score == bestScore) {
bestObj = null;
@Dykam
Dykam / Java 6 or 7.java
Last active August 29, 2015 14:06
Event & Threading model proposal (Usege example)
// When using Java 6 or 7
Observable<Vector> positions =
server.events.playerMove().map(new Fn<PlayerMoveEvent, Vector>() {
public Vector call(PlayerMoveEvent event) {
return event.getPlayer().getPosition();
}
})
.async() // continue on threadpool
.map(new Fn<Vector, Vector>() {
public Vector call(Vector vector) {
@Dykam
Dykam / interfaces.java
Last active August 29, 2015 14:06
Message Object Format
interface TextMessage {}
interface RawTextMessage extends TextMessage { String getValue(); }
interface Style extends TextMessage { TextStyle getStyle(); TextMessage getMessage(); }
interface Action extends TextMessage { TextAction getAction(); TextEvent getEvent(); TextMessage getMessage(); }
/* Combines multiple texts */
interface Combined extends TextMessage { List<TextMessage> getMessages(); }
@Dykam
Dykam / README
Last active August 29, 2015 14:06
Event and Threading model proposal
A small non-complete example design and implementation of Observables/Tasks integrated into events.
It is inspired by a mix of classic Observables and .NET's Tasks/SynchronizationContext.
@Dykam
Dykam / Program.cs
Last active August 29, 2015 14:19
Small stand-alone URL-echoing server
using Microsoft.Owin;
using Microsoft.Owin.Hosting;
using Owin;
using System;
using System.Net.Http;
namespace SelfHost
{
public class Program
{
@Dykam
Dykam / update.coffee
Last active August 29, 2015 14:21
Sponge updaters
#!/usr/bin/env node
// Run before first use:
// $ node install request
request = require "request"
fs = require "fs"
repo = "https://repo.spongepowered.org/maven"
console.log "Downloading verison list"
@Dykam
Dykam / x
Created May 9, 2009 09:18
Dykam's best Ubiqs.
CmdUtils.CreateCommand({
name: "execute",
icon: "http://example.com/example.png",
homepage: "http://Dykam.nl",
author: {name: "Dykam", email: "dev@dykam.nl"},
license: "GPL",
description: "Execute javascript.",
help: "Enter a javascript snippet.",
takes: {"code": /.*/},
preview: function(pblock, code) {
CmdeUtils.CreateCommand({
name: "execute",
icon: "http://example.com/example.png",
homepage: "http://Dykam.nl",
author: {name: "Dykam", email: "dev@dykam.nl"},
license: "GPL",
description: "Execute javascript.",
help: "Enter a javascript snippet.",
takes: {"code": /.*/},
preview: function(pblock, code) {
# .gitignore for .NET projects
# Thanks to Derick Bailey
# http://www.lostechies.com/blogs/derickbailey/archive/2009/05/18/a-net-c-developer-s-gitignore-file.aspx
# - Alexey Abramov
# Thanks to all others
# Standard VS.NET and ReSharper Foo
obj
bin
*.csproj.user
{
"from": "nus",
"tasks": [
{ "task": "systemmenu", "installIos": false, "version": 4.2, "region": "E" },
{ "task": "ios", "patchEsIdentify": false, "patchFakesign": false, "version": 70, "revision": 6687 },
{ "task": "channel", "name": "News Channel", "region": "J" },
{ "task": "title", "id": "000000010000001C", "revision": 1806, "patchEsIdentify": true, "patchFakesign": true, "patchNand": true, "from": "sd" }
]
}