Skip to content

Instantly share code, notes, and snippets.

View LiamPerson's full-sized avatar
⌨️
AI, Blockchain, Decentralization, Power to the People!

LiamPerson

⌨️
AI, Blockchain, Decentralization, Power to the People!
  • Australia
View GitHub Profile
@LiamPerson
LiamPerson / ajax_handle_b64IMG.php
Last active September 10, 2020 06:28
Handle HTML styled base64 images in PHP from something like an AJAX request. (Requires jQuery & Bootstrap 4)
/**
* Takes base64 html standard image blob string and saves it to the CDN. Returns URL of image.
*
* @param $_POST["base64"] // E.G: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAApsAAAH0CAYA ...
* @param $_POST["type"] // Mime type, e.g. image/jpg image/gif
* @return string|void
*/
if (isset($_POST["base64"]) && isset($_POST["type"])) {
$deleteMeFromString = "data:{$_POST["type"]};base64,";
@LiamPerson
LiamPerson / Movement.cs
Last active April 29, 2021 08:26
Physics-compliant 2D Platformer Movement in Unity using Rigidbody2D
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody2D))]
public class Movement : MonoBehaviour
{
// Rigidbody contained on the object this script is attached to.
private Rigidbody2D rb;
@LiamPerson
LiamPerson / HealthController.cs
Created May 20, 2021 09:28
A very very simple Health controller with constant health drain
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; // Import the UI module.
public class HealthController : MonoBehaviour
{
public Slider HealthBar;
public Text HealthBarTextValue;
@LiamPerson
LiamPerson / underscore.ahk
Created January 27, 2022 08:26
AutoHotkey script that turns spacebar into an _underscore_ key when you have Caps Lock on. Very useful when coding in CAPITALISED_SNAKE_CASE
; Tested and working with AHK V1.1.33.10
$Space::
state := GetKeyState("CapsLock", "T")
if state
Send _
else
Send {Space}
return
@LiamPerson
LiamPerson / Phaser3 Load Types.js
Last active March 28, 2022 07:15
All of the types that can be loaded with the loader plugin in Phaser 3
/**
* All the types that can be loaded with
* the loader plugin in Phaser 3
* grouped by settings.
*
* Referencing https://photonstorm.github.io/phaser3-docs/Phaser.Loader.LoaderPlugin.html
*/
switch(type.toUpperCase()) {
case "BINARY": // key url ...
@LiamPerson
LiamPerson / Phaser 3 Loader Plugin Types Normal Case.txt
Created April 26, 2022 09:12
Phaser 3's loadable files in the case of their method name.
"binary"
"css"
"html"
"script"
"sceneFile"
"text"
"tilemapCSV"
"tilemapImpact"
"tilemapTiledJSON"
"xml"
@LiamPerson
LiamPerson / badwords_243705
Last active May 23, 2022 13:04
243,705 words that maybe shouldn't be in usernames.
This file has been truncated, but you can view the full file.
!!v*$3x
!!v*5ex
!!v*sex
!!v3$3x
!!v3sex
!!v3zex
!!ve$ex
!!ve53x
!!ve5ex
!!ves*x
@LiamPerson
LiamPerson / generateStripes.js
Last active November 4, 2022 05:53
Generate a css striped background using javascript.
/**
* Generates a linear-gradient css function to use with the css background property to display a stripes.
* @param {String} col1 the first colour.
* @param {String} col2 the second colour.
* @param {String} angle what angle the chevron should appear at
* @param {Number} iterations how many stripes you want. 7 = 4 col1, 3 col2
* @returns {String}
* @example generateStripes("rgba(255, 255, 255, .2)", "white", "-45deg", 40) // returns "linear-gradient(-45deg,rgba(255, 255, 255, .2) 16.666666666666668%,rgba(255, 255, 255, .2) 16.666666666666668%, rgba(255, 255, 255, .2) 33.333333333333336% ,white 33.333333333333336%, white 50% ,rgba(255, 255, 255, .2) 50%, rgba(255, 255, 255, .2) 66.66666666666667% ,white 66.66666666666667%, white 83.33333333333334% ,rgba(255, 255, 255, .2) 83.33333333333334%, rgba(255, 255, 255, .2) 100% )"
*/
export const generateStripes = (col1, col2, angle, iterations) => {
@LiamPerson
LiamPerson / Color.ts
Created March 12, 2023 06:55
Color name inference class made for Typescript. Converts any {r: number, g: number, b: number} to a name defined by BASE_COLORS
export type RGBColor = {
r: number;
g: number;
b: number;
}
class Color {
/**
* Available color names to be used in the `asName` method
*/
@LiamPerson
LiamPerson / .gitconfig
Last active June 16, 2023 14:58
My personal git config.
[filter "lfs"]
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
[core]
ignorecase = false
[alias]
find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'"
show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'"