As a programmer, what tasks have you automated to make your everyday life easier?

As a programmer, what tasks have you automated to make your everyday life easier? by @ohmyroots

Answer by Sandeep Uppuluri:

Ruby and Python are really fun programming languages for this kind of stuff.

Here is a rather crude birthday bot that i wrote in like 10 minutes that wishes your facebook friends on their birthday.

require 'watir-webdriver'
@config = {
	url: 'http://www.facebook.com', 
	birthday: '/events/birthdays',
	day: 86400,
	wish: 'Wish you a very happy birthday! :)'
}
@account = {
	username: '', 
	password: ''
}

@locator = {
	email_id: 'email',
	password_id: 'pass',
	login_value: 'Log In'
}

while true
	@b=Watir::Browser.new :phantomjs
	@b.driver.manage.window.maximize
	@b.goto(@config[:url])
	@b.text_field(:id => @locator[:email_id]).set @account[:username]
	@b.text_field(:id => @locator[:password_id]).set @account[:password]
	@b.button(:value => @locator[:login_value]).click
	@b.goto(@config[:url] + @config[:birthday])
	birthdays = @b.textareas
	birthdays.each do |birthday|
		birthday.set @config[:wish]
		@b.send_keys :enter
	end
	@b.close
	sleep @config[:day]
end

UPDATE:

How do you use it?

If you are using mac, you will already have ruby installed on your machine. Considering you also have homebrew on your machine, you should do the following steps in your terminal

$ gem install watir-webdriver 
$ brew install phantomjs
$ ruby birthday.rb &

The bot keeps running wishing everyday until you kill it

If you are using windows, install below for ruby and phantomjs

Run the follow commands in command prompt

$ gem install watir-webdriver
ruby birthday.rb &

If you are using debian based linux system

1. Install phantomjs following this link How to install PhantomJS on Debian/Ubuntu (How to install PhantomJS on Debian/Ubuntu

2. Install ruby

$ \curl -L https://get.rvm.io | bash -s stable --ruby

3. Then $ gem install watir-webdriver

4. Switch on the bot $ ruby birthday.rb


The bot keeps running wishing everyday until you kill it

As a programmer, what tasks have you automated to make your everyday life easier?

Advertisements

Leave a comment

Filed under Life

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s