Skip to content

Instantly share code, notes, and snippets.

options:
parameters:
author: ''
catch_exceptions: 'True'
category: '[GRC Hier Blocks]'
cmake_opt: ''
comment: ''
copyright: ''
description: ''
gen_cmake: 'On'
@mdavey
mdavey / tp-w8961n-status.py
Created November 16, 2015 00:54
Example code for talking to a TP-Link TD-W8961N modem/router
import telnetlib
import re
import time
class TPW8961N(object):
def __init__(self, host):
self.host = host
@mdavey
mdavey / get-sources.py
Last active August 29, 2015 14:23
wow we suck
__author__ = 'Matthew'
import re
import urllib
def parse_reportlist(filename):
counter = 999
urls = []
with open(filename, 'r') as f:
@echo off
call :inputbox "Video ID" "Download Youtube video as MP3"
youtube-dl.exe -x --audio-format mp3 https://www.youtube.com/watch?v=%input%
exit /b
:InputBox
set input=
set heading=%~2
set message=%~1
echo wscript.echo inputbox(WScript.Arguments(0),WScript.Arguments(1)) >"%temp%\input.vbs"
@mdavey
mdavey / keyboard_svg_layout.lua
Created June 16, 2015 06:08
Code to generate SVG layout for a KBT Pure Pro Keyboard
--noescape--
local tag = doku.xml_tag
local unit = 19*2 -- Unit size, mapped straight to pixels
local space = 4 -- Spacing between keys (as pixels again)
local halfspace = space/2
local doublespace = space*2
local function setoptions(f)
local options = {}
local currentname = nil
local env = setmetatable({},
{
__index = function(self, method)
if method == 'set' then
return function(name)
if currentname ~= nil then
error('need to call "to" first')
@mdavey
mdavey / dump-text.lua
Created April 28, 2015 06:52
Dump printable strings of a hex dump (in ASCII)
local function readsection(f)
local colon = f:read(1)
if colon == nil then return nil end
if colon ~= ':' then error('section did not start with colon') end
local data = ''
while true do
local char = f:read(1)
if(char:byte() == 13) then
f:read(1) -- eat cr
return data
@mdavey
mdavey / crimsonland_pak.lua
Created November 29, 2014 11:15
Crimsonland Pak Format
BinaryFile = {}
BinaryFile.new = function(file)
return setmetatable({file=file}, {__index=BinaryFile})
end
BinaryFile.readint32 = function(self)
local data = self.file:read(4)
return (data:byte(4) * (256^3)) +
(data:byte(3) * (256^2)) +
@mdavey
mdavey / extensions.conf
Last active December 9, 2020 20:20
Simple hangup detection (Asterisk)
; Detect which party hungup an Asterisk call
; If we (the caller) hangup after Dial() we jump directly to h
; Because of the 'g' option if the other party hangs up we continue on
exten => s,1,Set(whoHungUp=CALLER)
exten => s,n,Dial(IAX2/provider/${number},,g)
exten => s,n,Set(whoHungUp=OTHERPARTY)
exten => s,n,Hangup
exten => h,1,NoOp(whoHungUp ${whoHungUp})
@mdavey
mdavey / clpak.py
Created June 18, 2014 02:03
Crimsonland (Steam) Pak Format
import os
import struct
"""
Crimsonland (Steam) pak file format
Header format:
50 40 4B 00 56 31 31 00 ("PAK" NUL "V11" NUL)