Happened to see Cuba Gooding Jr’s first tweet about 30 minutes or so after he created it.
Update: @cubagoodingjr is no longer active so not getting tweets from it any longer
At the time his profile said he had 559 followers. A few minutes later I refreshed his profile and saw the follower count had increased to 590 and every few minutes it kept increasing. By the end of the day he had about 4,000 followers.
I thought it would be interesting to track how his follower count changed going forward. So I used the Twitter API to get his follower count once per day, save the data, and then created a web page to visualize his follower count per day.
After 2 days Cuba had about 7,000 followers which averaged out to about 175 new followers per hour. However, the number of new followers slowed down quickly to 30 or so new followers per day and after about 3 months he only gets about 10 new followers per day. In fact, some days, he has net loss of followers, eg more people unfollow than him, than new follows on that day.
For the technically inclined, I setup an automatic retrieval of Cuba’s Tweets using Twitter’s API and the Tweepy Python module scheduled to run daily using a cron job.
The follower counts get put into a database. I created a PHP web page application to retrieve the data from the database, and create a web page that includes the Google Charts API to create a simple line chart to show Cuba’s regularly updated follower count by day.
You can get the cron job and PHP web page code from my Github repository.
If you want to run this code yourself you will need a Twitter developer account and an OAuth file.
Say you have a series of websites that are the same with the exception of city, topic, etc. It could be a real estate listing of different countries and you want a separate website for each or maybe different sites for different brands, product categories, client, etc. You could create subdomains or parameterized filtering in a single website on single domain, but what if you wanted to keep sites separate?
You could just use one CakePHP application and one MySQL datababse to serve websites for multiple domains.
All domains have to be hosted on shared hosting. Shared hosting has to allow pointing multiple domains to one subdomain directory. I’ve done it with Webfaction shared web hosting.
Put the CakePHP application files into the shared subdomain directory connect that application to the single MySQL database, which should have all the data for every website.
Create your CakePHP application as normal but add the following things so that you can filter database records specific to each website/domain being served/requested:
- A table called domain (or whatever you want with as many columns as you need) that will hold domain specific values that are retrieved to be used in in application. But at a minimum it should have the each site’s domain so you can do a lookup to match it to the domain being requested.
- Add domain table foreign key (domain_id) to other tables so that they can be filtered by domain when retrieving data. (This means likely you will require additional steps to ensure that the foreign key is written to your tables. How you do that is up to you but for example if you allow users to create accounts or post comments then you can simply record the domain_id (for example you CakePHP Configure::read value when new user or comment is added.)
- Add a getDomainSettings function to AppController and call it in AppController beforeFilter. This getDomainSettings function will read domain name from current site visitor and use it as parameter to filter database records to just that domain’s values. You can get these into application many different ways but it is nice and easy to use CakePHP Configure::write variables that can be used elsewhere in application.
- As required, add conditions when retrieving model data using CakePHP Configure:write in other controllers’ to retrieve only records for the current domain and modify view presentation.
The alternative to this is maintaining 6 separate CakePHP applications and MySQL databases. So this is a nice clean and easy solution.
Lots of potential here, you could also swap out css styles or CakePHP themes based on domain and make sites totally different.
Code is on Github: