Archive for the 'Computer' Category

AJAX validation on Rails

I had a ajax form to add languages in the system in one of my projects. A pretty simple form with just one text field. The problem I had was with validations and display the error message if something goes wrong.
After search the net for a while I came across this blog from bigsmoke which could solve my issues, but after looking a bit it kind of looks a bit complicated and I wanted something more simple.
I took some ideas from bigsmoke and did my own thing.

So here is my implementation of Ajax validation on Rails:

My controller has a “new” action which looks like this

def new
  @language = Language.new(params[:language])
  if @language.save
    @language.reload
    return if request.xhr?
  else
    render :partial => 'error', :status => 444
  end
end

The view where the languages are displayed I have added a hidden div which will display the error message if present

Here is where the most stuff happens, in the _error.rjs

page.replace_html 'errors', "Language could not be created. Reason: #{@language.errors.full_messages}"
page.delay(5) do
  page.visual_effect :fade, 'errors'
end
page["errors"].toggle

This replaces the errors div with a message and the errors returned from the validation, it starts a fade with a delay so that the error message will disappear after a while and finally, the div is set to visible.

That’s it! It really is that simple.

Push mail for iPhone with Cyrus and z-push

Some days ago I came across z-push a very interesting open source project. I decided to give it a try and see how it works with my iPhone.
I really didn’t expect to be up and running in only 5 minutes! So I won’t write anything here about the installation, just read the manual and everything should be clear.
But there are two things I have to mention if you are using Cyrus.

  • Synced mails will be marked as read! The solution for this is in this post in the z-push forum
  • Sync might not work due to encoding problems (iPhone will say that there is no connection to the server). The solution for this is in this post in the z-push forum.

After solving these two issues everything worked perfect! The only problem that remains, and this is nothing z-push can solve, is the battery usage of the iPhone. Be warned! Your battery will be empty after 2 days in some cases even after 1 day. This really sucks, I have to admit, this is where BlackBerry will get a point.

Creating a Ruby on Rails Search with Squirrel

I was trying to create a search form with all kind of search fields but almost no text fields so Ferret is nothing that would help me since I need no full text search.
I found several hints but none was really what I was looking for until I came across something on scribd (http://www.scribd.com/doc/3188387/Advanced-Searching-in-Rails) which didn’t help me either but it gave me the link to Squirrel which seemed to be exactly what I needed.
But as usual there is something that doesn’t quite work as expected, in my case the first problem was with checkboxes. What I tried to accomplish is that it should return all records that have true in the field if the checkbox is checked and ALL records (also the ones with false) if the checkbox is not checked.
My problem was that I was trying all kind of comparisons with ==true or ==1 which all failed. The correct way to do it is ==”1″ for true or ==”0″ for false. Here an example:

@course= Course.find(:all) do
kinderbetreuung==true unless params[:course_search][:kinderbetreuung]==”0″
end

The next problem I had is that I have for each day separate times for the course, yeah I know this is a bit to much work but I really had no better Idea how to solve it. Anyway, my problem was that a course could be on just one day of the week or 3 times a week. This makes the search a bit more complicated.
Let’s say you are searching all courses that start after 09:00. The correct way to do it is like this:

any do
kurszeit_mo_von >= zeit_von.to_s
kurszeit_mo_von==nil
end

This will return either if the coursetime for monday matches OR if the coursetime is null. Hope I could save someone a lot of time with this.

You get what you pay for

Some time ago I got an hosting account at a cheap company (I won’t mention any names). All was good and fine until the trouble started.

1. No detailed access logs

There is no way to see who logged in when over ftp. The only thing that is logged is the access over the web interface. This is not enough! I just found out that several index.html and index.php files where modified between april and may. They all where “infected” with some extra javascript code. Funny enough, somewhen during this time there was a modification to the FTP server of that provider. All passwords where modified and you had to change the password over the webinterface for all accounts. Strange isn’t it. There was no official statement about anything getting hacked. 

2. Useless webstats

One of my sites hosted there had in a day about 200Gig traffic. Although they promise you about 5000 Gig traffic per month, all my sites where locked down due to bandwidth exceeding. Support told me this:

All ***** accounts are allowed to use 167 GB of transfer per day. If you site goes over this limit it will be taken offline until the next day. 

 I tried to find anything about this on their website and find no trace about this limitation. Anyway, the reason for the huge traffic amount was of course someone with bad intentions. It is weird since there is no real website on that account. It was used for exchanging larger files (legal content, no piracy) and nothing that would really be of interest to someone. I couldn’t find out what was downloaded and from where to cause such huge traffic, the support was of no help and ALL MY SITES WHERE OFFLINE for one day. Really all of them! Not just the one causing the traffic. 

There where some other minor issues why I don’t like this provider, but they I can’t remember now and anyway, like I mentioned, they where minor issues. The two big issues I mentioned above is the reason why I will cancel my account. 

 

oh yes … one of the minor issues is they don’t support sFTP or FTP with SSL, just plain unencrypted FTP. Not very nice.

The top 8 worst Microsoft promo videos | Crave : The gadget blog

The top 8 worst Microsoft promo videos | Crave : The gadget blog
You thought that Microsoft Vista video from earlier today was bad? Watch these.

Lest us forget the turgid history of some other horrifically bad promotional videos from Microsoft that will forever be burned into our brains.

Windows XP, with Firewall

72029489.jpg

Mac OS Leopard bei Amazon vorbestellen, und 10 Euro sparen

Mac OS LeopardBei Amazon kann Mac OS Leopard vorbestellt werden und mit einem Gutscheincode kann man 10 Euro sparen.

Also, jetzt hier klicken, und nach der Bestellung diesen Gutscheincode verwenden: AMZNLPRDAPPL

Computerworld - Just how did Microsoft get OOXML support in Eastern Europe?

This question, is simply answered by reading my blog about corruption

After the International Organization for Standardization voted to reject Microsoft’s Office Open XML document format as a standard, the detailed results from ISO member countries give us a lot of material to analyze.

Votes from South-eastern Europe and former Yugoslavia countries showed Microsoft’s domination of that market, and especially good connections with authorities because most of the national standardization bodies voted “Yes with no comments”.

Romania and Bulgaria, members of European Union, together with Bosnia and Herzegovina, Croatia and Serbia, gave a green light for Microsoft’s format, with comments from Bulgaria. In this story, we take a look at the decision processes and reactions in those countries.

Read more on Computerworld - Just how did Microsoft get OOXML support in Eastern Europe?

Incredible stupid MS Dos commercial

On the worm that affects Skype for Windows users - Heartbeat

Skype has learned that a computer virus called “w32/Ramex.A” is affecting users of Skype for Windows. Users whose computers are infected with this virus will send a chat message to other Skype users asking them to click on a web link that can infect the computer of the person who receives the message.

Please note that Skype users ONLY become infected after they have downloaded the link and run the malicious software. The chat message, of which there are several versions, is cleverly written and may appear to be a legitimate chat message, which may fool some users into clicking on the link.

On the worm that affects Skype for Windows users - Heartbeat

Next Page »