среда, 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 :)