開発
Presentation tips for software engineers
denvazh
One cannot live without introduction…
Two weeks ago I had a presentation about importance of writing test prior to its code impementation. I talk about testing and why its very important, why everybody should do it and what happens if not…but in this blog post I would like to share one interesting perk that might help you with preparing presentation slides.
Search, search, search
Occasionally, I would put source-code in my presentation slides, and I’ve been doing it in a number of ways over the last 8 years:
- screen shot
- copy & paste and manually arrange spaces
- 2) + manually apply syntax highlight
- open terminal during presentation and show great hacker skills 🙂
 All methods above have clear benefits and drawbacks. Personally, when preparing presentation slides I try to improve visuals and overall positive impressions from the point of view of spectators.
With this idea in mind I decided to invest some time into searching for better ways of presenting source-code.
After few attempts to google for source-code and presentation,
I found this gist: https://gist.github.com/jimbojsb/1630790, which completely made my day. 
Let’s roll!
With this approach it is very easy to copy & paste source code with indents and syntax highlight preserved. In my case, I had to adjust styling, because I usually have bright background for slides and black boxes for source-code. It is also possible to select specific syntax highlight for certain language.
I will put some samples below. Note: even though ‘highlight’ might be available on other platforms, but in this blog post I would focus mainly on OS X.
To highlight bash script with darkness theme:
$: highlight --style darkness -S bash -O rtf script.sh | pbcopy
then with `Cmd + V` one can paste nicely looking source-code to the presentation.
As a real example, let’s consider this simple fibonacci sequence calculation:
#!/usr/bin/env ruby
def fibonacci(num)
	return 0 if (num == 0)
	return 1 if (num == 1 or num == 2) 
	return fibonacci(num - 1) + fibonacci(num - 2)
end
def benchmark
	t1 = Time.now
	yield
	t2 = Time.now
	return t2-t1
end
arr		=[]
items_num	=40
time = benchmark do 
	items_num.times do |t|
		arr << fibonacci(t)
	end
end
puts "Elapsed time: #{time}"
puts
puts "First #{items_num} numbers in Fibonacci sequence:\n#{arr.inspect}"
Changing the last command like follows:
$: highlight --style darkness -S ruby -O rtf fibonacci.rb | pbcopy
we can enjoy nicely rendered code in the presentation slides like follows:

 
                             2024/12/06
                  2024/12/06 2024/09/13
                  2024/09/13 2024/05/17
                  2024/05/17 2024/05/10
                                    2024/05/10 2024/01/05
                  2024/01/05 2023/08/18
                  2023/08/18 2023/07/14
                  2023/07/14 2023/05/12
                  2023/05/12