Tuesday, 27 April 2010

Monday, 29 March 2010

Windows Scripting Command Interpreter

Консольный интерпретатор JS/VBS-скриптов в автоматическом и интерактивном режимах.

Wednesday, 17 March 2010

Y-combinators

Tuesday, 16 February 2010

Hello, World!

with (love) {
    .from("Siberia")
    .say("Happy Birthday!");
}

Friday, 12 February 2010

CMD/BAT A few useful routines

Analogues of pwd, basename and dirname.

Thursday, 28 January 2010

CMD/BAT: Repeat a string multiple times

If you want to get a string repeated multiple times -- you can use this routine. I have realised this as an attempt to implement this optimal algorithm using CMD/BAT only. It accepts three arguments: the name of a variable to store the resulting string, the multiplier (number of time the input string should be repeated), and the input string.

Monday, 14 December 2009

MsgBox / InputBox in JScript

Unfortunately JScript does not have several useful features available in VBScript. The most famous things are MsgBox and InputBox. The following code makes them available in JScript too.

Wednesday, 11 November 2009

IEEE754 converter

Tuesday, 3 November 2009

Cross-platform date/time definition

Earlier here (in Russian) i have investigated ways how to obtain date and time parts using the CMD.EXE features. After that here (in Russian too) i have simplified this way until two lines of a code. But both ways are platform-dependent - the order of date parts depends on the locale settings.

Recently i found the excelent link (in Russian too) with the description how to obtain the subject platform-independently.

I slightly modified the established method and present it now.

Thursday, 29 October 2009

CMD/BAT Librarian

Introduction
Unfortunately CMD.EXE, the command line interpreter in Windows, does not allows to collect favorite scripts under appropriate folders and use them multiple times in the future. So we have to use the "copy-and-paste" technology to migrate some needed functionalities from one script to another.

The script below allows to store debugged scripts under the determined folder, use them mutiple times, compile and link automatically to the final script.

Logfile rotation by CMD/BAT

The script below allows to rotate file (e.g.: logfiles). By default, the length of rotation is 5. It means that this script rotates some file no more than for 5 times.

Let's consider the permanently growing file of some application named as something.log and we'd like to keep records in this file for the long time as much as possible. But for some reason this file is cleaning up periodically or a size of the file affects on the application's performance.

The recent records are available from the file something.log and the previously saved records are available under the name something.log.1, etc until the something.log.5. After the following rotation the content of the last file will be lost and replaced by the content of the previous file (something.log.4 will be copied to the something.log.5) and the first file something.log will be copied to the something.log.1. At the same time the something.log will be truncated.

rotate something.log 10

Sunday, 4 October 2009

WHICH: UNIX-to-NT ported

WHICH is unix-world command, implemented using CMD/BAT feature only.

Friday, 2 October 2009

Simple Batch Progress Bar

Example 1. Print the bar within the window with '#' as the default filling character
call :progressbar 50
Example 2. The same as above but with an another filling character
call :progressbar 50 *
Example 3. Print the bar in the window title
set progressbar_t=1
call :progressbar 50

Tuesday, 8 September 2009

CMD/BAT: GetOptions

This is flexible and useful library to manipulate with arguments in CMD/BAT scripts.

Wednesday, 19 August 2009

Substring extraction by CMD

Once i needed to solve the next task. I have a batch script with name corresponding to the following conditions:
  1. the script filename has to be matched the pattern (see below).
  2. this script has to be located within directory tree of free nestion but one of directories of the tree has to be macthed the same pattern.

Wednesday, 5 August 2009

Monday, 27 July 2009

URL parsing in Javascript

There is very simple way to parse URL in Javascript. Just define new method in the prototype of the String. Of course, it has own shortcomings but in the most cases it covers the wide range of URLs and protocols (http(s), ftp, mailto, etc; the mandatory part of URL, host is considered as domain names, IPs, and localhost separately), and moreover it considers the more complex URLs like jdbc:oracle://localhost:1521.

Thursday, 9 July 2009

JS2BAT converter 2

Earlier to embed javascript codes into batch files the JS2BAT tool has ben implemented with batch features only. In this topic the same tool has been implemented in pure javascript. As opposed to the previous version the present one is the more functional and has optional parmeters. Previously the js2bat.js script has been implemented in javascript. After that it has been converted to the js2bat.bat batch script by itself with the following command:
cscript js2bat.js js2bat.js

Tuesday, 7 July 2009

JS2BAT converter

This script allows you to embed Javascript codes into the batch-script immediately. So you can stop to worry about creating of an additional batch-wrapper or lost of some specific parameters. Perl distribution has the same functional script pl2bat but for wrapping of perl-scripts with batch-scripts. I am not author of this idea, i just implemented this feature as the standalone tool. The main feature is to write the prolog code that is valid both in a batch and javascript. When launching the batch it runs as batch and calls the javascript interpreter with the same file as javascript file. But the second one skips this prolog as valid javascript comments.

Friday, 3 July 2009

Finest code syntax highlighter

Quotation from the Code Syntax Highlighter, the homepage of the project, allowing to embed colorizing of text and fully written on Javascript.
SyntaxHighlighter is a fully functional self-contained code syntax highlighter developed in JavaScript.
It is really true! It is very useful, very flexible and easy to customize. The main idea is to use so-named brushes to colorize codes within <pre /> tags (it is defined by default and customizable too!). Colorizing is simple. You have to link scripts and styles to your pages and add brush via class attribute (like this class="brush:js" for colorizing of Javascript codes).
I decided to use it in my blog and found that it works fine. Unfortunately there is no brushes for cmd/bat scripts and i have implemented this embedding to the blog's layout the code from below.