Thursday, November 12, 2009

Installing Go programming language story

Few days ago google released 'go' programming language - very fast, compiling and many-many other features. Official site for this http://golang.org. Also you can view presentation on YouTube.

I've tried it on my Windows desktop under cygwin using http://golang.org/doc/install.html  and failed with an error:

%%%% making lib9 %%%%

quietgcc -ggdb -I/cygdrive/c/work/go/include -O2 -fno-inline -c /cygdrive/c/work/go/src/lib9/_p9dir.c
quietgcc -ggdb -I/cygdrive/c/work/go/include -O2 -fno-inline -c /cygdrive/c/work/go/src/lib9/_exits.c
quietgcc -ggdb -I/cygdrive/c/work/go/include -O2 -fno-inline -c /cygdrive/c/work/go/src/lib9/argv0.c
quietgcc -ggdb -I/cygdrive/c/work/go/include -O2 -fno-inline -c /cygdrive/c/work/go/src/lib9/atoi.c
/cygdrive/c/work/go/src/lib9/_p9dir.c:245: error: 'struct stat' has no member named 'st_gen'
make: *** [_p9dir.o] Error 1
make: *** Waiting for unfinished jobs....
 Next, I've installed latest version 3.0.10 of VirtualBox and Ubuntu 9.10 x64 on my Windows XP 32bit desktop.
Having installed all required dependencies and trying to clone repo:
svidyuk@svidyuk-desktop:~$ hg clone -r release https://go.googlecode.com/hg/ /home/svidyuk/go
abort: error: _ssl.c:480: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Googleing for this error found on launchpad that https not supported behind proxy... So, I've simply typed:
svidyuk@svidyuk-desktop:~$ hg clone -r release http://go.googlecode.com/hg/ /home/svidyuk/go
requesting all changes
adding changesets
adding manifests
adding file changes
added 3976 changesets with 16799 changes to 2931 files
updating working directory
1640 files updated, 0 files merged, 0 files removed, 0 files unresolved
And... in few minutes I've faced issue similar to 53. So I've added http to NOTEST in pkg/Makefile, then it hangs on testing net then added net to NOTEST and go!

./8.out
hello, world
And now... go,go,go! Install it and try. BTW does native client support means that we can script Chrome with go?

Tuesday, September 15, 2009

How-to: Running q/kdb+ as service on Windows

When simply running q on windows from command line you will end  with many q instances running consuming space on you taskbar and so on. If you spend some time and setup all your q dev/prod instances like services on Windows this will save you huge amount of time. BTW if you don't have q right now you can download it for free from KX Systems site:http://kx.com/Developers/FREE-DOWNLOAD.php

There are many tools for Windows to wrap any executable as service, but I will use free tool from Microsoft - SRVANY.
SrvAny is a tool found in the Windows NT Resource Kit that is used for running Windows NT applications as services. You can download it from Microsoft site:ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt40/i386/srvany_x86.exe .

To create a Windows service, perform the following steps:

1.Copy srvany.exe to c:\q

2. At command prompt(cmd.exe), type
instsrv.exe q5010 c:\q\srvany.exe
This will create service named q5010. We will use it to run q on port 5010(tickerplant)

3.Prepare Windows registry file to setup parameters for q5010 service:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\q5010\Parameters]
"Application"="c:\\q\\w32\\q.exe"
"AppParameters"="-p 5010 -q"
"AppDirectory"="c:\\q"
4. Now you can use q5010 service as usual windows service:

To start: sc start q5010 or net start q5010
To stop: sc stop q5010 or net stop q5010


If you want setup several instances repeat steps 2-3 for different service names and ports. If you run tickerplant, realtime and historical database you will have 3 services at minimum, q5010, q5011, q5012. To start in appropriate order you can setup dependencies between q5011 and q5010

sc.exe q5011 depend= q5010

Note that sign '=' must be immediately after word depend and space before service name.

In this way you can setup on windows complete kdb setup that starts and stops in right way.

Additional features:

Output redirect:
Also if you need to do redirect of output you must modify application using following reg file.
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\q5010\Parameters]
"Application"="c:\\WINDOWS\\system32\\cmd.exe"
"AppParameters"="/c c:\\q\\w32\\q.exe -p 5010 -q >c:\\q\\logs\\q.5010.log"
"AppDirectory"="c:\\q"
Environment setup:

1.Start regedit and go to following subkey:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\q5010\Parameters]
2. Add Value with name AppEnvironment with type REG_MULTI_SZ
3. In the Multi-String Editor, enter environment variables using the syntax =.
TZ=GMT
QHOME=c:\q
Do not forget to add a new line after the last line, or the value will be ignored.

Related articles:
How To Create a User-Defined Service:http://support.microsoft.com/kb/137890
Troubleshooting SrvAny Using Cmd.exe:http://support.microsoft.com/kb/152460
Passing Environment Variables to Applications Started by SRVANY:http://support.microsoft.com/kb/197178

Monday, August 24, 2009

How-to: Package single jar with netbeans

For desktop application it's quite usefull to package it as single jar and launch as java -jar ...
or wrap it with launch4j and make executable file for you platform(for windows now but also will try for OS X).
The story is short actually - Just add following section into your build.xml file.
<target name="-post-jar">
<jar update="true" destfile="${dist.jar}">
<zipfileset src="${dist.dir}/lib/lib1.jar"/>
<zipfileset src="${dist.dir}/lib/lib2.jar"/>
<zipfileset src="${dist.dir}/lib/lib3.jar"/>
</jar>
</target>

Also some libraries rely on content of MANIFEST.MF file, so actually you need to merge file with same names from all jar in META-INF folder. Will update on solution to this =)

