Skip to content

Instantly share code, notes, and snippets.

@PProvost
PProvost / gist:166202
Created August 12, 2009 00:26
Tekkub's setmetatable localization trick
-- Declare this near the top of your addon
local L = setmetatable({}, {__index=function(t,i) return i end})
-- Then for english use the english statement in the usage, like this:
tooltip:SetText( L["Click here to see something"] )
-- Later when you want to add a locale, change the declaration of L to include the new language in the base table
local L = setmetatable(GetLocale() == "koKR" and {
["Click here to see something"] = "something in korean",
} or {}, {__index=function(t,i) return i end})
@PProvost
PProvost / gist:177790
Created August 30, 2009 00:20
Wow Lua - convert from itemLoc to bag,slot
-- The following will convert from itemloc to inventory slot or container bag,slot
local ITEM_INVENTORY_PLAYER = 0x00300000
local ITEM_INVENTORY_BAGS = 0x00200000
local MASK_BAG = 0xf00
local MASK_SLOT = 0x3f
local bagMap = {
[0x000] = 0,
[0x100] = 1,
[0x200] = 2,
@PProvost
PProvost / shn2mp3.sh
Created November 28, 2009 21:17
A little helper script for converting shn to mp3
# Source: http://adventuresinswitching.blogspot.com/2008/04/convert-shn-shorten-to-mp3-or-flac-in.html
# convert all shn files in the current directory to wav
shntool conv -o wav *.shn
# convert all wav files in the current directory to mp3
for file in *.wav; do $(lame -V2 "$file" "${file%.wav}.mp3"); done
# clean up the mess
rm *.wav
@PProvost
PProvost / flac2mp3.sh
Created November 28, 2009 21:39
Convert a FLAC to MP3
for file in *.flac; do flac -cd "$file" | lame -f –-preset extreme – "${file%.flac}.mp3"; done
@PProvost
PProvost / gist:292357
Created February 2, 2010 04:19
How to tunnel through Putty with RDP
RDP Tunneling via Putty and SSH
1. Putty to the external address using ssh (e.g. yourmachine.dyndns.org)
2. Figure out the IP address of the machine inside your network that you want to connect to
e.g. 192.168.1.110
3. Open putty settings and add the following to the tunnels section
Source: 3333
Destination:192.168.1.110:3389
# Git functions
# Mark Embling (http://www.markembling.info/)
# Is the current directory a git repository/working copy?
function isCurrentDirectoryGitRepository {
if ((Test-Path ".git") -eq $TRUE) {
return $TRUE
}
# Test within parent dirs
@PProvost
PProvost / WeaselSim.lua
Created May 1, 2010 08:28
A lua solution to the weasel algorithm
--[[
-- Lua solution to the Weasel Program
-- by Peter Provost <pprovost_at_gmail_dot_com>
-- See: http://en.wikipedia.org/wiki/Weasel_program
-- Alternate language solutions: http://rosettacode.org/wiki/Evolutionary_algorithm#Python
--]]
local target = "METHINKS IT IS LIKE A WEASEL"
local alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "
local c, p = 100, 0.06
@PProvost
PProvost / gist:655093
Created October 30, 2010 08:20
[PS1] Fixup AVI Names with Regex
ls *.avi | % {
if( $_.Name -match "futurama-2(\d\d)-amc.avi") {
ren $_ Futurama.S02E$($Matches[1])-amc.avi
}
}
@PProvost
PProvost / Lua Resource Pools.lua
Created November 3, 2010 19:31
A simple resource pool implementation in lua
-- Replace this function with your "new" function
local function NewItem()
return { }
end
-- Storage of released items
local pool = {}
-- Get/create a new item
local function Acquire()
@PProvost
PProvost / DisableSecureScreensaver.reg
Created December 2, 2010 21:25
Forcably disable the screensaver password, even if the Group Policy is forcing it on you
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop]
"ScreenSaverIsSecure"="0"