Skip to content

Instantly share code, notes, and snippets.

Avatar
Test-driving things

Per Rovegård provegard

Test-driving things
View GitHub Profile
View send-sms.sh
#/bin/sh
dest=$1
test -n "$dest" || exit 1
read text
user=`whoami`
retries=5
cont=1
while test $retries -gt 0 -a $cont -ne 0; do
@provegard
provegard / dump_wallet_addresses.py
Last active Jun 1, 2021
Python script for dumping wallet addresses and private keys
View dump_wallet_addresses.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.
#
# Usage:
# ./dump_wallet_addresses.py <wallet binary>
#
@provegard
provegard / et_patch.py
Created Nov 21, 2011
ElementTree parsing for non-prefixed attributes with default namespace
View et_patch.py
#!/usr/bin/python
from xml.etree import ElementTree as ET
from cStringIO import StringIO
def parse_attrns(file):
"""Parse file to ElementTree instance. Patch non-prefixed attributes
with the namespace of the element they belong to.
"""
events = ("start", )
@provegard
provegard / ssdp-test.py
Created Dec 5, 2011
Small SSDP server/client test in Python
View ssdp-test.py
#!/usr/bin/python
# Python program that can send out M-SEARCH messages using SSDP (in server
# mode), or listen for SSDP messages (in client mode).
import sys
from twisted.internet import reactor, task
from twisted.internet.protocol import DatagramProtocol
SSDP_ADDR = '239.255.255.250'
@provegard
provegard / notify-up.service
Created Jun 17, 2018
Systemd boot service for calling notify-up.sh
View notify-up.service
[Unit]
Description=Sends SMS to notify about system coming up
After=network.target
[Service]
ExecStart=/usr/local/bin/notify-up.sh
Type=oneshot
[Install]
WantedBy=default.target
@provegard
provegard / notify-up.sh
Last active Jun 17, 2018
Script for sending sms on server start
View notify-up.sh
#!/bin/bash
set -x
msg="$SERVER has started."
shutdown_dt=$(last -x --time-format iso |grep shutdown | head -n 1 | awk '{print $7}')
if [ -n "$shutdown_dt" ]; then
msg="$msg Shutdown at $shutdown_dt"
fi
@provegard
provegard / ghclone.js
Last active Feb 23, 2017
A Node.js script that clones all non-forked repos and all gists on GitHub for a user.
View ghclone.js
/*
* A Node.js script that clones all non-forked repos and all gists on GitHub
* for a user. If the repos/gists have been cloned already, the script pulls
* new commits from GitHub instead.
*
* Usage:
*
* node ghclone.js -u <user> -p <password> -d <destination dir>
*
* Tested with Node.js version 0.6.7.
@provegard
provegard / getnifs.py
Created Dec 29, 2011
Python script for listing network interfaces with name, index and addresses
View getnifs.py
#!/usr/bin/python
# Based on getifaddrs.py from pydlnadms [http://code.google.com/p/pydlnadms/].
# Only tested on Linux!
from socket import AF_INET, AF_INET6, inet_ntop
from ctypes import (
Structure, Union, POINTER,
pointer, get_errno, cast,
c_ushort, c_byte, c_void_p, c_char_p, c_uint, c_int, c_uint16, c_uint32
@provegard
provegard / NUnitNSpec.cs
Last active Dec 30, 2016
Testing adapter that makes it possible to run NSpec-based tests using an NUnit runner.
View NUnitNSpec.cs
// Obsolete, see https://github.com/provegard/NSpecInNUnit
@provegard
provegard / HowToUse_Dll.cpp
Last active Dec 21, 2015
MediaInfo buffer usage
View HowToUse_Dll.cpp
/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license that can
* be found in the License.html file in the root of the source tree.
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Linux: g++ -o howtouse HowToUse_Dll.cpp -lmediainfo -lzen -ldl
// Windows: cl /Fehowtouse.exe HowToUse_Dll.cpp
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++