Skip to content

Instantly share code, notes, and snippets.

@kwharrigan
kwharrigan / migrate.py
Created April 11, 2012 21:17
migrate repos to gitolite from old server...
#!/bin/python
import os
repos = [''] # list of repo names here...
for repo in repos:
print repo
shortname = repo.split('.git')[0]
os.system('git clone --bare me@oldserver:/git/%s' % repo)
os.chdir(repo)
@kwharrigan
kwharrigan / mks_git_checkpoints.py
Created April 12, 2012 16:50
MKS fast-import script for git
#!/usr/bin/python
#Copyright (c) 2012 Kyle Harrigan
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
@kwharrigan
kwharrigan / md5_test.c
Created April 15, 2012 03:22
Use openssl to produce an md5 hash of a file
#include <openssl/md5.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char**argv)
{
FILE *fh;
long filesize;
unsigned char *buf;
@kwharrigan
kwharrigan / scan.sh
Last active March 1, 2019 01:54
A simple script to form a multipage PDF using scanimage / sane. It is hard-coded to my MF4270 device id as provided by scanimage -L.
outname=$1
startdir=$(pwd)
tmpdir=scan-$RANDOM
DEVICENAME=pixma:04A926B5_SFF780310398A
if [ $# -lt 1 ]
then
echo "Usage: scan.sh <filename.pdf>"
exit 1;
fi
@kwharrigan
kwharrigan / inode_test.sh
Last active April 30, 2016 19:23
Play around with inode allocation
# Example 1 - Remove file after every iteration... note inodes are
# often reused after each deletion
for i in {1..1000}; do
filename=/tmp/file$i
echo "Creating " $filename
echo "blahblah" > $filename
stat -c "%i" $filename
echo "Removing " $filename
rm $filename
done
@kwharrigan
kwharrigan / sha.sh
Created March 11, 2016 14:49
sha256 fingerprint on old ssh
awk '{print $2}' ssh_host_rsa_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwharrigan
kwharrigan / monitor.py
Created October 18, 2012 13:03
Server monitoring script
#!/usr/bin/python
from twisted.internet import task
from twisted.internet import reactor
from subprocess import Popen, PIPE, STDOUT
logfile = open('status.txt', 'a')
def runEverySecond():
output = Popen(["ssh", "user@host", "date"], stdout=PIPE, stderr=STDOUT).communicate()[0]