Skip to content

Instantly share code, notes, and snippets.

Laas Toom borgand

Block or report user

Report or block borgand

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@borgand
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](https://gist.github.com/danverbraganza/3320ccedd0eef2f2b88d)
View hangman.rb
->(license,word,scaffold,man,f){puts "You #{f.(word,scaffold,[],10,man,f) ? 'win!' : "loose!\n" + scaffold%man}\nWord was: #{word}"}.( 'https://opensource.org/licenses/MIT',File.read('/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
borgand / config-metarefresh.php
Last active Nov 25, 2015
TAAT eduGAIN metadata automaatne laadimine koos authproc lisamisega. Peamine juhend: https://simplesamlphp.org/docs/stable/simplesamlphp-automated_metadata
View config-metarefresh.php
<?php
$config = array(
'sets' => array(
'edugain' => array(
'cron' => array('hourly'),
'sources' => array(
array(
@borgand
borgand / compile_static_git.sh
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.
View compile_static_git.sh
#!/bin/sh
# What git version to build
git_version="2.2.2"
# 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
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
# https://github.com/phinze/landrush
# For linux:
# sudo apt-get install -y resolvconf dnsmasq
# sudo sh -c 'echo "server=/vm/127.0.0.1#10053" > /etc/dnsmasq.d/vagrant-landrush'
# sudo service dnsmasq restart
#
@borgand
borgand / ssl-cert-check
Last active Dec 31, 2017
Script to check SSL certificates for expiry. Slightly modified version of: http://prefetch.net/code/ssl-cert-check
View ssl-cert-check
#!/bin/bash
#
# Program: SSL Certificate Check <ssl-cert-check>
#
# Source code home: http://prefetch.net/code/ssl-cert-check
#
# Documentation: http://prefetch.net/articles/checkcertificate.html
#
# Author: Matty < matty91 at gmail dot com >
# Modified: Laas Toom <laas dot toom at gmail dot com >
@borgand
borgand / activeadmin.et.yml
Created Feb 18, 2014
ActiveAdmin Estonian translation
View activeadmin.et.yml
et:
active_admin:
dashboard: Töölaud
dashboard_welcome:
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
borgand / auth_test.sh
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.
View auth_test.sh
#!/bin/bash
# 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
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
<?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
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
#!/bin/bash
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
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
<?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.