Skip to content

Instantly share code, notes, and snippets.

@cowboy
cowboy / run-in-console.js
Last active September 8, 2023 09:45
Amits Launch Pad Pro Light Show Editor - Unofficial Launchpad Mini Mk3 support
// Run this in the console at https://midi.amitszone.com/LPP_LIGHTSHOW_BUILDER/
// to get it to work with the Launchpad Mini Mk3. It may work with other new
// Launchpads, I'm not sure (If it does, comment below, thanks!)
(() => {
// Create mapping of Launchpad Pro -> Mini Mk3 notes
// (This is only the mapping for the 8x8 grid area)
const noteMap = {}
for (let i = 1; i <= 8; i++) {
for (let j = 1; j <= 8; j++) {
@cowboy
cowboy / teensy-41-usbmidi-issue
Created August 23, 2022 04:36
Teensy 4.1 USB MIDI issue: note on/off messages get dropped when enough keys are pressed/released simultaneously (MIDI controller connected to USB host port, PC running MIDI OX connected to micro USB port)
// Settings:
// Tools > Board = "Teensy 4.1"
// Tools > USB Type to "MIDI"
#include <USBHost_t36.h> // access to USB MIDI devices (plugged into 2nd USB port)
// Create the ports for USB devices plugged into Teensy's 2nd USB port (via hubs)
USBHost myusb;
USBHub hub1(myusb);
MIDIDevice midiDevice(myusb);
@cowboy
cowboy / ba-detach.js
Created April 23, 2011 16:43
JavaScript detach: detach a node from the DOM, optionally reattaching it when done.
/*!
* JavaScript detach - v0.2 - 5/18/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
function detach(node, async, fn) {
@cowboy
cowboy / cowboy-launchkey-mini-mk3-supercharger.c
Last active July 27, 2023 04:37
Launchkey Mini MK3 Supercharger (USB MIDI) - for Teensy 4.1
// To give your project a unique name, this code must be
// placed into a .c file (its own tab). It can not be in
// a .cpp file or your main sketch (the .ino file).
#include "usb_names.h"
// Edit these lines to create your own name. The length must
// match the number of characters in your custom name.
#define MIDI_NAME {'C','B',' ','S','u','p','e','r',' ','L','a','u','n','c','h','k','e','y'}
@cowboy
cowboy / php-json-heredoc.php
Created June 8, 2010 15:32
PHP "JSON heredoc" for inline data.. good? bad? comments? I'm trying to keep it simple.
<?php
## Parse query string.
$sb_league = $_GET['league'] ? strtolower( $_GET['league'] ) : 'all';
## Nav data, as a JSON heredoc. Much less verbose than PHP arrays!
$navs = json_decode(<<<JSON
{
"mlb": {
"title_link": "http://stats.boston.com/mlb/scoreboard.asp",
@cowboy
cowboy / CB_VendorAutoBuy.lua
Last active June 12, 2023 09:27
WoW Classic :: CB_VendorAutoBuy :: Automatically buy rare items from vendors
-- Copyright (c) 2019 "Cowboy" Ben Alman
-- Licensed under the MIT license
local frameName = "CB_VENDOR_AUTO_BUY_FRAME"
if not _G[frameName] then
_G[frameName] = CreateFrame("Frame")
_G[frameName]:RegisterEvent("MERCHANT_SHOW")
end
local function Set(list)
@cowboy
cowboy / 1.usage.js
Created August 20, 2014 18:11
Lazy binding of "this" for inherited JavaScript instance methods
// Let's assume we've got a situation where there's going to be a lot of
// binding, eg. doSomethingWith(myThing.getProp.bind(myThing)); and we want
// to simplify app code by reducing the number of times .bind(myThing) gets
// called.
var myThing = new Thing("Test");
myThing.getProp() // "Test"
myThing.getProp.call(null) // "Test"
myThing.setProp("Another Test");
@cowboy
cowboy / reminder.js
Created September 3, 2014 15:36
JavaScript: don't forget about indirect eval, kiddos
(function(){ console.log( eval('this') ); }.call({a:1}))
// Object {a: 1}
(function(){ console.log( (0,eval)('this') ); }.call({a:1}))
// Window {top: Window, window: Window, location: Location, external: Object, chrome: Object…}
@cowboy
cowboy / unicorn1.txt
Last active June 4, 2023 05:59
OMG ASCII ART UNICORNS YAY!!!
/
.7
\ , //
|\.--._/|//
/\ ) ) ).'/
/( \ // /
/( J`((_/ \
/ ) | _\ /
/|) \ eJ L
@cowboy
cowboy / macros-cache.txt
Created June 25, 2011 13:30
WoW hunter macros
MACRO 16777217 "1. Attack" INV_Misc_QuestionMark
#showtooltip Hunter's Mark
/s0
/click [nocombat] CorkFrame
/click DominosActionButton1
/startattack
/s1
END
MACRO 16777228 "2. Sting" INV_Misc_QuestionMark