Skip to content

Instantly share code, notes, and snippets.

View aL3xa's full-sized avatar

Aleksandar Blagotić aL3xa

View GitHub Profile
@aL3xa
aL3xa / virtualbox.sh
Created September 13, 2011 10:28
Virtualbox custom startup script
#!/bin/bash
if [ -z $(lsmod | grep vboxdrv) ]; then
# load virtualbox module
gksudo modprobe vboxdrv
fi
# virtualbox module loaded
vm=`VBoxManage list vms | zenity --list --title="Virtualbox machines" --column="Machine"`
if [ ! -z "$vm" ]; then
VBoxManage startvm $vm
@aL3xa
aL3xa / sweave.sh
Created September 13, 2011 10:27
Custom Sweave bash script
#!/bin/bash
FILEBASE=${1%.*}
FILEXT=${1##*.}
FILEPATH=${1%/*}
TEXFILE=$FILEBASE.tex
PDFFILE=$FILEBASE.pdf
# errorexit
@aL3xa
aL3xa / .emacs
Last active September 27, 2015 04:47
My .emacs
;; start the timer
(defvar *emacs-load-start* (current-time))
;; Package repos
(require 'package)
;; MELPA
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
(global-set-key (kbd "C-c p") 'list-packages)
@aL3xa
aL3xa / grade_questionnaire.R
Created July 7, 2011 19:31
Questionnaire grading function
grade_questionnaire <- function(dtf, n.items, item.ind = NULL, scale.names, scale.labels = NULL, start = 1:length(scale.names), end = n.items, jump, rev.ind = NULL, rev.fn = NULL, total = FALSE, total.name = NULL, allowed.values = NULL, pre.process.fn = NULL, na.rm = FALSE, ...){
d <- subset(dtf, ...) # create subset if any
nc <- ncol(d) # number of columns
## number of columns sanity check
if (nc != n.items)
stop(sprintf("Incorrect number of items! %d items required, while %d were provided!", n.items, nc))
## check scale labels
@aL3xa
aL3xa / conkerorrc
Created April 11, 2011 02:27
Conkeror RC
// homepage = "http://www.google.com";
// set default webjump
read_url_handler_list = [read_url_make_default_webjump_handler("google")];
// possibly valid URL
function possibly_valid_url (str) {
return (/[\.\/:]/.test(str)) &&
!(/\S\s+\S/.test(str)) &&
!(/^\s*$/.test(str));
}
@aL3xa
aL3xa / serbian_locale.R
Created March 4, 2011 16:16
Сербиан локале
> set.seed(1)
> шушумига <- rnorm(10)
> шушумига
[1] 0.7996718 -0.9688060 -0.1634763 -1.1242522 -1.5689024 -0.6055469
[7] -0.3446827 -0.8229724 -0.6148953 2.5545790
> set.seed(1)
> ( blah <- factor(sample(c("један", "два", "три"), 100, replace = TRUE)) )
[1] један два два три један три три два два један један један
[13] три два три два три три два три три један два један