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.

29Nov/110

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.

29Nov/110

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:

http://community.godaddy.com/help/5238

Filed under: android, apache, Coding, ssl No Comments
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.

28Oct/110

Code debt accumulating interest

I get into this trap a little too often. I know there is some code that is not written correctly but for the sake of moving along, I ignore it temporarily with the intention of going back to refactor later on. Of course it is not something that is broken, but just poor convention and naming type of stuff. As I build more on top of that, whatever mess that was there before begins to infiltrate into new code through the use of those classes. If I extend upon them, it opens even a greater can of worms.

A friend had talked about code debt before and it speaks so true to these situations. Code debt will incur interest over time if not paid up. The longer you wait, the more expensive the payoff becomes. So just how I like to be financially debt-free, I should strive for code debt-free also.

Filed under: Coding No Comments
15Jun/110

Citibank web security

Big security hole at Citigroup website

Many may have read about the recent hack into the Citibank's website that leaked 200,000 user account. At first, one would imagine that it must have been a sophisticated job. Well, the news is just out on how the hacker broke in. It is something anyone could have done by just looking at the URL after they have logged into Citibank and replace the account number with another number to gain access to someone else's account. It is pure negligence on the part of Citibank's development team.

I wonder how many people are now looking at their own URLs to determine how much they are revealing.

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.

9Feb/110

A four letter word can ruin your day

halt + Amazon EC2 + Instance Store = A bad day

I did a stupid thing while on vacation. Decided to clone an EC2 server and executed halt from commandline without checking to see if the server was using Instance Store. Whoops, Amazon showed the server as terminating...terminated... ahhhhh.

After having to rebuild the server while on vacation, I have learned a valuable lesson.

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