All posts by Admin

Solution of problem in Latex Editor (LEd) with Pictures of *.eps type

I like LEd but today I met a problem during PDFLatex compiling of my source with picture of *.eps type. It was telling that “unknown graphics extension: .eps”. Let’s look at it(Click to enlarge):

I was very upset because all my work was done in LEd and I got pretty used to this editor and I didn’t want to change my editor to another, for example WinEDT or other. So I tried to solve this problem. And I found an answer here.

To solve this problem, try the following:

  1. Locate eps file in true directory and try to change it’s name
  2. Compile with LaTeX compilation and then DVI conversion to PDF.

VBScript for automatic opening of programs, files and folders

Here I will explain a simple VBScript that I wrote today to make opening of some programs and folders automatic. This problem occured in my work because I needed to open frequently my postgraduate dissertation and some other TeX files and needed to open some folders and other programs fastly when I need. So let’s look at the script:

Dim objShellApp, WshShell

'проверка на уверенность

Set WshShell = CreateObject ("WScript.Shell")
Set objShellApp = CreateObject ("Shell.Application")

a = WshShell.Popup ("Ты уверен(а), что хочешь запустить все нужные программы? =))",,"Подумай!", 4+32)
If a = 7 Then WScript.Quit

WshShell.CurrentDirectory = "C:\Program Files\LEd"
WshShell.Run "LEd.exe"
WshShell.Run "LEd.exe"
WshShell.Run "LEd.exe"

WshShell.CurrentDirectory = "C:\totalcmd"
WshShell.Run "TOTALCMD.exe"

WshShell.CurrentDirectory = "C:\Documents and Settings\wzbozon\Рабочий стол"
WshShell.Run "ImageSaver.exe"

objShellApp.Open("C:\Documents and Settings\wzbozon\Рабочий стол\TeX Books")

WshShell.CurrentDirectory = "C:\Documents and Settings\wzbozon\Рабочий стол\Alwawee\Приложения Alwawee\TexRef"
WshShell.Run "TexDatabase.xlsx"

WshShell.CurrentDirectory = "C:\Program Files\Google\Chrome\Application"
WshShell.Run "chrome.exe"

WshShell.CurrentDirectory = "c:\Аспирантура\DIPLOM\"
WshShell.Run "final.doc"


First of all I should say, that this is a usual text file, called StartAll.vbs, that is edited in NotePad++. It can be edited on usual Notepad also, but I strongly recommend you to use Notepad++.

Here, at first I create 2 objects, that are used to manipulate the file system in Windows Script Host. Then I ask with a popup window if the user is sure to run this script. I do this, because I don’t need to run script, if user or me just press two times on it, because this script makes a lot of things. Then Led.exe program is opened 3 times from a directory, where it is located and then Desktop is toggled. Then I open Total Commander, ImageSaver.exe and TeX Books folder. The rest is analogous. It is noteworthy that Excel and Word files can be opened directly with Run method.

Tweaking Windows XP to speed up Boot and Shutdown

In this post I will talk about some tweaks to speed up Windows XP Booting and Shutdown process, since sometimes it can become so long that you begin to think about reinstallation. Please, note that it is about Booting and Shutdown only. There are plenty of videos on youtube to speed up Windows XP. For instance, this one. With the following tweaks I remarkably speeded up my own Windows XP booting. May be they can also be used for other versions of Windows. So let’s begin.

  1. Remove programs from Autorun. To do this you can choose two ways. One is to delete some records in Windows registry. And the second, which I recommend, is to just open Start->Run->msconfig->Autorun and press “Switch off all”. Or switch off just some programs except, for example, antivirus.
  2. Remove loading Windows Logo. To do this open the same msconfig and on Boot.ini Tab check the /NOGUIBOOT checkbox. This will remove Windows Logo on start and so speed up Windows booting a bit.
  3. Decrease WaitToKillServiceTimeout. Open registry by Start->Run->regedit. Then open HKEY_LOCAL_Machine -> SYSTEM -> CurrentControlSet -> Control. Right-click on WaitToKillServiceTimeout, press change and change the value to 5000. This is a time that systems waits a service to stop after it asks it to stop while shutting down system. You can read about it here
  4. Decrease Boot.ini timeout by opening msconfig one more time, choosing Boot.ini tab and typing in Timeout textbox value 3 instead of 30 secs. This is time that computer waits user to choose the option of loading. Actually, this tweak is not very useful and almost useless if your computer always loads normally and doesn’t ask for safe mode, etc.
  5. Switch off unneeded Services in msconfig/services.
  6. Decrease startup delay by editing the following registry entry: HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> ContentIndex -> Startup Delay to 40000 in Decimal values. The delay was put into windows years ago, the idea was to give users a lot of time to choose boot options (e.g. press for safe mode) before windows takes over. Here some people say it didn’t help them, but still I tried it myself and recommend you to change this.

