среда, 17 августа 2011 г.

Lotus 8.5.2 memory tweak

By default Lotus Notes uses 256Mb only for Java Virtual Machine. But there is possibility to change it and speedup Lotus Notes client

Edit file:
lotus/notes/framework/rcp/deploy/jvm.properties

Change heap size (in MB) in this line:
vmarg.Xmx=-Xmx1024m

This setting affect maximum heap size for JVM.

 

среда, 10 августа 2011 г.

How to list junction points from command line

I created alot of junction points here and there but completely forgot where :)
To list every junction point on drive C: just type in command line:

dir c:\ /aL /s > c:\junctionPoints.txt

понедельник, 8 августа 2011 г.

Generate date range with MySQL

Time of time I need to generate reports in MySQL based on dates range. An intuitively obvious approach is to use some temporary table to build list of dates and build query based on that table.
But there is alternative way exists.
Using UNION with CROSS JOIN its possible to achieve same result without temporary tables and stored procedures.

To emulate a loop in MySQL from 1 to n we can use UNION n-times:

SELECT n FROM (SELECT 1 as n UNION SELECT 2) as LoopEmu;

This will return a result:


But what if we need to generate thousand of rows ? Repeating UNION thousand of times is not reasonable in that case. Here CROSS JOIN comes to help.
CROSS JOIN allows to multiply rows count as its work to cross join records each one to each one.
So for an example to get 25 rows we can use 8 unions only instead of 24:

SELECT @n:=@n+1 FROM 
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 ) q5
CROSS JOIN
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 ) q25,
(SELECT @n:=0) qInit;

To multiply rows count by 5 we need to add one more line only:


SELECT @n:=@n+1 FROM 
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 ) q5

CROSS JOIN
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 ) q25

CROSS JOIN 
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 ) q125,
(SELECT @n:=0) qInit;




Now here is few examples of date ranges queries:

Year To Day (YTD)
From: 1st day of current year
To: Current day


SELECT OnDate FROM
(
SELECT @DaysAgo:=@DaysAgo+1 as DaysAgo, Date(@EndDate:=@EndDate - INTERVAL 1 DAY) as OnDate FROM
  (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6) q6
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q30
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q150
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q750,
  (SELECT @StartDate:=Date(now()) + INTERVAL 365 DAY, @EndDate:=@StartDate, @DaysAgo:=0) qInit
) days750 WHERE OnDate Between DATE_FORMAT(NOW() ,'%Y-01-01') AND now();

Month To Day (MTD)
From: 1st day of current month
To: Current day

SELECT OnDate FROM
(
SELECT @DaysAgo:=@DaysAgo+1 as DaysAgo, Date(@EndDate:=@EndDate - INTERVAL 1 DAY) as OnDate FROM
  (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6) q6
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q30
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q150
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q750,
  (SELECT @StartDate:=Date(now()) + INTERVAL 365 DAY, @EndDate:=@StartDate, @DaysAgo:=0) qInit
) days750 WHERE OnDate Between DATE_FORMAT(NOW() ,'%Y-%m-01') AND now();

All days in current month
From: 1st day of current month
To: Last day of current month


SELECT OnDate FROM
(
SELECT @DaysAgo:=@DaysAgo+1 as DaysAgo, Date(@EndDate:=@EndDate - INTERVAL 1 DAY) as OnDate FROM
  (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6) q6
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q30
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q150
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q750,
  (SELECT @StartDate:=Date(now()) + INTERVAL 365 DAY, @EndDate:=@StartDate, @DaysAgo:=0) qInit
) days750 WHERE OnDate Between DATE_FORMAT(NOW() ,'%Y-%m-01') AND Last_Day(now());

Two months period
From: 1st day of previous month
To: Last day of next month


