Ruslan Ulanov’s Codeshack

The developer’s notebook


leave a comment

A function that calculates a number’s factorial using recursion.

function factorial(n) {
    return n * ((n > 1) ? factorial(n - 1) : 1);

Written by Ruslan Ulanov

October 15th, 2013 at 1:02 am

Posted in JavaScript

CSS Shorthand Tokens

leave a comment

In CSS, you will come across some shorthand notation for the margin, border-color, border-style, border-width, and padding properties. It isn’t obvious or easy to remember which token in the value applies to which side of the element so here’s a handy list of the 4 possible varieties:

  1. One token — all-sides-use-the-same-value
  2. Two tokens — top-and-bottom right-and-left
  3. Three tokens — top right-and-left bottom
  4. Four tokens — top right bottom left

At least the four-token example can be remembered by associating the element with a clock where time progresses clockwise.


Written by Ruslan Ulanov

April 25th, 2013 at 8:11 am

Posted in Uncategorized

CSS property: text-overflow

leave a comment

A better way to display lines that are way too long to fit in one line:

.longline {
  width: 200px; /* width is required */
  white-space: nowrap;
  overflow-x: hidden;
  overflow-y: hidden;
  text-overflow: ellipsis;

Written by Ruslan Ulanov

November 18th, 2010 at 2:43 am

Posted in CSS

Tagged with ,

Useful JavaScript Regular Expression Functions

leave a comment

Here’s a few links for commonly used REGEXs..

10+ Useful JavaScript Regular Expression Functions to improve your web applications efficiency

Check that an input string looks like a valid email address.

function isEmail (s) {
  var isEmail_re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
  return String(s).search (isEmail_re) != -1;

Returns a string with everything but the digits removed. Could be used to validate phone numbers, etc.

function getDigits (s) {
  return s.replace (/[^\d]/g, “”);

Written by Ruslan Ulanov

September 4th, 2009 at 12:16 pm

Posted in JavaScript

Tagged with ,

Regular Expressions in InstallScript


If you’ve ever had to parse strings in InstallShield’s InstallScript, you’d know that a few of InstallShield’s built-in String Functions might not be enough. Regular Expressions are a way to go, but unfortunatelly Acresso didn’t implement them (yet?) in their product.

This post from Acresso Community might have a solution for you (at least until Acresso will figure out a way to implement RegEx natively in their products).

Read the rest of this entry »

Written by Ruslan Ulanov

July 20th, 2009 at 11:16 am

Posted in Installer,VBScript

Tagged with

data Protocol – embed your data

leave a comment

Recently, looking for a completely unrelated subject I discovered that IE8 now supports the data protocol.

What is a data protocol?

In a few words, it’s a way to embed any data (like GIF images, for example) into text documents such as HTML or CSS. So, instead of linking to an external file, you can do something like this:


SRC='data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAA wAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfz gFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiO Spa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZ eGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81  M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7'

Read the rest of this entry »

Written by Ruslan Ulanov

July 8th, 2009 at 2:31 pm

Posted in CSS,HTML

Tagged with

Login To Multi Accounts Simultaneously In Same Site Using IE8

leave a comment

ie8_logo How many of you have multiple accounts for same site, say Yahoo or Orkut  or some other email or networking site or forums, which you would like to browse simultaneously. One of the option available was to install different browsers and then log in into the same site using different ids. But with the new features of Internet Explorer 8 you can do this within IE8 itself.

To make use of this feature, instead of creating a new tab, select “New Session” from File menu. Thus each new session will have its own cookies which will allow you to browse same site with simultaneous multiple ids.


Written by Ruslan Ulanov

June 16th, 2009 at 10:20 am

Posted in HTML

Tagged with

InstallShield Skinning

leave a comment

Ever wanted to get rid of the InstallShield branding on custom skins? Now you can! Just download the attached ZIP file and use the files in this ZIP to create your skins. It works just like the original skin toolkit.

Happy skinning…


Read the rest of this entry »

Written by Ruslan Ulanov

February 20th, 2009 at 1:20 pm

Posted in Installer

Tagged with

Using Regular Expressions in YUI CellEditor

leave a comment

Here’s a nice example of validating data in DataTable’s CellEditor using regular expressions.

Written by Ruslan Ulanov

January 28th, 2009 at 2:35 pm

Posted in JavaScript

Tagged with ,

Cyr2Lat Slugs – WordPress Plugin


?? ??????? ??????? ????…

If you happen to write Word Press posts in one of the Cyrillic-based languages (i.e. Russian, Bulgarian, Ukrainian, Belarusian, etc.) and are using post’s title in Permalinks then you know that your post’s URL will become an unreadable mash of encoded characters (like %45%f0%…)

I got finally tired of changing encoded slugs to their latin equivalents on my son’s blog, and started looking for ways to automate this process. The Cyrillic Slugs plug-in written by Petko Bossakov was my only alternative at the time in WordPress plug-in repository. Unfortunatelly that plug-in didn’t work for me, since Cyrillic Slugs expects the page to be written in Windows-1251 encoding, and my blog uses WP’s default/recommended UTF-8. Hence Cyr2Lat Slugs plug-in was born.

Here’s a sample that illustrates what this plug-in does.

Before Cyr2Lat Slugs:

  1. You write a post with title “?????? ?????????”
  2. WordPress creates permalink like this:…b2%d0%ba%d0%b0

After Cyr2Lat Slugs:

  1. You write a post with title “?????? ?????????”
  2. WordPress creates permalink like this:

Cyr2Lat Slugs is based on Petko’s original idea and uses one of his functions, but otherwise is written in a more contemporary, object-oriented fashion. It also uses strtr function instead of str_replace which should be much faster.

Please note that you have to save post (click Save or Publish button) for slug conversion to take place!

Version: 1.0
Requirements: WP 2.3+ (WP MU compatible)
Author: Ruslan Ulanov
License: GPL

Download Cyr2Lat Slugs plug-in now.


  1. Copy file cyr2lat-slugs.php to folder wp-content/plugins/ on your server.
  2. Activate Cyr2Lat Slugs in Plugins menu of your blog’s admin interface.
  3. You’re done. There are no options to configure.

Comments are welcome (moderated, no spam please).

*In Russian*

Cyr2Lat Slugs ??? ?????? ??? ????????? Word Press, ??????? ????????? ??????? ????? ? ????????? ????? ? ???????? (????????), ??? ????? ????? URL ???????? ? ????????? ??? ???????????.

???????????????? ?????? ??????? Cyr2Lat Slugs ?? ???????.

?? ????????? Cyr2Lat Slugs:

  1. ?? ?????? ???? ? ?????????? “?????? ?????????”
  2. WordPress ??????? ??? ???? ?????????:…b2%d0%ba%d0%b0

????? ????????? Cyr2Lat Slugs:

  1. ?? ?????? ???? ? ?????????? “?????? ?????????”
  2. WordPress ??????? ??? ???? ?????????:

??????????: ???? ?????????? ????????? (?????? ?????? Save ??? Publish), ????? ????????? ??? ????????? ? ????????!

??????: 1.0
??????????: WP 2.3+ (???????? ? WP MU)
?????: ?????? ??????
????????: GPL

????????? Cyr2Lat Slugs.


  1. ?????????? ???? cyr2lat-slugs.php ? ????? wp-content/plugins/ ?? ???????.
  2. ??????????? Cyr2Lat Slugs ? ???? Plugins ????????????????? ?????????? ?????? ?????.
  3. ??????. ?????? ?????? ??????????????? ?? ????.

??????????? ?????????????? (?? ????????????, ??? ?????????? ?????).

Written by Ruslan Ulanov

December 10th, 2008 at 7:41 pm

Posted in PHP

Tagged with