## Posts

Showing posts from October, 2010

### Create a Twitter ReTweet Bot

Personally, I needed a Twitter RT bot that can be used to collect various Tweets around a keyword or a hashtag.

Just simply coded using PHP, MySQL and abraham's twitteroauth.

The program flow is:

1) Get the search results,
2) and retweet a tweet if it is not retweeted yet.

It runs as a cronjob.

See the below code:
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,$key, $secret);$response = $connection->get('search', array('q'=>'#hashtag OR "some keyword"')); foreach ($response as $status) { for($i=0; $i < count($status); $i++) {$tweetid = $status[$i]; $result = mysql_fetch_array(mysql_query("select tid from tweets where tid = ".$tweetid.";")); if(empty($result['tid'])) { mysql_query("insert into tweets (tid) values (".$tweetid.");"); $connection->post('statuses/retweet/'.$tweetid); } } }

Apache Hama 0.2.0 RC1 is now available. Try it out and give us feedback. Submit bug reports to our JIRA bug tracker.

Hama ArchitectureGetting Started with HamaSerialize Printing Of "Hello BSP"BSP based Pi Estimator

### Apache Hama: BSP based Pi Estimator

Pi Estimator

The value of PI can be calculated in a number of ways. Consider the following method of estimating PI

Inscribe a circle in a squareRandomly generate points in the squareDetermine the number of points in the square that are also in the circleLet r be the number of points in the circle divided by the number of points in the squarePI ~ 4 r
Serial pseudo code for this procedure as below:
iterations = 10000 circle_count = 0 do j = 1,iterations generate 2 random numbers between 0 and 1 xcoordinate = random1 ycoordinate = random2 if (xcoordinate, ycoordinate) inside circle then circle_count = circle_count + 1 end do PI = 4.0*circle_count/iterations
The BSP implementation for Pi

A distributed strategy in HAMA with BSP programming model, is break the loop into portions that can be executed by the tasks.

Each task executes locally its portion of the loop a number of times.One task acts as master and collects the results through the BSP communication interface.
public class …