\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{azamaryk} \pdfinfo{ /Title (jython.pdf) /Creator (Cheatography) /Author (azamaryk) /Subject (Jython Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{B5B5B5} \definecolor{LightBackground}{HTML}{F5F5F5} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Jython Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{azamaryk} via \textcolor{DarkBackground}{\uline{cheatography.com/19851/cs/2797/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}azamaryk \\ \uline{cheatography.com/azamaryk} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 4th November, 2014.\\ Updated 12th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{4} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Chapter 9 and 10}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Top-Down Design}} \newline % Row Count 1 (+ 1) Breaking down of a system to gain insight to its compositional sub-systems. \newline % Row Count 3 (+ 2) {\bf{Bottom-Down Design}} \newline % Row Count 4 (+ 1) Piecing together of systems to give rise to more complex systems, this making the original sub-systems of the emergent system. \newline % Row Count 7 (+ 3) {\bf{Black-Box}} \newline % Row Count 8 (+ 1) Device, system or object which can be viewed in terms of its input, output and transfer characteristics without knowing what is inside. \newline % Row Count 11 (+ 3) {\bf{Glass-Box}} \newline % Row Count 12 (+ 1) Opposite of Black-Box. Inner components or logic are available for inspection. \newline % Row Count 14 (+ 2) {\bf{Triple Quotes}} \newline % Row Count 15 (+ 1) Use Triple quotes when a strings spans multiple lines. \newline % Row Count 17 (+ 2) {\bf{String Methods (string.method)}} \newline % Row Count 18 (+ 1) capitalize \newline % Row Count 19 (+ 1) startwith \newline % Row Count 20 (+ 1) endswith \newline % Row Count 21 (+ 1) find, rfind \newline % Row Count 22 (+ 1) upper, lower \newline % Row Count 23 (+ 1) swapcase \newline % Row Count 24 (+ 1) title \newline % Row Count 25 (+ 1) isalpha, isdigit \newline % Row Count 26 (+ 1) {\bf{Functions with Strings and Lists}} \newline % Row Count 27 (+ 1) len(aString),(aList) \newline % Row Count 28 (+ 1) max, min(aString) \newline % Row Count 29 (+ 1) max, min(aList) \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Chapter 9 and 10 (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{List Methods (list.method)}} \newline % Row Count 1 (+ 1) append \newline % Row Count 2 (+ 1) remove \newline % Row Count 3 (+ 1) sort \newline % Row Count 4 (+ 1) reverse \newline % Row Count 5 (+ 1) count \newline % Row Count 6 (+ 1) {\emph{Strings are immutable; lists are mutable}} \newline % Row Count 7 (+ 1) {\bf{Opening Files for Reading and Writing and Reading into a Variable}} \newline % Row Count 9 (+ 2) `file = open("practice.txt","wt")` {\emph{wt is writing and rt is reading}} \newline % Row Count 11 (+ 2) `file.write("a string"\textbackslash{}n)` {\emph{\textbackslash{}n makes a new line}} \newline % Row Count 12 (+ 1) `file.close()` \newline % Row Count 13 (+ 1) `data = file.read()` {\emph{Now you can use string methods on data}} \newline % Row Count 15 (+ 2) `data.method()` \newline % Row Count 16 (+ 1) {\bf{Modules}} \newline % Row Count 17 (+ 1) The {\bf{OS Module}} offers a number of powerful capabilities for dealing with files, e.g., renaming files, finding out when a file was last modified, and so on. \newline % Row Count 21 (+ 4) We start accessing the OS module by typing: \newline % Row Count 22 (+ 1) `import os` \newline % Row Count 23 (+ 1) The function that knows about directories is `listdir()`, used as `os.listdir()` \newline % Row Count 25 (+ 2) listdir takes a path to a directory as input. \newline % Row Count 26 (+ 1) {\bf{Random Module}} \newline % Row Count 27 (+ 1) `import random` \newline % Row Count 28 (+ 1) `for i in range(1,10):` \newline % Row Count 29 (+ 1) `print random.random()` \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Chapter 9 and 10 (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\emph{math knows about sin() and sqrt()}}% Row Count 1 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Chapter 11}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Modem}} \newline % Row Count 1 (+ 1) a combined device for modulation and demodulation, for example, between the digital data of a computer and the analog signal of a telephone line. \newline % Row Count 4 (+ 3) {\bf{Packet}} \newline % Row Count 5 (+ 1) formatted unit of data carried by a packet mode computer network. \newline % Row Count 7 (+ 2) {\bf{Ethernet}} \newline % Row Count 8 (+ 1) a system for connecting a number of computer systems to form a local area network, with protocols to control the passing of information and to avoid simultaneous transmission by two or more systems. \newline % Row Count 12 (+ 4) {\bf{Internet}} \newline % Row Count 13 (+ 1) The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite (TCP/IP) to link several billion devices worldwide. \newline % Row Count 17 (+ 4) {\bf{ISP}} \newline % Row Count 18 (+ 1) Internet Service Provider \newline % Row Count 19 (+ 1) {\bf{IP Address}} \newline % Row Count 20 (+ 1) a unique string of numbers separated by periods that identifies each computer using the Internet Protocol to communicate over a network. \newline % Row Count 23 (+ 3) {\bf{Domain Names}} \newline % Row Count 24 (+ 1) the part of a network address that identifies it as belonging to a particular domain. \newline % Row Count 26 (+ 2) {\bf{POP}} \newline % Row Count 27 (+ 1) Post Office Protocol {\emph{Used to retrieve email from a mail server}} \newline % Row Count 29 (+ 2) {\bf{SMTP}} \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Chapter 11 (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Simple Mail Transfer Protocol {\emph{Internet standard for electronic mail (e-mail) transmission}}% Row Count 2 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{2.67774 cm} p{0.75526 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Big O Estimates}} \tn % Row 0 \SetRowColor{LightBackground} Array Access (Selecting a character from a string) & O(1) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Binary Search of a Sorted Collection & \seqsplit{O(logsub2n)} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Linear Search & O(n) \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} Better Sorts (Quick Sort, Merge Sort) & O(n log n) \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} Slower Sorts (Bubble, Insertion, Selection) & O(n\textasciicircum{}2) \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} Traveling Salesmen (EX of NP-Complete problem) (Intractable Problem) & O(n!) \tn % Row Count 12 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{Halting Problem - Unsolvable (Proven by Alan Turing, 1936)} \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Chapter 11-2}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{FTP}} \newline % Row Count 1 (+ 1) The File Transfer Protocol {\emph{standard network protocol used to transfer computer files from one host to another host over a TCP-based network, such as the Internet}} \newline % Row Count 5 (+ 4) {\bf{URL(Web Address when used with HTTP)}} \newline % Row Count 6 (+ 1) Uniform Resource Locator {\emph{Specific character string that constitutes a reference to a resource}} \newline % Row Count 8 (+ 2) {\bf{HTTP}} \newline % Row Count 9 (+ 1) Hypertext Transfer Protocol {\emph{Application protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web}} \newline % Row Count 13 (+ 4) {\bf{HTML}} \newline % Row Count 14 (+ 1) Hypertext Markup Language {\emph{Standard language in the making of a web page}} \newline % Row Count 16 (+ 2) {\bf{Sound to Text}} \newline % Row Count 17 (+ 1) `def soundToText(sound,filename):` \newline % Row Count 18 (+ 1) ` file = open(filename,"wt")` \newline % Row Count 19 (+ 1) `for s in getSamples(sound):` \newline % Row Count 20 (+ 1) ` file.write(str(getSample(s))+"\textbackslash{}n")` \newline % Row Count 21 (+ 1) ` file.close()` \newline % Row Count 22 (+ 1) {\bf{Steganography}} \newline % Row Count 23 (+ 1) First: Make sure that all red values are even. \newline % Row Count 24 (+ 1) Second: For every pixel where the message picture is black, add one to the red value at the corresponding x,y. \newline % Row Count 27 (+ 3) `def encode(msgPic ,original ):` \newline % Row Count 28 (+ 1) `for pxl in getPixels(original ):` \newline % Row Count 29 (+ 1) `if (getRed(pxl) \% 2) == 1:` \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Chapter 11-2 (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{ `setRed(pxl , getRed(pxl) - 1)` \newline % Row Count 1 (+ 1) `for x in range(0, getWidth(original )):` \newline % Row Count 2 (+ 1) `for y in range(0, getHeight(original )):` \newline % Row Count 3 (+ 1) `msgPxl = getPixel(msgPic ,x,y)` \newline % Row Count 4 (+ 1) `origPxl = getPixel(original ,x,y)` \newline % Row Count 5 (+ 1) `if \seqsplit{(distance(getColor(msgPxl)},black) \textless{} 100.0):` \newline % Row Count 7 (+ 2) `setRed(origPxl , getRed(origPxl )+1)`% Row Count 8 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Chapter 12}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Simple WebPage}} \newline % Row Count 1 (+ 1) \textless{}!DOCTYPE HTML\textgreater{} \newline % Row Count 2 (+ 1) \textless{}html\textgreater{} \newline % Row Count 3 (+ 1) \textless{}head\textgreater{} \newline % Row Count 4 (+ 1) \textless{}title\textgreater{}The Simplest Possible Web Page\textless{}/title\textgreater{} \newline % Row Count 5 (+ 1) \textless{}/head\textgreater{} \newline % Row Count 6 (+ 1) \textless{}body\textgreater{} \newline % Row Count 7 (+ 1) \textless{}h1\textgreater{}A Simple Heading\textless{}/h1\textgreater{} \newline % Row Count 8 (+ 1) \textless{}p\textgreater{}This is a paragraph in the simplest \textless{}br \textbackslash{}\textgreater{} \newline % Row Count 9 (+ 1) possible Web page.\textless{}/p\textgreater{} \newline % Row Count 10 (+ 1) \textless{}img \seqsplit{src="mediasources/flower1}.jpg" /\textgreater{} \newline % Row Count 11 (+ 1) \textless{}/body\textgreater{} \newline % Row Count 12 (+ 1) \textless{}/html\textgreater{} \newline % Row Count 13 (+ 1) {\bf{Database}} \newline % Row Count 14 (+ 1) A structured set of data held in a computer, especially one that is accessible in various ways. \newline % Row Count 16 (+ 2) {\bf{Query}} \newline % Row Count 17 (+ 1) A request for information from a database. \newline % Row Count 18 (+ 1) {\bf{SQL}} \newline % Row Count 19 (+ 1) Structured Query Language \newline % Row Count 20 (+ 1) Special-purpose programming language designed for managing data held in a relational database management system. \newline % Row Count 23 (+ 3) {\bf{Hexadecimal is base 16}} \newline % Row Count 24 (+ 1) 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10 (16 base 10) \newline % Row Count 25 (+ 1) \#FF0000 is Red \newline % Row Count 26 (+ 1) {\emph{255 for red (FF), 0 for green, 0 for blue}} \newline % Row Count 27 (+ 1) \#0000FF is Blue \newline % Row Count 28 (+ 1) {\emph{0 for red, 0 for green, 255 for blue}} \newline % Row Count 29 (+ 1) \#000000 is black \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Chapter 12 (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\emph{0 for red, 0 for green, 0 for blue}} \newline % Row Count 1 (+ 1) \#FFFFFF is white \newline % Row Count 2 (+ 1) {\emph{255 for red, 255 for green, 255 for blue}}% Row Count 3 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Chapter 14}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Jython is first translated into Java, which is both compiled and interpreted, every time a program is run. Thus one reason Photoshop operations are so much faster than our picture functions is that Photoshop's code has already been compiled and is ready to run at the click of a button. \newline % Row Count 6 (+ 6) There are some practical issues that determine the relative speeds of different computers. Some are: the clock speed of the processor, the number of cores of the processor, the amount of cache memory on board the processor (or nearby), the amount and speed of RAM, the size and speed of the hard disk, the system bus width and speed.% Row Count 13 (+ 7) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}