Types supported by Rails Active Record

I’m always looking for those somewhere on web when I need them. Now I’m posting them here so I will always have them handy. If you need them then you can use this as a reference. Below is a list of supported types with its MySQL representation.

  • :primary_key – int(11) DEFAULT NULL auto_increment PRIMARY KEY
  • :stringvarchar(255)
  • :text – text
  • :integer – int limit 4
  • :float – float
  • :decimal – decimal
  • :datetime – datetime
  • :timestamp – datetime
  • :time – time
  • :date – date
  • :binary – blob
  • :boolean – tinyint(1)

It can also be found in this constant in ActiveRecord ConnectionAdapters MysqlAdapter

ActiveRecord::ConnectionAdapters::MysqlAdapter.NATIVE_DATABASE_TYPES

I think that all the other type mappings could be found in appropriate ActiveRecord Connection adapters.

Cheers, Gregster

WordPress page load time tweaks ended in … failure

Why was I trying to speed it up on a first place. Well, some of you might be aware of the fact that me and my Family moved to Sydney. We will be here until May. My blog and my hosting is in UK. Broadband in Oz is far below random average back in UK. I was never bothered to check my own blog for response time as it was always good. Trying to load my blog main page I was shocked waiting for few minutes for it to appear on a screen.

The beginning and general enthusiasm

What I did is a little analysis on a page with Firefox and YSlow. It turned out that a lot of time takes for JavaScript files to load. About 8 files that are not too big but for some bizarre reason takes ages. YSlow suggested to combine them into one file and compress.

That’s fine. Sounds like a plan. Grab all the JS files combine them into one and then compress. Turned out more complicated than one would think.

There was no JavaScript that comes with bare WordPress to compress and combine with other files. The JavaScript that I got on my blog was the one from additional plugins I have installed.

After a quick googling I found out that there is a WordPress plugin for JavaScript compression. It is called WP_JS. It works quite sweet, whenever you got a JS file and you need to add it to your post all you do you put this line:

<script src="<?php wp_js('path/to/js/file.js'); ?>"type="text/javascript"></script>

The problem with this one is that it will only work for a files from within your current theme folder.

JS files I would like to compress into one file are those inside plugins. Seems like WP JS doesn’t have access to that. Oh well, first hack then. Copy all the files to one folder that would be accessible to JavaScript compression plugin.

imageWhen I finished I had to go trough all the plugins and comment out the JavaScript imports. Finished with this task I moved to getting all the JS files in a header as one compressed file. So in other hands all the plugin JavaScripts would be compressed and loaded in one file.

When I done that it turned out that there are JavaScript errors on a page. Some plugins are spitting more to a HTML then just a JavaScript imports and they depend on a stuff inside those imports. In other words, one big mess. Impossible to decouple and extract as one file.

Good idea

It would be absolutely awesome if I could apply some sort of a filter for a HTML content before it is being spit out to a browser, grab all the JS imports, create one big JS on a flight, compress it and then send to a browser.

With a knowledge I got about WordPress it seems impossible at the moment.

Failure and what I ended up with

So I ended with disabling plugins. There is only few enabled with very little JavaScript.

Last final solution is to redo the plugins so the JavaScript they are using will be suitable for a single file compression.

I don’t have time for that, so … no plugins instead 🙂

Take care, Gregster

Ps. I’m not going to try to achieve anything similar with CSS :-

Difficult art of software design

image When I’m drawing a picture or just taking it with digital camera all I think is how good the picture will look like, how to compose it. If people I show it to will like it or not. When I design software it is a little bit different. It’s even more difficult when client needs something for his special purpose, customized etc. and also would like it to be flexible enough to resell it as a product.

When I take the approach of sticking to all the special needs that client has towards the product it could make it to complicated to customize for anyone else, even impossible to do so. If I take the road of making everything so flexible to accommodate everything client needs and also being ready to resell in a future, design could go crazy and I’m not event saying how long could development take (as I don’t know, but it would be much more then simple way).

So, compromise, meet somewhere in the middle. But how? Design flexible but don’t go crazy. Get ready for a lots of changes and client conversations. Communications is absolutely must have. Iterative development, testing and customer feedback. Don’t come up with 1000 pages design in front. Create some prototype and show it to the client.

If you are religious, pray, if you are not, learn how to be more patient. If this still doesn’t work for you and you end up being stressed like never before, make a career adjustment and switch to work in a library 🙂

Greg

How Google can help you kick start your project

greg If you are starting a project or a business and you don’t have too much money, this could be a good read for you 🙂

We are starting a new project. We have created a team of few guys. Each of us is  located in different city/country/continent. As with many projects and with kick starts not having to much money means that we can’t really rent an office where anyone can come to or spend a lot on cool software.

The obvious decision is to do all the stuff remotely. We still need software for knowledge sharing, meetings, etc. Skype can help us with conferences calls. What about email, calendar, documents and so on.

The obvious answer was, go for some free open source tools. But, for email, calendar, wiki, etc. we will need to host it somewhere. It also needs to be globally accessible and reliable. Seems like Google has some answers to all of that 🙂

 

image 

GMail

Possibly the best web based mail in the world. Quick and with huge storage. I don’t think I would have to delete my emails ever 🙂 It also has Google search integrated. I don’t have to organize it to much, I can always search for what I’m looking for. It also comes with integrated chat.

Google Talk

Integrated with GMail or works as a standalone client. Quick and simple chat, great for office communication.

Google Documents

This is absolutely awesome idea. Create, view and share documents with whoever you would like to. It reads and creates MS Office Word documents, Excel Spreadsheets and Power Point presentations. You can also view Adobe PDF files. There is also a facility to organize them in folders.

Google Calendar

Organize meetings, put dates of all the important events, etc. and then share them with all your fellows team mates. Calendar sends a reminders to your GMail account.

Google Sites

WIKI like service. You can define and invite its administrators and contributors. It integrates with Calendar so you can put some events on it. It integrates with other Google services like Images and YouTube videos.

Google Code

Useful for Software projects but only available with one of the Open Source licence.

Other stuff

There are also other services potentially useful for the start. Blogger, Reader, Maps, Groups, Picasa, Translate.

All the services might be useful for sharing and searching through a huge amount of information that Internet contains.

So, we are starting something. Not having to much money but having Internet access we can use Google. Its there and it always will. Reliable, simple and fun to use. Go ahead and give it a try if you haven’t yet 😉

Greg