Skip to content

Instantly share code, notes, and snippets.

View mtimkovich's full-sized avatar
🐢

Max Timkovich mtimkovich

🐢
View GitHub Profile
@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 / 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 / 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 / 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 / gist:3824517
Created October 3, 2012 02:04
llmergesort, midpoint, and dmerj
(defun midpoint (lst)
(setq current lst)
(setq prev lst)
(loop while (and lst (rest lst)) do
(setq lst (rest (rest lst)))
(setq prev current)
(setq current (rest current)))
prev)
(defun dmerj (x y)
me:
@true
a:
@true
sandwich:
@if test `whoami` != "root"; \
then \
echo "What? Make it yourself."; \
exit; \
else \
@mtimkovich
mtimkovich / unixlab.pl
Last active October 9, 2015 19:37
Perl script to assist with connecting to a UTCS Unix machine
#!/usr/bin/env perl
use strict;
use warnings;
use 5.012;
use feature qw(switch say);
use LWP::Simple;
my $url = "http://apps.cs.utexas.edu/unixlabstatus/";
my $html = get $url;
@mtimkovich
mtimkovich / beer-song.lisp
Last active February 17, 2016 03:25
Beer song in Lisp
(defun plural (n)
(if (> n 1) "s" ""))
(defun beer-song (n)
(format t "~a bottle~a of beer on the wall.~%" n (plural n))
(format t "~a bottle~a of beer.~%" n (plural n))
(format t "Take one down.~%")
(format t "Pass it around.~%")
(decf n)
@mtimkovich
mtimkovich / vector.py
Created August 30, 2012 16:27
I program I made for Physics class to calculate vectors and unit vector things
#!/usr/bin/env python
import math
class Vector(tuple):
def __add__(self, other):
return Vector(x + y for x, y in zip(self, other))
def __sub__(self, other):
return Vector(x - y for x, y in zip(self, other))
@mtimkovich
mtimkovich / absorb.pl
Last active October 9, 2015 12:57
Perl script to automate copying PKGBUILD scripts and makepkg in Arch Linux
#!/usr/bin/env perl
use strict;
use warnings;
use File::Copy::Recursive "dircopy";
use Cwd;
use autodie;
use feature 'say';
my @ABS_DIRS = qw(core extra community multilib);
my $BUILD_DIR = "$ENV{HOME}/abs";