SlideShare a Scribd company logo
Presenting Your Code
                                        Ian Dees
                              http://texagon.blogspot.com




Hi, I'm Ian Dees, a software developer for a test equipment manufacturer near Portland, Ore.

Today, we're going to talk about freeing your source code from your text editor and getting it into
your presentations.
TextMate
                                         http://www.macromates.com




                                         Smultron
                                         http://smultron.sf.net




The basic ideas will work on any platform, but the screenshots we're looking at today will primarily
be from two popular text editors for the Mac.
Let's say we're trying our hand at the great Computer Language Shootout with Ackermann's
Function. Here's what one solution looks like inside our text editor.
def ackermann(m, n)
           $memo ||= {}

           $memo[[m, n]] =
             $memo[[m, n]]   ? $memo[[m, n]]       :
             0 == m          ?n+1                  :
             0 < m && 0 == n ? ackermann(m - 1, 1) :
             ackermann(m - 1, ackermann(m, n - 1))
         end



         1.upto(8) {|n| puts ackermann(3, n)}




But if we do a Select All in our text editor and then copy and paste into our presentation, we lose all
the pretty syntax highlighting.
We could just take a screenshot from our text editor and paste it into the presentation as a graphic.
But that makes for large file sizes and blurry font sizes. And if we distribute our slides as PDFs,
readers won't be able to cut and paste our text.

Also, it's a pretty manual process.
pri
                                       nt         1 ! ackermann.rb ! 2007-09-03 23:11 ! Ian Dees

                                                   def ackermann(m, n)
                                                     $memo ||= {}

                                                     $memo[[m, n]] =
                                                       $memo[[m, n]]   ? $memo[[m, n]]       :
                                                       0 == m          ?n+1                  :
                                                       0 < m && 0 == n ? ackermann(m - 1, 1) :
                                                       ackermann(m - 1, ackermann(m, n - 1))
                                                   end


                                                   1.upto(8) {|n| puts ackermann(3, n)}



