Skip to content

Instantly share code, notes, and snippets.

@badcc
badcc / ToolbarShortcutKeyAlgorithm.lua
Last active August 29, 2015 14:18
Toolbar Shortcut Key Algorithm
local ToolbarMenuStrings = {"Hello", "World", "Menu", "Bar", "Has", "Awesome", "MenubarSupport"}
local Used = {}
function Eval(Str)
local Index = 0
local Current = Str:gsub('%U', '')
if (#Current == 0) then
Current = Str:gsub('%u', '')
end
while (Index < #Current+1) do
Index = Index + 1
--[[
@name Cluster
@desc Clustering algorithm. Originally authored by @BadccVoid. Optimizations?
@example_usage Cluster.Query({Vector3.new(), Vector3.new()}):Within(20):GetCenters() --> { Vector3.new() }
@example_usage Cluster.Query({Vector3.new(), Vector3.new()}):Within(4):GetClusters() --> { { Vector3.new(), Vector3.new() } }
]]
-- Source
local Cluster = {}
Cluster.__index = Cluster
function Cluster.Query(Points)
@badcc
badcc / AsmFibonacci.s
Last active August 29, 2015 14:24
Asm x86-64 Fibonacci Sequence Generator with Command Line Input
.intel_syntax noprefix # Set dialect to Intel (AT&T default for GAS)
.global main
.format:
.asciz "%2d\n"
main:
mov rdi, [rsi + 8] # argv[1]
call atoi # > eax
@badcc
badcc / mulall.s
Created July 6, 2015 04:47
Multiply Passed Arguments Together (x86, GAS)
.intel_syntax noprefix
.global main
.format:
.asciz "%d\n"
main:
xor rbx, rbx
inc rbx
add rsi, 8
dec rdi
var EXEC_FILE_LOCATION = process.argv[2]
var LUA_BINARY_NAME = process.argv[3] ? process.argv[3] : 'lua'
var chokidar = require('chokidar');
var fs = require('fs');
var http = require('http');
var exec = require('child_process').exec
var responses = []
local Tests = {
'<string name="Name">TEST</string>', -- pass
'<>TEST</string>', -- load
'< >TEST</string>', -- load
'<a a>TEST</string>', -- fail = not found
'<string a=" name="Name">TEST</string>', -- fail = not found
'<string a= a=""="">TEST</string>', -- ??? load
@badcc
badcc / IKSolve.lua
Last active December 30, 2017 20:53
-- Localized variables that I didn't copy over go here.
local function Solve(r0, r1, c, p)
local x,y,z,r00,r01,r02,r10,r11,r12,r20,r21,r22 = c:components()
local px,py,pz = p.x-x,p.y-y,p.z-z
local tx = r00*px+r10*py+r20*pz
local ty = r01*px+r11*py+r21*pz
local tz = r02*px+r12*py+r22*pz
local d = (tx*tx+ty*ty+tz*tz)^0.5
d = r0+r1<d and r0+r1 or d
local Message = "This is a very powerful function and can be used in multiple ways. Used simply it can replace all instances of the pattern provided with the replacement. A pair of values is returned, the modified string and the number of substitutions made. The optional fourth argument n can be used to limit the number of substitutions made:"
local Methods = {
{ "%s+", " " },
{ "are", "r" },
{ "be", "b" },
{ "you", "u" },
{ "i%sam", "i'm" },
{ "first", "1st" },
{ "second", "2nd" },
// Derived from
// http://burtleburtle.net/bob/rand/smallprng.html
// TODO(alex): SSE intrinsic
#if !defined(AB_RAND_H)
#define AB_RAND_H
#define ULONG_MAXF 4294967295.0 // 2^32-1
// Internal affixation, _
// 32 bit (u4, ulong)
#define _ab_rand_rot(x,k) (((x)<<(k))|((x)>>(32-(k))))
@badcc
badcc / regularexpressions.c
Created September 5, 2015 16:34
Depends on my personal library (currently private).
#include <stdio.h>
#define AB_WIN
#include "ab.h"
void MatchString(char *Match, const char *String, char *Result) {
int StringIndex = 0;
int MatchLength = 0;
int ResultLength = 0;
bool Class = false;
bool JustRestart = false;