SELECT OnDate FROM
(
SELECT @DaysAgo:=@DaysAgo+1 as DaysAgo, Date(@EndDate:=@EndDate - INTERVAL 1 DAY) as OnDate FROM
  (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6) q6
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q30
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q150
  CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) q750,
  (SELECT @StartDate:=Date(now()) + INTERVAL 365 DAY, @EndDate:=@StartDate, @DaysAgo:=0) qInit
) days750 WHERE OnDate Between DATE_FORMAT(NOW() - INTERVAL 1 MONTH ,'%Y-%m-01') AND Last_Day(now() + INTERVAL 1 MONTH);

среда, 3 августа 2011 г.

3G CDMA 450 router

How to connect Android phone to 3G network which operating in CDMA 450Mhz standard only ?
Not so elegant solution as MiFi but it works here in Ukraine in MTS network.
3G Modem AnyData ADU-500 and ASUS router 330n3G, powered with external battery. Works out of the box :)


воскресенье, 31 июля 2011 г.

Uninstall Symantec Endpoint Protection firewall (Teefer2) without password prompt

There is known trick to remove password prompt for disabling SEP protection and another one to disable uninstall password of SEP.

Here is batch file which can be used to uninstall firewall component of managed SEP client:

@echo off
rem Set smc_exit_test to zero to disable password on SMC stop
reg add "HKLM\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC" /v smc_exit_test /t REG_DWORD /d 0 /f
rem Stop SMC
C:\PROGRA~1\SYMANTEC\SYMANT~1\smc.exe -stop
rem Delete SmcInstData to disable SEP uninstall password
reg delete "HKLM\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC" /v SmcInstData /f
rem Uninstall SEP with specified install GUID
MsiExec.exe /I {AAE221D5-C3DD-4FE2-A063-C1368FE730A5} /qb RUNLIVEUPDATE=0 REMOVE="Firewall"


To get your Symantec install GUID you can use this .VBS snippet:

Const SEPName = "Symantec Endpoint Protection"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}\\.\root\cimv2")

Set softRecords = objWMIService.ExecQuery( "SELECT * FROM Win32_Product WHERE Name=""" & SEPName & """")
For Each softRecord in softRecords
SoftID = softRecord.IdentifyingNumber
Next

MsgBox SoftID

Or via command line:
wmic product where "Name='Symantec Endpoint Protection'" get IdentifyingNumber

четверг, 30 июня 2011 г.

MySQL sys_exec UDF for 64 bit Windows

I have a 64 bit MySQL server v5.5 running on x64 Windows 2008. Today I faced with problem when I tried to add lib_mysqludf_sys.dll as UDF plugin.
This plugin works fine in 32 bit environment but not in x64:
mysql> CREATE FUNCTION sys_exec
    -> RETURNS INTEGER
    -> SONAME "lib_mysqludf_sys.dll";
ERROR 1126 (HY000): Can't open shared library 'lib_mysqludf_sys.dll' (errno: 0 )
Google didn't help so I started new project in Visual Studio and compiled it from source for x64. After few unsuccessful tries I got working dll.
Download x64 lib_mysqludf_sys.dll

суббота, 22 января 2011 г.

Teamviewer lags, Mysql doesn't connect to local machine

I got a weird problem with Windows 7 few days ago after ugrading Teamviewer 5 to version 6. It stopped to work. Almost completely. Web-version of teamviewer worked fine but not installed one. Rolling back to version 5 didn't help.
My first assumption was virus. I checked whole system from bootable CD. It was absolutely clean. Losing hope I forgot about this problem.
But today I started to work on a project which require mysql. I downloaded latest version 5.5 from mysql site and started installation. Install process went upto applying security settings and hanged. I started to investigate my network problems more deeply and found what was cause. Some time ago I played with tcp/ip autotuning settings and set it to experimental value.
Executing
netsh interface tcp set global autotuninglevel=normal
resolved my Teamviewer and MySQL issues!
So huge size of tcp receive window was a problem for few applications though I hadn't any problem with Internet connection.