Skip to content

Instantly share code, notes, and snippets.

View return5's full-sized avatar
๐Ÿ€
edit status

chris return5

๐Ÿ€
edit status
  • tennessee
  • 23:07 (UTC -05:00)
View GitHub Profile

A metatable in Lua defines various extraneous behaviors for a table when indexed, modified, interacted with, etc. They are Lua's core metaprogramming feature; most well known for being useful to emulate classes much like an OOP language.

Any table (and userdata) may be assigned a metatable. You can define a metatable for a table as such:

-- Our sample table
local tab = {}
-- Our metatable
local metatable = {
 -- This table is then what holds the metamethods or metafields
@straker
straker / README.md
Last active September 1, 2025 04:02
Basic Missile Command HTML and JavaScript Game

Basic Missile Command HTML and JavaScript Game

This is a basic implementation of the Atari Missile Command game, but it's missing a few things intentionally and they're left as further exploration for the reader.

Further Exploration

  • Score
  • When a missile explodes (not a counter-missile), the score should increase by 25
@yatima1460
yatima1460 / CMakeLists.txt
Last active September 27, 2019 01:52
Load SDL2 on Arch with CMake
# Load SDL2
find_program(LSB_RELEASE_EXEC lsb_release)
execute_process(COMMAND ${LSB_RELEASE_EXEC} -is OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
message("Your distro is ${LSB_RELEASE_ID_SHORT}")
find_package(SDL2 REQUIRED)
if ("${LSB_RELEASE_ID_SHORT}" STREQUAL "Arch")
message("Arch distro detected, using Arch CMake linkage")
target_link_libraries(ProjectName SDL2::SDL2)
else ()
message("Non-Arch distro detected, using normal linkage")
@MineBartekSA
MineBartekSA / catbox
Last active September 7, 2025 16:11
CatBox - An implementation of catbox.moe API in Bash
#!/bin/bash
#
# CatBox v2.0
# An implementation of catbox.moe API in Bash
# Author: MineBartekSA
# Gist: https://gist.github.com/MineBartekSA/1d42d6973ddafb82793fd49b4fb06591
# Change log: https://gist.github.com/MineBartekSA/1d42d6973ddafb82793fd49b4fb06591?permalink_comment_id=4596132#gistcomment-4596132
#
# MIT License
#
@fnky
fnky / ANSI.md
Last active October 13, 2025 13:04
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@primaryobjects
primaryobjects / m3u8.md
Last active September 25, 2025 04:57
How to download m3u8 and ts video movie streams.

m3u8 Downloading

  1. Open Chrome Developer tools and click the Network tab.
  2. Navigate to the page with the video and get it to start playing.
  3. Filter the list of files to "m3u8".
  4. Find master.m3u8 or index.m3u8 and click on it.
  5. Save the file to disk and look inside it.
  6. If the file contains a single m3u8 master url, copy that one instead.
  7. Run the program m3u8x.
  8. Paste the same m3u8 url in both textboxes (URL and Quality URL) and click "Headers" and set the referral url and user-agent from the request as found in Chrome.
@CMCDragonkai
CMCDragonkai / regular_expression_engine_comparison.md
Last active September 26, 2025 08:50
Regular Expression Engine Comparison Chart

Regular Expression Engine Comparison Chart

Many different applications claim to support regular expressions. But what does that even mean?

Well there are lots of different regular expression engines, and they all have different feature sets and different time-space efficiencies.

The information here is just copied from: http://regular-expressions.mobi/refflavors.html

@BGR360
BGR360 / analyze_repo_languages.py
Created January 20, 2016 00:14
Analyzes a GitHub user's repositories to find their favorite programming languages.
"""
GitHub User Repository Language Analyzer
Created By: Ben Reeves
Date: January 8, 2015
Description:
This script uses the PyGithub library to access the Github API in order to perform some data analysis on a user's
repositories. Specifically, it will analyze all of the user's code and calculate the percentage of code written in
different programming languages.
"""
@soulik
soulik / html.lua
Last active October 27, 2024 03:25
HTML/XML grammar LPEG parser for Lua
local lpeg = require 'lpeg'
local L = lpeg.locale()
local P,V,C,Ct,S,R,Cg,Cc =
lpeg.P, lpeg.V, lpeg.C, lpeg.Ct, lpeg.S, lpeg.R, lpeg.Cg, lpeg.Cc
local ws = S'\r\n\f\t\v '
local ws0 = ws^0
local ws1 = ws^1
local name = S'_ ' + L.digit + L.alpha
@soulik
soulik / os_name.lua
Created May 12, 2015 18:23
OS type and CPU architecture detection in Lua language
local function getOS()
local raw_os_name, raw_arch_name = '', ''
-- LuaJIT shortcut
if jit and jit.os and jit.arch then
raw_os_name = jit.os
raw_arch_name = jit.arch
else
-- is popen supported?
local popen_status, popen_result = pcall(io.popen, "")