Skip to content

Instantly share code, notes, and snippets.

View williammustaffa's full-sized avatar
🎯

William Lima williammustaffa

🎯
View GitHub Profile
This file has been truncated, but you can view the full file.
{
"log": {
"version": "1.2",
"creator": {
"name": "Insomnia REST Client",
"version": "insomnia.desktop.app:v2023.5.8"
},
"entries": [
{
"startedDateTime": "2024-05-23T10:24:22.052Z",
function seconds_to_gamespeed(_seconds) {
return game_get_speed(gamespeed_fps) * _seconds;
}
/**
* new Timer(_bind, _callback)
* @param _bind scope of the callback, usually the
* @param _callback function to be executed
*
* Methods
@williammustaffa
williammustaffa / sh_element_clip.fsh
Last active May 8, 2022 13:21
Simple CSS-Like Game Maker Studio 2 UI
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
varying vec3 v_vPosition;
uniform vec4 u_bounds;
void main() {
vec4 color = v_vColour * texture2D(gm_BaseTexture, v_vTexcoord);
// calculate alpha
color.a *= float(
@williammustaffa
williammustaffa / load_xml.gml
Last active March 22, 2022 12:54
Load XML file into game maker ds_map
/**
* Reads a XML file and converts its content into a ds_map
*
* Example output:
*
* <ds_map>{
* type: "root",
* content: "",
* nodes: <ds_list>[
* <ds_map>{
@williammustaffa
williammustaffa / createPaginations.js
Created October 22, 2020 17:39
Simple pagination algorithm using lodash
import first from 'lodash/first'
import last from 'lodash/last'
import inRange from 'lodash/inRange'
export function createPagination(items, current, delta) {
const currentIndex = items.indexOf(current)
const left = currentIndex - delta
const right = currentIndex + delta + 1
const applyDots = (data, item, lastItem) => {
PinchZoom.prototype.getContainerCenter = function () {
var centerX = this.container.offsetLeft + this.container.offsetWidth / 2;
var centerY = this.container.offsetTop + this.container.offsetHeight / 2;
return {
x: centerX,
y: centerY,
};
};
const getLastDigits = (cardNumber = '') => {
const match = cardNumber.match(/(?<lastDigits>\d{4})$/);
return match && match.groups.lastDigits || false;
}
import pubsub from 'pubsub';
import spinner from 'spinner';
import ccLogger from 'ccLogger';
export default {
onLoad() {
const occDebugger = this._occDebugger;
occDebugger.debug('spinner');
occDebugger.debug('topics');
@williammustaffa
williammustaffa / customToFixed.js
Last active July 17, 2018 19:00
custom toFixed to prevent rounding values
Number.prototype.customToFixed = function (digits) {
return parseFloat(String(this).replace(new RegExp(`(\\d+\\.\\d{${digits}}).*`), '$1'));
};
/**
* "string".cuckalize(value)
* transform any word into a custom object
*
* @param {Any} v Variable value
*
* @return {Object}
*/
String.prototype.cuckalize = function (v) { return this.split('').reverse().reduce((p, c) => ({ [c]: p }), v) };