Monthly Archives: April 2017

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

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 @architv07

Answer by Archit Verma:

  • I am a big football fan. It often happens that there is a live football match but I also have some work to do. So I sit down with my laptop to do the work but end up switching to the browser to check the scores every couple of minutes. To solve the problem, the idea of creating soccer-cli came to me. It's a simple command line app to get live football scores, standings, team scores. It's open source, check it out here architv/soccer-cli
  • A lot of times when I open source my code, I forget to add license to to it. Without a license, all code is copyright the author and may not be used by anyone. So to add license, every time I have to copy the license template and add my name to it. To automate the process I created harvey. It's again a CLI which manages and adds license to your open source project. It's here: architv/harvey
  • I used to participate in a lot of online programming contests(I still do, but not so frequently). These challenges happen on a number of websites like hackerrank, codechef, spoj, hackerearth etc. Every time I had to visit each of the website seperately to check whether there was a programming challenge taking place. To automate the process, I created an open source online programming challenge aggregator Challenge Hunt. Code: ChallengeHunt/challengehunt

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

Leave a comment

Filed under Life

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 @rajani_tanmay

Answer by Tanmay Rajani:

Ah! This is something I do on a regular basis. I always look forward to find a way to automate things which I have to/want to do but are repetitive in nature.

Let’s start with newest first!

  • April 2017: I’ve been addicted to StackOverflow platform lately. I've recently built a Messenger ChatBot that sends unread StackOverflow inbox and reputation changes to you.

    Motivation was to avoid needing to open app / website even now and then (from phone / desktop) to see whether your question got answered or answer got upvoted / accepted or whether someone replied to your question / answer.

    Stackb0t is live at m.me/stackb0t (GitHub repo)

  • March 2017: At work, most of us need to fill timesheets on a regular basis. So, I built a timesheet filler script using a high-level browser automation library called nightmare. Though, script was meant for a particular timesheet webapp only (available on my GitHub tho!)
  • October 2016: I am a movie buff. I watch plenty of movies. But I had to google it (and than IMDb and all) every time I wanted to know about a movie.

    Solution? My first chatbot, Cinephi1e, it suggests movies, provides plot summary.. things like that. It uses a combination of TMDb and The Open Movie Database APIs to interact with you.

    Cinephi1e is live at m.me/cinephi1e (GitHub repo)

  • 2015: I used to follow a daily blog named F***ING HOMEPAGE. They used to post an image of the day which used to blow my mind everyday. So, I used to download the image almost everyday and have it as my desktop wallpaper. But, duh! That’s so boring and damn repetitive, no?

    Solution: Built a NodeJS app that scraps the blog, gets the image of the day and puts it into a Google Drive folder everyday.

    Next, I pointed my wallpaper directory on windows to this drive folder and boom! I had image of the day in my wallpaper rotation 🙂

    Though, my app is currently inactive, but here’s the collection of images it made during those days. And, GitHub repo.

    Also, one of my friends created A windows theme out the images collection.

  • 2014: There was a time, I was so addicted to Quora. I wanted to download some answers on my machine. So, I had built a chrome extension, Download Quora Answers, to have a download button on each answer/blog post we see on Quora.

    One of my friends had made a collection of amazing answers.

Answering again on Quora after long today.. Might have lost my charm 😀

Anyway, good to share my stuff which could be helpful to others.

Peace! 🙂

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

Leave a comment

Filed under Life

Is it time for us to dump the OOP paradigm? If yes, what can replace it?


There are two key goals in designing a programming language: decreasing coupling while increasing cohesion. That is, you're trying to split the problem "at the joints", where the parts that are naturally connected to each other stay connected, while the parts that can be swapped out are connected only at well-defined interfaces.

Answer by Joshua Engel:

There are two key goals in designing a programming language: decreasing coupling while increasing cohesion. That is, you're trying to split the problem "at the joints", where the parts that are naturally connected to each other stay connected, while the parts that can be swapped out are connected only at well-defined interfaces.

The fundamental unit of programming is the function, e.g.:

foo(a,b,c) -> d

A function wraps up some chunk of functionality and assigns it a name. Hopefully, you don't have to peer inside of it: you can deduce as much as possible about it from the name and its signature: "It takes as, bs, and cs, and foos them to make a d". 

What you find with many functions is that the first argument is special. You end up reading it as "You take an a, and you foo it with a b and a c, to make a d".

This is the fundamental concept behind object-oriented programming: you declare that the first argument is special and say, "I'm going to split the world at that joint. I'll even make a special syntax for it":

a.foo(b,c) -> d

If you've split the world correctly, you can find other functions that also have more "a"-ness to them, and put them together. If your language is stateful, you can let these functions unpack that state for each other, which forces them to be tightly coupled but at least controls the scope of that coupling.

Note that what we're talking about here is really psychology rather than computer science. The joint-splitting happens because it's how people naturally perceive the world. The human mind is fundamentally object-oriented, though people don't always realize that their objects and other people's objects aren't always the same ones. There's nearly always more than one way to look at the world, both the natural one and the artificial one that computers created for themselves (windows, file systems, etc.)

And, as the question observes, sometimes you really don't find a natural joint-splitting at all. You end up perceiving it in terms of functions. However, the larger the problem is, the more necessary it will be to find some way to split it. Even if the joints don't correspond to natural divisions of the world, they may correspond to the natural divisions of progammers working on the same project. One may have expertise in back ends, others in computation, others in display. You will still need to follow the properties of coherence and coupling, and object-oriented languages provide you a way to do that based on the natural human metaphor of putting things into boxes and hiding the details from the outside.

There is also mental baggage that comes from that, which is why small, one-shot programs tend to find the object-oriented paradigm cumbersome. Object-oriented paradigms tend to assume (without even realizing it) a natural flow-of-control, which can interfere when you try to adapt it to some other control mechanism (which is becoming increasingly common, as frameworks demand that you adhere to their flow of control rather than a library which follows your flow of control.)

I don't think OOP is going away any time soon. A more prominent trend, I believe, is going to be for transactionalism to begin to take center-stage. I'd like to see the distinction between short-term and long-term memory smudged (eliminating the embarrassing impedance mismatch problem of talking to long-term storage in a different language from your in-memory processing).

Is it time for us to dump the OOP paradigm? If yes, what can replace it?

Leave a comment

Filed under Life