Some tweaks do not work. Mind this, for instance, changing prefetcher value to 5 is useless



Solution of Internet Connection Problem After Uninstalling Dr. Web

Today I tried to uninstall Dr. Web antivirus and suddenly recognized that after this my internet connection got lost. I have Windows XP. I tried to figure out what the problem was in for about 4 hours. I read forums, for example, this topic, but it didn’t help. I tried this:

First, export the registry branch
HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ WinSock2
Start-Run (Run)
netsh winsock reset

But it also didn’t help. Also I tried to install Dr. Web antivirus again to make my internet start working at least, but I failed. I tried to use special utilities for uninstallation, that some people recommend, but it also didn’t help me.

Then I began to think by my own head and finally I solved the problem. No, I didn’t reinstall Windows. First of all, I recognized, that I had problems in Control Panel/System/devices/network devices. Also I saw that I got lost my Local Network Connection. What I did to solve those problems:

  1. Uninstalled Dr.Web
  2. Deleted all network devices in Control Panel/System/devices/network devices. Unforturnately, I have russian Windows, I hope you will understand what it is.
  3. Made automatic configuration update to get my network devices get installed. And here is the trick: when the network card is installed, the Local Network Connection is automatically set up for all network cards by default. So I got my Local Network Connection installed.
  4. I configured my Internet connection in TCP/IP settings of Local Network Connection (but this depends on your provider)

I hope this will help you.

String manipulation in iPhone applications

