Skip to content

Instantly share code, notes, and snippets.

Aleksandar Blagotić aL3xa

Block or report user

Report or block aL3xa

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
View foo.js
function foo(){
return typeof null === 'undefined';
}
for (var i=0; i<10000; ++i) console.log(foo());
@aL3xa
aL3xa / sweave.sh
Created Jul 26, 2013
Sweave script inspired by Dirk Eddelbuettel's answer on StackOverflow: http://stackoverflow.com/questions/2940756/ess-auctex-sweave-integration
View sweave.sh
#!/bin/bash
FILEBASE=${1%.*}
FILEXT=${1##*.}
FILEPATH=${1%/*}
TEXFILE=$FILEBASE.tex
PDFFILE=$FILEBASE.pdf
# errorexit
View lame-parsley-demo.html
<html>
<head>
<title></title>
<script type="text/javascript" src="http://cdn.rapporter.net/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/home/al3xa/packages/javascript/Parsley.js/parsley.js"></script>
</head>
<body>
<form method="GET" id="my_form">
<label for="name">Name</label>
<input type="text" id="name" name="name" value="" data-required="true" />
@aL3xa
aL3xa / mooifier.R
Last active Dec 10, 2015
Simple and pointless demonstration of R system call output manipulation
View mooifier.R
#!/usr/bin/Rscript --vanilla
## grab arguments from command line
args <- commandArgs(TRUE)
## replace all argument values with "moo"
s <- sapply(nchar(args) - 1, function(times) paste0("m", paste0(rep("o", times), collapse = "")))
## execute a system cmd (cowsay)
cs <- system2("cowsay", s, stdout = TRUE)
@aL3xa
aL3xa / PKGBUILD
Created Nov 21, 2012
RApache github PKGBUILD
View PKGBUILD
# Maintainer: Aleksandar Blagotić <aca.blagotic_at_gmail.com>
# Based on work by: Florian Breitwieser <florian.bw_at_gmail.com>
pkgname=rapache-git
pkgver=20121121
pkgrel=1
pkgdesc="R embedded inside Apache"
arch=('i686' 'x86_64')
url="https://github.com/jeffreyhorner/rapache"
license=('Apache License Version 2.0')
@aL3xa
aL3xa / imgur.sh
Created Apr 25, 2012
Imgur uploader
View imgur.sh
#! /bin/sh
TEXT=$(curl -F "image"=@"$1" -F "key"="a3793a1cce95f32435bb002b92e0fa5e" http://imgur.com/api/upload.xml | sed -e "s/.*<imgur_page>//" | sed -e "s/<.*//")
echo $TEXT | xclip -selection clipboard
notify-send "Image successfully uploaded to imgur"
return 0
@aL3xa
aL3xa / watermark.js
Created Apr 10, 2012
Quick and dirty jQuery watermark function
View watermark.js
// Quick & dirty watermark function
// inspired by https://github.com/marioestrada/jQuery-Watermark
(function ($){
$.fn.watermark = function(){
var $elems = $(this).filter('textarea, input[type="text"]');
$elems.each(function(i, e){
@aL3xa
aL3xa / send_http.php
Created Mar 6, 2012
Send HTTP request from PHP
View send_http.php
// send HTTP POST request
function send_http($url, $params = null, $type = 'GET')
{
$type = strtoupper($type); // request type
if (!preg_match('/^(GET|POST)$/', $type)) {
die("Unsupported method type: '$type'");
}
/* generate POST string */
$query_string = '';
@aL3xa
aL3xa / buildpkg.R
Created Jan 23, 2012
Build, Check, Install and (Re)Load R Package
View buildpkg.R
b <- function(path = "package/", ...){
require(devtools)
require(roxygen2)
pkg <- as.package(path) # package pointer
## update documentation
message("Updating documentation...")
roxygenise(path, ...)
@aL3xa
aL3xa / virtualbox.sh
Created Sep 13, 2011
Virtualbox custom startup script
View virtualbox.sh
#!/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
You can’t perform that action at this time.