Skip to content

Instantly share code, notes, and snippets.

View thwarted's full-sized avatar
🥓
increasingly at large

Andy Bakun thwarted

🥓
increasingly at large
View GitHub Profile
@thwarted
thwarted / inet-server-iterator.perl
Created September 30, 2009 07:35
quick comparison of using an iterator to accept network connections
#!/usr/bin/perl
use strict;
use warnings;
package ReceiveConnection;
use IO::Socket::INET;
sub TIEARRAY {
@thwarted
thwarted / perlthreadsperf.pl
Created December 16, 2009 17:56
perl threads perf
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use threads;
use threads::shared;
use Thread::Queue;
function sprintf() {
if (!arguments || arguments.length < 1 || !RegExp) { return; }
var str = arguments[0];
var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
var b = [], numSubstitutions = 0, numMatches = 0;
while (1) {
var a = re.exec(str);
if (!a) { break; }
var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
var pPrecision = a[5], pType = a[6], rightPart = a[7];
@thwarted
thwarted / rcs2git
Created March 23, 2010 20:05
rcs2git, quick and dirty brute force
#!/bin/bash
email_domain=example.com
export email_domain
# so nothing in the environment comes through
unset GIT_AUTHOR_EMAIL
unset GIT_AUTHOR_DATE
unset GIT_AUTHOR_NAME
unset GIT_COMMITTER_NAME
@thwarted
thwarted / screen-swap-x.diff
Created August 10, 2010 07:36
simplistic screen swap-x patch
diff -ur screen-4.0.3/display.c screen-4.0.3-swap-x/display.c
--- screen-4.0.3/display.c 2003-12-05 05:45:41.000000000 -0800
+++ screen-4.0.3-swap-x/display.c 2010-08-09 23:59:07.465303854 -0700
@@ -33,6 +33,8 @@
#include "extern.h"
#include "braille.h"
+int swap_x = 1;
+
static int CountChars __P((int));
@thwarted
thwarted / agentscreen
Created March 28, 2011 08:33
the script I use to restore my ssh-agent settings to running screen sessions
#!/bin/bash
if [ "$TERM" != "screen" ]; then
# if the auth socket variable is empty, don't do anything
if [ ! -z "$SSH_AUTH_SOCK" ]; then
# include USER to protect against shared HOME directories (rare)
NEWSOCK=$HOME/.agent-sshscreen-$USER.sock
if [ "$SSH_AUTH_SOCK" != "$NEWSOCK" ]; then
# test if the auth sock we have is actually working
# don't link to a dead socket
@thwarted
thwarted / gist:903028
Created April 5, 2011 04:21
migrating to a newly acquired computer
# install operating system onto new drive
# previous computer's drive is mounted in /mnt/oldinstall
# install all software my previous machine had installed
# - might want to trim off distribution and arch if going to a new release
# - or just skip this if going to a new release
yum install $( diff <( chroot /mnt/oldinstall rpm -qa | sort ) <( rpm -qa | sort) | grep \< | cut -c3- )
# or apt-get if you have it
# copy home directories
@thwarted
thwarted / nodejs.spec
Created June 7, 2011 05:20 — forked from charles-dyfis-net/nodejs.spec
node.js spec for Fedora 14
#node is an already known package. node.js have dot in name, so "nodejs"
#is a better name
#some ideas are taken from
#http://blog.fpmurphy.com/2010/12/node-js-and-npm-on-fedora-14.html
Name: nodejs
Version: 0.4.8
Release: 0%{?dist}
Summary: JavaScript server-side network application development
Group: Development/Languages/Other
License: MIT
@thwarted
thwarted / sshpub-to-rsa
Created June 14, 2011 09:12
converts an openssh RSA public key into a format usable by openssl rsautl (if you don't have openssh 5.6 or later with ssh-keygen PEM export format)
#!/usr/bin/env python
# with help and inspiration from
# * ASN1_generate_nconf(3) (specifically the SubjectPublicKeyInfo structure)
# * http://www.sysmic.org/dotclear/index.php?post/2010/03/24/Convert-keys-betweens-GnuPG%2C-OpenSsh-and-OpenSSL
# * http://blog.oddbit.com/2011/05/converting-openssh-public-keys.html
import sys
import base64
import struct
@thwarted
thwarted / footguy.c
Created June 22, 2011 06:40
footguy - he's very impatient
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <unistd.h>
void uxsleep(int time)
{
sleep(time);
}