Skip to content

Instantly share code, notes, and snippets.

extends Node2D
### Export variables
export var g_copies_of_each: int = 2
# y measured from bottom of sprites, so characters all line up
export var g_min_y: int = 860
export var g_max_y: int = 860
export var g_min_spawn_wait_ms = 1000
export var g_max_spawn_wait_ms = 2000
export var g_path: String = ""
@DarkWiiPlayer
DarkWiiPlayer / pool.lua
Last active May 17, 2019 20:51
Lua Pool
--- An abstract implementation of an object pool
-- @usage
-- local pool = require("pool"){
-- initialize = function(elem) elem.name = "John Doe"; return elem end;
-- max = 50;
-- }
-- local elem = pool:get() -- Creates a new element because pool is empty
-- print(elem.x) --> John Doe -- pool:put(elem) -- Puts element back into pool --- You know, the thing that this is all about, the pool class -- @type pool
local math = require "math"
@twilight-sparkle-irl
twilight-sparkle-irl / potions.txt
Created October 19, 2017 20:31
a...list of potion names?
Malevolent
Rudimentary body potion
Oculus Potion
Ever
Hermadeye Glo Poils
Rano Potion
Grand Potion
Solution Antidote
Befuddlemishing Potion Potion
Girding Potion
@samthor
samthor / importPolyfill.js
Last active November 11, 2024 07:10 — forked from surma/importPolyfill.js
Polyfill for dynamic module loading that supports onerror
// usage:
// importScript('./path/to/script.js').then((allExports) => { .... }));
function importScript(path) {
let entry = window.importScript.__db[path];
if (entry === undefined) {
const escape = path.replace(`'`, `\\'`);
const script = Object.assign(document.createElement('script'), {
type: 'module',
textContent: `import * as x from '${escape}'; importScript.__db['${escape}'].resolve(x);`,
});
@patricksimpson
patricksimpson / module.js
Last active April 16, 2020 14:21
JavaScript Design Patterns
var options = {
username: 'blah',
server: '127.0.0.1'
};
var ConfigObject = (function(params) {
var username = params.username || '',
server = params.server || '',
password = params.password || '';
@samthor
samthor / shadowlisten.js
Last active May 18, 2020 18:55
Listener to provide up-to-date Shadow DOM focus events
/**
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
<?php
class PasswordGenerator {
var $pwdMinLength = 12;
var $pwdMaxLength = 20;
var $pwdMap = [
[
'chars' => 'abcdefghijklmnopqrstuvwxyz',
'weight' => 30,
],
@soulik
soulik / html.lua
Last active October 27, 2024 03:25
HTML/XML grammar LPEG parser for Lua
local lpeg = require 'lpeg'
local L = lpeg.locale()
local P,V,C,Ct,S,R,Cg,Cc =
lpeg.P, lpeg.V, lpeg.C, lpeg.Ct, lpeg.S, lpeg.R, lpeg.Cg, lpeg.Cc
local ws = S'\r\n\f\t\v '
local ws0 = ws^0
local ws1 = ws^1
local name = S'_ ' + L.digit + L.alpha
@ischenkodv
ischenkodv / AsyncQueue.js
Created February 28, 2015 20:17
Asynchronous queue implementation. Functions could be added to queue and executed one by one immediately, or with intervals or in the next frame (using requestAnimationFrame).
;(function(window) {
'use strict';
/**
* AsyncQueue allows you to create a queue of function to be executed via
* setTimout that guaranteed to run in order. This can enable to run
* process-intensive operations without locking up UI.
*
* @constructor
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/