These examples of string manipulation in iPhone apps were taken from the Internet and I don’ pretend on the authority rights for them.

  1. Appending string to another string:

    NSString *myString = @"This";
    NSString *test = [myString stringByAppendingString:@" is just a test"];

  2. Method with wide possibilities to format string and concatenate several strings:

    - (NSString*) concatenateString:(NSString*)stringA withString:(NSString*)stringB {
    NSString *finalString = [NSString stringWithFormat:@"%@%@", stringA, stringB]; return finalString; }

    The advantage of this method is that it is simple to put text between the two strings (e.g. Put a “-” replace %@%@ by %@ – %@ and that will put a dash between stringA and stringB

  3. String Length:

    - (int) stringLength:(NSString*)string { return [string length]; //Not sure for east-asian languages, but works fine usually }

  4. Remove text from string:

    - (NSString*)remove:(NSString*)textToRemove fromString:(NSString*)input { return [input stringByReplacingOccurrencesOfString:textToRemove withString:@""]; }

  5. Uppercase / Lowercase / Titlecase:

    - (NSString*)uppercase:(NSString*)stringToUppercase { return [stringToUppercase upercaseString]; }

    - (NSString*)lowercase:(NSString*)stringToLowercase { return [stringToUppercase lowercaseString]; }

  6. Find/Replace:

    - (NSString*)findInString:(NSString*)string replaceWithString:(NSString*)stringToReplaceWith { return [input stringByReplacingOccurrencesOfString:string withString:stringToReplaceWith]; }

  7. String comparison Case Sensitive:

    if ([category isEqualToString:@"Some String"])
    doSomething = YES;

    Case Insensitive:

    if (!([category compare:@"Some String" options:NSCaseInsensitiveSearch]))
    doSomething = YES;


  2. – The best reference on this topic

How to speed up web page loading

There are some tips and tricks, that I discovered while creating our web page:

  1. It is better not to use cookies, if possible. And better use less Javascript. I used cookies in the following code to save a number of the current image. Then I took this number and tried to load a fresh image when user enters to the cite after a while.

    var currentN=0;
    currentN = get_cookie("currentN");
    //alert("Read currentN = " + currentN.toString());

    function changecenterimg(img_name)
    var N = getRandomArbitary(1, 4);
    N = Number(currentN) + Number(1);

    while(N == currentN)
    N = getRandomArbitary(1, 4);

    if (N != currentN)
    currentN = N;
    var img_src = 'images/c'+ N.toString() + '.jpg';
    set_cookie("currentN", currentN);
    //alert("Set currentN = " + currentN.toString());

    function init()
    //alert("init started");

    function set_cookie ( cookie_name, cookie_value )
    document.cookie = "currentN=" + currentN.toString();

    function get_cookie ( cookie_name )
    var cookie_string = document.cookie ;
    if (cookie_string.length != 0) {
    var cookie_value = cookie_string.match (
    '(^|;)[\s]*' +
    cookie_name +
    '=([^;]*)' );
    return decodeURIComponent ( cookie_value[2] ) ;


    And I understood after some time, that this code was seriously lowering web page loading. After this I tried to change center image loading process to the following:


    function changecenterimg(img_name)
    N = Number(currentN) + Number(1);
    if (N > 4)
    N = 1;
    currentN = N;
    var img_src = 'images/c'+ N.toString() + '.jpg';


    Less Javascript we have – faster the page loads. Also I removed infinite cycle in generating new random image number. Although this cycle didn’t work more than two times. It’s noteworthy that in Javascript to make a sum of two numbers we should write:


    N = Number(currentN) + Number(1);


    Because if we write just


    N = currentN + 1;


    we will get concatenation of strings, so that for example N will become 11 after 1+1.

  2. Images can be optimized to be smaller in size and unfortunately in quality. The following link was very useful for this purpose: I managed to make my images more than two times smaller from 24 kbyte to 10 kbyte

  3. Try to avoid reloading whole page and try to reload or change only some elements. For example, I was reloading page to refresh image after user clicks on it:

    <div id="center-column">  

    <a href="index.html">

    <img src="#" alt="Image" width="350" height="250" />




    I changed this to the following to reload only one image:

    <div id="center-column">

    <a href="javascript:changecenterimg('centerimg');">

    <img name="centerimg" src="#" alt="Image" width="350" height="250">



Examples of using Excel from C#

To begin using Excel from C# we should right-click on References in Solution Explorer or Project/Add Reference on File Menu and add a Reference to Excel (Microsoft Excel Object Library 12.0)

The following methods are not fully mine, they are the modification of code, taken from Internet.

1. Example of opening a definite Worksheet for future use.

Let’s assume that you have AAA.xls file previously created on C:\.

// Some additional namespaces
using System.IO;
using Excel = Microsoft.Office.Interop.Excel;

// Common variables for different methods
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;

private void OpenExcelWorksheet()

object misValue = System.Reflection.Missing.Value;

// Specify a "currently active folder"
string activeDir = @"c:\";

//Create a newPath - the Path to Excel file
string newPath = System.IO.Path.Combine(activeDir, "AAA");

// Create the subfolder
// System.IO.Directory.CreateDirectory(newPath);

// Create a new file name.
string newFileName = "AAA.xls";

// Combine the new file name with the path
newPath = System.IO.Path.Combine(newPath, newFileName);

xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(newPath, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);


2. Inserting data to Excel Worksheet

The following method inserts data in 2 column array “citations” to Excel worksheet to the lines from fromNum to toNum and columns B and C.

private void InsertToExcel(int fromNum, int toNum)
string fromRange, toRange;
fromRange = "B" + fromNum.ToString();
toRange = "C" + toNum.ToString();


xlApp.Visible = true;

//Fill A1:B20 with an array of values (First and Last Names).
xlWorkSheet.get_Range(fromRange, toRange).Value2 = citations;

//Make sure Excel is visible and give the user control
//of Microsoft Excel's lifetime.
xlApp.Visible = true;
xlApp.UserControl = true;
catch (Exception theException)
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat(errorMessage, theException.Message);
errorMessage = String.Concat(errorMessage, " Line: ");
errorMessage = String.Concat(errorMessage, theException.Source);

MessageBox.Show(errorMessage, "Error");



Creation of files in a given folder programmatically using Visual Basic Script (VBScript)

If a user must create, for instance, 20 files with names 1.tex, 2.tex, 3.tex, …, 20.tex, he will probably do it manually. Even the use of Total Commander with its hot key Shift+F4 for creation of files will not save you from the boring and stupid work. But a programmer is not a user and you can write the following Visual Basic Script (VBScript) with file name, for example, “CreateFilesScript.vbs”.


'(C) Author: Denis Kutlubaev, Alwawee Company, Moscow, 2011
'This script creates files with names 25.tex to 36.tex in a given folder
'folderPath - path to folder where files must be created
'fileName - generated file name
'filePathAndName - generated full path and file name
'start and stopIndex - numbers to start and stop file naming and creation

Dim folderPath, fileName, filePathAndName
Dim fileNumber, i
Set FSO = CreateObject("Scripting.FileSystemObject")

folderPath = "c:\Documents and Settings\wzbozon\Рабочий стол\LaTeX\Lessons\"

For i = 25 To 36
fileNumber = i
fileName = CStr(fileNumber) & ".tex"
filePathAndName = folderPath & fileName


It is noteworthy that in Visual Basic Script there are some restrictions. For example, the loop

For i = 25 To 36

cannot be unhardcoded.

Also, you cannot define step for loop, it is always 1.

In this line

fileName = CStr(fileNumber) & ".tex"

there is a concatenation of a string, produced by CStr operator from a number and a file extension.

If you write a VBScript, you will wish to debug it. To debug it, write in a command line:
wscript //X CreateFilesScript.vbs

After this you can choose Visual Studio as a default debugger for VBScript and you will catch the line, where the script fails. Unfortunately, without much information about the bug.

Some useful links:

  1. – Concatenation of strings in VBScript
  2. – Loops in VBScript
  3. – Good source for script writing (in Russian)

Случайная расстановка записей в Microsoft Excel 2007

Если у вас возникла задача: случайно расставить записи в Excel, не нужно писать программу на VBA. Есть более простой метод:

1. Каждой записи приписываем номер. Сделать это легко. Ставим 1, 2 номера на первые две записи и далее просто растягиваем на все записи. Или выделяем ячейки с этими номерами и нажимаем дважды на уголок, все остальные записи пронумеруются.

2. Пишем функцию для ячейки в соседнем столбце. Например =SIN(наша ячейка с порядковым номером). Аналогично растягиваем эту функцию на все записи. Должно получиться что-то подобное (чтобы увеличить картинку, нажмите на нее, затем вернитесь, нажав назад в браузере):

3. Нажимаем на вкладку “Данные” в Ribbon или Главном меню. Далее в разделе “Сортировка и фильтр” нажимаем “Сортировка”. Далее в появившемся окне выбираем столбец со значениями нашей функции. На рисунке показано, где эта кнопка находится:

4. Записи отсортируются и получится случайное их распределение. Теперь можно их снова пронумеровать. После сортировки мы получим следующее распределение:

Обновление TableView из Detail View

Иногда возникает ситуация, когда нужно изменить набор или содержание Table View, находясь в Detail View, то есть в дочернем View для данного Table View. При этом известно, что ViewDidLoad уже не запустится после того, как произойдет Dismiss дочернего экрана. Для решения этой проблемы нужно писать код по обновлению и загрузке Table View не в ViewDidLoad, а в ViewWillAppear. Например,

- (void)viewWillAppear:(BOOL)animated {
favoritesEntries = [[NSMutableArray alloc] init];
[self grabFavs];
[favoritesTable reloadData];
[super viewWillAppear:animated];

Здесь функция grabFavs заполняет каждый раз заново массив favoritesEntries элементами, которые затем используются в Table View. Функция reloadData – это стандартная функция, которая перегружает Table View.