Powered by Syntax Highlighter scripts!

FOR XML PATH in Microsoft SQL Server for quick debugging on Multiple Table Joins

I was having a case where I need to search users who have more than 1 role and also see the Role names at the same time. It is not for use in application and its for me to debug on an issue.
I found that the FOR XML PATH clause on SELECT statement can be used to extract all of this information in one shot.

SELECT ID, FIRST_NAME, LAST_NAME, USERNAME,
 (SELECT COUNT(1) FROM USER_ROLE UR WHERE UR.USER_ID = AU.ID) AS ROLE_COUNT,
 (SELECT R.NAME as role FROM ROLE R, USER_ROLE UR
  WHERE R.ID = UR.ROLE_ID
  AND UR.USER_ID = TU.ID
  FOR XML PATH('')
 ) AS ROLE_NAMES
FROM MY_APP_USER AU
WHERE (SELECT COUNT(1) FROM USER_ROLE UR WHERE UR.USER_ID = AU.ID) > 1
;

GZip encryption changes for json content

Enabling GZIP encryption for Jersey Resource classes


 Jersey REST Service
 com.sun.jersey.spi.container.servlet.ServletContainer
 
  com.sun.jersey.config.property.packages
  com.mypackage1.resource;com.mypackage2.resource.provider
 
 
  com.sun.jersey.api.json.POJOMappingFeature
  true
 
 
  com.sun.jersey.spi.container.ContainerResponseFilters
  com.sun.jersey.api.container.filter.GZIPContentEncodingFilter
 
 1

Installing apache webserver locally and enabling gzip compression for json response on ajax calls

Tried installing the apache web server in my laptop,
First used the mod_jk connector to connect to local tomcat. (ref to link)
Then disabled the mod_jk connector and switched to use the mod_proxy connector to connect to local tomcat. (ref to link)

Goal of installing apache http server locally is to enable gzip compression for the site content.

Enabled compression in tomcat directly using the connector syntax below,

 Jersey REST Service
 com.sun.jersey.spi.container.servlet.ServletContainer
 
  com.sun.jersey.config.property.packages
  com.mypackage1.resource;com.mypackage2.resource.provider
 
 
  com.sun.jersey.api.json.POJOMappingFeature
  true
 
 
  com.sun.jersey.spi.container.ContainerResponseFilters
  com.sun.jersey.api.container.filter.GZIPContentEncodingFilter
 
 1


This worked fine as long as we use the port 8080, once we have the web server listening on port 80 infront of tomcat, the gzip compression is not enabled.
To get the gzip enabled on apache http server, added the line below to httpd-vhosts.conf file

AddOutputFilterByType DEFLATE text/html application/json text/plain text/xml text/javascript text/json text/x-js application/x-javascript application/javascript

This however is working for compression the response JSON for some ajax calls and not working for some ajax calls.

Getting alerts when ever Google detects a new page with your name

I search for myself in google some times just to see if I was tagged in by somebody in the places I should not be. And for some times to see if my personal data (photos, family blog entries etc.. ) is getting leaked into the public search results.
While changing some of the google sccount entries I found this useful setting to get automatic alerts for a search keyword when a new page is scanned to have the 'keyword' in it.

Go to your Account page.
   While you are in Gmail, click on your profile photo, it opens a layout with links 'Account', 'Privacy', 'View Profile' etc.
   Click on the 'Account' link.
   In the Accounts page, Expand the 'Account' from left navigation
    Click on the link 'Me on the Web'
'Me on the Web' page opens with 3 sections, click on the 'Manage web alerts' button in 'Stay current with web alerts' section.
Your name is pre-populated, click on 'Add'

The Google Alerts feature has been there for a long time, I personally used it around 9 years back for some time.
But i feel making use of Alerts in this form makes sense and just a smart reuse of an existing feature!