Skip to content

Instantly share code, notes, and snippets.

View cmouse's full-sized avatar

Aki Tuomi cmouse

View GitHub Profile
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/insert_linebreaks.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/archive/iterators/ostream_iterator.hpp>
#include <sstream>
#include <string>

Keybase proof

I hereby claim:

  • I am cmouse on github.
  • I am cmouse (https://keybase.io/cmouse) on keybase.
  • I have a public key whose fingerprint is 679B 0D92 9835 590B CB0A 1BCA A834 22A2 22B5 7165

To claim this, I am signing this object:

@cmouse
cmouse / pkcs13.cc
Last active August 29, 2015 13:59
PKCS#11 RSA key generation
$ sqlite3 /var/lib/softhsm/slot4.db
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE Token (variableID INTEGER PRIMARY KEY,value TEXT DEFAULT NULL);
INSERT INTO "Token" VALUES(0,'test4 ');
INSERT INTO "Token" VALUES(1,'66C782E8F95BA958F28ADAAE576C42A263C2449AF416FB844499BEF7FD41B2D0');
@cmouse
cmouse / test.py
Last active August 29, 2015 14:09
Subprocess issue
import io,re,unittest,os,json,sys
from subprocess import PIPE, STDOUT, Popen
sub = Popen(["/usr/bin/python3.4", "test2.py", "pipe"], stdin=PIPE, stdout=PIPE, stderr=sys.stderr, close_fds=True, shell=False)
(writer,reader) = (sub.stdin, sub.stdout)
writer.write("HELO\t1\n".encode("utf-8"))
writer.flush()
sub.poll()
line = reader.readline().decode("utf-8")
assert(re.match("^OK\t", line))
writer.write("Q\ttest.com\tIN\tSOA\t-1\t127.0.0.1\n".encode("utf-8"))
#include "config.h"
#include "namespaces.hh"
#include "dns.hh"
#include "dnsparser.hh"
#include "dnspacket.hh"
#include "dnsrecords.hh"
#include "tkey.hh"
#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>
@cmouse
cmouse / check-v4.rb
Created May 1, 2015 17:35
Exabgp peering
#!/usr/bin/ruby
require 'socket'
# our IP here
@target = 'x.212'
# bind these to lo using ip addr add x.x.x.x/32 dev lo
@routes = %w[ x.245/32 x.8/32 x.6/32 x.22/32 x.7/32 ]
@sockfile = '/var/run/pdns_recursor.controlsocket'
@state = :announce
@cmouse
cmouse / post-update
Last active August 29, 2015 14:21
NLNOG Ring key management
#!/bin/sh
set -o errexit
git archive --format=tar HEAD | tar -Ox --wildcards '*.key' > $HOME/ssh-keys.new
if [ -s $HOME/ssh-keys.new ]; then
cat > $HOME/ssh-keys.tmp <<EOF
## THIS FILE IS AUTOGENERATED FROM GIT
## Do not edit by hand - instead add your key
@cmouse
cmouse / ciro.lua
Last active September 14, 2015 12:41
---
--- Domain blacklist/override - LUA evaluation script
---
--- v0.1 (20141025) - Ciro Iriarte <ciro.iriarte@gmail.com>
--- - First release
--- v0.2 (20141029) - Ciro Iriarte <ciro.iriarte@gmail.com>
--- - Added verification for *.arpa requests, exit inmediatly
--- - Added support for "domain ending in", with *.badboy.com
--- - ToDo: cleanup duplicated code?
--- v0.3 (20141215) - Ciro Iriarte <ciro.iriarte@gmail.com>
option :client_options, {
:site => 'https://manage.stripe.com',
:authorize_url => '/oauth/authorize',
:token_url => '/oauth/token',
}
option :token_params, {
:parse => :query
}
k=0;
for(rapidjson::Value::ConstValueIterator itr = parameters["nsset"].Begin(); itr != parameters["nsset"].End(); itr++) {
k++;
for (rapidjson::Value::ConstMemberIterator itr2 = itr->MemberBegin(); itr2 != itr->MemberEnd(); itr2++) {