Skip to content

Instantly share code, notes, and snippets.

@canton7
canton7 / 0_readme.md
Created April 17, 2012 17:30
Penisnet

Penisnet

So. One of my housemates pranked me, and I decided to get my revenge. My revenge was 100% inspired by upside-down-ternet, and goes as follows:

  1. Linux box running the ruby script below, which acts as a transparent proxy
  2. iptables rules on the linux box route all port 80 requests through the proxy
  3. arp poisoning routes all of the victim's traffic through the linux box
  4. Proxy isn't actually transparent. It intercepts requests for images, and does some processing on them, blurring them and writing a rude word in the middle.
@canton7
canton7 / multi_loader.rb
Created April 20, 2012 17:05
Rack MultiLoader
class MultiLoader
def initialize(input)
@input = input
initial_map
end
def initial_map
@map = {}
@input.each do |host, opts|
if opts.is_a?(String)
config = IniParser.new('config.ini').load
p config['section.key']
p config.get('section.not_a_key', 'my_default')
p config['section.two.key3']
config['section.key'] = 'hi'
config.set('section.two.key4', 'the_value', 'This is the comment')
config.save
@canton7
canton7 / 0main.md
Created September 17, 2012 12:57
Git Bisect and Feature Branches

Git Bisect and Feature Branches

There are people out there who claim that merge-based workflows (that is, workflows which contain non-fast-forward merges) are bad. They claim that git bisect gets confused by merge-based workflows, and instead advocate rebase-based workflows without explicit feature branches.

They're wrong.

Furthermore, the "advantages" of their workflows are in fact disadvantages. Let me show you.

@canton7
canton7 / 0main.md
Last active December 15, 2015 01:09
Golf'd ruby sudoku solver

Assuming a board in the style

b = [
  nil, nil, nil, 3, 9, nil, nil, 1, nil,
  5, nil, 1, nil, nil, nil, nil, 4, nil,
  9, nil, nil, 7, nil, nil, 5, nil, nil,
  6, nil, 2, 5, 3, nil, nil, 7, nil,
  nil, nil, nil, nil, 7, nil, nil, nil, 8,
  7, nil, nil, 8, nil, nil, 9, nil, 3,
@canton7
canton7 / RSAConverter.cs
Last active July 1, 2022 08:28
C# class to convert OpenSSL private keys into PuTTY'-format private keys. Can't handle encryption or anything else funky
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
// Usage:
@canton7
canton7 / gist:5780755
Created June 14, 2013 09:58
Finding files deleted by evil merges
The following snippet might help detect evil merges which deleted a file.
$ for rev in `git rev-list --merges HEAD`; do del=`( git diff --name-only --diff-filter=D $rev^ $rev; git diff --name-only --diff-filter=D $rev^2 $rev ) | sort | uniq -u | tr '\n' ' '`; [ -n "$del" ] && echo "$rev $del"; done
@canton7
canton7 / ValidatingScreen.cs
Last active May 30, 2020 22:28
Caliburn Micro Validations
using Caliburn.Micro;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ValidationTest
{
#!/bin/bash
SVN="svn/trunk"
MASTER="master"
die() { echo "$@" >&2; exit 1; }
ensure_clean()
{
if ! git diff --no-ext-diff --ignore-submodules --quiet --exit-code; then
@canton7
canton7 / SingleAccessTaskScheduler.cs
Created January 19, 2014 12:23
TaskScheduler to allow single-thread access to some resource, while allowing inlining if possible
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace TaskSchedulerTest
{
/// <summary>