Prevent horizontal jumping with centered web pages

If you have a centered web page, you might have noticed ugly annoying jumping when you change between pages where some extend beyond the browser bottom and some don’t. This is of course caused by the simple fact that the vertical scroll bar appears and disappears depending on how long the page is.

Not a big deal, but I find it annoying. A simple fix is to simply always show the vertical scroll bar, which you can do with a tiny piece of CSS.

html
{
    overflow-y: scroll;
}

Problem solved.

JavaScript: Delayed keypress event (sort of)

Wanted to do an AJAX call whenever the content of a field was changed. This can be done simply with the onchange event, but the problem is that you have to tab out of the field to make it fire. You can also do it with the keypress event, but then you’ll get one AJAX call for each and every keypress, which is just silly.

Found a nice and easy solution, and here it is slightly changed.

Continue reading

Nice font for code

Don’t remember where or how I came over this font… Might have been a tweet linking to this post… Either way, it’s a very nice font I think. Sure looks a lot better than the default Eclipse font anyways :roll:

The font is called Bitstream Vera Sans Mono, and you can download it for free at dafont.com/bitstream-vera-mono.font. Go try it out!

Unicode test strings

Some strings you can shove into your application and see if you at least sort of handle Unicode correctly. For example, if you have a form which stores a text value in a database and then shows it later on a webpage, you can try to stick these in the form and see if they come out correctly in the other end.

  • Iñtërnâtiônàližætiøn
  • Ādam

First one includes many non-ascii characters. Second one starts with a multi-byte character.

Convert windows-1252 to utf-8 on Windows

Tried to find out how to convert windows-1252 code files to utf-8 without messing up Norwegian characters today. Couldn’t really find anything good other than linux tools and php stuff. Finally, *facepalm*, I remembered it might be possible using Notepad… And sure enough, seems to work great. Just open up the windows-1252 encoded file in Notepad, then choose ‘Save as’ and set encoding to UTF-8.

Hopefully I won’t forget this the next time I need it… *sigh*

PHP: One way of differing between DEV and PROD environments with Kohana

Usually when I develop websites, they will be deployed to a domain, for example www.geekality.net. But when I develop this site locally, I usually want it to be in some sub-folder of localhost, since I usually have more than one website going on, and I don’t want the trouble with virtual-hosts. So, to solve this for my Kohana websites I do the following simple thing. This technique would work for other websites programmed in PHP as well, but the PHP part would probably be a bit different.

Continue reading

Oracle: Finding all constraints and their affected columns

Found an SQL script to list all constraints in an Oracle database together with affected columns. Putting it here in case I need it again… Took a while to run, but sure beats having to look through all the table definitions to find what exactly is preventing me from deleting a row…

SELECT UC.OWNER
,      UC.CONSTRAINT_NAME
,      UCC1.TABLE_NAME||'.'||UCC1.COLUMN_NAME "CONSTRAINT_SOURCE"
,      'REFERENCES'
,      UCC2.TABLE_NAME||'.'||UCC2.COLUMN_NAME "REFERENCES_COLUMN"
FROM USER_CONSTRAINTS uc
,    USER_CONS_COLUMNS ucc1
,    USER_CONS_COLUMNS ucc2
WHERE UC.CONSTRAINT_NAME = UCC1.CONSTRAINT_NAME
  AND UC.R_CONSTRAINT_NAME = UCC2.CONSTRAINT_NAME
  AND UCC1.POSITION = UCC2.POSITION -- Correction for multiple column primary keys.
  AND UC.CONSTRAINT_TYPE = 'R'
ORDER BY UCC1.TABLE_NAME
,        UC.CONSTRAINT_NAME;

If you’re just looking for one particular constraint you can of course also add and UC.CONSTRAINT_NAME = 'SOME NAME' :)