Skip to content

Instantly share code, notes, and snippets.

MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)"
function GetNamePattern(name)
local u = name:match(MULTIBYTE_FIRST_CHAR):upper()
if not u or u:len() == 0 then Prat:Print("GetNamePattern: name error", name) return end
local l = u:lower()
local namepat
if u == l then
MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)"
function GetNamePattern(name)
local u = name:match(MULTIBYTE_FIRST_CHAR):upper()
if not u or u:len() == 0 then Prat:Print("GetNamePattern: name error", name) return end
local l = u:lower()
local namepat
@sylvanaar
sylvanaar / gist:8f11afca6cda1941d817
Created June 1, 2015 16:39
Value or Reference Semantics for Arrays?
// Non-Working Code
if var monthArray = self.orderHistory[monthStr] {
monthArray.append(anOrder)
} else {
var monthArray = [HLOOrder]()
self.orderHistory[monthStr] = monthArray
monthArray.append(anOrder)
}
@sylvanaar
sylvanaar / gist:3315139169a0c9bc4877
Created March 9, 2016 21:26
ambiguous reference
// Ojc Category on NSError
@interface NSError (MyCategory)
+ (NSError *) clientErrorWithCode: (NSInteger) code;
@end
// Swift Error Enum
@objc enum AppError : Int {
case Foo = 0
case Bar = 1
}
@sylvanaar
sylvanaar / gist:60a12797b7decf99d597
Created March 14, 2016 18:10
Should this need a try or do/catch
let a = ["foo", "bar", "baz", ""]
let allLenGreaterThanZero = a.map {$0.characters.count>0}.reduce(false, combine: { $0 || $1})
1x LibWho-2.0\LibWho-2.0\LibWho-2.0-148.lua:917: attempt to index field 'Result' (a nil value)
LibWho-2.0\LibWho-2.0\LibWho-2.0-148.lua:917: in function `ProcessWhoResults'
LibWho-2.0\LibWho-2.0\LibWho-2.0-148.lua:897: in function `?'
LibWho-2.0\LibWho-2.0\LibWho-2.0-148.lua:930: in function <LibWho-2.0\LibWho-2.0\LibWho-2.0.lua:929>
Locals:
self = <table> {
GetNextFromScheduler = <function> defined @LibWho-2.0\LibWho-2.0\LibWho-2.0.lua:377
ReturnWho = <function> defined @LibWho-2.0\LibWho-2.0\LibWho-2.0.lua:502
Cache = <table> {
Prat:AddModuleToLoad(function()
local SMFHax = Prat:NewModule("SMFHax", "AceHook-3.0")
SMFHax.fs_pool = {}
local new, del
do
local wipe = wipe
local cache = setmetatable({}, {__mode='k'})
@sylvanaar
sylvanaar / LibChatTypes.lua
Last active July 2, 2020 16:30
Idea for a library to handle addon output in a cleaner way
local lib, oldminor = LibStub:NewLibrary("LibChatTypes-1.0", 1)
if not lib then return end
local registry = {}
local emitterproto = {}
local function dbg(...)
--Prat:PrintLiteral(...)
end
@sylvanaar
sylvanaar / machine.js
Last active August 3, 2020 06:46
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@sylvanaar
sylvanaar / machine.js
Last active August 13, 2020 19:25
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)