fromano
fromano
Reputation Top 1%
francesco romano
9 Snippets  (101st place)
Published
0 Channels
Created
4 Channels
Following
271 points  (111st place)
Reputation
Junior Code Generator
Serious Code Generator
Junior Publisher
Serious Publisher
Junior Popular Coder
Serious Popular Coder
Junior Autobiographer
Serious Autobiographer
Senior Autobiographer
Junior Famous Coder
Serious Famous Coder
Junior Wise Coder
Serious Popular Coder
Serious Famous Coder

Recent Snippets See all snippets by fromano

public by fromano  1688  0  4  0

Key-Value function options in Matlab

options = struct(   ...
    'KEY1',      value1,... 
    'KEY2',         value2
    );

%# read the acceptable names
optionNames = fieldnames(options);

%# count arguments
nArgs = length(varargin);
if round(nArgs/2)~=nArgs/2
    error('FUNCTIONAME needs propertyName/propertyValue pairs')
end

for pair = reshape(varargin,2,[]) %# pair is {propName;propValue}
    inpName = upper(pair{1}); %# make case insensitive
    
    if any(strcmp(inpName,optionNames))
        %# overwrite options. If you want you can test for the right class here
        %# Also, if you find out that there is an option you keep getting wrong,
        %# you can use "if strcmp(inpName,'problemOption'),testMore,end"-statements
        options.(inpName) = pair{2};
    else
        error('%s is not a recognized parameter name',inpName)
    end
end
            
;

public by fromano  1992  0  5  1

Snip2Code OS X Preferences

Preferences for OS X Snip2Code client which can be activated by command line
#Read preferences
defaults read com.snip2code.Snip2Code.osx

#Show network trace
defaults write com.snip2code.Snip2Code.osx debug.core.networktrace YES

#Change server
CurrentSnip2CodeServerAddress http://www.snip2code.com
;

public by fromano  1879  0  5  1

Redirect a yarp read to a yarp write while filtering the data

cut -c 5- will remove all the lines from 1 to 5 tr -d 'characters' will remove all the listed characters By piping the yarp read to the yarp write it is possible to "clean" the input format
# Enter here the actual content of the snippet.            

yarp read ... /wholeBodyDynamicsTree/floatingbasestate:o | cut -c 5- | tr -d '()' | yarp write /wbd3/clean:o

;

public by fromano  1937  0  5  0

Latex: specify PDF version when compiling

#in example: 1.5 PDF version

#Xelatex (only when compiling)
xelatex -output-driver="xdvipdfmx -V 5" <file>

#pdflate:
#.tex file
\pdfminorversion=5
;

public by fromano  1824  1  4  0

OS X bash configuration

# Terminal colours
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

#favorite editor
export EDITOR=vim

#bash completion for brew
if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
fi

#bash completion for git
if [ -f ~/.git-completion.bash ]; then
    . ~/.git-completion.bash
fi


###either add the above lines into .bash_profile
###or if added to .bashrc add the following lines into .bash_profile

if [ -f ~/.bashrc ]; then 
    source ~/.bashrc 
fi
;