Skip to content

Instantly share code, notes, and snippets.

View mtimkovich's full-sized avatar
🐢

Max Timkovich mtimkovich

🐢
View GitHub Profile
@mtimkovich
mtimkovich / randomCapitals.scala
Created October 20, 2012 02:48
Random Capitals
object randomCapitals {
def randomUpper(sentence: String) = {
sentence.map(c =>
if (math.random > .5)
c.toUpper
else
c.toLower)
}
def main(args: Array[String]) {
@mtimkovich
mtimkovich / Paul.java
Last active October 12, 2015 19:08
The Campbell Sorting Algorithm
public class Paul {
public static void printArray(int[] array) {
System.out.print("{");
for (int i = 0; i < array.length; i++) {
System.out.print(array[i]);
if (i < array.length - 1) {
System.out.print(", ");
}
@mtimkovich
mtimkovich / gist:4193572
Last active October 13, 2015 12:08
Random Capitals program in Java
public class randomCapitals {
public static String randomUpper(String sentence) {
StringBuilder output = new StringBuilder();
for (int i = 0; i < sentence.length(); i++) {
char c = sentence.charAt(i);
if (Math.random() > .5) {
c = Character.toUpperCase(c);
} else {
@mtimkovich
mtimkovich / Chess960.go
Last active April 17, 2017 20:28
Chess960 in Go
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().UnixNano())
@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++;
}
@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 / 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 / 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 / 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 / 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();