If you're using Smultron as your editor, you can print to a PDF and then drag the PDF file into your
slide--assuming your slides have a white background.
But I prefer a bit more flexibility. Let's look at HTML for a potential solution. We could just submit
our code to Pastie, and then cut/paste the result into our presentation.
<span class=quot;rquot;>def</span>
         <span class=quot;fuquot;>ackermann</span>(m, n)




         .r { color:#080; font-weight:bold }
         .fu { color:#06B; font-weight:bold }




And since Pastie's stylesheets are pretty simple, we could even tweak the colors before we put the
code into our presentation.
http://www.ruby-lang.org



But there's another way that doesn't require a round trip to the Pastie servers every time you want
to highlight your code.

First, get Ruby.
gem install syntax



Then, install the Syntax gem.
http://pastie.caboo.se/95056



Finally, grab the Ruby source code from this file and save it to your hard drive somewhere.
⌘B




Now, you can configure your text editor to run the script. In Smultron, hit Cmd-B to bring up the
Commands window. Create a new command, bind it to a keystroke if you like, and fill in its
contents like this. You'll want to substitute the paths to where you keep your Ruby interpreter and
where you saved the script, of course.
Now, whenever you hit your chosen hotkey, Smultron generates the HTML and (if you've enabled it
in the script) launches your browser for easy cutting and pasting.
⌘⌥R




The process is similar in TextMate. Just hit Cmd-Option-R to bring up the Filter Through
Command dialog, browse to where you saved the script, and select Show as HTML.
When you press Execute, TextMate brings up a new window with highlighted code that remembers
its colors...
def ackermann(m, n)
            $memo ||= {}

            $memo[[m, n]] =
              $memo[[m, n]]   ? $memo[[m, n]]       :
              0 == m          ?n+1                  :
              0 < m && 0 == n ? ackermann(m - 1, 1) :
              ackermann(m - 1, ackermann(m, n - 1))
          end



          1.upto(8) {|n| puts ackermann(3, n)}




...when you paste it into a slide, like this.
def ackermann(m, n)
                                                 $memo ||= {}

                                                 $memo[[m, n]] =
                                                   $memo[[m, n]]   ? $memo[[m, n]]       :
                                                   0 == m          ?n+1                  :
                                                   0 < m && 0 == n ? ackermann(m - 1, 1) :
                                                   ackermann(m - 1, ackermann(m, n - 1))
                                               end



                                               1.upto(8) {|n| puts ackermann(3, n)}


There will be a few minor dierences, of course. Punctuation, class names, and constants might be
colored a little dierently between your text editor and the resulting HTML. But with a little
tweaking, you can get pretty darn close.
⌘⌃R




And in the specific case of TextMate, you can do even better than just quot;pretty darn close.quot; Run the
quot;TextMate  Create HTML From Documentquot; command, which is bound to Cmd-Ctrl-R (as opposed
to Cmd-Opt-R) on my system. By default, that brings up the raw HTML tags in a new window, but
you can configure TextMate to actually render the HTML instead.
Presenting Your Code
                                        Ian Dees
                              http://texagon.blogspot.com




And that's it. Thanks for your time.

More Related Content

Similar to Presenting Your Code

Similar to Presenting Your Code (20)

Basic concept of MATLAB.ppt
Basic concept of MATLAB.pptBasic concept of MATLAB.ppt
Basic concept of MATLAB.ppt
 
Computer fundamentals
Computer fundamentalsComputer fundamentals
Computer fundamentals
 
Matlab1
Matlab1Matlab1
Matlab1
 
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
 
R Basics
R BasicsR Basics
R Basics
 
08 functions
08 functions08 functions
08 functions
 
Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)
 
R Programming: Export/Output Data In R
R Programming: Export/Output Data In RR Programming: Export/Output Data In R
R Programming: Export/Output Data In R
 
Palm m3 chapter1b
Palm m3 chapter1bPalm m3 chapter1b
Palm m3 chapter1b
 
Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4Introduction to matlab lecture 4 of 4
Introduction to matlab lecture 4 of 4
 
Learn Matlab
Learn MatlabLearn Matlab
Learn Matlab
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
R Language
R LanguageR Language
R Language
 
DataWeave 2.0 - MuleSoft CONNECT 2019
DataWeave 2.0 - MuleSoft CONNECT 2019DataWeave 2.0 - MuleSoft CONNECT 2019
DataWeave 2.0 - MuleSoft CONNECT 2019
 
Chapter 1.ppt
Chapter 1.pptChapter 1.ppt
Chapter 1.ppt
 
MATLAB for Technical Computing
MATLAB for Technical ComputingMATLAB for Technical Computing
MATLAB for Technical Computing
 
AWS Summit Singapore - 21st Century Modern Architecture
AWS Summit Singapore - 21st Century Modern ArchitectureAWS Summit Singapore - 21st Century Modern Architecture
AWS Summit Singapore - 21st Century Modern Architecture
 
An implementation of RSA policy
An implementation of RSA policyAn implementation of RSA policy
An implementation of RSA policy
 
Structures-2
Structures-2Structures-2
Structures-2
 

More from moto

Science Illustration
Science IllustrationScience Illustration
Science Illustrationmoto
 
Euia Medicaments 2007 2008
Euia Medicaments 2007 2008Euia Medicaments 2007 2008
Euia Medicaments 2007 2008moto
 
Funny8
Funny8Funny8
Funny8moto
 
Tintin And The Red Sea Sharks
Tintin And The Red Sea SharksTintin And The Red Sea Sharks
Tintin And The Red Sea Sharksmoto
 
The Mullet
The MulletThe Mullet
The Mulletmoto
 
Snappy Baby
Snappy  BabySnappy  Baby
Snappy Babymoto
 
Redes Peea
Redes PeeaRedes Peea
Redes Peeamoto
 
Funny Cartoons
Funny CartoonsFunny Cartoons
Funny Cartoonsmoto
 
Flowers
FlowersFlowers
Flowersmoto
 
Ravel Bolero
Ravel BoleroRavel Bolero
Ravel Boleromoto
 
Where In The World
Where In The WorldWhere In The World
Where In The Worldmoto
 
Very Funny
Very FunnyVery Funny
Very Funnymoto
 
Funny Slideshow
Funny SlideshowFunny Slideshow
Funny Slideshowmoto
 
Funny Humor
Funny HumorFunny Humor
Funny Humormoto
 
Crazy Picture
Crazy PictureCrazy Picture
Crazy Picturemoto
 
Dream House
Dream HouseDream House
Dream Housemoto
 
Best Websites List
Best Websites ListBest Websites List
Best Websites Listmoto
 
[Awesome] Military Photos Of The Twin Towers
[Awesome] Military Photos Of The Twin Towers[Awesome] Military Photos Of The Twin Towers
[Awesome] Military Photos Of The Twin Towersmoto
 
Audrey 20 Portraits Of Audrey Hepburn
Audrey  20 Portraits Of Audrey HepburnAudrey  20 Portraits Of Audrey Hepburn
Audrey 20 Portraits Of Audrey Hepburnmoto
 
What Is Love
What Is LoveWhat Is Love
What Is Lovemoto
 

More from moto (20)

Science Illustration
Science IllustrationScience Illustration
Science Illustration
 
Euia Medicaments 2007 2008
Euia Medicaments 2007 2008Euia Medicaments 2007 2008
Euia Medicaments 2007 2008
 
Funny8
Funny8Funny8
Funny8
 
Tintin And The Red Sea Sharks
Tintin And The Red Sea SharksTintin And The Red Sea Sharks
Tintin And The Red Sea Sharks
 
The Mullet
The MulletThe Mullet
The Mullet
 
Snappy Baby
Snappy  BabySnappy  Baby
Snappy Baby
 
Redes Peea
Redes PeeaRedes Peea
Redes Peea
 
Funny Cartoons
Funny CartoonsFunny Cartoons
Funny Cartoons
 
Flowers
FlowersFlowers
Flowers
 
Ravel Bolero
Ravel BoleroRavel Bolero
Ravel Bolero
 
Where In The World
Where In The WorldWhere In The World
Where In The World
 
Very Funny
Very FunnyVery Funny
Very Funny
 
Funny Slideshow
Funny SlideshowFunny Slideshow
Funny Slideshow
 
Funny Humor
Funny HumorFunny Humor
Funny Humor
 
Crazy Picture
Crazy PictureCrazy Picture
Crazy Picture
 
Dream House
Dream HouseDream House
Dream House
 
Best Websites List
Best Websites ListBest Websites List
Best Websites List
 
[Awesome] Military Photos Of The Twin Towers
[Awesome] Military Photos Of The Twin Towers[Awesome] Military Photos Of The Twin Towers
[Awesome] Military Photos Of The Twin Towers
 
Audrey 20 Portraits Of Audrey Hepburn
Audrey  20 Portraits Of Audrey HepburnAudrey  20 Portraits Of Audrey Hepburn
Audrey 20 Portraits Of Audrey Hepburn
 
What Is Love
What Is LoveWhat Is Love
What Is Love
 

Recently uploaded

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform EngineeringJemma Hussein Allen
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™UiPathCommunity
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaRTTS
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...Elena Simperl
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance
 

Recently uploaded (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Ransomware Mallox [EN].pdf
Ransomware         Mallox       [EN].pdfRansomware         Mallox       [EN].pdf
Ransomware Mallox [EN].pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 

Presenting Your Code

  • 1. Presenting Your Code Ian Dees http://texagon.blogspot.com Hi, I'm Ian Dees, a software developer for a test equipment manufacturer near Portland, Ore. Today, we're going to talk about freeing your source code from your text editor and getting it into your presentations.
  • 2. TextMate http://www.macromates.com Smultron http://smultron.sf.net The basic ideas will work on any platform, but the screenshots we're looking at today will primarily be from two popular text editors for the Mac.
  • 3. Let's say we're trying our hand at the great Computer Language Shootout with Ackermann's Function. Here's what one solution looks like inside our text editor.
  • 4. def ackermann(m, n) $memo ||= {} $memo[[m, n]] = $memo[[m, n]] ? $memo[[m, n]] : 0 == m ?n+1 : 0 < m && 0 == n ? ackermann(m - 1, 1) : ackermann(m - 1, ackermann(m, n - 1)) end 1.upto(8) {|n| puts ackermann(3, n)} But if we do a Select All in our text editor and then copy and paste into our presentation, we lose all the pretty syntax highlighting.
  • 5. We could just take a screenshot from our text editor and paste it into the presentation as a graphic. But that makes for large file sizes and blurry font sizes. And if we distribute our slides as PDFs, readers won't be able to cut and paste our text. Also, it's a pretty manual process.
  • 6. pri nt 1 ! ackermann.rb ! 2007-09-03 23:11 ! Ian Dees def ackermann(m, n) $memo ||= {} $memo[[m, n]] = $memo[[m, n]] ? $memo[[m, n]] : 0 == m ?n+1 : 0 < m && 0 == n ? ackermann(m - 1, 1) : ackermann(m - 1, ackermann(m, n - 1)) end 1.upto(8) {|n| puts ackermann(3, n)} If you're using Smultron as your editor, you can print to a PDF and then drag the PDF file into your slide--assuming your slides have a white background.
  • 7. But I prefer a bit more flexibility. Let's look at HTML for a potential solution. We could just submit our code to Pastie, and then cut/paste the result into our presentation.
  • 8. <span class=quot;rquot;>def</span> <span class=quot;fuquot;>ackermann</span>(m, n) .r { color:#080; font-weight:bold } .fu { color:#06B; font-weight:bold } And since Pastie's stylesheets are pretty simple, we could even tweak the colors before we put the code into our presentation.
  • 9. http://www.ruby-lang.org But there's another way that doesn't require a round trip to the Pastie servers every time you want to highlight your code. First, get Ruby.
  • 10. gem install syntax Then, install the Syntax gem.
  • 11. http://pastie.caboo.se/95056 Finally, grab the Ruby source code from this file and save it to your hard drive somewhere.
  • 12. ⌘B Now, you can configure your text editor to run the script. In Smultron, hit Cmd-B to bring up the Commands window. Create a new command, bind it to a keystroke if you like, and fill in its contents like this. You'll want to substitute the paths to where you keep your Ruby interpreter and where you saved the script, of course.
  • 13. Now, whenever you hit your chosen hotkey, Smultron generates the HTML and (if you've enabled it in the script) launches your browser for easy cutting and pasting.
  • 14. ⌘⌥R The process is similar in TextMate. Just hit Cmd-Option-R to bring up the Filter Through Command dialog, browse to where you saved the script, and select Show as HTML.
  • 15. When you press Execute, TextMate brings up a new window with highlighted code that remembers its colors...
  • 16. def ackermann(m, n) $memo ||= {} $memo[[m, n]] = $memo[[m, n]] ? $memo[[m, n]] : 0 == m ?n+1 : 0 < m && 0 == n ? ackermann(m - 1, 1) : ackermann(m - 1, ackermann(m, n - 1)) end 1.upto(8) {|n| puts ackermann(3, n)} ...when you paste it into a slide, like this.
  • 17. def ackermann(m, n) $memo ||= {} $memo[[m, n]] = $memo[[m, n]] ? $memo[[m, n]] : 0 == m ?n+1 : 0 < m && 0 == n ? ackermann(m - 1, 1) : ackermann(m - 1, ackermann(m, n - 1)) end 1.upto(8) {|n| puts ackermann(3, n)} There will be a few minor dierences, of course. Punctuation, class names, and constants might be colored a little dierently between your text editor and the resulting HTML. But with a little tweaking, you can get pretty darn close.
  • 18. ⌘⌃R And in the specific case of TextMate, you can do even better than just quot;pretty darn close.quot; Run the quot;TextMate Create HTML From Documentquot; command, which is bound to Cmd-Ctrl-R (as opposed to Cmd-Opt-R) on my system. By default, that brings up the raw HTML tags in a new window, but you can configure TextMate to actually render the HTML instead.
  • 19. Presenting Your Code Ian Dees http://texagon.blogspot.com And that's it. Thanks for your time.