User:Timothee Flutre/Notebook/Postdoc/2012/05/16: Difference between revisions
From OpenWetWare
(→About programming: add tuto scipy + fix links to templates) |
|||
(24 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
| colspan="2"| | | colspan="2"| | ||
<!-- ##### DO NOT edit above this line unless you know what you are doing. ##### --> | <!-- ##### DO NOT edit above this line unless you know what you are doing. ##### --> | ||
== | ==About programming== | ||
* '''Resources''': most of the time, it's not necessary to buy a book, search online instead! | |||
** [http://software-carpentry.org/ Software Carpentry] to learn about tests, versioning, Makefile, regular expressions, etc | |||
** [http://www.cplusplus.com/doc/tutorial/ C++ tutorial], a must-read | |||
** [http://scipy-lectures.github.io/ Python tutorial] for scientists | |||
* ''' | * '''Program templates''': it is always rewarding on the long term to start any piece of computer software with a minimum amount of generic code (command-line options, help message, license, usage of gzipped files, running time, etc). But it's a pain to write all this every time, right? And often we know how to do something in one language but not in another. So below are my typical templates for any C++/Python/R/Bash program, as well as Beamer presentation. | ||
** '''C++''': download the file [http://github.com/timflutre/quantgen/blob/master/myprogram.cpp myprogram.cpp], as well as [http://github.com/timflutre/quantgen/blob/master/utils_io.cpp utils_io.cpp] along with its header [http://github.com/timflutre/quantgen/blob/master/utils_io.hpp utils_io.hpp]. | |||
** '''Python''': download the file [http://github.com/timflutre/quantgen/blob/master/myprogram.py myprogram.py] | |||
** '''R''': download the file [http://github.com/timflutre/quantgen/blob/master/myprogram.R myprogram.R] | |||
** '''Bash''': download the file [http://github.com/timflutre/quantgen/blob/master/myprogram.bash myprogram.bash] | |||
* '''Language-independent user documentation''': I'm a firm believer that it is necessary to add some user documentation, even minimal, to any program. An easy way to do this is to simply generate such documentation from the "help" message, as long as it is "properly" formatted (see [http://www.gnu.org/s/help2man/ help2man]). The following commands work for any programming language: | |||
<nowiki> | <nowiki> | ||
help2man -o myprogram.man ./myprogram | |||
man ./myprogram.man | |||
groff -mandoc myprogram.man > myprogram.ps | |||
ps2pdf myprogram.ps myprogram.pdf | |||
</nowiki> | </nowiki> | ||
* '''Latex-Beamer''': it is assumed that the code below is copied into a file named "mypresentation.tex" | * '''Latex-Beamer''': it is assumed that the code below is copied into a file named "mypresentation.tex" and that several packages are already installed. The current directory is also assumed to contain a sub-directory named "figures" in which are saved all picture files included in the presentation. | ||
<nowiki> | <nowiki> | ||
% | % Copyright (C) 2012 Timothee Flutre. | ||
\documentclass{beamer} | \documentclass{beamer} | ||
\usepackage{amsmath} | \usepackage{amsmath} | ||
\usepackage{bm} % to have mathematical symbols in bold | \usepackage{bm} % to have mathematical symbols in bold | ||
\usepackage{hyperref} | \usepackage{hyperref} | ||
\hypersetup{colorlinks, linkcolor=black, urlcolor=gray} | \hypersetup{colorlinks, linkcolor=black, urlcolor=gray} | ||
Line 310: | Line 42: | ||
\usepackage[francais]{babel} | \usepackage[francais]{babel} | ||
\usepackage[utf8]{inputenc} | \usepackage[utf8]{inputenc} | ||
\graphicspath{{./figures/}} | \graphicspath{{./figures/}} | ||
%----------------------------------------------------------------------------- | %----------------------------------------------------------------------------- | ||
\setbeamertemplate{caption}[numbered] | \setbeamertemplate{caption}[numbered] | ||
Line 332: | Line 63: | ||
\usebeamerfont{section in head/foot}\insertshorttitle | \usebeamerfont{section in head/foot}\insertshorttitle | ||
\end{beamercolorbox} | \end{beamercolorbox} | ||
\begin{beamercolorbox}[wd=.27\paperwidth,ht=2.25ex,dp=1ex,right]{section in head/foot}% | \begin{beamercolorbox}[wd=.27\paperwidth,ht=2.25ex,dp=1ex,right]{section in head/foot}% | ||
\usebeamerfont{section in head/foot}\insertshortdate{}\hspace*{2em} | \usebeamerfont{section in head/foot}\insertshortdate{}\hspace*{2em} | ||
\insertframenumber{} / \inserttotalframenumber\hspace*{2ex} | \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} | ||
Line 349: | Line 80: | ||
} | } | ||
%----------------------------------------------------------------------------- | %----------------------------------------------------------------------------- | ||
\title[Short title]{Long title} | \title[Short title]{Long title} | ||
Line 358: | Line 89: | ||
begin{document} | begin{document} | ||
\begin{frame} | \begin{frame} | ||
\titlepage | \titlepage | ||
\end{frame} | \end{frame} | ||
\begin{frame} | \begin{frame} | ||
\frametitle{Outline} | \frametitle{Outline} | ||
\tableofcontents | \tableofcontents | ||
\end{frame} | \end{frame} | ||
\section{First section} | \section{First section} | ||
\begin{frame} | \begin{frame} | ||
\frametitle{I.1.} | \frametitle{I.1.} | ||
Line 381: | Line 111: | ||
\frametitle{II.1.} | \frametitle{II.1.} | ||
\begin{center} | \begin{center} | ||
%\includegraphics[width=0.95\textwidth,height=0.90\textheight,keepaspectratio=true]{myplot}% | %\includegraphics[width=0.95\textwidth,height=0.90\textheight,keepaspectratio=true]{myplot}% | ||
\end{center} | \end{center} | ||
\end{frame} | \end{frame} | ||
Line 387: | Line 117: | ||
end{document} | end{document} | ||
</nowiki> | </nowiki> | ||
<!-- ##### DO NOT edit below this line unless you know what you are doing. ##### --> | <!-- ##### DO NOT edit below this line unless you know what you are doing. ##### --> |
Revision as of 09:38, 16 October 2013
Project name | <html><img src="/images/9/94/Report.png" border="0" /></html> Main project page <html><img src="/images/c/c3/Resultset_previous.png" border="0" /></html>Previous entry<html> </html>Next entry<html><img src="/images/5/5c/Resultset_next.png" border="0" /></html> |
About programming
help2man -o myprogram.man ./myprogram man ./myprogram.man groff -mandoc myprogram.man > myprogram.ps ps2pdf myprogram.ps myprogram.pdf
% Copyright (C) 2012 Timothee Flutre. \documentclass{beamer} \usepackage{amsmath} \usepackage{bm} % to have mathematical symbols in bold \usepackage{hyperref} \hypersetup{colorlinks, linkcolor=black, urlcolor=gray} \usepackage{multirow} \usepackage{tikz} \usepackage[francais]{babel} \usepackage[utf8]{inputenc} \graphicspath{{./figures/}} %----------------------------------------------------------------------------- \setbeamertemplate{caption}[numbered] \setbeamerfont{caption}{size=\scriptsize} \setbeamertemplate{navigation symbols}{} \setbeamercolor{alerted text}{fg=purple} \setbeamertemplate{footline} { \leavevmode \hbox{ \hspace*{-0.06cm} \begin{beamercolorbox}[wd=.2\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot} \usebeamerfont{author in head/foot}\insertshortauthor \hspace*{1em} \insertshortinstitute \end{beamercolorbox} \begin{beamercolorbox}[wd=.50\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot} \usebeamerfont{section in head/foot}\insertshorttitle \end{beamercolorbox} \begin{beamercolorbox}[wd=.27\paperwidth,ht=2.25ex,dp=1ex,right]{section in head/foot}% \usebeamerfont{section in head/foot}\insertshortdate{}\hspace*{2em} \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} \end{beamercolorbox} } \vskip0pt } \AtBeginSection[] { \begin{frame} \frametitle{Outline} \addtocounter{framenumber}{-1} \tableofcontents[currentsection] \end{frame} } %----------------------------------------------------------------------------- \title[Short title]{Long title} \author[T. Flutre]{Timoth\'{e}e Flutre} \institute[Short affiliation]{Long affiliation} \date{\today} begin{document} \begin{frame} \titlepage \end{frame} \begin{frame} \frametitle{Outline} \tableofcontents \end{frame} \section{First section} \begin{frame} \frametitle{I.1.} \begin{itemize} \item \end{itemize} \end{frame} \section{Second section} \begin{frame} \frametitle{II.1.} \begin{center} %\includegraphics[width=0.95\textwidth,height=0.90\textheight,keepaspectratio=true]{myplot}% \end{center} \end{frame} end{document} |