Skip to content

Instantly share code, notes, and snippets.

@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)
@mdavey
mdavey / globalhotkeys.py
Created June 5, 2014 09:51
Global hot keys in Python for Win32
import ctypes
import ctypes.wintypes
import win32con
class GlobalHotKeys(object):
"""
Register a key using the register() method, or using the @register decorator
Use listen() to start the message pump
"""
Finds all Snom brand phones in a /24 and tells them to key in 6405 turn on the hands free speaker.
(6405 is an extension that plays the stock monkies sound from Asterisk)
"""
import urllib2
import socket
import sys
def enumerate_snom_ips(base):
@mdavey
mdavey / count_svn_blame.php
Last active December 26, 2015 09:39
PHP code to count who was last to commit each line of code (uses svn blame)
<?php
function is_library($filename)
{
static $libraryNames = array(
'/Zend/',
'/html2ps',
'/simpletest/',
'/phpMailer/',
'/dompdf',