Skip to content

Instantly share code, notes, and snippets.

@lehnerpat
lehnerpat / xkcd.java
Created October 4, 2012 10:28
xkcd.java
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@lehnerpat
lehnerpat / iptrules.txt
Created November 14, 2012 17:36
Firewall rules
These lines are saved to a text file and loaded into iptables with iptables-restore (like "/sbin/iptables-restore </etc/iptables.conf"):
:DO_BLACKLIST - [0:0]
:IN_SSH - [0:0]
-A INPUT -m recent --rcheck --seconds 3600 --name blacklist --rsource -j DROP
-A INPUT -p tcp -m tcp --dport 22 -j IN_SSH
-A IN_SSH -s 192.168.1.0/24 -p tcp -m tcp --dport 22 -j ACCEPT
-A IN_SSH -m recent --rcheck --seconds 60 --hitcount 4 --name ssh_limits --rsource -j DO_BLACKLIST
-A IN_SSH -p tcp -m tcp --dport 22 --tcp-flags FIN,SYN,RST,ACK SYN -m recent --set --name ssh_limits --rsource -j ACCEPT
-A IN_SSH -j ACCEPT
@lehnerpat
lehnerpat / sha-changer.sh
Created November 15, 2012 12:23
Script to replace full shas with shorter versions (arbitrary length)
#!/bin/bash
git log --format=">%H< %cN" -10 | while read line
do
pre=`echo $line|sed -e "s/\(.*\)>[^<]*<.*/\1/"`
sha=`echo $line|sed -e "s/.*>\([0-9a-fA-F]*\)<.*/\1/"`
#echo "Cut sha as: $sha"
sha=`git rev-parse --short=4 $sha`
rest=`echo $line|sed -e "s/.*>[^<]*<\(.*\)/\1/"`
echo "$pre -- $sha -- $rest"
@lehnerpat
lehnerpat / gh-compare.md
Last active September 3, 2022 04:33
GitHub Compare view

GitHub's compare view is available at:

https://github.com/$USER/$REPO/compare/$REV_A...$REV_B

Naturally, $USER and $REPO are the owner (user/organization) and repository names, respectively.

$REV{A,B} are the two sides of the compare view; they can either be a ref in $USER's repository, i.e. the name of a branch, tag or a commit SHA, or it can be a ref in $OWNER's fork of the repository by using the format $OWNER:$REF.

You can get a diff or patch for the result of the compare view by appending .diff or .patch to the URL, respectively.

@lehnerpat
lehnerpat / readme.md
Last active December 18, 2015 00:09 — forked from anonymous/readme.md
  1. Paradoxes
  • Page 17
  • Page 24
@lehnerpat
lehnerpat / payload.json
Created July 6, 2013 13:48
example webhook payload
{
"after":"98248f0e892ce4e4e37411730ac98b53f2aa1261",
"base_ref":"refs/heads/br2",
"before":"0000000000000000000000000000000000000000",
"commits":[
],
"compare":"https://github.com/nevik/testrepo/compare/tag2",
"created":true,
"deleted":false,
/* Software License Agreement (BSD License)
*
* Copyright (c) 2011, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
@lehnerpat
lehnerpat / git-add--interactive--words.pl
Created February 2, 2014 08:13
Fixed git-add-interactive script to use color-words-diff with interactive checkout
#!/usr/bin/perl
use lib (split(/:/, $ENV{GITPERLLIB} || "/usr/share/perl/5.14.2"));
use 5.008;
use strict;
use warnings;
use Git;
binmode(STDOUT, ":raw");
@lehnerpat
lehnerpat / dual-output-jack-ubuntu13.10.markdown
Last active June 1, 2020 06:23
Simultaneous output to Analog and HDMI with Jack on Ubuntu 13.10

How to get simultaneous / dual output to both Analog out and HDMI out with Jack Audio on Ubuntu 13.10

Configuration used:

  • OS: Xubuntu (Ubuntu) 13.10 (saucy)
  • Audio: HDA Intel PCH (ALC269VB Analog) on an Intel Core i5 2557M (Sandy Bridge microarch)

Install below packages and set user group, then reboot

Packages you will need (and the versions I had when I did this):

  • jackd2, 1.9.9.5+20130622git7de15e7a-1
@lehnerpat
lehnerpat / inw-output-test-linux.txt
Last active October 6, 2016 14:54
Test and comparison of inotifywait vs. inotify-win output and exclusion pattern application
############################################################
## TEST GROUP 1: simple events, watching absolute path
############################################################
{$ inotifywait -qmr /tmp/inwtest/}
[/tmp/inwtest]$ touch testfile
/tmp/inwtest/ CREATE testfile
/tmp/inwtest/ OPEN testfile