Solving httpd MaxClients and mod_status stuck
Solving httpd MaxClients and mod_status stuck.
This article really demystifies how php sessions should and should not be used. Especially if you are using a lot of AJAX within a page and they all use session, being efficient with closing sessions immediately after you're done is a must.
Kelli Anderson Designs
Came across this via a TED talk. I especially like the paper folding project she made as a holiday card.
DollarShaveClub.com – Our Blades Are F***ing Great – YouTube
Great way to promote a new startup.
Ubuntu 12.04 LTS Beta Is Out
There are supposed to be many changes in the upcoming release of Ubuntu desktop. One notable UI change is HUD (Head-Up Display) where you can type a menu command to get to an application's functionality without navigation through the menu system. It is useful for users who are experienced with an application and know what they want to get to without menu, sub-menu, sub-sub-menu, etc.
I will need to do a VirtualBox install to play around soon.
http://www.pcworld.com/businesscenter/article/251367/ubuntu_linux_1204_oneups_windows_and_mac_shuttleworth_says.html
How To Keep An Android Service Running
How to keep an Android service running? This is kind of a trick question as the best practice is to not keep an Android service running. If you need to have something done continuously by your app via a service, the service should be started by an AlarmManager at a regular interval and kills itself after the task is done. The reason for this is that a long running service on Android is up to the OS to determine priority and in some cases would stop running. By using this methodology, you are treading lightly since the service does not stay in memory.
Here is some sample code.
Service implementation
public class HeartBeat extends Service {
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onStart(Intent i, int startId) {
this.beat.run();
this.stopSelf();
}
public Runnable beat = new Runnable() {
public void run() {
// Do something
}
};
}
The AlarmManager that starts it.
Intent iHeartBeatService = new Intent(this, HeartBeat.class); PendingIntent piHeartBeatService = PendingIntent.getService(this, 0, iHeartBeatService, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(piHeartBeatService); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000, piHeartBeatService);
Now the heartbeat service will start every second and do something and kill itself.
The Current State of Hosting With Dreamhost
I have had a Dreamhost account since 2006 and have various domains hosted on the ridiculous unlimited plan. Back then, their service was very reliable and fairly robust especially compared to some of the other shared hosting services out there. However, over the years their service had definitely degraded culminating to a horrible past few months.
Dreamhost had an unfortunate security breach a few months ago that leaked a bunch of passwords causing a mass reset of passwords. Then their service had been quite unstable with outages lasting a few hours at a time. During the morning of 3/5/2012, many sites were inaccessible along with dreamhost.com being down. They claimed it was caused by a disruption to network connection to one of their data centers.
Over the years, I have moved most of our sites onto cloud server at Rackspace or Amazon AWS. The only sites on Dreamhost are either staging or very low traffic sites that would not be hurt by a few hours of downtime. I will probably keep our Dreamhost account for now, but we just are careful what we decide to put there.
Auto start Sphinx searchd after reboot on Linux
By default, after you install and configure Sphinx, you will find that once your OS restarts, search will not be working. That is because searchd is not setup to auto start. The following will solve that problem.
Create file /etc/init.d/searchd.
sudo vi /etc/init.d/searchd
Copy the following into searchd.
#!/bin/bash
case "${1:-''}" in
'start')
/usr/local/bin/searchd
;;
'stop')
/usr/local/bin/searchd --stop
;;
'restart')
/usr/local/bin/searchd --stop && /usr/local/bin/searchd
;;
*)
echo "Usage: $SELF start|stop|restart"
exit 1
;;
esac
Add execute to the file
sudo chmod -x /etc/init.d/searchd
Register with auto start
sudo update-rc.d searchd defaults
Codeigniter header already sent error using json header
Getting this error when moving from development server to staging server and getting this error.
Severity: Warning --> Cannot modify header information - headers already sent
The error shows up if you are doing all of the following.
1. Change header using
$this->output->set_content_type('application/json');
2. Outputting using echo (which is not recommended by Codeigniter).
3. In php.ini, have output_buffering set very small, like 0.
Solution
There are two solutions to this issue.
1. Increase the output_buffering enough so to buffer your echo. (this is a hack)
2. Recommended solution is to replace echo with CIs built in $this->output->set_output('content') method.
Groupon pump and dump?
Ever since the IPO of Groupon which landed at around $28 the first day, it has been sliding constantly. Today it is around $16. Wondering if the merchant horror stories are catching up with them.
Android making https requests with SSL from GoDaddy – No peer certificate error
Another hair pulling session that all ended well.
Task:
Make a secure call to a server using a httprequest and get the httpresponse for further processing.
Android http request and response:
HttpClient client = new DefaultHttpClient();
HttpGet req = new HttpGet("https://www.example.com");
HttpResponse res = client.execute(req);
Error:
javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
Problem:
The issue is that cert from GoDaddy was installed but not installed completely. An Intermediate cert is required for the server/domain in order to have a fully installed cert.
Reference: