Skip to content

Instantly share code, notes, and snippets.

Avatar

Maurycy Zarzycki EvidentlyCube

View GitHub Profile
@EvidentlyCube
EvidentlyCube / pre-commit
Created May 27, 2022
Pre commit hook that helps you avoid accidentally committing debug code + prevent commits to certain branches
View pre-commit
#!/bin/bash
confirm() {
while true; do
read -p "$1 y/n " -n 1 yn < /dev/tty
case $yn in
[Yy]* ) echo ;break;;
[Nn]* ) echo ;exit 1;;
* ) echo ;echo "Please answer y or n.";;
esac
@EvidentlyCube
EvidentlyCube / Pool.ts
Created Apr 26, 2019
A simple Pool class I used for Trans Neuronica
View Pool.ts
export class Pool<T>
{
private readonly _pool: T[];
private readonly _construct: () => T;
private readonly _autoHydrateSize: number;
private _indexInPool: number;
constructor(initialCapacity: number, construct: () => T, autoHydrateSize: number = 1)
{
this._pool = [];
@EvidentlyCube
EvidentlyCube / BufferableContainer.ts
Last active Apr 26, 2019
PIXI Optimized add/remove child container
View BufferableContainer.ts
import * as PIXI from 'pixi.js';
// Caution #1: it's written in TypeScript!
// Caution #2: it uses the fast element removal method (move last element into removed element's place and change array length)
// which changes the order of items in the array, so your rendering order will be affected
// Caution #3: events are not triggered
export class BufferableContainer extends PIXI.Container
{
private readonly childrenToAdd: PIXI.DisplayObject[];
@EvidentlyCube
EvidentlyCube / hookJsdom.js
Last active Apr 19, 2019
Hooking JSDom for PixiJS to run correctly in Mocha
View hookJsdom.js
/**
* Adapted from https://github.com/rstacruz/jsdom-global
* Make sure this file is registered when running tests by adding this to the command with which you run mocha:
* -r <path>/hookJsdom.js
*/
const JSDOM = require( 'jsdom' ).JSDOM;
const jsdomOptions = {
url: 'http://localhost/'
};
@EvidentlyCube
EvidentlyCube / Main.cs
Last active Oct 7, 2016
Rewriting TN in MonoGame #1: Setting Up the Project - Bootstrap files - related post at: http://retrocade.net/2016/10/07/rewriting-tn-in-monogame-1-setting-up-the-project/
View Main.cs
using System;
namespace TransNeuronica
{
//#if WINDOWS || LINUX // This conditional compilation is commented out because right now not all constants are correctly defined
// and we can't add our own in a simple fashion. I'll figure it out later
public static class Program
{
[STAThread]
static void Main()
@EvidentlyCube
EvidentlyCube / Trimps autoplay script
Created Sep 10, 2016
A simple autoscript for Trimps game for personal use, is not very intelligent. Press "a" to toggle on/off. In order to run it open the game page, press open developer tools (F12 in Chrome and FF), select console, now refresh the page,, wait for it to load, paste the script and press enter. It runs by default, press a in game window to toggle it …
View Trimps autoplay script
window.isAutomaticTrimpsRunning = true;
if (typeof game !== 'undefined'){
window.game = game;
}
if (typeof window.game === 'undefined' || window.game == null){
console.error("Save and refresh the page and run the script again");
throw new Error("");
}
@EvidentlyCube
EvidentlyCube / Trimps plugin: Precise number on hover
Created Aug 31, 2016
Displays a tooltip with precise number when hovering over all numbers in Trimps. Warning: the numbers rendered before the plugin is loaded won't register the tooltip handlers, so for example HPs before you fight might not react.
View Trimps plugin: Precise number on hover
// ==UserScript==
// @name Trimps precise number hover
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Displays a tooltip with precise number when hovering over all numbers in Trimps. Warning: the numbers rendered before the plugin is loaded won't register the tooltip handlers, so for example HPs before you fight might not react.
// @author Maurycy Zarzycki, Retrocade.net
// @match https://trimps.github.io/
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// ==/UserScript==
@EvidentlyCube
EvidentlyCube / Align_Center_Middle.ts
Last active Aug 29, 2015
Phaser augments by Retrocade.net
View Align_Center_Middle.ts
(function(Phaser, PIXI){
var defineFor = function(classDef){
classDef.prototype.positionCenter = function(){
this.center = Phaser.GAMES[0].width / 2;
};
classDef.prototype.positionMiddle = function(){
this.middle = Phaser.GAMES[0].height / 2;
};
classDef.prototype.positionCenterParent = function(){
if (this.parent !== null){