Agile Zone is brought to you in partnership with:
DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
  • submit to reddit
Whitney Baker06/29/14
0 replies

The Best of the Week (June 20): Agile Zone

Make sure you didn't miss anything with this list of the Best of the Week in the Agile Zone (June 20 to June 27). This week's topics include software development terminology, lean startup tools, sprints, estimates and dealing with kids.

John Ferguson Smart06/28/14
0 replies

It's Testing, Jim, But Not As We Know It

Behaviour Driven Development is an increasingly popular Agile development practice that turns testing on its head.

Johannes Brodwall06/28/14
20 replies

Pair programming with Sankalpa

One of my favorite ways to develop software is to do it together with others. Pair programming has always been a motivating and fun activity for me, but some pairings work better than others.

A. Jesse Jiryu Davis06/27/14
0 replies

Write An Excellent Programming Blog

I want you to write. Not just code. Also words. If you're a member of the open source community, you can help us by writing about programming, just as much as by actually programming. And writing helps you, too: you can become better known and promote your ideas. Even more importantly, writing is thinking. There is no more thorough way to understand than to explain in writing.

Erich Styger06/27/14
0 replies

Slow 32 kHz Oscillator Startup

In an IoT project I'm using the Freescale KL15Z microcontroller. It worked very well, but some system failed: they need to quickly check sensor signals after power-up. So I instrumented the application to toggle an LED so I can monitor what happens: It was over 400 ms after power-on! Yikes!

Swizec Teller06/27/14
0 replies

My New Favourite JavaScript Trick

Using returns and callbacks in the same function. Sounds like crazy talk I know, but hear me out, I have good reason. I think.

#!/usr/bin/env ruby
# Author : Emad Elsaid (
require 'open-uri'
require 'digest'

SAVE_TO = '/home/eelsaid/Desktop/gravatar/'

# read emails from source
emails = open(EMAIL_LIST).read.lines

# iterate over all emails, get the gravatar image
# and save it locally with the email as file name
# but i convert the @ character to a dot .
emails.each do | email |
  gravatar_id = Digest::MD5::hexdigest(email.strip.downcase)
  gravatar_url = "{gravatar_id}"
  image_data = open(gravatar_url).read
  file_name = email.strip.downcase.gsub '@', '.'
  File.write "#{SAVE_TO}#{file_name}", image_data
#!/usr/bin/env ruby
# Author : Emad Elsaid (

require 'gtk2' # gem install gtk2

# lets define some constants we need
WORKING_HOURS = 8 # hours
ALERT = "Your working hours have been ended,\n go out and enjoy your life."

# we'll inherit the Gtk window
# and make our custom behaviour inside it
class WorkEndWindow < Gtk::Window

  # set some window properties
  # and insert a label with the desired text
  # then link the window destroy event with a
  # method to exit the application
  def initialize

    self.title = ':D'
    self.border_width = 20
    self.window_position = Gtk::Window::POS_CENTER_ALWAYS

    add ALERT
    signal_connect("destroy") { Gtk.main_quit }

# this will wait for you to finish work and 
# then pops up the amazing window that will
# tell you to go home ^_^ 
# it will create a window then start 
# the Gtk main loop
#!/usr/bin/env ruby
# Author : Emad Elsaid (
def swap_methods(from_obj, from_method, to_obj, to_method)
  from_alias  = "#{from_method}_#{rand 1000}"
  to_alias    = "#{to_method}_#{rand 1000}"

  # alias methods in both objects
  from_obj.class.class_eval do
    alias_method from_alias, from_method

  to_obj.class.class_eval do
    alias_method to_alias, to_method

  # override methods and call aliases in both direction
  from_obj.define_singleton_method(from_method) do |*params, &block|
    to_obj.send(to_alias, *params, &block)

  to_obj.define_singleton_method(to_method) do |*params, &block|
    from_obj.send(from_alias, *params, &block)


# calling swap between two methods on two objects
# should swap them, so if you call obj1.method1 
# will execute obj2.method2 and vice versa
obj1 = "this is my first string object"
obj2 = "this is my second string object"
swap_methods obj1, :to_s, obj2, :to_s

# this should print the second string
puts obj1.to_s
#  and this should print the first one
puts obj2.to_s

# swapping String new method with
# other class new method, so whenever
# you create a new String an instance of
# the other class
class X
  attr_accessor :value
  def initialize(value)
    @value = value
swap_methods String, :new, X, :new
x_instance = "Heeeey"
puts x_instance.class

# this code will output the following lines:
# this is my second string object
# this is my first string object
# X
# it normally should be :
# this is my frist string object
# this is my second string object
# String
#!/usr/bin/env ruby
# Author : Emad Elsaid (
# this script will get your followers count
# across socsial media, i get the user profile
# page and use Regex to grab the followers number
require 'open-uri'

# Getting github followers
def github( username )
  page = open("{username}").read
  followers = page.scan(/<.+>([0-9]+)<.+>[[:space:]]+followers/i).flatten.first
  puts "Github : #{followers} Followers"

