Added cat commands to slides
[cipher-training.git] / slides / caesar-encipher.html
index c4e8fb10f4d01ebff0b8e4d249e3599df61e4f93..279c2bdf8aa96de2b978f9e012381fcb57705a71 100644 (file)
         text-shadow: 0 0 20px #333;
         padding: 2px 5px;
       }
+      .indexlink {
+        position: absolute;
+        bottom: 1em;
+        left: 1em;
+      }
     </style>
   </head>
   <body>
@@ -50,6 +55,12 @@ Letter-by-letter enciphering
 
 ---
 
+layout: true
+
+.indexlink[[Index](index.html)]
+
+---
+
 # Enciphering and deciphering
 
 ## Arithmetic on letters
@@ -71,6 +82,34 @@ chr()
 
 ---
 
+# Using the tools
+
+Before doing anything, create a new branch in Git
+
+* This will keep your changes isolated
+
+Experiment in IPython (ephemeral, for us)
+
+Once you've got something working, export the code into a `.py` file (permanent and reusable)
+
+```python
+from imp import reload
+
+import test
+reload(test)
+from test import *
+```
+
+Re-evaluate the second cell to reload the file into the IPython notebook
+
+When you've made progress, make a Git commit
+
+* Commit early and often!
+
+When you've finished, change back to `master` branch and `merge` the development branch
+
+---
+
 # The [string module](http://docs.python.org/3.3/library/string.html) is your friend
 
 ```python
@@ -84,6 +123,7 @@ string.punctuation
 ```
 
 ---
+
 # DRY and YAGNI
 
 Is your code DRY?
@@ -120,7 +160,7 @@ if __name__ == "__main__":
 
 ---
 
-# Doing all the letters
+# Doing the whole message
 
 ## Test-first developement
 
@@ -131,7 +171,7 @@ if __name__ == "__main__":
 
 ---
 
-# Doing all the letters
+# Doing the whole message
 
 ## Abysmal
 
@@ -141,9 +181,11 @@ for i in range(len(plaintext)):
     ciphertext += caesar_encipher_letter(plaintext[i], key)
 ```
 
+Try it in IPython
+
 ---
 
-# Doing all the letters
+# Doing the whole message
 
 ## Bad
 
@@ -157,7 +199,7 @@ for p in plaintext:
 
 ---
 
-# Doing all the letters
+# Doing the whole message
 
 ## Good (but unPythonic)
 
@@ -167,7 +209,7 @@ ciphertext = map(lambda p: caesar_encipher_letter(p, key), plaintext)
 
 ---
 
-# Doing all the letters
+# Doing the whole message
 
 ## Best
 
@@ -182,11 +224,20 @@ ciphertext = [caesar_encipher_letter(p, key) for p in plaintext]
 ''.join()
 ```
 
+You'll be doing this a lot, so define a couple of utility functions:
+
+```python
+cat = ''.join
+wcat = ' '.join
+```
+
+`cat` after the Unix command (_concatenate_ files), `wcat` for _word concatenate_.
+
     </textarea>
     <script src="http://gnab.github.io/remark/downloads/remark-0.6.0.min.js" type="text/javascript">
     </script>
     <script type="text/javascript">
-      var slideshow = remark.create();
+      var slideshow = remark.create({ ratio: "16:9" });
     </script>
   </body>
 </html>
\ No newline at end of file