-
Notifications
You must be signed in to change notification settings - Fork 4
/
atom.xml
2276 lines (1746 loc) · 181 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[Automate All the Things!]]></title>
<link href="http://dougireton.github.io/atom.xml" rel="self"/>
<link href="http://dougireton.github.io/"/>
<updated>2013-06-24T15:53:17-07:00</updated>
<id>http://dougireton.github.io/</id>
<author>
<name><![CDATA[Doug Ireton]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[Encouraging Women in Dev/Ops]]></title>
<link href="http://dougireton.github.io/blog/2013/06/23/encouraging-women-in-dev-slash-ops/"/>
<updated>2013-06-23T21:00:00-07:00</updated>
<id>http://dougireton.github.io/blog/2013/06/23/encouraging-women-in-dev-slash-ops</id>
<content type="html"><![CDATA[<p>This past week, I went to <a href="http://velocityconf.com/velocity2013">Velocity</a> and <a href="http://devopsdays.org/events/2013-mountainview/program/">DevOps Days</a> in Silicon Valley, CA. Both
conferences were amazing and I learned a ton. During DevOps Days I led an <a href="http://martinfowler.com/bliki/OpenSpace.html">Open Space</a> session on “Encouraging Women in Dev/Ops”. I was humbled by the number of people who attended and their passion for the topic. Read on for a summary of
my notes taken during the hour we had.</p>
<!-- more -->
<ol>
<li><p>Women will apply for job when they meet 100% of criteria, men 60%
I suspect this is because women are taught not to be boastful as girls, while
boys are taught to “go for it”. Not sure if there’s science to back up this
claim.</p></li>
<li><p>Hiring managers tend to hire first from their personal networks and those networks contain too few women, so expand those networks.</p></li>
<li><p>Universities are not going to solve the number of women graduating from STEM
programs problem anytime soon, so look for other ways to train women as
developers, ops.<br/>
Example: Austin has Girls Hack, provides bonding place for women in tech.<br/>
Other cities have women’s tech meetups. For example, here’s a <a href="http://www.meetup.com/find/?categories=&keywords=women+technology&radius=5">good listing in
Seattle</a></p></li>
<li><p>Benefits: Longer maternity, job share, and flex hours are better for women candidates.<br/>
Foosball table is not necessarily a selling point. Be careful not
to create a “dude’s” environment at work.</p></li>
<li><p>As a manager treat everyone as an individual. Be careful not to treat women
on your team as “one of the guys”, but also not like a “fragile flower”.</p></li>
<li><p>We praise women for appearance and kindness; men praised for accomplishments, so
praise women for accomplishments. This is an awareness thing and takes practice.</p></li>
<li><p>“Feels great to not be the only woman on team, very empowering”. This quote
really struck me. Of course it’s better to have one woman on your team than
none, but in order for the woman to not feel like the token woman on the team
it’s better to have two or more.</p></li>
<li><p>Need women on DevOps Days Organizing team. The DevOps Days organizers really
would like women to participate in planning future DevOps Days events. Email
<a href="mailto:[email protected]">[email protected]</a> for more information.</p></li>
</ol>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Ruby Fundamentals: Using Custom Setters to clean up Instance Variables]]></title>
<link href="http://dougireton.github.io/blog/2013/05/19/ruby-fundamentals-using-custom-setters-to-clean-up-instance-variables/"/>
<updated>2013-05-19T21:56:00-07:00</updated>
<id>http://dougireton.github.io/blog/2013/05/19/ruby-fundamentals-using-custom-setters-to-clean-up-instance-variables</id>
<content type="html"><![CDATA[<p>Ohai Fellow Rubyists!</p>
<p>This week we’re going to look at using custom setter methods in your Ruby class
initializers to do any custom logic before setting instance variables. I just
had to do this last week for a gem I’m writing. Here’s a quick snippet. Read on
for the full explanation.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">class</span> <span class="nc">StashNotifier</span>
</span><span class='line'> <span class="kp">attr_reader</span> <span class="ss">:job_status</span>
</span><span class='line'>
</span><span class='line'> <span class="no">VALID_JOB_STATUSES</span> <span class="o">=</span> <span class="sx">%w{ INPROGRESS SUCCESSFUL FAILED }</span>
</span><span class='line'>
</span><span class='line'> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
</span><span class='line'> <span class="c1"># other instance vars omitted</span>
</span><span class='line'> <span class="nb">self</span><span class="o">.</span><span class="n">job_status</span> <span class="o">=</span> <span class="n">args</span><span class="o">[</span><span class="ss">:job_status</span><span class="o">]</span> <span class="c1"># <= call the custom setter</span>
</span><span class='line'> <span class="vi">@job_key</span> <span class="o">=</span> <span class="n">args</span><span class="o">[</span><span class="ss">:job_key</span><span class="o">]</span>
</span><span class='line'> <span class="vi">@job_url</span> <span class="o">=</span> <span class="n">args</span><span class="o">[</span><span class="ss">:job_url</span><span class="o">]</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'>
</span><span class='line'> <span class="c1"># custom setter method</span>
</span><span class='line'> <span class="k">def</span> <span class="nf">job_status</span><span class="o">=</span><span class="p">(</span><span class="n">new_job_status</span><span class="p">)</span>
</span><span class='line'> <span class="n">new_job_status</span> <span class="o">=</span> <span class="n">new_job_status</span><span class="o">.</span><span class="n">strip</span><span class="o">.</span><span class="n">upcase</span>
</span><span class='line'>
</span><span class='line'> <span class="k">if</span> <span class="no">VALID_JOB_STATUSES</span><span class="o">.</span><span class="n">include?</span><span class="p">(</span><span class="n">new_job_status</span><span class="p">)</span>
</span><span class='line'> <span class="vi">@job_status</span> <span class="o">=</span> <span class="n">new_job_status</span>
</span><span class='line'> <span class="k">else</span>
</span><span class='line'> <span class="k">raise</span> <span class="no">ArgumentError</span><span class="p">,</span> <span class="s2">"'</span><span class="si">#{</span><span class="n">new_job_status</span><span class="si">}</span><span class="s2">' is not a valid Stash Build</span>
</span><span class='line'><span class="s2">Status! Valid job statuses are </span><span class="si">#{</span><span class="no">VALID_JOB_STATUSES</span><span class="si">}</span><span class="s2">."</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'><span class="c1"># rest of class omitted</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<!-- more -->
<h2>Background</h2>
<p>Recently, I’ve been working on a gem to send Jenkins build status to our <a href="http://www.atlassian.com/software/stash/overview">Stash git server</a> as part of our CD pipeline.</p>
<p>This gem, ‘stash_notifier’, takes <code>job_status</code> as an argument in its class initializer. At first I just set the <code>@job_status</code> instance variable directly like this:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
</span><span class='line'> <span class="c1"># other instance vars omitted</span>
</span><span class='line'> <span class="vi">@job_status</span> <span class="o">=</span> <span class="n">args</span><span class="o">[</span><span class="ss">:job_status</span><span class="o">]</span>
</span><span class='line'> <span class="vi">@job_key</span> <span class="o">=</span> <span class="n">args</span><span class="o">[</span><span class="ss">:job_key</span><span class="o">]</span>
</span><span class='line'> <span class="vi">@job_url</span> <span class="o">=</span> <span class="n">args</span><span class="o">[</span><span class="ss">:job_url</span><span class="o">]</span>
</span><span class='line'> <span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>But then I realized I really should <code>upcase</code> the <code>job_status</code> per the <a href="https://developer.atlassian.com/stash/docs/latest/how-tos/updating-build-status-for-commits.html#Updating_build_results">Atlassian SDK docs</a>. Plus I wanted to check the <code>job_status</code> parameter the user passed into the <code>StashNotifier.new</code> method to make sure it was valid. To solve this I wrote a custom setter.</p>
<h2>Custom Setters</h2>
<p>Ruby includes some nice helper methods, <code>attr_reader</code>, <code>attr_writer</code>, and <code>attr_accessor</code> to create setters and getters for you. These just set or return the instance variables and don’t allow for any customization. If you want to do some validation or modify the passed-in parameters, define a custom setter like this:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="no">Class</span> <span class="no">StashNotifier</span>
</span><span class='line'> <span class="kp">attr_reader</span> <span class="ss">:job_status</span>
</span><span class='line'>
</span><span class='line'> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
</span><span class='line'> <span class="c1"># other instance vars omitted</span>
</span><span class='line'> <span class="nb">self</span><span class="o">.</span><span class="n">job_status</span> <span class="o">=</span> <span class="n">args</span><span class="o">[</span><span class="ss">:job_status</span><span class="o">]</span> <span class="c1"># <= call the custom setter</span>
</span><span class='line'> <span class="vi">@job_key</span> <span class="o">=</span> <span class="n">args</span><span class="o">[</span><span class="ss">:job_key</span><span class="o">]</span>
</span><span class='line'> <span class="vi">@job_url</span> <span class="o">=</span> <span class="n">args</span><span class="o">[</span><span class="ss">:job_url</span><span class="o">]</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'>
</span><span class='line'> <span class="c1"># custom setter method</span>
</span><span class='line'> <span class="k">def</span> <span class="nf">job_status</span><span class="o">=</span><span class="p">(</span><span class="n">new_job_status</span><span class="p">)</span>
</span><span class='line'> <span class="c1"># define custom logic here</span>
</span><span class='line'> <span class="c1"># see code sample above for full example</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>We first define an <code>attr_reader</code> to have Ruby create the getter for us. We’ll define the setter separately so we can add some of our own logic.</p>
<p>Instead of setting the <code>job_status</code> instance variable in our class initializer, we call the custom setter, <code>job_status=</code>. By defining it as a method with a trailing <code>=</code>, we make it a setter. We prepend it with <code>self.</code> to specify that it’s a method and not a local variable.</p>
<p>This setter method will be called during initialization, <em>and</em> anytime we do this:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'> <span class="n">notifier</span> <span class="o">=</span> <span class="no">StashNotifer</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
</span><span class='line'> <span class="n">notifier</span><span class="o">.</span><span class="n">job_status</span> <span class="o">=</span> <span class="s1">'failed'</span>
</span></code></pre></td></tr></table></div></figure>
<p>By calling the custom setter in the class initiaize method, we make sure that our custom setter is always called, both at initialization time and whenever we set the <code>job_status</code> “property” on our class instance, making our solution DRY.</p>
<h2>Summary</h2>
<p>I hope you’ve found this useful. It took quite a bit of Googling for me to find out this little tidbit. Here are a couple of links I found helpful during my research:</p>
<ol>
<li><a href="http://ruby.about.com/od/oo/ss/Using-Attributes.htm">http://ruby.about.com/od/oo/ss/Using-Attributes.htm</a></li>
<li><a href="http://stackoverflow.com/questions/12097726/ruby-classes-initialize-self-vs-variable">http://stackoverflow.com/questions/12097726/ruby-classes-initialize-self-vs-variable</a></li>
</ol>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[How to present at a tech conference]]></title>
<link href="http://dougireton.github.io/blog/2013/05/12/how-to-present-at-a-tech-conference/"/>
<updated>2013-05-12T21:33:00-07:00</updated>
<id>http://dougireton.github.io/blog/2013/05/12/how-to-present-at-a-tech-conference</id>
<content type="html"><![CDATA[<p>Ohai Chefs!</p>
<p>This week I’ll share my tips and tricks for presenting at a tech conference,
based on my vast experience of one conference. So, take it with several grains
of salt.</p>
<!-- more -->
<h2>Chef Conf 2013</h2>
<p>I had the opportunity to speak at Chef Conf 2013 on April 26th on <a href="http://youtu.be/APBSff1_oVY">Tips and
Tricks for Automating Windows with Chef</a>. I actually proposed a completely
different talk back in January which when it just wasn’t coming together in
early April, I had to abandon.</p>
<h2>The Proposal</h2>
<p>I don’t have a lot of advice here, except to share my mistake. In January, I
submitted this proposal:</p>
<p>“Come hear about how Nordstrom developed a Continuous Delivery workflow for Chef
development. Engineers test cookbooks locally using Vagrant, then commit to Git,
which triggers a Jenkins build. Jenkins runs cookbook tests, then uploads
cookbooks to our Private Chef server.”</p>
<p>Which would have made a great talk. In January, we hadn’t even started on a CD
pipeline for Chef Cookbooks. By April, we hadn’t even started on a CD
pipeline for Chef Cookbooks. I finally had to admit, there was no way I could
get up and talk about something we hadn’t done yet. I had to email Nathen Harvey
at Opscode and tell him I needed to talk about a different topic. He was great
and I was able to pick a new topic, one I knew I had quite a bit of experience
with.</p>
<p>So my advice is to pick a topic on which you already have experience instead of
something you hope to get to before the confernece.</p>
<h2>The Preparation</h2>
<p>Preparing for a talk is a lot of work. I estimate I spent an 60-75 min for every
minute of actual speaking time, roughly 30-35 hours of work for a 25 min talk.
When you know you’re going to be speaking in front of very smart engineers, you
really need to know your topic thoroughly and anticipate the kinds of questions
you’ll get.</p>
<h2>Tell a Story</h2>
<p>Don’t just dive into technical details and code samples. Tell a story. We humans
are hard-wired to engage with stories. Share a problem you faced, why it was
challenging, what you tried that didn’t work, and how you overcame it. Then dive
into the technical details. Your audience will be ready to hear you talk about
the technical nitty-gritty after you’ve got their attention with a story.</p>
<h2>Presentation Zen</h2>
<p>I have used <a href="http://www.amazon.com/Presentation-Zen-Simple-Delivery-Edition/dp/0321811984">Presentation Zen</a> by Garr Reynolds for several presentations and
I can’t recommend it enough. You should read this before your next presentation.</p>
<h2>Practice</h2>
<p>I gave my talk three times before I gave it for real. I presented it to my team
twice and I presented it to the Seattle Chef meetup the week before Chef Conf.
Even though these were unfinished drafts, I got very valuble feedback from a
friendly audience. My talk was much better because of the practice and feedback
I received. It also gave me confidence that my topic was useful and helpful to
people.</p>
<p>Nathen Harvey (Opscode) also scheduled a few Google+ hangouts for conference
speakers which were very helpful. I got a chance to meet some other speakers and
get my questions answered. He also encouraged speakers to send him our slides
before the conference. It was just additional reassurance that I was on the
right track.</p>
<h2>Logistics</h2>
<p>And finally, some logistical tips.</p>
<ol>
<li><p>Follow the code of conduct. This should go without saying, but no
inappropriate content in your slides.</p></li>
<li><p>Ask what resolution you’ll be presenting at. I formatted my slides for 1024 x
768 originally, and then had to change to 1280 x 720. This makes a big
difference if you are using full-bleed photos.</p></li>
<li><p>Make sure any photos are licensed for reuse. I find nearly all my slide
photos by doing Creative Commons-licensed searches on Flickr.com.</p></li>
<li><p>Give proper attribution for photos you use. I usually just paste the link to
the photo in the bottom right-hand corner of the slide.</p></li>
<li><p>Have your slides on your laptop <strong>and</strong> on a USB stick. Even if you are
supposed to present on your laptop, it may not work and you may have to use a
conference provided laptop.</p></li>
<li><p>Don’t depend on using Keynote Remote from your phone to drive the slides. You
can almost count on conference wifi or a Bluetooth connection being flaky.
Use a real remote.</p></li>
<li><p>Show up 15 min before your talk to get setup with the mic, make sure your
laptop can connect to the projector, etc.</p></li>
<li><p>Ask for a glass or bottle of water for your talk.</p></li>
<li><p>Get enough sleep the night before.</p></li>
<li><p>Bring any video adapters you may need, e.g HDMI, DVI, etc.</p></li>
<li><p>If you are having one of your teammates join you on stage, ask the
conference organizers for a mic for them.</p></li>
<li><p>Repeat the question. People in the audience and people watching your
presentation later will appreciate you repeating any questions you get
before answering them.</p></li>
<li><p>Display code on a light background. If you create Github gists for each of your
code samples, you can copy/paste those into your slides and it will preserve
the formatting.</p></li>
<li><p>Have a printed copy of your slide notes with you. Your carefully crafted
prensenter display may not work with the conference projector and you may
end up with just your slides showing on your laptop instead of your presenter
display with slide notes.</p></li>
</ol>
<h2>Summary</h2>
<p>That’s it for this week. I hope you’ll get a chance to present at a future
conference if you haven’t already. I’d love to hear your presentation tips in
the comments. Cheers.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Will you join us?]]></title>
<link href="http://dougireton.github.io/blog/2013/04/14/will-you-join-us/"/>
<updated>2013-04-14T21:00:00-07:00</updated>
<id>http://dougireton.github.io/blog/2013/04/14/will-you-join-us</id>
<content type="html"><![CDATA[<p>Ohai Chefs!</p>
<p>This week, the week before Chef Conf, I’d like to talk a bit about our team and our culture, and invite you to join us.</p>
<p><img src="http://dougireton.github.io/images/infeng_area.png" width="450" height="300" title="'Our work area'" ></p>
<h2>tl;dr</h2>
<p>We have a spot on our Infrastructure Engineering team, and I hope you’ll read on to get a personal feel for our team and the huge cultural shift happening right now at Nordstrom.</p>
<p>If you are interested, please email me: doug.ireton at nordstrom.com</p>
<!-- more -->
<h2>At Nordstrom, you have an opportunity to follow your passion</h2>
<p>I’ve been working at Nordstrom for five years, first on the Windows Server Engineering team, then on Nordstrom.com as a developer, then as a build engineer, and finally on the Infrastructure Engineering team as a developer, working with Chef everyday. I’ve had opportunities to follow my passion, even when I wasn’t qualified “on paper”. My managers have encouraged me to pursue my interests, even when it meant leaving their teams. This is in strong contrast to other companies I’ve worked for, where I felt I had to leave the company to do something different. For example, at Microsoft in the late 90’s, I was forever stuck as a tester, with no opportunity to try my hand at development.</p>
<h2>At Nordstrom, managers support you</h2>
<p>This may sound cliche, but the management culture is built around supporting engineers, and removing roadblocks. Nordstrom actually draws their org charts upside-down so managers are on the bottom and engineers are on top. This is weird at first but managers are committed to their role supporting their employees. No manager will ever say they manage a team, they always say they “support a team”. This may sound cheesy, but I have seen it lived out for the five years I’ve been here and it’s one of the reasons I love working here.</p>
<h2>At Nordstrom, you will have an opportunity to use and contribute to open source</h2>
<p>Nordstrom, like most “enterprise” IT shops has up until recently been adverse to even using open source software, much less allowing engineers to contribute to open source software. About eight months ago, I started hearing that we were working on an open-source agreement to allow employees to use and contribute to open-source projects on behalf of Nordstrom. Once the agreement finally came out, I was pleasantly surprised. We are using more open source tools now and we view contributing to the community in the form of patches, documentation, IRC, speaking, etc. as a vital part of keeping those communities healthy. We have benefitted so much from the Chef community and it’s been great to be able to give back, and to have paid work time to contribute.</p>
<p>We also have a strong relationship with Opscode, which is only five blocks away from our building. We are regular attenders at the monthly DevOps meetups at Opscode and also attend the Opscode Community Summit in the fall and ChefConf in the spring. Recently, I had the opportunity to work with Adam Jacob and Chris McClimans on a continuous delivery pilot project for six weeks, which was awesome.</p>
<h2>Our team is small and focused</h2>
<p>Our team, Infrastructure Engineering, is only three engineers right now. I work with two other engineers who I have incredible respect for and enjoy working with, Jon, and Kevin. Our manager, Rob has a strong technical background.</p>
<p>We work in an open, collaborative environment and regularly bounce ideas off one another. We also have a 55” monitor on which we do code reviews, display our Chef Client run metrics (via StatsD, Graphite, and Team Dashboard), and keep up with DevOps Reactions.</p>
<p>Though we have a small team, we are working closely with other teams to spread the DevOps love. For the past four months, we’ve had a couple of other engineers from our web ops team embedded on our team, sitting next to us, working on automating our web server builds and configuration. This has by far been the best way to cross-pollenate the devops culture and knowledge of Chef, Ruby, Git, code review, etc. At this point, our web ops team has successfully picked up Chef, Ruby, Git, etc. and is running with it with only a little help now and then. It’s been awesome to see them run with it.</p>
<p>Though we have been primarily focused on automating our web servers, we have also written Chef cookbooks and recipes for a Hadoop cluster, SQL servers critical to our stores, and a WordPress blog setup for an incident status blog. There are new opportunities and challenges every week.</p>
<h2>At Nordstrom, we are at the beginning of a cultural sea change</h2>
<p>Up until very recently, Nordstrom has run a pretty traditional IT shop: big, heavily-planned projects, a preference for expensive, complicated vendor tools (Oracle, CA, Microsoft, BMC, etc.) and siloed teams. In the past 18 months we have been evolving towards a faster, more agile approach, but recently, I’ve seen a cultural sea change.</p>
<p>We had Adam Jacob and Chris McClimans from Opscode come in and do a Continuous Delivery pilot project with us for six weeks. We had weekly demos and by the end we had a working, prototype CD pipeline built which delivered code changes to our staging environment at the push of a button. It was eye-opening. That project has sparked an intense discussion around what it really takes to move at speed, to continually deliver customer features to prod instead of large batches.</p>
<p>More importantly, we are having the right discussions about the huge cultural changes required to truly adopt a DevOps culture. I have never seen leadership, from the CIO on down (or “up” in Nordstrom terms) more committed to setting Nordstrom on the course to DevOps, Continuous Delivery, and empowering engineers. It’s an exciting time to be here.</p>
<h2>Will you join us?</h2>
<p>We are looking to grow our team. Will you join us? We are looking for smart, passionate engineers who care about DevOps culture, contribute (or excited to be able to) to open source, and have experience with Chef, Puppet or other automation tools. As a team we are challenged to learn new things every day to make Nordstrom better. We care about metrics, we go to conferences (Ruby on Ales, ChefConf, Velocity, DevOps days this year), we love programming and solving problems.</p>
<p>Our whole team will be at ChefConf next week and two of us are speaking. Rob has a keynote, and I’ll be speaking about Chef on Windows. Two of us will also be at Velocity and DevOps Days in June. We’d love to meet you, and chat about the position. Feel free to DM us on Twitter or just meet us during one of the conferences.</p>
<p>If you’ve read this far, thank you. I hope I’ve made a compelling pitch for why I look forward to going to work everyday. We look forward to meeting you.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Favorites from the treasure chest]]></title>
<link href="http://dougireton.github.io/blog/2013/04/06/favorites-from-the-treasure-chest/"/>
<updated>2013-04-06T07:51:00-07:00</updated>
<id>http://dougireton.github.io/blog/2013/04/06/favorites-from-the-treasure-chest</id>
<content type="html"><![CDATA[<p>Ohai Chefs!</p>
<p>Work has been busy and I’ve been working on my <a href="http://chefconf.opscode.com/">Chef Conf</a> presentation in my “free” time, so this week I’m rounding up some links I think you’ll like.</p>
<ol>
<li><p><a href="http://jtimberman.housepub.org/blog/2013/02/16/last-check-in-time-for-nodes/">Last check-in time for nodes</a> by Josh Timberman. Nice short post with great explanations.</p></li>
<li><p><a href="http://erik.hollensbe.org/2013/03/16/the-chef-resource-run-queue/">How the Chef client builds the Resource Collection queue</a> by Eric Hollensbe. I have a much better understanding of how a Chef run actually works after reading this.</p></li>
<li><p>Good <a href="https://speakerdeck.com/nathenharvey/testing-your-automation">overview of Chef testing</a> by Nathen Harvey.</p></li>
<li><p>Also see Joshua Timberman’s <a href="http://jtimberman.housepub.org/blog/2013/03/19/anatomy-of-a-test-kitchen-1-dot-0-cookbook-part-1/">Anatomy of a Test Kitchen 1.0 Cookbook</a> for more testing goodness.</p></li>
</ol>
<!--more-->
<ol>
<li><p>Chef Shell (a.k.a. Shef) <a href="http://stevendanna.github.io/blog/2012/01/28/shef-debugging-tips-1/">debugging tips</a> by Steven Danna. This is one blog post I really need to dig into when I have a free morning.</p></li>
<li><p><a href="http://www.slideshare.net/500startups/ross-synder-etsy-sxsw-lean-startup-2013">Continuous Deployment at Etsy</a>. An excellent presentation by Ross Snyder at Etsy. Need to convince your boss that Continuous Delivery/Deployment is a good idea? This will help.</p></li>
<li><p>Jon Cowie from Etsy will reprise his Velocity 2012 talk <a href="http://oreillynet.com/pub/e/2576">Michelin Starred Cooking with Chef</a> on May 14th, 2013. I attended this talk at Velocity last year and I’m looking forward to seeing it again. Highly recommended.</p></li>
<li><p>I was just going to have seven links but I couldn’t help add this one in. Josh Timberman’s Big Ruby Conf talk on <a href="https://speakerdeck.com/jtimberman/5-things-you-didnt-know-about-chef">5 Things You Didn’t Know About Chef</a>.</p></li>
</ol>
<p>That’s it for this week. Hope you pick up some good tips from these links. Happy Cooking!</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Chef wanted. Apply within]]></title>
<link href="http://dougireton.github.io/blog/2013/03/31/chef-wanted-apply-within/"/>
<updated>2013-03-31T19:54:00-07:00</updated>
<id>http://dougireton.github.io/blog/2013/03/31/chef-wanted-apply-within</id>
<content type="html"><![CDATA[<p>Ohai Chefs!</p>
<p>This week, we’ll take a look at <a href="http://tickets.opscode.com/browse/CHEF-3571"><code>chef-apply</code></a>, a command-line tool, new to Chef 11, which assists with rapid development and troubleshooting by letting you run a single recipe at a time.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[ruby -p -i -e]]></title>
<link href="http://dougireton.github.io/blog/2013/03/24/ruby-p-i-e/"/>
<updated>2013-03-24T21:28:00-07:00</updated>
<id>http://dougireton.github.io/blog/2013/03/24/ruby-p-i-e</id>
<content type="html"><![CDATA[<p>This week we’ll look at a practical example of combining a simple shell script with a Ruby one-liner to set and unset environment variables.</p>
<h2><a href="http://www.youtube.com/watch?v=bKK-KLDlm20">The Tragic Backstory</a></h2>
<p>At work, we have to go through a proxy server to get to the Internet. To use git, curl, etc. I have to set my <code>http(s)_proxy</code> environment varables. At home I have to unset them since I don’t have a proxy at home. Editing my .zshenv twice a day got pretty tedious so I decided to script it.</p>
<p>At first I tried using sed but after trying for an hour to understand how to write a simple sed script, I opted for Ruby. As it turns out, Ruby has very good support for line-editing and substitution.</p>
<!--more-->
<h2>The Problem</h2>
<p>Here are the first two lines of my <code>.zshenv</code> file with the relevant proxy variables:</p>
<figure class='code'><figcaption><span>.zshenv</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nb">export </span><span class="nv">http_proxy</span><span class="o">=</span><span class="s2">"http://proxy.example.com:80"</span>
</span><span class='line'><span class="nb">export </span><span class="nv">https_proxy</span><span class="o">=</span><span class="s2">"http://proxy.example.com:80"</span>
</span><span class='line'>
</span><span class='line'><span class="c"># --- <snip> ---</span>
</span></code></pre></td></tr></table></div></figure>
<p>My script needed to be able to comment out only those two lines, like this:</p>
<figure class='code'><figcaption><span>.zshenv with proxy lines commented</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># export http_proxy="http://proxy.example.com:80"</span>
</span><span class='line'><span class="c"># export https_proxy="http://proxy.example.com:80"</span>
</span><span class='line'>
</span><span class='line'><span class="c"># --- <snip> ---</span>
</span></code></pre></td></tr></table></div></figure>
<h2>The solution – <a href="http://www.crumblycookie.net/2012/06/16/strawberry-rhubarb-pie/">Delicious PIE</a></h2>
<p>Ruby has many command line options (type <code>ruby -h</code> to see them), but three are particularly relevant to solving this problem. The first one is <code>-i</code>, which means edit in place instead of making a copy. The next one is <code>-p</code>, which makes Ruby “print”, or iterate over each line of your input file so your script can act on each line. Basically it saves you the trouble of reading in the file and creating a line interator. Pretty handy. Finally, the <code>-e</code> allows you to pass a one-line Ruby script to <code>ruby</code>.</p>
<p>All together, these options allow you to read in an input file, interate over each line (<code>-p</code>), edit in place (<code>-i</code>), and execute a one-line script (<code>-e</code>) against each line.</p>
<figure class='code'><figcaption><span>noproxy.sh script</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># Comment out lines beginning with "export http(s)_proxy"</span>
</span><span class='line'><span class="c"># This will set no proxy</span>
</span><span class='line'>ruby -i -pe <span class="s2">"gsub /^export https{0,1}_proxy=/, '# \0'"</span> ~/.zshenv
</span><span class='line'>
</span><span class='line'><span class="nb">source</span> ~/.zshenv
</span></code></pre></td></tr></table></div></figure>
<p>Above is the script to comment out <code>http(s)_proxy</code> lines for when I’m not at work. The Ruby one-liner is a gsub which finds lines beginning with <code>http_proxy</code> or <code>https_proxy</code> and prepends a comment char (#) before the entire match, represented with <code>\0</code>.</p>
<figure class='code'><figcaption><span>proxy.sh script</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># Uncomment lines beginning with "export http(s)_proxy"</span>
</span><span class='line'><span class="c"># This will set a proxy</span>
</span><span class='line'>ruby -i -pe <span class="s2">"gsub /^# (export https{0,1}_proxy=)/, '\1'"</span> ~/.zshenv
</span><span class='line'>
</span><span class='line'><span class="nb">source</span> ~/.zshenv
</span></code></pre></td></tr></table></div></figure>
<p>This is the script to uncomment the <code>http(s)_proxy</code> lines for when I’m working for the man. It’s quite similar to the script above but replaces the <code>http(s)_proxy</code> lines with the <code>\1</code> reference which matches the part of the match in parenthesis.</p>
<p>By making this script executable, and putting it in my <code>~/bin</code> directory, I can just run <code>proxy.sh</code> to set my proxy, and <code>noproxy.sh</code> to unset my proxy. The script automatically re-sources my <code>.zshenv</code> so I don’t have to close and reopen my terminal.</p>
<h2>The 80/20 Rule</h2>
<p>All in all I’m pretty happy with my solution. It’s not perfect. I’d really like to automatically run when I switch Mac network Locations, but for now it’s making my life easier with only one line of Ruby. It gets me at least 80% of the way there and I’m happy to stop bike shedding it for now.</p>
<h2>Wrap Up</h2>
<p>So, with the help of Ruby’s command-line options, we learned how to write a simple shell script to gsub lines in a text file using a Ruby one-liner. Ruby’s command-line options are pretty handy, check them out with <code>ruby -h</code>.</p>
<p>For even more Ruby one-liners, check out <a href="http://benoithamelin.tumblr.com/post/10945200630/text-processing-1liners-ruby-vs-awk">“Text processing one-liners: Ruby vs. Awk”</a>, and <a href="http://benoithamelin.tumblr.com/ruby1line/">“Ruby one-liners”</a></p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[A knife.rb for our time]]></title>
<link href="http://dougireton.github.io/blog/2013/03/17/a-knife-dot-rb-for-our-time/"/>
<updated>2013-03-17T20:44:00-07:00</updated>
<id>http://dougireton.github.io/blog/2013/03/17/a-knife-dot-rb-for-our-time</id>
<content type="html"><![CDATA[<p>Ohai Chefs!</p>
<p>The basic knife.rb you get from the Chef server works, but it’s not suitable to check into version control or share with your team. It has the name of your .pem file hardcoded into it and isn’t flexible enough for team use. This week we’ll look at a generic, flexible <code>knife.rb</code> you can keep in your <code>chef-repo</code> and share with your team.</p>
<!--more-->
<h2>What you get out of the box</h2>
<p>Here’s the knife.rb you’ll get if you ask the Chef server to generate one for you:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">current_dir</span> <span class="o">=</span> <span class="no">File</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="bp">__FILE__</span><span class="p">)</span>
</span><span class='line'><span class="n">log_level</span> <span class="ss">:info</span>
</span><span class='line'><span class="n">log_location</span> <span class="no">STDOUT</span>
</span><span class='line'><span class="n">node_name</span> <span class="s2">"my_username"</span>
</span><span class='line'><span class="n">client_key</span> <span class="s2">"</span><span class="si">#{</span><span class="n">current_dir</span><span class="si">}</span><span class="s2">/my_username.pem"</span>
</span><span class='line'><span class="n">validation_client_name</span> <span class="s2">"my_org-validator"</span>
</span><span class='line'><span class="n">validation_key</span> <span class="s2">"</span><span class="si">#{</span><span class="n">current_dir</span><span class="si">}</span><span class="s2">/my_org-validator.pem"</span>
</span><span class='line'><span class="n">chef_server_url</span> <span class="s2">"https://chefserver.example.com/organizations/my_org"</span>
</span><span class='line'><span class="n">cache_type</span> <span class="s1">'BasicFile'</span>
</span><span class='line'><span class="n">cache_options</span><span class="p">(</span> <span class="ss">:path</span> <span class="o">=></span> <span class="s2">"</span><span class="si">#{</span><span class="no">ENV</span><span class="o">[</span><span class="s1">'HOME'</span><span class="o">]</span><span class="si">}</span><span class="s2">/.chef/checksums"</span> <span class="p">)</span>
</span><span class='line'><span class="n">cookbook_path</span> <span class="o">[</span><span class="s2">"</span><span class="si">#{</span><span class="n">current_dir</span><span class="si">}</span><span class="s2">/../cookbooks"</span><span class="o">]</span>
</span></code></pre></td></tr></table></div></figure>
<h2>A Better Implementation</h2>
<p>Here’s what we’ve come up with after lots of tinkering. It works on Windows and Mac/Linux. Put this in your <code>chef-repo/.chef/</code> directory and check it into source control.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">current_dir</span> <span class="o">=</span> <span class="no">File</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="bp">__FILE__</span><span class="p">)</span>
</span><span class='line'><span class="n">user_email</span> <span class="o">=</span> <span class="sb">`git config --get user.email`</span>
</span><span class='line'><span class="n">home_dir</span> <span class="o">=</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">'HOME'</span><span class="o">]</span> <span class="o">||</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">'HOMEDRIVE'</span><span class="o">]</span>
</span><span class='line'><span class="n">org</span> <span class="o">=</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">'chef_org'</span><span class="o">]</span> <span class="o">||</span> <span class="s1">'my_org'</span>
</span><span class='line'>
</span><span class='line'><span class="n">knife_override</span> <span class="o">=</span> <span class="s2">"</span><span class="si">#{</span><span class="n">home_dir</span><span class="si">}</span><span class="s2">/.chef/knife_override.rb"</span>
</span><span class='line'>
</span><span class='line'><span class="n">chef_server_url</span> <span class="s2">"https://chefserver.example.com/organizations/</span><span class="si">#{</span><span class="n">org</span><span class="si">}</span><span class="s2">"</span>
</span><span class='line'><span class="n">log_level</span> <span class="ss">:info</span>
</span><span class='line'><span class="n">log_location</span> <span class="no">STDOUT</span>
</span><span class='line'>
</span><span class='line'><span class="c1"># USERNAME is UPPERCASE in Windows, but lowercase in the Chef server,</span>
</span><span class='line'><span class="c1"># so `downcase` it.</span>
</span><span class='line'><span class="n">node_name</span> <span class="p">(</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">'USER'</span><span class="o">]</span> <span class="o">||</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">'USERNAME'</span><span class="o">]</span> <span class="p">)</span><span class="o">.</span><span class="n">downcase</span>
</span><span class='line'><span class="n">client_key</span> <span class="s2">"</span><span class="si">#{</span><span class="n">home_dir</span><span class="si">}</span><span class="s2">/.chef/</span><span class="si">#{</span><span class="n">node_name</span><span class="si">}</span><span class="s2">.pem"</span>
</span><span class='line'><span class="n">cache_type</span> <span class="s1">'BasicFile'</span>
</span><span class='line'><span class="n">cache_options</span><span class="p">(</span> <span class="ss">:path</span> <span class="o">=></span> <span class="s2">"</span><span class="si">#{</span><span class="n">home_dir</span><span class="si">}</span><span class="s2">/.chef/checksums"</span> <span class="p">)</span>
</span><span class='line'>
</span><span class='line'><span class="c1"># We keep our cookbooks in separate repos under a ~/chef/cookbooks dir</span>
</span><span class='line'><span class="n">cookbook_path</span> <span class="o">[</span><span class="s2">"</span><span class="si">#{</span><span class="n">current_dir</span><span class="si">}</span><span class="s2">/../../../cookbooks"</span><span class="o">]</span>
</span><span class='line'><span class="n">cookbook_copyright</span> <span class="s2">"Your Company, Inc."</span>
</span><span class='line'><span class="n">cookbook_license</span> <span class="s2">"none"</span>
</span><span class='line'><span class="n">cookbook_email</span> <span class="s2">"</span><span class="si">#{</span><span class="n">user_email</span><span class="si">}</span><span class="s2">"</span>
</span><span class='line'>
</span><span class='line'><span class="n">http_proxy</span> <span class="s2">"http://webproxy.example.com:80"</span>
</span><span class='line'><span class="n">https_proxy</span> <span class="s2">"http://webproxy.example.com:80"</span>
</span><span class='line'><span class="n">no_proxy</span> <span class="s2">"localhost, 10.*, *.example.com, *.dev.example.com"</span>
</span><span class='line'>
</span><span class='line'><span class="c1"># Allow overriding values in this knife.rb</span>
</span><span class='line'><span class="ss">Chef</span><span class="p">:</span><span class="ss">:Config</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">knife_override</span><span class="p">)</span> <span class="k">if</span> <span class="no">File</span><span class="o">.</span><span class="n">exist?</span><span class="p">(</span><span class="n">knife_override</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>
<h2>The Goods</h2>
<p>Most of this should be self-explanitory, but there are a couple of interesting things to note. We are getting the user’s email from git config on the fly. We use this to set the <code>cookbook_email</code> attribute so it’s automatically populated when you create a new cookbook. On line three, we are getting the Home directory which is <code>HOME</code> on Mac and <code>HOMEDRIVE</code> on Windows. On line four, we are getting the <code>org</code> variable. It will default to <code>my_org</code>, but allows you to override it by setting the <code>chef_org</code> environment variable.</p>
<h2>Knife Override</h2>
<p>On line six, we are setting the path to a <code>knife_override.rb</code> file. We source the file at the end of this <code>knife.rb</code> so you can override any values specified in this <code>knife.rb</code>. So far we’ve never used it, but it seemed like a good idea at the time.</p>
<h2>Client keys</h2>
<p>On line 14 we are setting the <code>node_name</code> which is your Chef server username. On Mac/Linux, your username is stored in the <code>USER</code> env variable. On Windows, it’s <code>USERNAME</code>. Windows usually stores your username in UPPERCASE. We downcase it here since Chef server usernames are lowercase.</p>
<p>On line 15, we are specifying the location of the user’s Chef client key (.pem file). We store it in our home directories since we use the same client key for mulitple orgs.</p>
<h2>Proxies, etc</h2>
<p>The rest of the file is pretty straightforward. We use a proxy server at work, so we specify proxy settings. Finally, we source our <code>knife_override.rb</code> if it exists.</p>
<h2>Wrap Up</h2>
<p>So there you have it. We use this same <code>knife.rb</code> in all our <code>chef-repos</code> and check it into version control. When someone wants to use our repo, they just check it out of Git and they can start using knife immediately. The only other step they have to do is to move their client key (username.pem file) to <code>~/.chef/</code>.</p>
<p>I’d be remiss if I didn’t point out Joshua Timberman’s excellent <a href="https://gist.github.com/jtimberman/1718805">“Commented knife.rb for all the things”</a>. Lot’s of good ideas in there too.</p>
<p>Let me know any cool tricks you’re using in your <code>knife.rb</code>. Thanks and see you next week!</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Flip your unicorn!]]></title>
<link href="http://dougireton.github.io/blog/2013/03/07/flip-your-unicorn/"/>
<updated>2013-03-07T20:47:00-08:00</updated>
<id>http://dougireton.github.io/blog/2013/03/07/flip-your-unicorn</id>
<content type="html"><![CDATA[<p>Let’s say you had a unicorn in your code. Maybe something like this:</p>
<pre>
________
.##@@&&&@@##.
\ ,##@&::%&&%%::&@##.
^\^ #@&:%%000000000%%:&@#
/.((( #@&:%00' '00%:&@#
(,/"(((__,--. #@&:%0' '0%:&@#
\ ) _( /{ #@&:%0 0%:&@#
!|| " :|| #@&:%0 0%:&@#
!|| :|| #@&:%0 0%:&@#
''' ''' "" ' " " ' ""
</pre>
<h2>But it’s so wrong!</h2>
<p>Clearly, something is wrong with the unicorn. It’s not facing the rainbow. This week, we’ll learn how to flip the unicorn (or any other text) with an awesome Vim <a href="http://www.drchip.org/astronaut/vim/index.html#Maps">Visual mode mapping</a> courtesy of the inimitable <a href="http://www.drchip.org/astronaut/vim/index.html">Dr. Chip</a></p>
<!--more-->
<h2>Show me the map!</h2>
<p>Here it is, just don’t ask me to explain it.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'>vno <span class="p"><</span><span class="k">silent</span><span class="p">></span> <span class="p"><</span>Leader<span class="p">></span>fR <span class="k">c</span><span class="p"><</span>C<span class="p">-</span>O<span class="p">></span>:<span class="k">set</span> <span class="k">ri</span> <span class="nb">lz</span><span class="p"><</span><span class="k">cr</span><span class="p">><</span>C<span class="p">-</span>R<span class="p">></span>"<span class="p"><</span>esc<span class="p">></span>:norm<span class="p">!</span> dd`<span class="p"><<</span><span class="k">cr</span><span class="p">></span>:<span class="k">set</span> <span class="k">ri</span><span class="p">!</span> <span class="nb">lz</span><span class="p">!<</span><span class="k">cr</span><span class="p">></span>
</span></code></pre></td></tr></table></div></figure>
<h2>And, here are the results*</h2>
<pre>
/ \
^/^ ^\^
))).\ /.(((
.--,__)))"\,) (,/"(((__,--.
}\ )_ ( / \ ) _( /{
||: " ||! !|| " :||
||: ||! !|| :||
''' ''' ''' '''
</pre>
<p>Well, not exactly. The mapping doesn’t exactly flip text. It won’t turn a <code>)</code> into a <code>(</code>, or a <code>}</code> into a <code>{</code>. It just exchanges or swaps the places of the characters. Still it gets pretty close, much easier than trying to do it by hand. You can then run substitute commands to flip the <code>)</code>, <code>\</code>, and <code>}</code>.</p>
<h2>The Actual Results</h2>
<pre>
\
^\^
(((./
.--,__((("/,(
{/ (_ ) \
||: " ||!
||: ||!
''' '''
</pre>
<h2>Uhhh, ok, why would you want to do this?</h2>
<p>I have no idea, unless you had a unicorn you wanted to flip on a deadline. Thanks to Google and Dr. Chip for this (marginally useful) Vim tip! Until next week, cheers!</p>
<p>For the rest of the mappings which will flip text upside down as well, see <a href="http://www.drchip.org/astronaut/vim/index.html#Maps">Dr. Chip’s maps section</a> on his awesomely 1995 website.</p>
<pre>
________
.##@@&&&@@##.
/ ,##@&::%&&%%::&@##. \
^/^ #@&:%%000000000%%:&@# ^\^
))).\ #@&:%00' '00%:&@# /.(((
.--,__)))"\,) #@&:%0' '0%:&@# (,/"(((__,--.
}\ )_ ( / #@&:%0 0%:&@# \ ) _( /{
||: " ||! #@&:%0 0%:&@# !|| " :||
||: ||! #@&:%0 0%:&@# !|| :||
''' ''' "" ' " " ' "" ''' '''
</pre>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Send application deploy times to StatsD in a Chef recipe]]></title>
<link href="http://dougireton.github.io/blog/2013/03/02/send-application-deploy-times-to-statsd-in-a-chef-recipe/"/>
<updated>2013-03-02T14:48:00-08:00</updated>
<id>http://dougireton.github.io/blog/2013/03/02/send-application-deploy-times-to-statsd-in-a-chef-recipe</id>
<content type="html"><![CDATA[<p>Ohai Chefs!</p>
<p>This week, I’ll show you how to time application deploys (or anything else) inside a Chef recipe and send metrics to <a href="http://codeascraft.etsy.com/2011/02/15/measure-anything-measure-everything/">StatsD</a>.</p>
<p>At work, we’re working to integrate metrics into more and more aspects of our development pipeline. We are already sending Chef run data to Graphite and <a href="http://codeascraft.etsy.com/2011/02/15/measure-anything-measure-everything/">Chef client version metrics</a> to StatsD/Graphite. This past week, I worked on timing our application deploys via the <a href="https://github.com/reinh/statsd">Statsd-Ruby</a> library inside a Chef recipe. Read on to see how easy it is.</p>
<!--more-->
<h2>Deploy Recipe Part One – Require StatsD</h2>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="no">GEM_SERVER</span> <span class="o">=</span> <span class="n">node</span><span class="o">[</span><span class="s1">'gem_server'</span><span class="o">]</span>
</span><span class='line'>
</span><span class='line'><span class="n">chef_gem</span> <span class="s1">'statsd-ruby'</span> <span class="k">do</span>
</span><span class='line'><span class="n">version</span> <span class="s1">'1.2.0'</span>
</span><span class='line'><span class="n">options</span><span class="p">(</span><span class="s2">"--clear-sources --source </span><span class="si">#{</span><span class="no">GEM_SERVER</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="nb">require</span> <span class="s1">'statsd'</span>
</span></code></pre></td></tr></table></div></figure>
<p>We use an internal Gem server, since our servers are behind firewalls without open access to the Internet. The first part of our app deployment recipe just gets the <code>statsd-ruby</code> gem installed and ready.</p>
<h2>Deploy Recipe Part Two – Start the Timer</h2>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">statsd</span> <span class="o">=</span> <span class="no">Statsd</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s1">'mystatsd-server.example.com'</span><span class="p">,</span> <span class="mi">8125</span><span class="p">)</span>
</span><span class='line'>
</span><span class='line'><span class="n">ruby_block</span> <span class="s1">'Start of app deployment'</span> <span class="k">do</span>
</span><span class='line'> <span class="n">block</span> <span class="k">do</span>
</span><span class='line'> <span class="c1"># start the timer</span>
</span><span class='line'> <span class="n">node</span><span class="o">.</span><span class="n">run_state</span><span class="o">[</span><span class="s1">'app_deploy_start'</span><span class="o">]</span> <span class="o">=</span> <span class="no">Time</span><span class="o">.</span><span class="n">now</span>
</span><span class='line'> <span class="ss">Chef</span><span class="p">:</span><span class="ss">:Log</span><span class="o">.</span><span class="n">info</span> <span class="s2">"Starting app deploy at </span><span class="si">#{</span><span class="n">node</span><span class="o">.</span><span class="n">run_state</span><span class="o">[</span><span class="s1">'app_deploy_start'</span><span class="o">]</span><span class="si">}</span><span class="s2">"</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>In this section of our deply recipe, we initialize a new StatsD server variable and save our app deploy start time in a <code>node.run_state</code> variable. I had trouble getting local variables to work for saving the start time for use later so I ended up using Chef’s <code>node.run_state</code> to save the start time. Big thanks to <a href="https://twitter.com/hippiehacker">Chris McClimans</a> for this solution.</p>
<h2>Deploy Recipe Part Three – Send Elapsed Time to StatsD</h2>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="c1"># --------------------------------------------------------------------</span>
</span><span class='line'><span class="c1"># Insert Chef resources here needed to deploy the app to our web sever</span>
</span><span class='line'><span class="c1"># --------------------------------------------------------------------</span>
</span><span class='line'><span class="n">execute</span> <span class="s2">"Deploy the app"</span> <span class="k">do</span>
</span><span class='line'> <span class="c1"># ...</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="n">ruby_block</span> <span class="s2">"End of app deployment"</span> <span class="k">do</span>
</span><span class='line'> <span class="n">block</span> <span class="k">do</span>
</span><span class='line'> <span class="c1"># calculate elapsed time for deployment and send to StatsD</span>
</span><span class='line'> <span class="n">deploy_end</span> <span class="o">=</span> <span class="no">Time</span><span class="o">.</span><span class="n">now</span>
</span><span class='line'> <span class="n">elapsed_time</span> <span class="o">=</span> <span class="n">deploy_end</span> <span class="o">-</span> <span class="n">node</span><span class="o">.</span><span class="n">run_state</span><span class="o">[</span><span class="s1">'app_deploy_start'</span><span class="o">]</span>
</span><span class='line'>
</span><span class='line'> <span class="c1"># Replace "." with underscores in node name so Graphite doesn't create</span>
</span><span class='line'> <span class="c1"># a bucket for each part of the FQDN</span>
</span><span class='line'> <span class="n">node_name_underscores</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">gsub</span><span class="p">(</span><span class="s1">'.'</span><span class="p">,</span> <span class="s1">'_'</span><span class="p">)</span>
</span><span class='line'>
</span><span class='line'> <span class="c1"># Use `statsd-ruby` timing method to send data to StatsD</span>
</span><span class='line'> <span class="n">statsd</span><span class="o">.</span><span class="n">timing</span> <span class="s2">"my_app.</span><span class="si">#{</span><span class="n">node</span><span class="o">.</span><span class="n">chef_environment</span><span class="si">}</span><span class="s2">.</span><span class="si">#{</span><span class="n">node_name_underscores</span><span class="si">}</span><span class="s2">.deploy_time"</span><span class="p">,</span> <span class="n">elapsed_time</span>
</span><span class='line'> <span class="ss">Chef</span><span class="p">:</span><span class="ss">:Log</span><span class="o">.</span><span class="n">info</span> <span class="s2">"App deployment took </span><span class="si">#{</span><span class="n">elapsed_time</span><span class="si">}</span><span class="s2"> seconds."</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>In the final part of our recipe, we do the actual deploy (not shown), then calculate the elapsed time and send to StatsD in a final Ruby block resource. We have to use a <code>ruby_block</code> resource because that will ensure the timing code is run at <a href="http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run">Convege time instead of earlier in Compile time</a>.</p>
<h2>Results</h2>
<div>
<img class="left" src="http://dougireton.github.io/images/app_deploy_times.png" width="800" height="600" title="'App Deploy Times'" >
</div>
<p>As you can see, our app is deploying in roughly 100 seconds. Although we are just starting out with tracking “all the things”, it’s pretty addicting once you get started.</p>
<p>Hopefully you’ve seen this week how easy it is to send metrics to StatsD/Graphite from inside a Chef recipe. I’d love to hear in the comments what kind of stats you are tracking. Thanks for reading.</p>
<p>Finally, I’d be remiss if I didn’t point to the blog post which got us started down the metrics road, Etsy’s <a href="http://codeascraft.etsy.com/2010/12/08/track-every-release/">“Tracking Every Release”</a></p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Lay out your .vimrc like a Boss]]></title>
<link href="http://dougireton.github.io/blog/2013/02/23/layout-your-vimrc-like-a-boss/"/>
<updated>2013-02-23T15:21:00-08:00</updated>
<id>http://dougireton.github.io/blog/2013/02/23/layout-your-vimrc-like-a-boss</id>
<content type="html"><![CDATA[<p>I’ve been using <a href="http://www.vim.org/">Vim</a> for a few years now starting with the excellent <a href="https://github.com/carlhuda/janus">Janus</a> distribution of Vim settings and plugins. As excellent as Janus is though, I really wanted to know each and every setting and plugin for myself. I didn’t want any settings I didn’t understand.</p>
<p>About eight months ago I decided to get serious. I stripped down my .vimrc to about 20 settings I understood and could start using. I put my .vimrc and plugins in a <a href="https://github.com/dougireton/vimfiles">Git repo</a>. I slowly added settings one by one as I learned more about Vim.</p>
<p>If you want to take a similar path, what follows is my recommended way of organizing your .vimrc to keep things organized.</p>
<!--more-->
<h2>Knobs and Dials</h2>
<p>Vim has hundreds if not thousands of settings. It can be overwhelming or exciting, depending on your tolerance for fiddling with “knobs and dials”. For a long time, I was frustrated with most .vimrcs I saw, including my own. They seemed like giant junk drawers of settings.</p>
<h2>The <code>:options</code> command</h2>
<p>Finally, I hit upon a good organizing pattern. If you type <code>:options</code> in Vim’s command mode, you get a giant list of Vim options grouped into related categories, e.g. “moving around, searching and patterns”, “tags”, “displaying text” and so on. These categories make an excellent way of grouping your own .vimrc settings. To get started, I just ran the <code>:options</code> command and copied each section heading in the same order as in the <em>option_window</em>.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
</pre></td><td class='code'><pre><code class='text'><span class='line'> 1 important
</span><span class='line'> 2 moving around, searching and patterns
</span><span class='line'> 3 tags
</span><span class='line'> 4 displaying text
</span><span class='line'> 5 syntax, highlighting and spelling
</span><span class='line'> 6 multiple windows
</span><span class='line'> 7 multiple tab pages
</span><span class='line'> 8 terminal
</span><span class='line'> 9 using the mouse
</span><span class='line'>10 printing
</span><span class='line'>11 messages and info
</span><span class='line'>12 selecting text
</span><span class='line'>13 editing text
</span><span class='line'>14 tabs and indenting
</span><span class='line'>15 folding
</span><span class='line'>16 diff mode
</span><span class='line'>17 mapping
</span><span class='line'>18 reading and writing files
</span><span class='line'>19 the swap file
</span><span class='line'>20 command line editing
</span><span class='line'>21 executing external commands
</span><span class='line'>22 running make and jumping to errors
</span><span class='line'>23 language specific
</span><span class='line'>24 multi-byte characters
</span><span class='line'>25 various
</span></code></pre></td></tr></table></div></figure>
<h2>A snippet from my .vimrc</h2>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="c">" ----------------------------------------------------------------------------</span>
</span><span class='line'><span class="c">" moving around, searching and patterns</span>
</span><span class='line'><span class="c">" ----------------------------------------------------------------------------</span>
</span><span class='line'><span class="k">set</span> <span class="nb">nostartofline</span> <span class="c">" keep cursor in same column for long-range motion cmds</span>
</span><span class='line'><span class="k">set</span> <span class="nb">incsearch</span> <span class="c">" Highlight pattern matches as you type</span>
</span><span class='line'><span class="k">set</span> <span class="nb">ignorecase</span> <span class="c">" ignore case when using a search pattern</span>
</span><span class='line'><span class="k">set</span> <span class="nb">smartcase</span> <span class="c">" override 'ignorecase' when pattern</span>
</span><span class='line'><span class="c"> " has upper case character</span>
</span><span class='line'>
</span><span class='line'><span class="c">" ----------------------------------------------------------------------------</span>
</span><span class='line'><span class="c">" tags</span>
</span><span class='line'><span class="c">" ----------------------------------------------------------------------------</span>