Skip to content

Instantly share code, notes, and snippets.

View PlayerSpreader.java
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
@PaulBGD
PaulBGD / Model.ts
Created May 20, 2017
Some sort of routing system in an MVP (this is just MP) pattern
View Model.ts
type Listener<T> = () => any;
type Canceller = () => void;
export interface Depends {
[key: string]: Model<any, any>;
}
abstract class Model<T, D extends Depends> {
private _listeners: Listener<T>[];
private _cancel: Canceller[]; // from old code, is this supposed to do something? maybe unload all data from a specific page?
@PaulBGD
PaulBGD / hacky-preact-inject.ts
Created Jun 10, 2016
Files required to use preact in typescript
View hacky-preact-inject.ts
/// <reference path="typings/preact.d.ts"/>
import {h} from 'preact';
export function createElement<P>(type: any, props?: P, ...children: any[]): any {
return h(type, props, children);
}
View .esconfig.json
{
"indent": {
"value": " ",
"FunctionExpression": 1,
"ArrayExpression": 1,
"ObjectExpression": 1
},
"plugins": [
"esformatter-jsx"
],
View .vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'itchyny/lightline.vim'
@PaulBGD
PaulBGD / connect-smart-redis.d.ts
Created Jan 4, 2016
TypeScript definition for the NPM module connect-smart-redis
View connect-smart-redis.d.ts
/// <reference path="../express-session/express-session.d.ts" />
declare module 'connect-smart-redis' {
import Session = require('express-session');
module s {
interface SmartRedisOptions {
ttl: number;
client: any;
prefix?: string;
@PaulBGD
PaulBGD / client-api.tsx
Last active Jan 2, 2016
Easy Validation
View client-api.tsx
/// <reference path="../../typings/tsd.d.ts" />
import {Router, Request, Response} from 'express';
import * as ArtisanValidator from 'artisan-validator';
import {DatabaseClient, DatabaseError} from '../database';
let ClientAPI: Router = Router();
let validator: ArtisanValidator.Validator = ArtisanValidator();
@PaulBGD
PaulBGD / artisan-validator.d.ts
Last active Dec 5, 2015
Artisan Validator TypeScript Definition + Example
View artisan-validator.d.ts
/// <reference path="../bluebird/bluebird.d.ts" />
declare module ArtisanValidator {
class Validator<R> {
try(checking: any, rules: R): Promise<ValidatorResult<R>>;
validators: ArtisanValidator.Validators;
}
interface ValidatorResult<R> {
View shouldhavebroken.js
updateSelector() {
if (this.running) {
return this.selector.style.display = 'none';
}
let lines = this.lines;
let length = this.input.value.length;
if (!this.running) {
length += this.prefix.length;
}
length -= this.input.value.length - this.input.selectionStart;
@PaulBGD
PaulBGD / Hologram.java
Last active Dec 3, 2016
No dependency 1.8+ holograms and item holograms
View Hologram.java
package net.burngames.decorations.utils;
import lombok.Getter;
import org.bukkit.Location;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
/**
* @author PaulBGD