Skip to content

Instantly share code, notes, and snippets.

View oskaritimperi's full-sized avatar

Oskari Timperi oskaritimperi

View GitHub Profile
@oskaritimperi
oskaritimperi / main.cpp
Created September 18, 2019 08:04
pybind11 bound function as callback keeping C++ object alive
#include <functional>
#include <cstdio>
#include <thread>
#include <chrono>
#include <pybind11/pybind11.h>
#include <pybind11/functional.h>
namespace py = pybind11;
@oskaritimperi
oskaritimperi / pageant.py
Last active April 25, 2016 12:23
add all keys in a directory to pageant
import csv
import os
import subprocess
import time
KEYDIR = os.path.dirname(os.path.abspath(__file__))
PAGEANT_EXE = 'C:/tools/putty/pageant.exe'
def running_processes():
s = subprocess.check_output(['tasklist.exe', '/fo', 'csv']).decode('cp437')
@oskaritimperi
oskaritimperi / sqlite.cpp
Created February 20, 2014 16:06
Very simple SQLite C++ wrapper
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cstdarg>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#ifndef STRINGREF_H
#define STRINGREF_H
#include <string>
#include <algorithm>
template<class StringT>
class BasicStringRef
{
public:
@oskaritimperi
oskaritimperi / xxdi.tcl
Created January 17, 2014 07:55
Tcl version of `xxdi -i` command. Somewhat inspired by http://www.kroah.com/log/blog/2013/09/11/xxd-i/
if {$argc > 0} then {
set infile [open [lindex $argv 0]]
set doclose 1
set varname [string map {/ _ . _ - _} [lindex $argv 0]]
} else {
set infile stdin
set doclose 0
set varname stdin
}
@oskaritimperi
oskaritimperi / my_inet_pton.c
Created August 21, 2013 10:01
inet_pton() implementation for older windows versions
/*
* Use as you wish
*/
static int my_inet_pton(int family, const char *src, void *dst)
{
int rc;
struct sockaddr_storage addr;
int addr_len;
# usage:
#
# $ virtualenv venv
# $ ./venv/bin/pip install sleekxmpp dnspython
# $ ./venv/bin/python peptest.py -j foo@bar.com -p secretpassword --subscribe other@bar.com/other -d
import sys
import os
import ssl
import logging