User:Timothee Flutre/Notebook/Postdoc/2012/05/16: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
(→‎About programming: add tuto Python FR)
(add course parallel computations in C++)
 
(12 intermediate revisions by 2 users not shown)
Line 2: Line 2:
|-
|-
|style="background-color: #EEE"|[[Image:owwnotebook_icon.png|128px]]<span style="font-size:22px;"> Project name</span>
|style="background-color: #EEE"|[[Image:owwnotebook_icon.png|128px]]<span style="font-size:22px;"> Project name</span>
|style="background-color: #F2F2F2" align="center"|<html><img src="/images/9/94/Report.png" border="0" /></html> [[{{#sub:{{FULLPAGENAME}}|0|-11}}|Main project page]]<br />{{#if:{{#lnpreventry:{{FULLPAGENAME}}}}|<html><img src="/images/c/c3/Resultset_previous.png" border="0" /></html>[[{{#lnpreventry:{{FULLPAGENAME}}}}{{!}}Previous entry]]<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</html>}}{{#if:{{#lnnextentry:{{FULLPAGENAME}}}}|[[{{#lnnextentry:{{FULLPAGENAME}}}}{{!}}Next entry]]<html><img src="/images/5/5c/Resultset_next.png" border="0" /></html>}}
|style="background-color: #F2F2F2" align="center"|[[File:Report.png|frameless|link={{#sub:{{FULLPAGENAME}}|0|-11}}]][[{{#sub:{{FULLPAGENAME}}|0|-11}}|Main project page]]<br />{{#if:{{#lnpreventry:{{FULLPAGENAME}}}}|[[File:Resultset_previous.png|frameless|link={{#lnpreventry:{{FULLPAGENAME}}}}]][[{{#lnpreventry:{{FULLPAGENAME}}}}{{!}}Previous entry]]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}}{{#if:{{#lnnextentry:{{FULLPAGENAME}}}}|[[{{#lnnextentry:{{FULLPAGENAME}}}}{{!}}Next entry]][[File:Resultset_next.png|frameless|link={{#lnnextentry:{{FULLPAGENAME}}}}]]}}
|-
|-
| colspan="2"|
| colspan="2"|
Line 13: Line 13:
** my own page on [http://openwetware.org/wiki/User:Timothee_Flutre/Notebook/Postdoc/2011/11/07 R]
** my own page on [http://openwetware.org/wiki/User:Timothee_Flutre/Notebook/Postdoc/2011/11/07 R]
** [http://www.cplusplus.com/doc/tutorial/ C++ tutorial], a must-read (and a [http://www.mycplus.com/featured-articles/best-free-programming-courses-online/ list] of the best free C/C++ resources online)
** [http://www.cplusplus.com/doc/tutorial/ C++ tutorial], a must-read (and a [http://www.mycplus.com/featured-articles/best-free-programming-courses-online/ list] of the best free C/C++ resources online)
** [http://scipy-lectures.github.io/ Python tutorial] for scientists, [http://www.jchr.be/python/manuel.htm tutoriel Python] (in French)
** Python tutorials: for [http://www.tutorialspoint.com/python/index.htm everyone] ([http://anandology.com/python-practice-book/index.html another]), [http://scipy-lectures.github.io/ scientists] ([http://www.sam.math.ethz.ch/~raoulb/teaching/PythonTutorial/index.html another]), [http://www.jchr.be/python/manuel.htm in French], [https://packaging.python.org/en/latest/index.html packaging], [http://www.labri.fr/perso/nrougier/from-python-to-numpy/ numpy]
** [http://resrc.io/list/10/list-of-free-programming-books/ list] of free programming books
** [http://resrc.io/list/10/list-of-free-programming-books/ list] of free programming books
** C: THE [https://en.wikipedia.org/wiki/The_C_Programming_Language book], [http://nullprogram.com/blog/2014/12/23/ interactive programming], [http://nullprogram.com/blog/2014/12/23/ OOP]
** [http://ppc.cs.aalto.fi/ course] on parallel computations in C++
* '''Regular expressions''':
** [http://www.regular-expressions.info/quickstart.html quick start]
** [https://github.com/zeeshanu/learn-regex learn-regex] on GitHub
** online validators: [http://regexr.com/ regexr.com], [https://regex101.com/ regex101.com]


* '''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.
* '''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.
Line 21: Line 28:
** '''R''': download the file [http://github.com/timflutre/quantgen/blob/master/myprogram.R myprogram.R]
** '''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]
** '''Bash''': download the file [http://github.com/timflutre/quantgen/blob/master/myprogram.bash myprogram.bash]
** '''Latex-Beamer''': download the file [http://github.com/timflutre/quantgen/blob/master/myslides.tex myslides.tex]
** '''org-mode''': download the file [http://github.com/timflutre/quantgen/blob/master/myreadme.org myreadme.org]


* '''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:
* '''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
help2man -N -o myprogram.man ./myprogram
man ./myprogram.man
man ./myprogram.man
groff -mandoc myprogram.man > myprogram.ps
groff -mandoc myprogram.man > myprogram.ps
Line 34: Line 43:
** via the command-line: [http://man7.org/linux/man-pages/man1/time.1.html time] (see also [https://github.com/jhclark/memusg memusg])
** via the command-line: [http://man7.org/linux/man-pages/man1/time.1.html time] (see also [https://github.com/jhclark/memusg memusg])
** in R: [http://cran.r-project.org/web/packages/rbenchmark/index.html rbenchmark]
** in R: [http://cran.r-project.org/web/packages/rbenchmark/index.html rbenchmark]
* '''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. In the future, I should have a longer look at Karl Broman's [http://kbroman.wordpress.com/2013/10/07/better-looking-latexbeamer-slides/ post], and try [http://sourceforge.net/projects/qpdfpresenter/ QPdfPresenter].
<nowiki>
% 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}
</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. ##### -->

Latest revision as of 02:14, 8 November 2019

Project name Main project page
Previous entry      Next entry

About programming

  • 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.
  • 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 help2man). The following commands work for any programming language:
help2man -N -o myprogram.man ./myprogram
man ./myprogram.man
groff -mandoc myprogram.man > myprogram.ps
ps2pdf myprogram.ps myprogram.pdf