Skip to content

Instantly share code, notes, and snippets.

View ellisgl's full-sized avatar
💭
Coding!

Ellis ellisgl

💭
Coding!
View GitHub Profile
@ellisgl
ellisgl / index.php
Last active August 29, 2015 13:56 — forked from jeremeamia/index.php
TweetMVC Returns - A PHP 5.4 MVC framework that fits in 3 tweets (A couple bytes smaller)
<?php # TweetMVC Example App Bootstrap
# Import TweetMVC using error suppression to hide notices and warnings from the cold golfing
@include 'tmvc.php';
use TMVC\Cor\A;
# Basic namespaced autoloader, nothing too fancy
spl_autoload_register(function($class) {return @include __DIR__.'/src/'.strtr($class, '\\', '/').'.php';});
# Instantiate, configure, and execute the app
@ellisgl
ellisgl / gist:3b92a7fbca4962297bec4c906420a916
Last active December 7, 2021 19:51
FLSun Cube Bot Config
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@ellisgl
ellisgl / GLT-KB-E-1-R.kbd.json
Last active February 16, 2020 05:04
GLT-KB-E-1-R
[
{
"backcolor": "#666666",
"name": "GLT-KB-E-1-R",
"author": "Geeklab Technologies",
"switchMount": "cherry",
"switchBrand": "cherry",
"pcb": true,
"plate": false
},
@ellisgl
ellisgl / keyCap.schema.md
Last active February 27, 2020 00:36
Advanced Keyboard Layout Editor Object Schemas
@ellisgl
ellisgl / PaginationTest.php
Last active August 28, 2021 21:15
Pagination of a MySQL query sorted by non-unique values benchmark.
<?php
// Pagination of a MySQL query ordered by non-unique values benchmark:
// The normal way with limit/offset.
// Grabbing all the id's and then doing the queries w/ groups of ids.
// This uses the MySQL employee example DB: https://dev.mysql.com/doc/employee/en/
function get_time() {
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
@ellisgl
ellisgl / colormd.js
Created October 6, 2021 01:40
16 Color support MD?
// Support Color Markdown
data = data.replace(/\{color fg:(White|Black|Blue|Green|Red|Brown|Purple|Orange|Yellow|LightGreen|Cyan|LightCyan|LightBlue|PinkGray|LightGray)\}([^{]+)\{\/color\}/img, '<span style="color:$1;">$2</span>');
data = data.replace(/\{color bg:(White|Black|Blue|Green|Red|Brown|Purple|Orange|Yellow|LightGreen|Cyan|LightCyan|LightBlue|PinkGray|LightGray)\}([^{]+)\{\/color\}/img, '<span style="background-color:$1;">$2</span>');
data = data.replace(/\{color fg:(White|Black|Blue|Green|Red|Brown|Purple|Orange|Yellow|LightGreen|Cyan|LightCyan|LightBlue|PinkGray|LightGray) bg:(White|Black|Blue|Green|Red|Brown|Purple|Orange|Yellow|LightGreen|Cyan|LightCyan|LightBlue|PinkGray|LightGray)\}([^{]+)\{\/color\}/img, '<span style="color:$1; background-color:$2;">$3</span>');
data = data.replace(/\{color bg:(White|Black|Blue|Green|Red|Brown|Purple|Orange|Yellow|LightGreen|Cyan|LightCyan|LightBlue|PinkGray|LightGray) fg:(White|Black|Blue|Green|Red|Brown|Purple|Orange|Yellow|LightGreen|Cyan|LightCyan|LightBl
/*
SQLyog Community v8.3
MySQL - 5.1.36-community-log : Database - x5
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
@ellisgl
ellisgl / 01-Original.sql
Last active November 6, 2021 15:55
MySQL performance optimization (OR to UNION)
# tbla idx1 b,e,f
SELECT a.*
FROM tblA a
INNER JOIN tblB b ON a.id = b.aId
WHERE a.b IN (1,2,3)
AND (a.c IN (3,4,5) OR a.d IS NOT NULL)
AND a.e = 0
AND a.f = 0
ORDER BY a.g ASC
@ellisgl
ellisgl / Serial Protocol RFC.md
Last active May 14, 2023 03:14
[DRAFT] Request For Comments: Universal Serial Device Communication Protocol (USDCP)

# RFC: Universal Serial Device Communication Protocol (USDCP)

## Introduction: This document describes the Universal Serial Device Communication Protocol (USDCP), a standard communication protocol for serial devices. The purpose of this protocol is to provide a standardized format for requesting and receiving data from serial devices. The protocol defines the structure of request and response packets, and also provides specific definitions for certain requests and their responses.

USDCP supports three baud rates: 115,200, 9600, and 1200, with 115,200 being the default.

## Packet/Frame Structures: USDCP request and response packets consist of the following fields:

@ellisgl
ellisgl / PHPDocReturnTypes.php
Last active May 7, 2023 15:38
Use PHPStan\PhpDocParser to parse the return types listed in a PHPDoc comment.
<?php
include 'vendor/autoload.php';
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode;
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;