Skip to content

Instantly share code, notes, and snippets.

@imliam
imliam / skill-charging.lua
Created May 7, 2017 02:24
Transformice Skill Charging
-- List of keycodes
keys = {
['LEFT'] = 0,
['UP'] = 1,
['RIGHT'] = 2,
['DOWN'] = 3,
['BACKSPACE'] = 8,
['SHIFT'] = 16,
['CTRL'] = 17,
['ALT'] = 18,
-- Weigh rows against eachother based on different conditions,
-- ordering the results based on their given weights so that
-- more precise matches will show higher up in the results.
-- In this example, an exact match will show up at the top
-- of the results, a match at the beginning of the string
-- will show next, and a match anywhere will show last.
set @query = 'Liam';
--- Create a flat list of all files in a directory
-- @param directory - The directory to scan (default value = './')
-- @param recursive - Whether or not to scan subdirectories recursively (default value = true)
-- @param extensions - List of extensions to collect, if blank all will be collected
function scandir(directory, recursive, extensions)
directory = directory or ''
recursive = recursive or false
-- if string.sub(directory, -1) ~= '/' then directory = directory .. '/' end
if recursive then command = command .. 'R' end
local currentDirectory = directory
@imliam
imliam / tfm-cookieclicker.lua
Last active September 29, 2022 06:37
Cookie Clicker game remade in Lua as a Transformice module
--http://cookieclicker.wikia.com/wiki/Upgrades
tfm.exec.disableAutoNewGame(true)
tfm.exec.disableAutoShaman(true)
tick=0
timePassed=0
players={}
map=[[<C><P L="1600" /><Z><S><S L="1600" H="48" X="800" Y="380" T="12" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DS Y="345" X="400" /></D><O /><L /></Z></C>]]
img={
cookie={"168537abe8d",250,250},
@imliam
imliam / popover-dom-content.html
Last active May 16, 2022 06:19
Bootstrap 4 - Load Popover Content From DOM
<div id="unique-id" style="display:none;">
<div class="popover-heading">This is a heading</div>
<div class="popover-body">This is HTML content that will be loaded inside a </div>
</div>
<span tabindex="0" role="button" data-toggle="popover" data-placement="bottom" data-popover-content="#unique-id">
Click me to load a popover
</span>
@imliam
imliam / popover-close-when-losing-focus.js
Created March 17, 2017 16:42
Bootstrap 4 - Close Popover When Losing Focus
/*
|--------------------------------------------------------------------------
| Bootstrap 4 - Close Popover When Losing Focus
|--------------------------------------------------------------------------
|
| A JavaScript snippet that closes a Bootstrap 4 popover when clicking off
| of it, but unlike the default behaviour, allows it to stay open when
| clicking within the popover itself.
*/

You can register the mixin class in the register method of a Laravel service provider:

use Illuminate\Foundation\Testing\TestResponse;

TestResponse::mixin(TestResponseMixin::class);
@imliam
imliam / bind_methods.php
Created January 10, 2018 18:10
Trait to dynamically bind methods to a class.
<?php
trait BindMethods
{
private $boundMethods = [];
public function bindMethod($methodName, $method) {
$this->boundMethods[$methodName] = Closure::bind($method, $this, get_class());
}
@imliam
imliam / operator-mono-lig.css
Created July 5, 2018 12:37
Use the Operator Mono Lig typeface on any website.
/** General websites **/
code { font-family: "Operator Mono Lig" !important; font-weight: 200; }
pre > code { font-family: "Operator Mono Lig" !important; font-size: 1.2em !important; font-weight: 200; }
/** GitHub **/
.blob-code-inner, .blob-num, .highlight pre { font-family: "Operator Mono Lig" !important; font-weight: 200; }
.pl-c, .pl-e { font-style: italic; }
.pl-c { color: #4CAF50; }
/** Prism JS **/
@imliam
imliam / example.php
Created August 23, 2018 20:17
Define a set of constants to be used as flags for bitmasked options.
<?php
set_bitmask_flags([
'FLAG_1',
'FLAG_2',
'FLAG_3',
'FLAG_4',
'FLAG_5',
]);