Skip to content

Instantly share code, notes, and snippets.

export type EventsDictionary = Record<
string,
(event: CustomEvent<any>) => void
>
// Polyfill of CustomEvent for Node Environments
export class CustomEvent<T> extends Event {
@colxi
colxi / musical-types.ts
Created January 18, 2020 18:06
Type Definition for musical Nodes (MIDI notation, standard musical notation, JSON based object notation)
/**
*
* Notes :
* Classic Piano keys range : 'A0' (MIDI 21) - 'C8' (MIDI 109)
* MIDI supported keys range : 'C-1' (MIDI 0) - 'G9' (MIDI 127)
*
*/
// prettier-ignore
@colxi
colxi / README.md
Last active January 2, 2020 18:42
SCRIPT-8
@colxi
colxi / README.md
Last active August 9, 2020 21:45
SCRIPT-8
@colxi
colxi / README.md
Created January 2, 2020 00:28
SCRIPT-8
@colxi
colxi / adaptive-grid-layout.html
Created August 15, 2019 11:45
Adaptive grid layout (adjust min and max width, and elements per row)
<!-- behaviour example (gif) :https://cdn-images-1.medium.com/max/800/1%2A1FOrkyNbaabo3_LJxcdDbg.gif -->
<style>
.container {
display: grid;
grid-gap: 5px;
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
grid-template-rows: repeat(2, 100px);
}
</style>
<div class="container">
@colxi
colxi / random-masonry.js
Created July 1, 2019 18:50
Random Masonry element slideshow
var results = Array.from( document.querySelectorAll('.masonry_box.small_pin_box > .image_wrapper') );
var div = document.createElement('div');
div.style =`
position: fixed;
width:100%;
height: 100%;
background:black;
top :0px;
@colxi
colxi / Array.prototype.sortnum.js
Created April 27, 2019 05:25
Array.prototype.sortnum
/*
Method Name: Array.prototype.sortnum()
Usage: yourArray.sortnum('merge'|'bubble'|'insertion'|'selection' , [true|false]);
Description: Expansion for Array.prototype, with a sorting algoritms set
focused on numeric one-dimensional array operations. This method will modify the original array.
NOT SUITABLE FOR NON NUMERICAL ARRAYS!
Implemented sorting methods: Merge sort, Bubble sort, Selection sort and Insertion sort
Version: 1.0.2
Author: c0lx1
Author URI: /
@colxi
colxi / php-console.php
Created April 27, 2019 04:59
php-console.php
<?php
/*
Project Name: PHPConsole
Usage: Upload this file to FTP space, and run it from browser.
Description: PHPConsole is a simple and compact browser-based AJAX PHP console, that
allows direct acces to the PHP erver-side interpreter, recieving via AJAX all your
code output.
WARNING! ENSURE YOU CHANGE THE DEFAULT PASSWORD BEFORE UPLOADING!
Version: 1.5
Author: c0lx1
@colxi
colxi / fps.js
Created April 12, 2019 03:58
Calculate FPS average with customizable fps sample length
const fps = {
sampleSize : 60,
value : 0,
_sample_ : [],
_index_ : 0,
_lastTick_: false,
tick : function(){
// if is first tick, just set tick timestamp and return
if( !this._lastTick_ ){