Skip to content

Instantly share code, notes, and snippets.

borgand / hangman.rb
Created Feb 10, 2016
Hangman implemented in 1 line of Ruby. Probably the ugliest piece of code I have written, but I was intrigued (and inspired) by the [Hangman implemented in 3 lines of Python](
View hangman.rb
->(license,word,scaffold,man,f){puts "You #{f.(word,scaffold,[],10,man,f) ? 'win!' : "loose!\n" + scaffold%man}\nWord was: #{word}"}.( '','/usr/share/dict/words').split.shuffle.find{|w| w=~/^\w+$/}.upcase,"|======\n| |\n| %4$s %1$s %6$s\n| %3$s%2$s%5$s\n| %7$s %9$s\n| %8$s %10$s\n|",%w(O T - \\ - / / | \\ | ),->(word,scaffold,guesses,guesses_left,man,f){[$stdout.print("#{guesses.join(', ')}(#{guesses_left} guesses left)\n #{scaffold%(man.take(10-guesses_left) + [' '] * guesses_left)}\n #{word.gsub(/./){|c| (guesses.include?(c) ? c : '_') + ' '}}: "), ->(guess){[(guesses<<guess).uniq!,word.include?(guess) && guesses_left || guesses_left -= 1][1]}.(gets[0].chomp.upcase)][1] > 0 ? (word.each_char.all?{|c| guesses.include?(c)} ? true : f.(word,scaffold,guesses,guesses_left,man,f)) : false})
borgand / config-metarefresh.php
Last active Nov 25, 2015
TAAT eduGAIN metadata automaatne laadimine koos authproc lisamisega. Peamine juhend:
View config-metarefresh.php
$config = array(
'sets' => array(
'edugain' => array(
'cron' => array('hourly'),
'sources' => array(
borgand /
Last active Aug 29, 2015
Compile static git (e.g. for use in jailed server environment). NB! The kernel version must match that of the destination for the binary to work.
# What git version to build
# let's make sure we have all we need to proceed
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel autoconf
# Download sources
cd /tmp
borgand / Vagrantfile
Created Oct 7, 2014
Generic multi-machine Vagrantfile that supports fast and easy way to get testing machines up and running. Provisioning is done through multi-tier shell scripting
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Landrush domain name suffix
# For linux:
# sudo apt-get install -y resolvconf dnsmasq
# sudo sh -c 'echo "server=/vm/" > /etc/dnsmasq.d/vagrant-landrush'
# sudo service dnsmasq restart
borgand / ssl-cert-check
Last active Dec 31, 2017
Script to check SSL certificates for expiry. Slightly modified version of:
View ssl-cert-check
# Program: SSL Certificate Check <ssl-cert-check>
# Source code home:
# Documentation:
# Author: Matty < matty91 at gmail dot com >
# Modified: Laas Toom <laas dot toom at gmail dot com >
borgand /
Created Feb 18, 2014
ActiveAdmin Estonian translation
dashboard: Töölaud
welcome: "Tere tulemast Active Adminisse. See on vaikimisi töölaud."
call_to_action: "Et lisada töölauale sektsioonie, uuri 'app/admin/dashboard.rb'"
view: "Vaata"
edit: "Muuda"
delete: "Kustuta"
delete_confirmation: "Oled sa kindel, et soovid seda kustutada?"
borgand /
Created Sep 26, 2013
Round-trip check for Shibboleth and SimpleSAMLphp SSO setup. Uses sed to carve out tokens, so you must adapt to your HTML layout.
# This script is used make a full roundtrip test to SimpleSAMLphp based SSO
# Exit statuses indicate problem and are suitable for usage in Nagios.
BASENAME=$(basename $0)
if [[ $1 == '-h' || $1 == '--help' ]]; then
cat <<EOF
USAGE: $BASENAME [URL] [test-string] [username] [password]
borgand / Asset.php
Last active Dec 17, 2015
A SimpleSAMLphp Asset helper to produce MD5-fingerprinted URLs to assets. This allows long-term agressive caching by the browser while retaining instantaneous refreshing when the asset changes. Put this file in some SSP module's lib directory and rename the class name to match the module name (e.g. sspmod_mymodule_Asset).
View Asset.php
* Helper class for working with Assets
* @author Laas Toom, University of tartu
class sspmod_utmodule_Asset {
* Get absolute URL to a specified asset.
borgand / git-merge-svn
Last active Jan 7, 2019
A helper script to set *svn:mergeinfo* property when using `git svn dcommit` on merged git branches.This makes it possible to merge two SVN branches using **git-svn**.NB! the merged-from branch **MUST** be pushed to SVN.USAGE: git merge-svn <branch name>EDIT: added exit condition when mergeinfo calculation fails to avoid pushing incomplete merge…
View git-merge-svn
function usage {
echo "USAGE: git merge-svn <from> [<to>]"
echo ""
echo " from The branch name to be merged FROM"
echo " to Optional branch name to be merged onto. Default: HEAD"
echo ""
borgand / Controller.php
Created Apr 9, 2013
Add this to your protected/components/Controller.php class to allow mixed cache keys in Yii: $this->beginCache($product)
View Controller.php
* Controller is the customized base controller class.
* All controller classes for this application should extend from this base class.
class Controller extends CController
// Rest of the Controller class
You can’t perform that action at this time.