CategoryEnglish

Piece of wizdom

The original code

<%= select(“city”,”kind”, t(:place_types).map.map!.each{|key, value| [value, key]}, {:include_blank => t(:chose), :selected => @city.kind}) %>

The bad code

t(:place_types).map.map!.each{|key, value| [value, key]}, {:include_blank => t(:chose), :selected => @city.kind})

the replacement

key_values = t(:place_types).collect{|key, value| [value.to_s, key.to_s, ]}

Rails.ouch.ouch.omg!

10 Questions From Modern Web Designers: Answered

This article is talking on designers but I think most of the things there apply for coders also.

If you read it now and get it – you will be ok, else you will learn all those rules by own in the future.

Read the full article here…

http://www.onextrapixel.com/2010/08/18/10-questions-from-modern-web-designers-answered/comment-page-1/#comment-7981

Search Logic and whats wrong with it

The idea of the Searchlogic is to save you time and give flexibility.

The first time I saw this gem  I was very excited about it.

With only a few lines of code an you have the whole search done. I have start using it.

Once I want to apply it to a complicated search. The problem was that I have to write more code and “patches” in order to keep the Searchlogic working….

So my advice is – don’t use such boosters if you can apply your own solution. There will be aways a time when you want to extend your search and you will loose a lot of time search how to do it with the 3rd party solution.

Do it yourself.

Hiring Juniors

Starting a company or a team

If you think that by hiring juniors you will save money and will get working application – you are wrong.
You will loose much more than money.

Yes they are low cost, but read the rest of the post to be not tricked. Continue reading

How to access a server via sftp with ssh tunnel

Here is what we want to do

We have the following case:

Developer workstation windows with putty

Spider.bg – a host which has access to the www.psspy.se server

www.psspy.se – firewalled host – we want to put files here via sftp

What we want to do is to use spider.bg host as a proxy and connect to the psspy.se machine.

Tools that are used –

Here are the screenshots with the steps ….

Continue reading

Publishing article with SEO rules

As I want to keep this post secret as possible I will not follow those rules here :)

  1. which keywords I need to have into the title of the article
  2. which additional keywords I need to have into the subtitle
  3. which text I want to promote to Heading or make it strong
  4. check the most important text in the article that has nice keyword density around my important information.
  5. if there are abbreviations – add the acronym tag to describe them.
  6. all images should have nice alt/title/file name text, When possible add link to the image to relevant information.
  7. links:
    1. which are my important links (containing keywords)
    2. which links should be interesting to be linked on psspy/dagens archive for more news
    3. does all links have title / alt tags, what keywords can I add there?
  8. do I want to provide a box with related news on this article

Argh…this rmagick gem – aways difficult to install/maintain.

I have recently upgraded to Ubuntu 10.04 and I got this nasty rmagick gem error:

RMagick2.so: This installation of RMagick was configured with ImageMagick 6.5.5 but ImageMagick 6.5.7-8 is in use. (RuntimeError)

google for This installation of RMagick was configured with ImageMagick 6.5.5 but ImageMagick 6.5.7-8 is in use. (RuntimeError)

then found this page in mixed English/Chinees

and finally got a page in German :)

Then I decide to write this post in English and slightly modify the solution

instead of putting

RMAGICK_BYPASS_VERSION_TEST = true in the deploy.rb

I have put this in the development.rb

and all it works – this way on the production I will be forced to use real compatible library or at least check again for another solution or gem.

AUCH! This solution doesn’t work even in development I got weird core dumps :( …so here it is another try

Here is the real working  solution:

su -
git clone http://github.com/rmagick/rmagick.git
cd rmagick/
ruby setup.rb
ruby setup.rb  install

Nice code

I have just finished one method and I was not happy with the code. Then I put a comment on top of the method “Far from perfect….”.

Then I read the class – it was ugly.

here is the before

def validate
 return if is_email == false
 found = InternetComunicatorType.find(:first, :conditions => {
 :is_email => true,
 })

 return unless found

 if found.id != id
 errors.add(:is_email, "We have already email type")
 return
 end
end

here is the after

def validate
  if is_email
    found = InternetComunicatorType.find(:first, :conditions => {
      :is_email => true,
    })

    if found and found.id != id
      errors.add(:is_email, "We have already email type")
    end
  end
end

The result is much far readable

Mongoid presentations

When starting with mongoid I have missed a lot some demo source code.

How it works with controllers, does it plays nice with nested attributes, such things.

Here is presentation of mongo  and here are some slides

Mongoid

I writing this post for those who start using Mongo in their rails applications. I want to share my experience. First I discovered mongoid but then i saw mongo_mapper  – so I decide to go with the crowd. But! I was wrong. I there is no documentation for mongo_mapper but some blog posts arround, the examples are not aways working and you have to fight with all the code – I don’t maybe I have found some old documentation. When you dive in the code – again no documentation and not clear behaviour. Maybe it is a good solution but for me it doesn’t work. I lost 1.5 days experimenting and hoping that the things will go.

Then I give a try with mongoid. It has wonderfull documentation for starters also it seems at first glance that the code in mongoid is more readably and human friendly. It took me 2hours to port all my models to mongoid.

The guy developing mongoid seems pretty active.

last words – it is pleasure to work with mongoid – I recommend it to all.

© 2024 Gudasoft

Theme by Anders NorénUp ↑