Skip to content

Instantly share code, notes, and snippets.

View aL3xa's full-sized avatar

Aleksandar Blagotić aL3xa

View GitHub Profile
function foo(){
return typeof null === 'undefined';
}
for (var i=0; i<10000; ++i) console.log(foo());
@aL3xa
aL3xa / sweave.sh
Created July 26, 2013 18:29
Sweave script inspired by Dirk Eddelbuettel's answer on StackOverflow: http://stackoverflow.com/questions/2940756/ess-auctex-sweave-integration
#!/bin/bash
FILEBASE=${1%.*}
FILEXT=${1##*.}
FILEPATH=${1%/*}
TEXFILE=$FILEBASE.tex
PDFFILE=$FILEBASE.pdf
# errorexit
<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 December 10, 2015 15:38
Simple and pointless demonstration of R system call output manipulation
#!/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 November 21, 2012 01:51
RApache github 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 April 25, 2012 19:53
Imgur uploader
#! /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 April 10, 2012 23:32
Quick and dirty jQuery watermark function
// 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 March 6, 2012 17:45
Send HTTP request from 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 January 23, 2012 14:35
Build, Check, Install and (Re)Load R Package
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 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