Skip to content

Instantly share code, notes, and snippets.

View ianunruh's full-sized avatar

Ian Unruh ianunruh

View GitHub Profile
@ianunruh
ianunruh / RecursiveSortFilterProxyModel.java
Created March 21, 2012 09:07
RecursiveSortFilterProxyModel
import com.trolltech.qt.core.QModelIndex;
import com.trolltech.qt.gui.*;
public class RecursiveSortFilterProxyModel extends QSortFilterProxyModel {
protected boolean filterAcceptsRow(int row, QModelIndex parent) {
if(super.filterAcceptsRow(row, parent)) {
return true;
}
QStandardItemModel model = (QStandardItemModel)sourceModel();
#include <stdio.h>
int main(int argc, char** argv)
{
int x;
printf("Enter the number to count up to: ");
if(scanf("%d", &x) != 1) {
printf("I don't think you know what a number is\n");
return -1;
}
@ianunruh
ianunruh / snorby.md
Last active December 14, 2015 03:09
Snorby tutorial

This tutorial assumes that you have a 64-bit installation of Debian Wheezy and are running as the root user.

MySQL

First, we'll install and configure MySQL.

apt-get install mysql-server
mysql -u root -p

Enter your root password that you set when installing MySQL and execute these queries:

@ianunruh
ianunruh / happening.rb
Last active December 16, 2015 17:09
Port of my Happening bot to Cinch
require 'cinch'
class Happening
include Cinch::Plugin
match /is it happening/i, :method => :happening, :use_prefix => false
match /happening (.+)/, :method => :add_happening
def initialize(s)
super
@ianunruh
ianunruh / .zshrc
Created November 25, 2013 19:29
Vagrant aliases for ZSH
# Vagrant aliases
alias vs="vagrant ssh"
alias vu="vagrant up --no-provision"
alias vp="vagrant provision"
# Depends on the vagrant-vbox-snapshot plugin
alias vsb="vagrant snapshot back"
alias vst="vagrant snapshot take"
function vr() {
vagrant snapshot back $1
@ianunruh
ianunruh / gist:8392026
Last active December 17, 2020 15:38
Force10 S4810 configuration with LACP + graceful degradation
! Version 8.3.12.0
! Last configuration change at Sat Apr 26 09:22:44 2014 by admin
! Startup-config last updated at Sat Apr 26 11:01:20 2014 by admin
!
boot system stack-unit 0 primary system: A:
boot system stack-unit 0 secondary system: B:
boot system stack-unit 0 default system: A:
!
redundancy auto-synchronize full
!
@ianunruh
ianunruh / keybase.md
Created April 8, 2014 20:52
Keybase Proof

Keybase proof

I hereby claim:

  • I am ianunruh on github.
  • I am ianunruh (https://keybase.io/ianunruh) on keybase.
  • I have a public key whose fingerprint is 1FBD D5AA 1B08 7B07 323C B0A9 FB39 D5CA 4CBD 3A67

To claim this, I am signing this object:

@ianunruh
ianunruh / redis-tx.rb
Last active August 29, 2015 13:59
Object-oriented Redis transaction
require 'redis'
require 'set'
class RedisTransaction
def initialize(redis)
@redis = redis
@watch_keys = Set.new
@preconditions = []
@executions = []
end
@ianunruh
ianunruh / install-redis.sh
Last active July 13, 2018 14:35
Install single instance of Redis on Ubuntu 14.04
#!/bin/bash
if [ "$#" -ne "2" ]; then
echo "Usage: ./install-redis-instance.sh NAME PORT"
exit 1
fi
if [ ! -x /usr/local/bin/redis-server ]; then
apt-get install -y build-essential
curl -O -L http://download.redis.io/releases/redis-2.8.9.tar.gz
@ianunruh
ianunruh / join-rabbitmq-cluster.rb
Last active September 27, 2020 17:54
Join RabbitMQ to cluster via Consul
#!/usr/bin/env ruby
require 'json'
require 'net/http'
require 'optparse'
require 'ostruct'
options = OpenStruct.new
options.service_name = "rabbitmq"
options.port = 8500