This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function case_insensitive_pattern(pattern) | |
local p = pattern:gsub("(%%?)(.)", function(percent, letter) -- match regex | |
if percent ~= "" or not letter:match("%a") then | |
-- if % is matched or 'letter' is not a letter | |
return percent .. letter | |
else | |
return string.format("[%s%s]", letter:upper(), letter:lower()) | |
end | |
end) | |
return p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rand_str(len) | |
len = tonumber(len) or 1 | |
local function rand_char() | |
return math.random() > 0.5 | |
and string.char(math.random(65, 90)) | |
or string.char(math.random(97, 122)) | |
end | |
local function rand_num() | |
return string.char(math.random(48, 57)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function explode(input, separator) | |
if input:len() == 0 then return {} end | |
if input:len() == 1 then return { input } end | |
separator = type(separator) == "string" and separator:sub(1, 1) or tostring(separator) | |
local results = {} | |
local lastPos = 1 -- Note: in Lua, '1' is the start of everything, including strings | |
for i = 1, input:len() do -- or: for i = 1, string.len(input) do | |
if string.sub(input, i, i) == separator then -- or: if input:sub(i, i) == separator then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Meme-Speak™ - rEPeaTEdLy turNs caPS LOCK oN and ofF sO yoU Can SPeAK LiKE ReaL memERs | |
Repeat = False | |
; Turns meme-speak on | |
F1:: | |
Repeat := True | |
while (Repeat) { | |
SetCapsLockState, on | |
Sleep, 10 | |
SetCapsLockState, off |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import colorsys | |
import RPi.GPIO as GPIO | |
import Adafruit_WS2801 | |
import Adafruit_GPIO.SPI as SPI | |
PIXEL_COUNT = 160 | |
BRIGHTNESS = 0.05 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sleep(time, func, ...) | |
local now = os.time() | |
local thread = coroutine.create(func) | |
repeat until (os.time() - now > time) | |
coroutine.resume(thread, ...) | |
end | |
function asleep(time, func, ...) | |
coroutine.wrap(function() | |
local now = os.time() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef HEADER_FREQUENCY_H | |
#define HEADER_FREQUENCY_H | |
// Taken from http://www.phy.mtu.edu/~suits/notefreqs.html | |
// Rounded to nearest number | |
// Format: <note><octave>(sharp/flat) | |
// Ex: C5S = C# note in 5th octave | |
#define C0 16 | |
#define C0S 17 | |
#define D0F C0S |
NewerOlder