Archive

Archive for the ‘Ruby’ Category

Automatic syntax checking for your puppet manifests

October 23rd, 2010 Ahmed El Gamil 2 comments

So i write a lot of puppet code these days to automate infrastructure stuff that i do, and it came to me that every time i have to make an addition/change to my puppet code i always run syntax checking with the “puppet apply” command, so why not automate this procedure and use the beautiful Growl notifications on my Mac in order to get instant desktop notification with the output of puppet manifests syntax checking ;-)

Introducing Puppet-growl


  • Puppet-growl is a ruby script that watches if there is any changes to your puppet manifests (by monitoring .pp files) and sends notifications to your desktop if the puppet manifest you just created/edited passes the syntax checks or not.
  • It aims to facilitate the development of puppet code by sending instant notifications to your OS X desktop.
  • puppet-growl uses eventmachine, em-dir-watcher and ruby-growl

For installation/configuration, please visit the puppet-growl on github: http://github.com/AhmedElGamil/puppet-growl

I would love to see someone hack the script to add libnotify support for the Linux desktop.

Thanks for Mohammed Safwat and Karim Allah Ahmed for hacking around the code with me.

http://growl.info/

Auto-completion in Ruby IRB

February 5th, 2009 Ahmed El Gamil 4 comments

الحمد لله و كفى وصلاة و سلاماً على عباده الذين اصطفى ثم أما بعد..

فبينما أقوم بتجربة لغة البرمجة Ruby كلغة بديلة لل Bash Scripting للقيام ببعض أعمال اداره نظم التشغيل (System Administration) (والتى تبين لى انها قوية جداً فى هذا المجال و يبدو أنى سأستخدمها من الان فصاعداً), اذ تعرضت لل Interactive Ruby او ما يسمى أختصاراً  Irb و هو عبارة عن نوع من ال Shells و لكنه للتعامل مع لغة Ruby نفسها لتجربة بعض الطرق البرمجية قبل استخدامها فعلياً فى برامجك..

المشكلة التى قابلتنى هى انى وجدت Irb لا يقوم بعملية الاكمال التلقائى (Auto completion) لل Class & Methods و هذا شىء صعب للغاية على مدمن Shells مثلى ! :-D

و بعد البحث عن الموضوع مع العملاق جوجل وجدت انه يجب عليك ان تقوم بضبط بعض الخواص فى ملف ال Configuration الخاص ب Irb و الذى يوجد فى مجلد ال Home بأسم irbrc. حتى يكون الملف كالاتى

IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_READLINE] = true
IRB.conf[:LOAD_MODULES] = []  unless IRB.conf.key?(:LOAD_MODULES)
unless IRB.conf[:LOAD_MODULES].include?('irb/completion')
  IRB.conf[:LOAD_MODULES] << 'irb/completion'
end

و هكذا ترى النتيجة بعد الانتهاء من هذا التعديل البسيط  8-)

irb

سبحانك الله و بحمدك..أشهد ان لا اله إلا أنت..أستغفرك و أتوب إليك