Skip to content

Instantly share code, notes, and snippets.

View ndugger's full-sized avatar

Nick Dugger ndugger

  • Minneapolis, MN
View GitHub Profile
import router from 'redshirt';
import { admin, body } from '../middleware';
import { db, slugify } from '../util';
const NEW = 'new';
router.group('/forums/categories')
.get('/', async () => {
const categories = await db.forums.categories.all();
import Plugin from '../core/plugin';
import Component from '../core/component';
import System from '../core/system';
import quantity from '../core/components/quantity';
import texture from '../core/components/texture';
const particle = new Component({
all: Component.types.array,
color: Component.types.string,
import router from 'redshirt';
import { admin, body } from '../middleware';
import { db, json, slugify } from '../util';
router.group('/forums/categories')
.get('/', async () => {
return json(await db.forums.categories.all());
})
.post('/', [ admin, body ], async request => {
import engine from '../engine';
import system from '../system';
import input from '../components/input';
import position from '../components/position';
import velocity from '../components/velocity';
export default system([ input, position, velocity ], entity => {
const { keyboard } = engine;
const { controls } = input.of(entity);
import { execFileSync } from 'child_process';
import { JSDOM } from 'jsdom';
const { Promise } = global;
const options = { resources: 'usable', runScripts: 'dangerously' };
const server = execFileSync('node', [ './dist/server/index.js' ], { cwd: process.cwd() });
const browser = { };
beforeAll(async () => {
import { execFile } from 'child_process';
import { JSDOM } from 'jsdom';
const { Promise } = global;
const options = { resources: 'usable', runScripts: 'dangerously' };
const server = execFile('node', [ './dist/server/index.js' ], { cwd: process.cwd() });
const browser = { };
beforeAll(async () => {
import { Server } from 'uws';
import actions from './actions';
import messenger from './messenger';
import router from './router';
import state from './state';
const { PORT, TEST_PORT } = process.env;
actions.register();
export default function query () {
let cql = '';
return {
insert (table, data) {
const keys = Object.keys(data).join(', ');
const values = Object.values(data).join(', ');
cql += `INSERT INTO ${ table } (${ keys }) VALUES (${ values }) `;
import vm from 'vm';
export default {
[ '>' ] (input) {
const context = {
Array,
Boolean,
Buffer,
Date,
function arithmetic (input) {
let expression = input.replace(/\s/g, '');
const numbers = /((?:\d|\.)+)/;
const groups = /\(([^(]+?)\)/;
const methods = [
{ op: /(\^|\*{2})/, fn: (x, o, y) => x ** y },
{ op: /(\*|\/|\%)/, fn: (x, o, y) => {
if (o === '*') return x * y;
if (o === '/') return x / y;