Archive for the ‘Uncategorized’ Category

Exceptions vs method missing in Ruby and Rails

After some looking around here is what i found and thought others would find useful as well
Exceptions in general are really slow in ruby and should be thought of as exceptional. method_missing is not an exception but is actually a kernel method of ruby. When you invoke a method on ruby the runtime will search the entire class and module heirarchhy all the way to object, class and module and then as a last case call method_missing. Its more like it just calls this method and you can override this method at anypoint in the chain. Its definitely slower than calling a method that does exist because it has to search up the heirarchy but it is definitely faster than exceptions.
Here are some other posts that i found useful during my review of this area:

WordPress and Ubuntu 64bit and zlib extension

I looked all over the web and found some links to this but it was not easy to find so i thought i would write a little article about it.

You will see this error:

Abort class-pclzip.php : Missing zlib extensions

This is because in the file class-pclzip which is in your wordpress directory

at ${wordpress_root}/wp-admin/include

wordpress looks for gzopen and now in php that is called gzopen64 so just find all occurances of gzopen and replace it with gzopen64.

Now you can install plugins and themes again. Good luck and hope this helps others.

dynamic content in a webos command menu

As i have been doing more webos app development, i thought i would just keep little snippets of things i learned as i was developing. One thing that i really wanted to do was to have a spinner in as a button in the command menu (aka the button bar at the bottom). First you need the code to setup the commandMenu. This is called in the setup method of your assistant. In this case, i have a menu with a new button on the left and 2 buttons on the right and a spinner in the last spot (aka the dynamic content).

this.cmdMenuModel = { items: [
	{
		items: [{label: $L('New'), icon: 'new', command: 'new'}]
	},
	{},
	{
		items: [
		{label: $L('undo'), icon: 'refresh', command: 'undo'},
		{label: $L('search'), icon: 'search', command: 'search'},
		{example: 'A', template: 'common/spinner'}]
	}]
};
this.controller.setupWidget(Mojo.Menu.commandMenu, undefined, this.cmdMenuModel);

this.controller.setupWidget('spinner', {
		spinnerSize: Mojo.Widget.spinnerSmall,
	},
	sceneAssistant.spinnerModel = {
		spinning: true
	});
this.spinnerWidget = this.controller.get('spinner');

The template for something to show up in the button bar looks like this. This makes it still look like a button but you can show your content. The main thing to notice is that the item from the command model above is passed to the template for variable expansion.

#{example}

Now you should have something that looks like:

Spinner Command Menu

Also, you can now enable and disable the spinner with:

	this.spinnerModel.spinning = false;
	this.controller.modelChanged(this.spinnerModel);

inertia

I have been thinking a lot about what it takes to start a company or even start anything in the world. Starting a website, a blog, a project or even something as simple as an exercise schedule. For all of these things it takes something very simple, it just takes the first step towards doing it. The larger the task the harder it is to take that first step, but i have also realized that once you take the first step, the second, third, etc become exponentially easier. I don’t think this is something that just I have discovered. If you read any self help book or talk to any motivational speaker they tell you this and yet its hard. Its hard to internalize it, its hard to step out. Some of it is fear, some of it is just laziness. Somehow, a single step just seemed subtly simple. I hope that all of you have the ability to take your first step….

lens review

I just spend the last week or so reading about all different type of lenses and which one does what and is how good etc. There are a lot of reviews but there are very few that really talk about whats good/bad in simple terms that an average SLR camera consumer can understand. So here is my take on the subject :) . You need to know some basics before you break it all down:

  1. F Stop is something that has lots of explanations but at the most minimal level. The lower the number the more light you get. The lower the number the more expensive the lens :) . The lower the number the more background blur (aka bokeh) that you get.
  2. Xmm to Xmm is what tells you how much you can zoom. Most kit lense are 18-55. If you are going to shoot sports or want long stuff you want 70-200. If you want super wide for landscapes you want < 18. If you are like the rest of us you want somewhere between 18-75.
  3. A “Prime lens” is one that does not zoom but is set at a specific mm
  4. A kit lens is usually 18-55mm with a F3.5-5. When you see FX – Y that means that it is only X at the wide zoom and then goes to less light at greater zoom.

The ultimate lens that a consumer would want but does not exist is:

  • 11-300mm F1.4 that is super small and light

If you say okay lets look around see what we can find, you will see a number of lenses that are close but not exact.

  • 24-70mm F2.8
  • 28-75 F2.8
  • 18-270 F3.5-6.5 (aka superzoom)
  • 18-55 F2.8

