Skip to content

Instantly share code, notes, and snippets.

View mtimkovich's full-sized avatar
🐢

Max Timkovich mtimkovich

🐢
View GitHub Profile
@mtimkovich
mtimkovich / Cons.java
Last active December 31, 2015 07:19
Lisp-like linked list implementation in Java
interface Functor<T, S> {
public S fn(T t);
}
interface Predicate<T> {
public boolean pred(T t);
}
public class Cons<T> {
private T first;
@mtimkovich
mtimkovich / Chess960.scala
Last active December 28, 2015 07:19
Chess960 Initial Position Generator (Scala)
import util.Random
object Chess960 {
def main(args: Array[String]) {
var board = new Array[Char](8)
(0 to 1).foreach { i =>
var r = Random.nextInt(board.length/2) * 2
if (i == 1)
@mtimkovich
mtimkovich / .vimrc
Last active December 20, 2015 14:09
Starter .vimrc
syntax on
set nocompatible
filetype on
filetype plugin on
filetype plugin indent on
set ignorecase
set smartcase
@mtimkovich
mtimkovich / procps.patch
Last active December 14, 2015 05:29
Adding "99 problems, 0 bitches" to top's Tasks line http://i.imgur.com/7IKfQT3.jpg
--- src/procps-procps/top/top_nls.c 2012-05-19 23:39:52.000000000 -0500
+++ tmp/top_nls.c 2013-02-25 21:37:50.625067795 -0600
@@ -410,7 +410,7 @@
" 'd' or <Space> toggles display, 's' sets sort. Use 'q' or <Esc> to end! ");
Uniq_nlstab[STATE_line_1_fmt] = _("%s:~3"
- " %3u ~2total,~3 %3u ~2running,~3 %3u ~2sleeping,~3 %3u ~2stopped,~3 %3u ~2zombie~3\n");
+ " %3u ~2total,~3 %3u ~2running,~3 %3u ~2sleeping,~3 %3u ~2stopped,~3 %3u ~2zombie,~3 99 ~2problems,~3 0 ~2bitches\n");
Uniq_nlstab[STATE_lin2x4_fmt] = _("%%%s~3"
@mtimkovich
mtimkovich / peterson.pl
Created February 12, 2013 00:51
Download all object files from a server directory
#!/usr/bin/env perl
use strict;
use warnings;
use feature "say";
use WWW::Mechanize;
my $dir = "yb";
my $url = "http://www.cs.utexas.edu/users/peterson/yb/";
my $mech = WWW::Mechanize->new();
@mtimkovich
mtimkovich / rename.pl
Last active December 11, 2015 03:48
Batch rename files using Perl code. Code operates on $_.
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Std;
use feature 'say';
sub yesno {
my ($prompt) = @_;
print "$prompt [Y/n] ";
@mtimkovich
mtimkovich / weather.pl
Last active December 11, 2015 02:09
Program to fetch the weather information
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(switch say);
use Getopt::Std;
use LWP::Simple;
sub help {
say "Usage: $0 [-cf] <zip code>";
exit;
@mtimkovich
mtimkovich / gist:4339646
Created December 19, 2012 19:20
Anagram program using the wordlist from http://www.isc.ro/en/commands/lists.html
#!/usr/bin/env python
import collections
d = collections.defaultdict(list)
output = 0
f = open("TWL06.txt")
for line in f.readlines():
line = line.strip().lower()
@mtimkovich
mtimkovich / anagrams.pl
Last active December 9, 2015 22:09
Anagram program using the wordlist from http://www.isc.ro/en/commands/lists.html
#!/usr/bin/env perl
use strict;
use warnings;
my %hash;
my $output = 0;
open FILE, "TWL06.txt" or die $!;
while (<FILE>) {
@mtimkovich
mtimkovich / Chess960.java
Last active October 13, 2015 17:58
Chess960 initial position generator in Java
public class Chess960 {
public static void main(String[] args) {
char[] board = new char[8];
for (int i = 0; i < 2; i++) {
int r = (int) (Math.random() * 4) * 2;
if (i == 1) {
r++;
}