\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{bossross333} \pdfinfo{ /Title (omis-120.pdf) /Creator (Cheatography) /Author (bossross333) /Subject (OMIS 120 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}{87A3A1} \definecolor{LightBackground}{HTML}{F7F9F9} \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{OMIS 120 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{bossross333} via \textcolor{DarkBackground}{\uline{cheatography.com/21907/cs/4344/}}} \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}bossross333 \\ \uline{cheatography.com/bossross333} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 9th June, 2015.\\ Updated 11th 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*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{HTML}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\textless{}link href ="layout.css" rel="stylesheet" type="text/css"\textgreater{} \newline \textless{}form action ="test.php" method="get"\textgreater{} \newline \textless{}input type="text" id="tester"\textgreater{} \newline \textless{}input type="submit" id="submit" value="submit"\textgreater{} \newline \newline \textless{}img src="name" align="left"\textgreater{} Aligns an image: left \newline \newline input types="radio,"checkbox" \newline \textless{}select name="xyz"\textgreater{} \newline \textless{}option value="jerry"\textgreater{}Jerry\textless{}/option\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.54287 cm} x{3.43413 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{HTML 2}} \tn % Row 0 \SetRowColor{LightBackground} \textless{}div id="test"\textgreater{} & for CSS \#test\{color:\#fff\} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \textless{}div class="test"\textgreater{} & for CSS .test\{\} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \textless{}ol\textgreater{}\textless{}/ol\textgreater{} & Creates a numbered list \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} \textless{}ul\textgreater{}\textless{}/ul\textgreater{} & Creates a bulleted list \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} \textless{}li\textgreater{}\textless{}/li\textgreater{} & Precedes each list item, and adds a number or symbol depending upon the type of list selected \tn % Row Count 10 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{CSS}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/bossross333_1433805753_cssimg.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{HTML/CSS example}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\textless{}h1\textgreater{}Baby Geneva's Web Page\textless{}/h1\textgreater{}\textless{}div id="notice"\textgreater{} \textless{}img src="geneva.jpg" alt="Geneva" /\textgreater{} What is your name? \textless{}span class="notice"\textgreater{} (I am Geneva!)\textless{}/span\textgreater{}\textless{}/div\textgreater{}\textless{}p class="notice"\textgreater{}I \textless{}br /\textgreater{} am \textless{}br /\textgreater{} 15 \textless{}br /\textgreater{} months \textless{}br /\textgreater{} old\textless{}/p\textgreater{}\textless{}p class="notice"\textgreater{} My \textless{}br /\textgreater{} favorite \textless{}br /\textgreater{} toy \textless{}br /\textgreater{} is \textless{}br /\textgreater{} your \textless{}br /\textgreater{} cell phone \textless{}/p\textgreater{}\textless{}h2\textgreater{}(written by Geneva, May 2008)\textless{}/h2\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{HTML/CSS example}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{CSS \newline h1 \{ text-align: center; border: 2px solid black; \} \#notice .notice \{ text-decoration: underline; \} p.notice \{ border: 2px solid black; float: right; width: 10\%; \} h2 \{ clear: both; \} h2, \#notice \{ border-top: 1px dashed black; border-bottom: 1px dashed black; \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{MySQL}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{LIKE,ORDER BY, LIMIT, INSERT, UPDATE, DELETE, INSERT INTO table\_name(column1) VALUES(value1);% Row Count 2 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP(SQL)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{// Create connection \newline \$dbhandle = \seqsplit{mysql\_connect(\$hostname}, \$username, \$password) or die("Unable to connect to MySQL"); \newline \newline //database select \newline \$db\_select = \seqsplit{mysql\_select\_db("\$db\_name"}, \$dbhandle) or die("Cannot connect to database"); \newline \newline \$JuiceID = \$\_POST{[}'JuiceID'{]}; \newline \$Attributes = \$\_POST{[}'Attributes'{]}; \newline \$attValue = \$\_POST{[}'attIn'{]}; \newline \newline if(\$sql = "SELECT * FROM Juices WHERE JuiceID=\$JuiceID")\{ \newline \$result = mysql\_query(\$sql); \} \newline \newline while(\$row = \seqsplit{mysql\_fetch\_array(\$result}, MYSQL\_ASSOC)) \{ \newline print " ".\$row{[}"JuiceID"{]}." ".\$row{[}"JuiceBrand"{]}." "; \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP q4}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\textless{}?php \$letter=strtolower(\$\_GET{[} "letter"{]}); \newline \$times=( int) \$\_GET{[} "times"{]}; \newline \$matches=0; \newline foreach (file( "peeps.txt", \seqsplit{FILE\_IGNORE\_NEW\_LINES)} as \$line) \{ \seqsplit{\$lowerline=strtolower(\$line);} \newline \$count=0 ; \newline for (\$i=0 ; \$i \textless{} strlen(\$line); \$i++) \{ \newline \$ch=\$ lowerline{[}\$i{]}; \newline if (\$ch==\$ letter) \{ \newline \$count++; \} \} \newline if (\$count\textgreater{}= \$times) \{ \$matches++; ?\textgreater{} \newline \textless{}p\textgreater{}\textless{}strong\textgreater{}\textless{}?= \$line ?\textgreater{}\textless{}/strong\textgreater{} \newline contains ' \newline \textless{}?=\$ letter ?\textgreater{}' exactly \newline \textless{}?=\$ times ?\textgreater{}times.\textless{}/p\textgreater{} \newline \textless{}?php \} \} if (\$matches==0 ) \{ ?\textgreater{} \newline \textless{}p\textgreater{}No names contained ' \newline \textless{}?=\$ letter ?\textgreater{}' enough times.\textless{}/p\textgreater{} \newline \textless{}?php \} ?\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PHP mid\_q3}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\$babyName=\$\_GET{[}"name"{]}; \newline \$lines = file("names.txt"); \newline \$output=-1; //default value \newline for(\$i=0; \$i\textless{}count(\$lines); \$i++)\{ \newline \$line = \$lines{[}\$i{]}; \newline \$tokens = explode(" ", \$line); \newline if(strtolower(\$babyName)==strtolower(\$tokens{[}0{]}))\{ \$output=\$tokens{[}1{]}; \newline for(\$j=2; \$j\textless{}count(\$tokens); \$j++)\{ \newline if((int)\$output\textgreater{}(int)\$tokens{[}\$j{]})\{ \newline \$output=\$tokens{[}\$j{]}; \newline \} \} \} \} \newline print \$output;} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{\#getmoviename}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\#get movie name \newline \$movie=\$\_REQUEST{[}'movie'{]}; \newline \$filePath="moviefiles/".\$movie."info.txt"; \newline list(\$movieName,\$year,\$score)=file(\$filePath); \newline print"\textless{}h1\textgreater{} \$movieName (\$year) \textless{}/h1\textgreater{}"; \newline \#add a line to a file \newline \$new\_txt="hello there"; \newline file\_put\_contents("poem.txt", \$new\_txt, FILE\_AMMEND);} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{PhP String functions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{var str= "abcd,efgh"; \newline var a=str.length;//gets 9 \newline var b=str.substring(1,3);//gets "bc" \newline var \seqsplit{c=str.indexOf('b');//gets} 1 \newline var \seqsplit{d=str.toUpperCase();//gets} "ABCD,EFGH" \newline var e=str.charAt(2);//gets "c" \newline var f=str.split(","); \newline //gets array ("abcd,"efgh")} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{JavaScript divide function}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{window.onload = function() \{ \newline document.getElementById("del").onclick = divideAll; \newline \}; \newline \newline function divideAll() \{ \newline var divisor = document.getElementById ("divisor").value; \newline var div = document.getElementById ("buttons"); \newline var buttons = \seqsplit{div.getElementsByTagName("button");} \newline for (var i = 0; i \textless{} buttons.length; i++) \{ \newline var number = buttons{[}i{]}.innerHTML; \newline if (number \% divisor == 0) \{ \newline div.removeChild(buttons{[}i{]}); \newline i-{}-;\}\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{JavaScript ex}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\textless{}script LANGUAGE="JavaScript" type="text/javascript"\textgreater{} \newline function yearConvert (form)\{ \newline form.dYears.value = form.hYears.value*7; \newline \} \newline \textless{}/script\textgreater{} \newline \newline \textless{}input TYPE="button" VALUE="change color" \seqsplit{ONCLICK="document.body.style.backgroundColor} = '\#' + \seqsplit{Math.random().toString(16).slice(2},8);"\textgreater{} \newline \textless{}INPUT TYPE ="text" NAME="hYears" SIZE=10\textgreater{} \newline \textless{}INPUT TYPE ="button" VALUE="Calculate" \seqsplit{ONCLICK="yearConvert(this}.form)"\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{JavaScript guess rand}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\textless{}script LANGUAGE="JavaScript" type="text/javascript"\textgreater{} \newline var randnum = Math.floor(Math.random() * 10) + 1; //Generate random number \newline var count = 0; \newline function Guess() \{ \newline var x = \seqsplit{document.resultform.guess.value;count++;} \newline status = "Tries: " + count; \newline if (x \textless{} randnum) \{ \newline \seqsplit{ document.resultform.tip.value} = "Too low!";\} \newline \newline if (x \textgreater{} randnum) \newline \seqsplit{ document.resultform.tip.value} = "Too high!"; \newline \newline if (x == randnum) \{ \newline \seqsplit{ document.resultform.tip.value} = "You got it right in " + count + " tries!";\} \newline \seqsplit{ document.getElementById('total').innerHTML} = + x;\} \newline \textless{}/script\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{parent-child script}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\textless{}div id="div1"\textgreater{} \newline \textless{}p id="p1"\textgreater{}This is words\textless{}/p\textgreater{} \newline \textless{}p id="p2"\textgreater{}This is more words\textless{}/p\textgreater{} \newline \textless{}/div\textgreater{} \newline \newline var \seqsplit{para=document.creatElement("p");} \newline var \seqsplit{node=document.createTextNode("This} is new"); \newline para.appendChild(node); \newline var \seqsplit{parent=document.getElementById("div1");} \newline var \seqsplit{child=document.getElementById("p1");} \newline parent.replaceChild(para,child);} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}