You notice that you can get a super zoom lens but the F stop is so high that you might not really get great pictures in terms of light. I searched high and low for a 24-200 or a 18-200 with F2.8 and they just dont exist. So now that you have come to picking something that is based on what is available you have two choices.

Choice 1: Get 2 lens one for 24-70 and one for 70-200
Choice 2: Get 2 lens one that is a 18-270 and then get a 18-55 2.8

I went with choice 1 mostly because i want to start with the 28-75 and see if that is good enough zoom for most cases for me. If it is then i am done with one lens, if not then i have to get the 70-200 F2.8 but at least i have 2.8 across the whole range and that makes for some nice pics.

OH!!! The last thing that is super important that no one tells you about is the flash. If you get a 430EX2 flash then the indoor portrait pictures can come out amazing. The lighting for photos is half the photos beauty. With a simple flash you can get some amazing shots of people and things and not need perfect sunlight to get the beauty you want.

I could write more about each lens and good/bad etc but then it wouldn’t be short a simple would it?

web hosting review

Well it took me a bit of time to get this blog/webpage up and running and during the process I learned a lot about domain names, hosting and what is good/bad. I tried to find this information on Google and there are bits here and there but the big problem is that no one just puts it into a simple breakdown. I think the Web Hosts are actually working to make it harder to figure this stuff out. In any case here are the few simple things i learned. There are really 3 main web hosting types and charging models that i looked at:

Shared Server — Monthly Pay

Examples: JustHost, GoDaddy, etc..

The idea here is that these companies have large farms of servers and they are renting out part of it to you. In general you dont get to pick the OS running on it and you don’t get to install custom software. You get a set of software choices that they have like WordPress, PHP5 scripts that have predefined, Site Creators that they have chosen etc.. This looks really too good to be true because it says Unlimited Space, Unlimited Bandwidth and only $5. It is unlimited in those areas but it limits your ability to really use it because the tools and services they have are highly restricted. For example, you can install wordpress but only install their “accepted plugins”. You can run PHP scripts but none that write to the disk. They try to glitz and glamor you into buying their hosting solution by giving you “a free domain name” or “Free Google AdSense money”. I would really recommend that you just ignore the hype here and go with simple and easy. This is a great example of something being subtly simple. This looks simpler because its all setup and you have choices to install your apps and you are going to up and running in minutes. But then you want to make this small change, you don’t like the way the UI looks or you want to store images there and suddenly all the shackles of these sites show up.

Pros:

  • Very Simple to setup
  • Tons of templates

Cons:

  • Cant customize very much
  • No custom software

Virtual Private Server (VPS) –  Monthly Pay

Examples of this type of service are LiNode (the one i went with) or slicehost. With this type of host you are paying a monthly fee for a pre defined amount of space and bandwidth. You can usually get the lowest version of this for about $20. The general idea is that you are just getting a virtual machine in the sky. You can install whatever operating systems that they support and then you get root access and you install whatever you want and configure whatever you want. There is usually a small admin UI that allows you to setup the virtual machine and manage it but you really only use that when you can get to your own machine through SSH because something is really broken in your own setup.

Pros:

  • Simple to understand if you have some technical background
  • Root Access which means put whatever you want on it. (Subversion, wordpress, drupal, django.. whatever)
  • You can kill the whole machine and start over at any time
  • Very customizable to your liking and is a good playground for just trying different configurations etc.

Cons:

  • A little more expensive than the shared server
  • Lots of your configuration so if you dont want to twiddle a bit this is not for you

Virtual Private Server (VPS) — Measured Pay

Examples: Amazon EC2, Rackspace

This is the same as the VPS Monthly Pay but they charge you based on the amount of space and bandwidth that you use. This seems like a good idea when you are doing tons of data or tons of bandwidth but its hard to figure out what it is going to cost you monthly. It is not just $X monthly it might be very little or a lot depending on how your site does. While this could be much more ecconomical in the long run i would suggest you just start with simple and then can worry bout all the math to figure out how much your site traffic and storage will cost you.

Pros:

  • Might be cheaper if you dont have a ton of data or a ton of traffic

Cons:

  • Not simple. You have to guess how much space you are going to have, how much data, how many requests etc and that is something as a novice user you are not going to know of the top of your head.

Summary:

There are many other types of hosting like co-locate and dedicated hosting etc. These are more for companies and people who really want to get into the hardware of hosting and not just the software. If you look at the above choices,  would really recommend going with a VPS – Monthly and then switching to a VPS – Measured when you have more stats about what it will cost you.

Return top