Skip to content

Instantly share code, notes, and snippets.

Avatar

Max Timkovich mtimkovich

View GitHub Profile
@mtimkovich
mtimkovich / absorb.sh
Created May 9, 2011
A simple Bash script I wrote to automate copying PKGBUILD scripts and makepkg in Arch Linux
View absorb.sh
#!/bin/bash
yesno()
{
echo -ne "$1 [Y/n] "
read -r
case $REPLY in
[yY]) return 0 ;;
*) return 1 ;;
esac
@mtimkovich
mtimkovich / chess960.rb
Created Oct 29, 2011
Chess960 Initial Position Generator (Ruby)
View chess960.rb
#!/usr/bin/ruby
board = Array.new(8)
# Bishops
2.times do |i|
r = rand(4) * 2
if i == 1
r += 1
@mtimkovich
mtimkovich / ci-new.sh
Created Jun 6, 2012
CodeIgniter New Project Generator
View ci-new.sh
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 [app]"
exit
fi
cache_dir="$XDG_CONFIG_HOME/codeigniter"
if [ ! -d $cache_dir ]; then
@mtimkovich
mtimkovich / chess960.py
Last active Dec 9, 2020
Chess960 Initial Position Generator (Python)
View chess960.py
#!/usr/bin/env python
import random
def empty(lst):
return [i for i, value in enumerate(lst) if value == 0]
board = [0] * 8
# Bishops
for i in range(2):
@mtimkovich
mtimkovich / absorb.pl
Last active Oct 9, 2015
Perl script to automate copying PKGBUILD scripts and makepkg in Arch Linux
View absorb.pl
#!/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";
@mtimkovich
mtimkovich / vector.py
Created Aug 30, 2012
I program I made for Physics class to calculate vectors and unit vector things
View vector.py
#!/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 / beer-song.lisp
Last active Feb 17, 2016
Beer song in Lisp
View beer-song.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 / unixlab.pl
Last active Oct 9, 2015
Perl script to assist with connecting to a UTCS Unix machine
View unixlab.pl
#!/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;
View Makefile
me:
@true
a:
@true
sandwich:
@if test `whoami` != "root"; \
then \
echo "What? Make it yourself."; \
exit; \
else \
@mtimkovich
mtimkovich / gist:3824517
Created Oct 3, 2012
llmergesort, midpoint, and dmerj
View gist:3824517
(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)
You can’t perform that action at this time.