UPD: Article on this topic was published on java.sun.com: http://java.sun.com/developer/technicalArticles/java_warehouse/single_jar/ . No solution for merging MANIFEST.MF files proposed =(

UPD2: You can use exclude tag inside zipfileset to exclude manifest update: META-INF/MANIFEST.MF

Sunday, July 26, 2009

Необычное вокруг #1

"Космомясо"
Туборг ГРИН Черной и Туборг ГРИН Лимон
Оказывается женскую гигиену можно просто купить

Saturday, July 25, 2009

Новый сайт с использованием служб Google

Вчера открыли в публичный доступ новый сайт - Паркет Premium (http://www.parketpremium.ru ). Сайт целиком и полностью был сделан с использованием Google Apps, разве что кроме автоматической регистрации домена(зона .ru) сейчас не поддерживается.
Интересно что все из того что может понадобится для сайта небольшой компании имеется в наличии, а именно:

  • Формы обратной связи и опросники(также возможно за несколько минут создать любую другую форму с автоматическим сохранением результатов в spreadsheets). Это делается на основе Google docs for apps. Также очень понравилась возможность элементарного встраивания формы в тело страницы в любом месте.
  • Большой выбор стандартных тем для сайта с очень большими возможностями настройки фона/размеров/шрифтов.
  • Интеграция с Google Analytics и Webmasters. Возможность автоматической интеграции с Яндекс.Вебмастер отсутствует, так что пришлось подтвержать с помощью загрузки файла(Управление сайтом - Приложения - Добавить) yandex_xxxxxxxxxxxxxx.txt в корень сайта. Обратите внимание на то что пустой файл загрузить не дает.
  • Автоматическая генерация дерева сайта и возможность гибкой настройки меню.
  • Удобные макеты для организации структуры каждой отдельной страницы(1,2,3 колонки с/без header/footer)

Friday, July 24, 2009

Загадки для детей из мурзилки 30-летней давности

1. Чтобы спереди погладить, нужно сзади полизать. (Почтовая марка)

2. Кругом волоса, посредине колбаса. (Кукуруза)

3. Сверху черно внутри красно, как засунешь так прекрасно. (Галоши)

4. Волос на волос, тело на тело и начинается темное дело. (Веки)

5. То холодный - то горячий, то висячий - то стоячий. (Душ)

6. Туда - сюда - обратно, тебе и мне приятно. (Качели)

7. Что ты смотришь на меня? Раздевайся я твоя! (Кровать)

8. Волосатая головка за щеку заходит ловко. (Зубная щетка)

9. Мы - ребята удалые лазим в щели половые! (Веник)

10. Лежит на спине - никому не нужна. Прислони к стене - пригодится она. (Лестница)

11. В темной комнате, на белой простыне 2 часа удовольствия.(Кино)

12. Ты помни его немножко, станет твердым как картошка. (Снежок)

13. Возьму его в руки, Сожму его крепко - Он станет упругим и твердым, как репка. (Снежок)

14. Красная головка в дырку лезет ловко (Дятел)

15. Если б не бабушкины лохматушки - мерзли бы дедушкины колотушки.(Варежки)

16. Не хрен, не морковка - красная головка. (Пионер в пилотке)
(еще имеются тут)

Слух 1:
Загадка была опубликована в годы московской олимпиады(1980 если кто не помнит).
Слух 2:
В конце 80х годов, за публикацию этих загадок, какие-то люди лишились своих мест в редакции журнала мурзилка

Расскажите какие впечатления после прочтения этих загадок =)

Monday, July 13, 2009

Monday, April 13, 2009

Setting up CUDA project

Any developer sooner or later returns to 'first high level language' - C. Java developer with realy great IDEs or very dynamic Rubyist may be confused with all that 'old' stuff. Linux kernel developer will ask why he need an IDE if there is vim or emacs editors =)

When starting developing with new framework, we always spend some time especially on Windows to setup appropriate paths, tools etc.

So I've decided to write down some check list to setup Visual Studio 2008 express edition to develop with CUDA.

1. Download and install Visual Studio Express 2008 for C++. From here: http://www.microsoft.com/express/vc/

2. Install latest drivers from NVidia. From here: http://www.nvidia.com/Download/index.aspx?lang=en-us

3. Download and install Cuda Toolkit and CUDA SDK. From here:http://www.nvidia.com/object/cuda_get.html

4. Set CUDA_INC_PATH,CUDA_LIB_PATH in windows environment variables

5. Copy project folder to $CUDA_SDK_HOME\projects\

6. Use instructions from $CUDA_SDK_HOME\doc\syntax_highlighting to enable syntax highlighting for .cu files

7. cppIntegration project from CUDA SDK have very helpful build rules for .cu file. So just add additional xml sections to you .vcproj file. Don't know if there is standard way to do this, so I've done this by hand.
Add ToolFile to ToolFiles section:
<ToolFiles> <ToolFile RelativePath="..\..\common\Cuda.rules" /> </ToolFiles>

Add additional build rule to all of your Configurations:

<Tool Name="CUDA Build Rule" Include="$(CUDA_INC_PATH);$(CUDA_SDK_INC)" />

After that from properties of .cu file you can tell Visual studio to build that file with nvcc just by specifying build rule as 'CUDA Build Rule"

Go GPU, Go!

Thursday, January 22, 2009

Can't install Google Chrome while behind proxy?

I had quickly moved to chrome after release on my home computer and want to do the same on laptop. But faced issue with infinite installation :(
Suggestions to install one from google pack without updates not for me- no dev builds! =)
So you can try to make easy two steps to fix this:
1) Uncheck Control Panel->Internet Properties->Connections->LAN Settings->Automatically detect settings.
2) Install in a normal way from google.com/chrome