Thursday, January 15, 2015

select it!

select * from (

select 'lkj' name, 1 isSup, 0 isHse, 1 isMgr
union
select 'lky' name, 0 isSup, 0 isHse, 1 isMgr
union
select 'Jon' name, 0 isSup, 1 isHse, 0 isMgr
union
select 'Kim' name, 1 isSup, 0 isHse, 0 isMgr

) myTable
where isSup in (1) and isHse in (0,1) and isMgr in (0,1)

Tuesday, December 30, 2014

mysql group_concat

SET SESSION group_concat_max_len = 1000000;
SELECT
cast(
concat(
PCR_M.PCR_Year,
'-',
LPAD(PCR_M.PCR_Id,4,'0')
) as CHAR
) as PCR_Id,
PCR_M.PCR_Name,
PCR_M.PCR_SEV_Id as Severity,
(
select
group_concat(I.ITM_Name separator ", ")
from
LINK_PCR_ITEM ITM
join ITEM I
where
I.ITM_Id=ITM.ITM_Id and ITM.PCR_Year=PCR_M.PCR_Year and ITM.PCR_Id=PCR_M.PCR_Id group by 'ITM_Id'
) as CSCI,


(
select group_concat(
"[Start][",
(select USR_Name from USERS where PAN.PAN_Author=USR_Id),
"] [",
date_format(PAN.PAN_Modification_Date, "%Y%m%d %H:%i"),
"]\r\n",
PAN.PAN_Comment,
"\r\n[End][",
(select USR_Name from USERS where PAN.PAN_Author=USR_Id),
"] [",
date_format(PAN.PAN_Modification_Date, "%Y%m%d %H:%i"),
"]"
separator "\r\n\r\n"
)
from PCR_ANALYSIS PAN
where (PCR_M.PCR_Id=PAN.PCR_Id and PCR_M.PCR_Year=PAN.PCR_Year)
) as Analysis,

(
select group_concat(
"[Start][",
(select USR_Name from USERS where PCT.PCT_Author=USR_Id),
"] [",
date_format(PCT.PCT_Modification_Date, "%Y%m%d %H:%i"),
"]\r\n",
PCT.PCT_Comment,
"\r\n[End][",
(select USR_Name from USERS where PCT.PCT_Author=USR_Id),
"] [",
date_format(PCT.PCT_Modification_Date, "%Y%m%d %H:%i"),
"]"
separator "\r\n\r\n"
)
from PCR_CORRECTIVE PCT
where (PCR_M.PCR_Id=PCT.PCR_Id and PCR_M.PCR_Year=PCT.PCR_Year)
) as Corrective

from PCR_MAIN PCR_M;

Wednesday, June 04, 2014

Truncated Text SSRS display in IE 10

Reference URL: http://answers.microsoft.com/en-us/ie/forum/ie10-windows_7/ie-10-ssrs-report-viewer-issue-after-kb2888505/1e82a8b9-dea6-4351-90d3-7f4f47c4fb2a

<script> block:

    try {

        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() {

            document.getElementById("ReportViewerControl_fixedTable").style.tableLayout = '';

        });

    } catch(e) {

        //ignore me alert("error");

    }

Monday, March 31, 2014

Timeline plotting



Graphite
http://graphite.wikidot.com/


OpenTSDB
http://opentsdb.net/index.html

npm bucky-server


FLOT?

references
http://jedi.be/blog/2012/01/04/monitoring-wonderland-visualization/
http://matt.aimonetti.net/posts/2013/06/26/practical-guide-to-graphite-monitoring/

http://www.designyourway.net/drb/javascript-visualization-libraries-to-display-charts-and-graphs-34-items/

Sunday, March 16, 2014

Binary decoding with AWK

http://awk.info/?doc/bitmaps.html


function Bytes2Number( String, x, y, z, Number ) {
x = split( String, Scratch, "" )
Number = 0
for( y = 1; y <= x; y++ ) {
z = index( CharString, Scratch[ y ] ) -1
Number = Number + z * (256^(x - y))
}
return Number
}

BEGIN{
for( x = 0; x <= 255; x++ ) {
CharString = CharString sprintf( "%c", x )
FS= ""
RS = /ABC/
}

{ Width = Bytes2Number( $22 $21 $20 $19 )
Height = Bytes2Number( $26 $25 $24 $23 )
Data = Bytes2Number( $14 $13 $12 $11 )
Size = Bytes2Number( $6 $5 $4 $3 )
Depth = Bytes2Number( $30 $29 ) / 8
ImgSize = Bytes2Number( $38 $37 $36 $35 )
....
}

Wednesday, February 19, 2014

Monday, December 16, 2013

node-mapnik on windows

1) Cleaning up mess
npm cache clean if encounter issues despite changes

2) binding.gyp

2a) From the dos command prompt, running npm install
set protobuf_src=
eg set protobuf_src=x:\progra~1\protobuf\src
set cairo_src=
eg set cairo_src=x:\progra~1\cairo\src

2b) Modifying binding.gyp in directory node-mapnik
from
 'conditions': [
      ['OS=="win"', {
        'variables': {
          'PROTOBUF_INCLUDES%':'C:/dev2/protobuf/vsprojects/include',
          'PROTOBUF_LIBS%':'C:/dev2/protobuf/vsprojects/Release',
          'PROTOBUF_LIBRARY%':'libprotobuf-lite.lib',
to
 'conditions': [
      ['OS=="win"', {
        'variables': {
          'CAIRO_INCLUDES%':'$(CAIRO_SRC)',
          'PROTOBUF_INCLUDES%':'$(PROTOBUF_SRC)',
          'PROTOBUF_LIBS%':'$(PROTOBUF_SRC)/../vsprojects/Release',
          'PROTOBUF_LIBRARY%':'libprotobuf-lite.lib',

2c) from
'conditions': [
        ['OS=="win"', {
            'include_dirs':[
                '<!@(mapnik-config --includes)',
                '<!@(mapnik-config --dep-includes)',
                '<@(PROTOBUF_INCLUDES)'
              ],

to
'conditions': [
        ['OS=="win"', {
            'include_dirs':[
                '<!@(mapnik-config --includes)',
                '<!@(mapnik-config --dep-includes)',
                '<@(PROTOBUF_INCLUDES)',
                '<@(CAIRO_INCLUDES)'
              ],


3) As advised in binding.gyp, make changes to .node-gyp\*\common.gypi under user directory
xp - c:\documents and settings\username\...
win7 - c:\users\username\...


see https://groups.google.com/forum/?fromgroups=#!topic/gyp-developer/p98GJxYJuH4
see https://github.com/TooTallNate/node-gyp/issues/26


4)  Testing
npm install -g mocha
npm install sphericalmercator

Grab a copy of GDAL for windows from http://www.gisinternals.com/sdk/
sdkshell.bat to set the environment for
4a) PROJ_LIB
4b) GDAL_DATA


mocha -R spec to list details