# get twitter followers by twitter handle
def twitter( username )
  page = open("{username}").read
  followers = page.scan(/followers<.+>[[:space:]]+<.+>([0-9]+)<.+>/i).flatten.first
  puts "Twitter : #{followers} Followers"

# use them to print your followers
# using github username and
# twitter handle
github 'blazeeboy'
twitter 'blaz_boy'
#!/usr/bin/env ruby
# Author : Emad Elsaid (

require 'sinatra' # gem install sinatra

# specify port and environment as production
# to allow external access to server
set :port, 3000
set :environment, :production
# your media library path
MEDIA_PATH = '/Volumes/Data/Songs'

# get all mp3 files in my media library and sort
# then by file name
mp3s = Dir.glob("#{MEDIA_PATH}/**/*.mp3")
data = do |mp3|
    path: mp3,
    filename: File.basename(mp3, '.mp3')

# render the index page as set if files names
# and a player beside it, player will sent file index in data variable
# and another path will read file to stream it
get '/' do
  media_partial = do |d, i| 
    '<audio src="/play/'+i.to_s+'" controls preload="none"></audio> '+
    '<a href="/play/'+i.to_s+'">'+d[:filename]+'</a>'
  end.join '</br>'
<!DOCTYPE html>
        font: 14px Tahoma;
        line-height: 150%;
    <title>Shared Media Center</title>
    #{data.size} Media files found.

# this path will catch any url starts with "play"
# and will stream media to user, so when
# user hit the play button it'll start playing
# the mp3 file
get '/play/:id' do
  send_file data[params[:id].to_i][:path]
#!/usr/bin/env ruby
# Author : Emad Elsaid (
# autochanging wallpaper from reddit images
# you have to point the script to your existing
# file you set it as a wallpaper and it will override
# it with a new image every 5 minutes.
# this script works on centos 6 with GNOME/GTK2 interface
require 'open-uri' # we'll need to download image with that
require 'ruby_reddit_api' # gem install ruby_reddit_api

# class will be initialized with
# a subreddit to monitor and a 
# destination file to write the
# downloaded image to it
class RedditWallpaper

  def initialize( subreddit, destination_file = 'bg.jpg' )
    @subreddit = subreddit
    @path = destination_file
    @downloaded = []
    @not_downloaded = []

  # download the url to destination
  def download( url )
    image = open( "#{url}.jpg" ).read
    File.write  @path, image

  # update wallpaper and update images cache
  def update
    # make me a reddit client please
    r =

    # update earth
    posts = r.browse @subreddit
    posts.each do |r|
      @not_downloaded << r.url if r.url.include?('imgur') and !@downloaded.include?(r.url)

    image = @not_downloaded.shift
    download image



# i'll get images from earthporn
# they have lots of great images of
# nature places
# and then i'll update it every 5 minutes
downloader = 'earthPorn', '/home/eelsaid/Pictures/bg.jpg'
loop do
  sleep 5*60 # wait for 5 minutes

Benjamin Ball06/26/14
0 replies

Google I/O 2014: Android Meets the Internet of Things with Android Wear, Android Auto, and Google Fit

There was lots of exciting material to be covered during the Google I/O 2014 keynote from San Francisco. But for me, the news I was waiting for centered about Google finally showing off a bit more about Android Wear, and potentially releasing an opponent for Apple's Homekit in the home automation realm.

Mehdi Daoudi06/26/14
0 replies

Understanding the Anatomy of a Wireless Connection

Consider your smartphone, the wireless infrastructure it relies on, and the websites it surfs. These parts must work together; and if we understand the reasoning for their designs and functions, and the resulting latencies, it may help us improve mobile experience and better address the growing trend of mobile internet usage.

Ricky Yim06/26/14
0 replies

Baby steps with Protractor and AngularJS

Protractor is an emerging E2E (end to end) testing framework in the AngularJS world. This article shows you how to run your very first test in Protractor.

Ariya Hidayat06/26/14
0 replies

The Curious Case of JavaScript NaN

NaN, not a number, is a special value used to denote an unrepresentable value. With JavaScript, NaN can cause some confusion, starting from its typeof and all to the way the comparison is handled.

Gil Zilberfeld06/26/14
0 replies

More #NoEstimates

There’s a problem with the assumption that we can “know” stuff. We can’t know stuff about the future. Guessing, or estimating, as we call it is the current alternative. To improve, we can at most try to forecast.

Bozhidar Bozhanov06/26/14
3 replies

How to Handle Incompetence

We’ve all had incompetent colleagues. People that tend to write bad code, make bad decisions or just can’t understand some of the concepts in the project(s). And it’s never trivial to handle this scenario.

Mike Bushong06/26/14
0 replies

Changing the way we configure and provision our networks

It is mostly accepted that configuration deals with the deployment of devices and applications within an infrastructure.

Whitney Baker06/25/14
0 replies

Is Your Organization Ready for Agile?

In the latest of a series of posts examining Agile adoption in organizations and businesses, blogger Suzanne Miller takes a look at specific Agile practices and how they can be evaluated. She mostly talks about governmental organizations, but the evaluations are valuable for all organizations.