Tech Blog Using technology to help your business

5Dec/110

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.

1Nov/110

Codeigniter running into some major growth issues

I have been using Codeigniter for a while on many projects and it had been very useful as it is non-intrusive. Its very small footprint also allows for the extremely good performance on page loads. However, these projects were simply using just the CI core and not implementing any plugins. Some base classes have been extended, but purely specifically for the individual project so not causing any conflict with other code.

Recently, I started building a startup project using CI and would like to employ more plugins do speed up development. Pleasantly surprised, I found that CI had implemented Sparks for searching and installing plugins to CI. Great right! So I implemented an ORM called DataMapper and it was brilliant.

Here comes the reality check. After upgrading from CI 2.0.2 to 2.0.3, everything broke. Why? Because CI changed a lot of methods within its core classes from public to protected. That of course is not actually a bad thing as it was in fact incorrectly implemented before allowing a developer to mess with core functionality too much. However, through researching into these issues, I came to a huge realization that I missed about CI before. CI only allows plugins and developers to modify core classes by extending them into MY_core_class.php. If multiple plugins need to extended the same class, even if they need to overload different methods, it requires some code merging by the developer. If the plugins need to overload the same method in the same core class, that becomes a huge undertaking for the developer to understand what each plugin is trying to do and write merged code that works for both in the same overloaded method.

After that realization, I have determined that CI is fine for applications that are going to use mainly the core classes. If you intend to implement plugins, be very careful understanding what core classes each one will extend. Choose wisely. If those requirements cannot be met, look for another framework.

5Apr/113

Replacing OpenGeo Suites on Windows with GeoServer on Linux

After our initial installation of OpenGeo Suites for WMS service on Windows, we encountered some stability issues that could not be resolved. We could have hired some high priced consultants to debug the issue but we opted for a lighter weight infrastructure.

Our initial system specs:

  • Windows Server 2008
  • 4GB ram
  • Quad core
  • Open Geo Suites running as Windows application

Our slim and fast system specs:

  • Ubuntu 10.04
  • 512MB ram
  • Quad core
  • GeoServer running as java process

So far so good. All layers are loading super fast. We will see how the stability issue is resolved. At least we are using a lot few resources now which makes scaling out to a cluster of GeoServers much more affordable.

11Mar/110

Running stored procedures on MSSQL via any language on Linux

If you need to run store procedures on Microsoft SQL Server on perl, php, ruby, etc., you need to configure /etc/freetds/freetds.conf with the server connection information. Specifically, specify the tds version to be 8.0. Something like the following.

/etc/freetds/freetds.conf

[Server80]
host = domain.com
port = 1433
tds version = 8.0

Connection to the server via php would look like this.

$link = mssql_connect("Server80", "user", "pass");

3Mar/110

Scaling down from MS to open source

We just moved a service that was running on the Microsoft stack (Windows Server 2008, .NET, MSSql Server, IIS) to an open source stack (Ubuntu Server, php, Codeigniter framework, apache2, postgres).

We now run the service on a cloud server with dual cpu and 256MB ram (Yes, that's megabytes).

The old server ran on dual core with 2GB of ram.

5Aug/101

sendmail[2525]: My unqualified host name (servername) unknown

If you see these messages in your syslog, your sendmail is not configured correctly with the domain name. If you are sending from a fully qualified domain, add it to the local-host-names file. In Ubuntu, it would be /etc/mail/local-host-names. Make sure it reads something like this.

localhost
[domain.com]
[server name]

Now in the /etc/hosts, make sure it reads the following.

127.0.0.1 [domain.com] [server name] localhost
...

Then

sudo /etc/init.d/sendmail restart

and the error should not continue filling the syslog.

22Jul/101

A beautiful plugin that creates eye pleasing social media links. This is a great example of using javascript and css to achieve aesthetics.

Filed under: design, Open Source 1 Comment
15Apr/102

Changing Mysql data directory require change to AppArmor

After a bit of googling and hair-pulling, I realized that if I just changed the datadir directive in my.cnf will cause mysql start to fail on Ubuntu. The other thing is to add permissions to apparmor for mysql to access the new data directories.

Steps
1. sudo vi /etc/apparmor.d/usr.sbin.mysqld
2. Add
/newdir/ r,
/newdir/** rwk,
3. sudo /etc/init.d/apparmor restart
4. sudo /etc/init.d/mysql restart

If that still does not work, check the nix permissions to be sure mysql is owner and group for the new directory recursively.
chown -R mysql:mysql “new datadir path”

8Dec/090

Ubuntu 9.10 Karmic slow Firefox

There is a bug in the IPv6 lookup in Karmic that is making any application requesting IPv6 while a NAT is not configured to respond to IPv6 respond very slowly. It is still a bug not solved at this time. Buta solution for Firefox is given here as a work around for now.

2Oct/090

Sphinx Search default limit is 20

When using the sphinx api, you must use SetLimts if you want more than 20 records.  Currently, it is not documented on the sphinx api doc.

Plugin from the creators of Brindes Personalizados :: More at Pazzani Technologies