Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔

Max Timkovich mtimkovich

🤔
View GitHub Profile
View randomCapitals.scala
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 Oct 12, 2015
The Campbell Sorting Algorithm
View Paul.java
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 Oct 13, 2015
Random Capitals program in Java
View gist:4193572
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 Apr 17, 2017
Chess960 in Go
View Chess960.go
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().UnixNano())
@mtimkovich
mtimkovich / Chess960.java
Last active Oct 13, 2015
Chess960 initial position generator in Java
View Chess960.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 Dec 9, 2015
Anagram program using the wordlist from http://www.isc.ro/en/commands/lists.html
View anagrams.pl
#!/usr/bin/env perl
use strict;
use warnings;
my %hash;
my $output = 0;
open FILE, "TWL06.txt" or die $!;
while (<FILE>) {
View gist:4339646
#!/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 Dec 11, 2015
Program to fetch the weather information
View weather.pl
#!/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 Dec 11, 2015
Batch rename files using Perl code. Code operates on $_.
View rename.pl
#!/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 Feb 12, 2013
Download all object files from a server directory
View peterson.pl
#!/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();