Alessio Caiazza is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

nolith / ruby-beamer

My template for beamer slides with ruby code examples

Clone this repository (size: 534.4 KB): HTTPS / SSH
hg clone https://bitbucket.org/nolith/ruby-beamer
hg clone ssh://hg@bitbucket.org/nolith/ruby-beamer

ruby-beamer / ruby.sty

\RequirePackage{color}
%\RequirePackage{fancyvrb}
\RequirePackage{ifthen}
\RequirePackage{listings}

\definecolor{CommentColor}{rgb}{0.0,0.0,1.0}
\definecolor{ReferenceColor}{rgb}{0.8039215,0.0,0.0}
\definecolor{StringColor}{rgb}{0.0,0.545098,0.0}
\definecolor{FunctionColor}{rgb}{0.545098,0.1372549,0.1372549}
\definecolor{KeywordColor}{rgb}{0.545098,0.0,0.0}
\definecolor{VariableColor}{rgb}{0.545098,0.0,0.545098}
\definecolor{TypeColor}{rgb}{0.2745098,0.5098,0.7058823}

\providecommand{\codecomment}[1]{{\color{CommentColor}#1}}
\providecommand{\codereference}[1]{{\color{ReferenceColor}#1}}
\providecommand{\codestring}[1]{{\color{StringColor}#1}}
\providecommand{\codefunctionname}[1]{{\color{FunctionColor}#1}}
\providecommand{\codekeyword}[1]{{\color{KeywordColor}#1}}
\providecommand{\codevariablename}[1]{{\color{VariableColor}#1}}
\providecommand{\codetype}[1]{{\color{TypeColor}#1}}

\definecolor{RubyBack}{rgb}{1.0,0.95,0.9}   
\definecolor{RubyFrame}{rgb}{0.9,0.0,0.0}

\definecolor{OutputBack}{rgb}{0.9,0.95,1.0}
\definecolor{OutputFrame}{rgb}{0.0,0.0,0.9}

\definecolor{ShellBack}{rgb}{0.95,1,0.9}
\definecolor{ShellFrame}{rgb}{0.0,0.9,0.0}

\newlength{\rubyindent}
\setlength{\rubyindent}{1ex}
\providecommand{\RubyIndent}[1]{\hspace{#1\rubyindent}}

\lstdefinestyle{rubysource}{language=Ruby,columns=fullflexible,showstringspaces=false,
  aboveskip=0.4em,
  belowskip=0em,
  escapeinside=��,
  numbers=left,
  numberstyle=\tiny\texttt,
  numbersep=1em,  
  xleftmargin=2em,
  frame=lines,
  framexleftmargin=2em,
  backgroundcolor=\color{RubyBack},
  rulecolor=\color{RubyFrame}
}

\lstdefinestyle{rubyout}{%
  columns=fullflexible,showstringspaces=false,
  %aboveskip=1pt,
  %belowskip=1em,
  escapeinside=��,
  numbers=left,
  numberstyle=\tiny\texttt,
  numbersep=1em,
  xleftmargin=2em,
  frame=lines,
  framexleftmargin=2em,
  backgroundcolor=\color{OutputBack},
  rulecolor=\color{OutputFrame}
}

\lstdefinestyle{shell}{%
  columns=fullflexible,showstringspaces=false,
  %aboveskip=1pt,
  %belowskip=1em,
  escapeinside=��,
  numbers=none,
  numberstyle=\tiny\texttt,
  numbersep=1em,
  xleftmargin=1em,
  frame=lines,
  framexleftmargin=1em,
  backgroundcolor=\color{ShellBack},
  rulecolor=\color{ShellFrame}
}

\definecolor{ReferenceColor}{rgb}{0.8039215,0.0,0.0}
\definecolor{FunctionColor}{rgb}{0.545098,0.1372549,0.1372549}
\definecolor{KeywordColor}{rgb}{0.545098,0.0,0.0}
\definecolor{VariableColor}{rgb}{0.545098,0.0,0.545098}
\definecolor{TypeColor}{rgb}{0.2745098,0.5098,0.7058823}

\providecommand{\rubysource}[2][]{%   
\begin{otherlanguage}{english}
  \lstinputlisting[style=rubysource,#1]{#2} 
\end{otherlanguage}
}

\providecommand{\rubyout}[2][]{ 
\begin{otherlanguage}{english}
  \lstinputlisting[style=rubyout,#1]{#2.out} 
\end{otherlanguage}
}


\providecommand{\ShellInput}[2][]{
\begin{otherlanguage}{english}
        \lstinputlisting[style=shell,#1]{#2}
\end{otherlanguage}     
}

\newlength{\xmpsize}
\setlength{\xmpsize}{2cm}
\providecommand{\RubyXMP}[3][2cm]{%
  \setlength{\xmpsize}{#1}%
  \rubysource[#2]{#3.xmp}%
}
\providecommand{\XMPresult}[1]{\hfill{\makebox[\xmpsize][l]{\textit{>>\ #1}}}}

\newlength{\sidebysidewidth}
\providecommand{\sidebyside}[3][0.5]{%
  \makebox{%
    \setlength{\sidebysidewidth}{\textwidth}%
    \setlength{\sidebysidewidth}{#1\sidebysidewidth}
    \addtolength{\sidebysidewidth}{-0.5em}%
    \begin{minipage}[t]{\sidebysidewidth}%
      #2%
    \end{minipage}%
    \setlength{\sidebysidewidth}{\textwidth}%
    \addtolength{\sidebysidewidth}{-#1\textwidth}%
    \addtolength{\sidebysidewidth}{-0.5em}%
    \hspace{1em}%
    \begin{minipage}[t]{\sidebysidewidth}%
      #3%
    \end{minipage}}%
}

\newcommand{\exercise}[2]{%
  \begin{block}{#1}
    #2
  \end{block}}