www.hutsky.cz / blog / twitter /

Drag and drop to change position of elements

June 2nd, 2010

Long time ago, I was trying to figure out how to change position of items in a list. Let’s say there’s a list of product in an e-commerce solution and the user wants to choose what items go first and what go last. What I used back then was to create a simple form which called a function that takes the id of the previous or next item and swaps it for the current item’s id and vice versa. It was simple, but it worked. But now I needed something more user-friendly, after all it’s true that this solution was not very convenient for long lists. This is where the motto of jQuery “write less, do more” comes handy.

See demo here.

First, you need a table containing the items:

  1. <table id="positions">
  2.           <tr id="1"><td>item 1</td></tr>
  3.           <tr id="2"><td>item 2</td></tr>
  4.           <tr id="3"><td>item 3</td></tr>
  5.           <tr id="4"><td>item 4</td></tr>
  6.           <tr id="5"><td>item 5</td></tr>
  7.           <tr id="6"><td>item 6</td></tr>
  8. </table>

Now download jQuery and the Table Drag and Drop plugin (if you are new to jQuery, there’s great documentation on their page).

Having installed jQuery file and the TableDnD plugin, we need to get things working. Include this in the head section of the website:

Read the rest of this entry »

Half-life 2: Episode Two

June 2nd, 2010

To my great delight, I discovered that Half-life 2 is now available for something like 10 € nowadays. I know the game is quite old now, but I only played Episode One back then so I couldn’t resist to learn more about Episode Two. Even though it’s old, the graphics is still damn good when you use the highest details, and most importantly, it’s loads of fun. Read the rest of this entry »

Change all tags to lowercase in VIM

May 30th, 2010

Sometimes, you’ve got a whole chunk of HTML code that needs cleaning up a bit before you can use it. This week I got some materials in .doc format that had to be put on a website. There was so much of it that simple cut and paste was not possible. It would have been be particularly tiresome to try to get all the tables to HTML. On the other hand, it’s quite easy to save a word document as an html file. However, the generated HTML code is not very clean and definitely doesn’t comply with XHTML standards (though it seems to me that the result is much better when you use OpenOffice rather than MS Office).

Now that you have a very messy piece of HTML code, making it look better would mean even more toil than the copy and paste process. This is where a little bit of Vim magic comes handy.

1. First we change all tags to lowercase:

:%s/<\/\?\zs\(\a\+\)\ze[ >]/\L\1/g

2. Note that this will change tag names only. To change tag attributes to lowercase as well, use this command:

:%s/\(<[^>]*\)\@<=\<\(\a*\)\ze=['"]/\L\2/g

3. The above two expressions were found using google. Now I needed something that would wipe out all attributes to get rid of unnecessary styles attached to tags so I came up with this search and replace expression:

:%s/<\([a-z]*\)\s\([^>]*\)/<\1/g

Flexibee accounting package

May 15th, 2010

One of the few things I really do miss in Linux environment is a proper accounting software.

About a year ago, I managed to convince a friend of mine who owns this local store to try Linux on his office computer. He took to the idea gladly because the computer in his office was used by many various users, his father, part-time workers etc. Every one of them installed an icq toolbar here, a small application there and as a result, we had to re-install Windows quite often since the computer was constantly overloaded with unnecessary applications, spyware and viruses. Yes, we could have set up a Windows account with more restrictive rules, but Linux simply seemed a safer choice. At first I was worried about how people who don’t know much about computers, people who use computers just for browsing, e-mails or editing excel documents would react to a completely different operating system.

Read the rest of this entry »

Lands of Lore

April 13th, 2010

This has nothing to do with my work, but it’s related to computers anyway and life’s not work all the time, is it.

Read the rest of this entry »

Internet Explorer: Expected Identifier

February 10th, 2010

Today, I got feedback about a bug in an application in which I did some minor alterations not long ago. The application gives several rather long lists containing names and as it was often quite difficult to tell which list you are viewing after scrolling down a little bit, I was asked to do something about it. There was no easier way than to show only the first ten names of each list and put the rest in a hidden container, which is shown with help of a “show more” link.

  1. <a id="i_box10" class="show_hidden_list" href="#">see more / hide » »</a>
  2. <div class="hiddenclass show_box10">…list….</div>

Read the rest of this entry »

Kohana php framework – part 1.

January 26th, 2010

Just like most people, I like working on projects that are exceptional and require an innovative approach, but just like with most other jobs, the greater part of my work tends to be repetitive (and one cannot allow himself the luxury of turning such projects down). A framework is supposed to make this repetitive work a great deal easier. But when building a simple website such as this one , there’s no actual need for a sophisticated framework. The bigger projects, where a framework could have been useful, were always to be tailored to the client’s individual needs so I deemed it wiser to stick to clean php code; and beyond that the deadlines were usually so deadly that there was no space for trying out anything new. Read the rest of this entry »

Opensolaris – my first encounter

January 24th, 2010

I got a liveCD with Opensolaris from my brother today. I know he has been toying with it for some time now, but all I know about Opensolaris is that it’s based on Solaris by Sun, it is UNIX-like, supposedly very stable and famous for its file system. My brother had asked me if I wanted to try it out several times, but unlike him, who earns his bread maintaining OS, I never really got to it with that little time I have.

Read the rest of this entry »

Ubuntu / Debian remote desktop problem

January 21st, 2010

Sometimes, it happens that when I want to connect to one of my Debian machines over the vncviewer tool, I just can’t type in the password to unlock the screen. Read the rest of this entry »

Maintaining mobile web content

January 15th, 2010

This post is no official guideline but rather a log of steps I’m taking after having decided to build my sites in a more mobile device friendly way and a compilation of sources generally available on the net (most links included).

Why serve mobile content?

Mobile web content. The big question for me was why bother at all? Optimizing websites for mobiles means extra costs and few of my clients even know it’s possible, so I’ve never faced a demand to consider any of my projects from the mobile point of view nor was I particularly worried about this issue myself.

This changed when I bought my first handheld device and discovered that with the exception of big players like BBC or Google, it was often frustrating to browse most of the regular websites out there. Naturally, I turned to my own websites to see how they were standing. Luckily for me, it’d always been my opinion that a website should be kept as simple as possible, using JS only as a supplementary feature and avoiding flash completely if possible, so I was glad to find out that I was able to view and navigate the bigger part of my websites. However, lots of things were pretty bad – above all the size of the page. Read the rest of this entry »