Skip to content

Instantly share code, notes, and snippets.

@fbender
fbender / fortran-num.m
Last active August 29, 2015 14:02
Validate a Fortran number literal in Matlab (Snippet).
validInt = '^\d+$';
ri = regexp(value, validInt);
if size(ri, 2) == 1
% integer
end
validDouble = '^(\d+(\.\d*)?|\.\d+)[dD][+-]?\d{1,3}$';
rd = regexp(value, validDouble);
@fbender
fbender / base64.m
Last active December 25, 2016 21:20
Base64 for MATLAB
function b64 = base64( str )
%BASE64 Encode string (array of chars) into Base64
% Currently seems to fail for any input > 4 characters. :(
%% Settings
% Valid output codes to choose from.
base64Chars = char([65:90, 97:122, 48:57, 43, 47]); % +/ per RFC 2045 et al.
%base64UrlChars = char([65:90, 97:122, 48:57, 45, 95]); % -_ per RFC 4648 §4
base64PadChar = '=';
@fbender
fbender / netinfo-if-network-link.md
Last active August 29, 2015 13:56
W3C/netinfo: the `NetworkLink` interface
@fbender
fbender / vbox-ext-update.sh
Last active December 28, 2015 00:59
Oracle VirtualBox Extension Pack update helper (based on https://forums.virtualbox.org/viewtopic.php?f=7&t=44337#p199593).
#!/bin/bash
# license: MIT
# author: Florian Bender
# original script: Sasquatch (https://forums.virtualbox.org/viewtopic.php?f=7&t=44337#p199593)
# see comment below!
version=$(vboxmanage -v)
echo -n "Installed: $version; "
var1=$(echo $version | cut -d 'r' -f 1)
@fbender
fbender / colorset.sh
Last active December 18, 2015 00:09
Simple helper function for the lazy to colorize terminal scripts. MIT License. Color codes from https://wiki.archlinux.org/index.php/Color_Bash_Prompt#Advanced_prompts
#!/bin/bash
# Copyright (c) 2013 Florian Bender
# License: MIT (see http://opensource.org/licenses/MIT)
function colorset {
style=""
case $1 in
text) style="0;3" ;; ## regular text
HItext) style="0;9" ;; ## high intensity regular text