Skip to content

Instantly share code, notes, and snippets.

View digitalresistor's full-sized avatar
🔒
ALL THE THINGS!

Delta Regeer digitalresistor

🔒
ALL THE THINGS!
  • ::1
View GitHub Profile
@digitalresistor
digitalresistor / update-branches.sh
Created March 20, 2011 08:18
Procedure to take a library that contains files for multiple programming languages, and split off the language specific features into separate branches
cat << EOF > /dev/null
These procedures are helpful if you have a structure like this in your source tree and it can be anything like
Google protobuf, grammar syntax, shared source code of some sort that gets transformed to Python and C++, or
really anything that has a common base from which it is derived but when included (subtree'd/submoduled in git)
we only need the language specific part, not the rest.
What we do is create completely new branches in which we place a copy from the proper subdirectory from the
master branch. Yes that technically means we are duplicating files/commits in two different locations, but it
is a better option that having your Python specific source tree carrying around C++ files it does not need.
@digitalresistor
digitalresistor / Expected vs Actual.md
Created April 12, 2011 07:36
Simple REQ/REP socket setup ...

Steps

Start the py-req-die.py REQ "client" first, after starting that, start the py-rep.py script, it will sit and wait for 10 seconds for the py-req-die.py script do its business, which should be way shorter, but what can I say, I am careful.

What happens

After the server starts up, the client connects, sends data and then dies before the REP socket server can receive it and handle it. At this point a send on that socket is getting sent to nothingness.

@digitalresistor
digitalresistor / ostream-istream.cc
Created May 15, 2011 07:16
Why do the two reading code blocks produce different output?
#include <iostream>
#include <fstream>
#include <iterator>
#include <algorithm>
#include <vector>
int main(int argc, const char *argv[]) {
{
std::ofstream outfile;
@digitalresistor
digitalresistor / pom.xml
Created May 20, 2011 00:33
Compile against JDK 1.6
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version> <!-- This will have to change depending on the latest version -->
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
@digitalresistor
digitalresistor / .bash_profile
Created February 10, 2012 22:58
shortcut for lsof
# Add this to your .bash_profile
function lsockets {
lsof -a -c $1 -i -l -P
}
# example:
#
# lsockets steward
#
@digitalresistor
digitalresistor / README.md
Created February 11, 2012 04:18
Generates various mpeg4 files from a gource run ...

Collection of Gource Helper Scripts

This collection of helper scripts are used to generate .mp4 files containing the output from [gource][1], a visualisation tool that generates pretty output from the git log output.

Requirements

  1. gource
  2. ffmpeg with x264 support
@digitalresistor
digitalresistor / getaddrinfo.c
Created August 2, 2012 00:30
Verify sanity with regards to bind() on sockets when receiving info from getaddrinfo(). AF_INET vs AF_INET6.
/*
* There is inconsistent behaviour regarding the way various operating
* systems use IPV6_V6ONLY by default and interactions with bind() to bind a
* wildcard socket (as in all available addresses) on an AF_INET6 (IPv6)
* socket.
*
* getaddrinfo() returns two results, the first one being AF_INET and the
* second being AF_INET6 (Unless you are on an OS that prefers IPv6, I'm
* looking at you OI). We create a socket, bind, and listen on AF_INET first.
* At that point we try to create a socket, bind and then listen on AF_INET6.
# collect
# global
# states entries|searches|inserts|removals [diff]
# counters match|bad-offset|fragment|...|synproxy [diff]
# (see pfctl -si output, same strings)
# interface name pass|block packets|bytes in|out v4|v6 [diff]
# queue name passed|dropped|other packets|bytes|number [diff]
collect 1 = interface "nfe0" pass bytes in ipv4 diff
collect 2 = interface "nfe0" pass bytes out ipv4 diff
@digitalresistor
digitalresistor / Duplicate_EVP_PKEY.md
Last active October 23, 2018 01:38
Stupid OpenSSL idiosyncrasies/bad documentation/missing documentation I run across, or simply completely undocumented functions.

You are now getting to a point where you know you want to get a copy of an EVP_PKEY for one reason or another, not that it matters much why, you just need it.

So you start looking for a way to duplicate it, there has to be a function for it, right? You come across EVP_PKEY_CTX_dup, so you make the assumption that EVP_PKEY_dup should probably exist too ... well you'd be wrong. You come across this message on the OpenSSL mailling list: http://www.mail-archive.com/openssl-users@openssl.org/msg17608.html and the next follow-up says to just up the reference count, or RSA_dup() and copy it into the new EVP_PKEY ... except RSA_dup() doesn't exist either.

No real solutions come out of that email thread. No deep copies seem to be possible, well until you simply consider converting it from an EVP_PKEY format to PEM/DER and then back to an EVP_PKEY.

So, in that case all that is left is to encode it to PEM/DER and then decode it from PEM/DER.

// Create new memory BIO

BIO* tbio = BIO_new(BIO_s_

#!/bin/sh
# PROVIDE: ec2_fetchkey
# REQUIRE: NETWORKING
# BEFORE: LOGIN ec2_firstboot
# Define ec2_fetchkey_enable=YES in /etc/rc.conf and create /root/firstboot
# to enable SSH key fetching when the system next boots.
#
: ${ec2_fetchkey_enable=NO}