Friday, November 11, 2016

How to troubleshoot dynamically generated html (Tooltip/Popover) issues in Javascript libraries and frameworks

Context: AngularJS 1.5 front end having UI-Bootstrap library for some of the controls like popover and tooltip.

Issue: In record listing page the tooltips were displaying only the arrow (triangle) with no content.  Therefore we needed to figure out where the other part of the tooltip was within the html page. Since this tooltip mark up is generated on the fly by bootstrap when we hover on a target element, we had to freeze the application UI at the hover state. I was not able to retain the popover and investigate things on devtools. After trying all possible things with web dev tools (opens when F12 is pressed on google chrome) we found something in Stack Overflow that gave a hidden gem technique. Though I do not have the exact URL now, I grabbed a screen shot of the method to follow. I am recording  this here because I know it will be beneficial for me in future as well as to somebody who would stumble upon such a scenario.



Monday, December 29, 2014

Advanced Level 2014 ICT Results - Amazed

Friend of mine ( Fuzuly) was called by an English medium advanced level accounts teacher asking if he knows an ICT teacher. I was sitting next to my friend and suddenly he asked if I have any idea of teaching ICT.  Let me think about it I told. After some thinking, I told my friend 'ok I will do this' and asked him to give my words to accounts teacher.

This is how my ICT teaching started back in early June 2014 for 4 girls from Good Shepherd Convent - Colombo 13. There were only 3 months left for the examination.

The students were very afraid of some lessons like python, database management system, karnough maps to name a few and they had no teacher to turn to. As a computer science graduate from the University of Colombo, I agreed to make these things comfortable for them. Finally they became competent on the subjects I touched. They were a very obedient and smart set of students and also my first batch of students.

They sat for the exams and got results on 27th of December 2014.
This 3 months effort plus their commitment gave in one "B" for one of the students. The rest got "C" grade each. Even surprising they got the Best grade for ICT, out of the 3 main subjects each person took.

Remember this is only 3 months effort. I wish this could be 4 "A"s for the 4 students for ICT subject provided that they learnt from me the whole ICT Syllabus for Advanced Level.

However I am very happy about the results and so do my students. I have high hopes in them and wish them all the success in their future endeavors.

I have started Teaching ICT in Hambantota for students of Zahira National School in my leisure time. I'm Thankful for my partners Fuzuly and Naseeh for providing full support for this effort although I am not in the office at Dehiwala, working remotely most of the time from Hambantota.

"Geniuz Institute of Technology" my educational initiative rolling out on 1st January 2015 in Hambantota.


- Shiham Samsudeen,




Sunday, November 16, 2014

How to find disk space used by the SQL Server Database



  • Find out database size as a whole and also the data file and log file space usage
EXEC sp_helpdb @dbname= 'StairWay3'

  • Find space used by each table

SELECT 
    t.NAME AS TableName,
    s.Name AS SchemaName,
    p.rows AS RowCounts,
    SUM(a.total_pages) * 8 AS TotalSpaceKB, 
    SUM(a.used_pages) * 8 AS UsedSpaceKB, 
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM 
    sys.tables t
INNER JOIN      
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN 
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN 
    sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN 
    sys.schemas s ON t.schema_id = s.schema_id
WHERE 
    t.NAME NOT LIKE 'dt%' 
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255 
GROUP BY 
    t.Name, s.Name, p.Rows
ORDER BY 
    t.Name

Friday, March 21, 2014

Piracy and Unconventional Wisdom

This is something i came across today. It was a real informer.

"As software developers, piracy is something that affects us all. You might not see it directly if you work for a large company but you still have an interest in who is using your company's software. If you work for a small company or are a solo developer, piracy hits a lot closer to home. 
Both large and small companies usually offer "knee jerk" reactions. Such reactions are despite conventional wisdom and are generally incorrect. "

This article is a little one year old. But it has a lot to offer for the knowledge workers. Read the complete article here :

Thursday, March 20, 2014

Display buzy icon during windows client web service call .Net 4.5

Think of a situation where you encounter delay when performing remote service calls from your thick client. For example a windows forms application calling a long running process. Your user might have no clue of what is going on with their application. So it is very important at-least to let the user know something is going behind the scenes. One option is to use a busy cursor when performing a service call and hide when the service call is done. As a developer this can be achieved in several ways. But we need to look into the best possible option to fulfill this requirement in a generalized way.

Since this requirement is common and we will have to duplicate code in each place where the application calls a service, there is an elegant common solution to this. 

Whenever we need to intercept service calls to and from client and the server, .Net framework has provided necessary tools with extension points to tap into the service call and perform actions.


Take a look at Message Inspectors at MSDN


http://msdn.microsoft.com/en-us/library/aa717047(v=vs.110).aspx


We can use the BeforeSendRequest method to display the buzy cursor and AfterReceiveReply to hide the wait cursor

Thursday, June 27, 2013

Custom WCF Bahavior GOTCHA

WCF also provides a higher-level runtime that sits on top of the channel layer, targeted more at the application developer. It is often referred to throughout the WCF documentation as the service model layer. This higher-level runtime consists primarily of a component called the dispatcher (within the context of a service host) and a component called the proxy (within the context of a client). The dispatcher/proxy combination serves one primary purpose—to translate between WCF Message objects and Microsoft® .NET Framework method calls (see Figure). These components follow a well-defined sequence of steps to perform this process, and at each step along the way they provide extensibility points that you can plug into. You can use these extensibility points to implement a wide variety of custom behaviors including message or parameter validation, message logging, message transformations, custom serialization/deserialization formats, output caching, object pooling, error handling, and authorization, to name a few. Here I'll focus on the implementation of these types of custom behaviors
Figure : WCF Runtime Architecture

When you add a custom behavior to a WCF service to intercept calls before the operation is invoked, you need to add the Fully-Qualified Type Name (FQTN) into the web.config file like the following example.

<behaviorExtensions><add name=”MessageInspector” type=”MessageInspector.MessageInspectorEndpointBehaviour, MessageInspector Version=1.1.0.0, Culture=neutral, PublicKeyToken=2a8e0f2687fa1def″ /></behaviorExtensions>

How to find the Fully Qualified Assembly Name(FQAN) of a GAC registered assembly called 'MessageInspector'?

Command: GACUTIL.EXE /L MessageInspector
Result = MessageInspector, Version=1.1.0.0, Culture=neutral, PublicKeyToken=2a8e0f2687fa1def, processorArchitecture=MSIL


However if you then add the type name to that FQAN, the interceptor fails to execute. Why?
Well see the processor architecture directive at the end? REMOVE IT.
For some reason, Microsoft are doing a string comparison on the FQTN name when determining whether the WCF custom behavior is valid. As a result your WCF services will stop working.

Friday, April 19, 2013

Clean Sticky Footer

We had a requirement in one the of the web applications i am working on to have the footer stick to the bottom no matter what the height of the page content is. When i googled for this task, there are many solutions out there. In fact I experimented several of them to find that the footer hides some of the page contents when the content is larger than the height of the  page content height.

Finally found the solution at cleanstickyfooter which worked like charm.

I just wanted to mark this here first of all for my reference, and then for anybody who came here in search of a solution for a similar problem.


Tuesday, January 10, 2012

What can make me Happy?


This is often time a question that arises in almost every one of us. I would like to discuss this in brief with my own point of view.

Believe it or not the average time that we’ll live on this world is quite small compared to what our heart desires in our young healthy age. You would NOT WASTE the BEST of your time in where you need to be experiencing the joys of the life. I am wondering how one could merely give priority to money other than anything else.


These people bring forth a common equation,

  • Happiness = Money
  • Happiness = Luxury House + Vehicle + Social Parties + Other show Offs
Can I convince myself “Ok, I am HAPPY now”. I personally know people who live in bungalows, run many businesses, and drive the latest of the vehicles, VIPs of social gatherings. As some claim these people could be the Happiest of all. They would cry if you seriously talk to their hearts of the burdens they carry. Often times the family life is shattered. Often times the living is ONLY for the sake of living.


Get to know one thing at least. That is the PURPOSE of the LIFE.

  1. Why did we come to this world?
  2. Why should we give priorities to what we are taught to give?
  3. Are we doing the right thing?
  4. Are we on the right track?
Developing a rational thinking will at least make you understand that you should LIVE your life for a PURPOSE.
I would like to discuss the difference between a Person who is CONTENT with what he Posses and a Person who would always thrive to seek more on MATERIALS and blindly follow the desires of the hearts.

Being content with what you have DOES NOT mean that you should stagnate in one place. You should have PLANs to improve your every aspect. But again this is to do with how one would be HAPPY when he has less expectation but rewarded with something more than what was expected. This is about you being the BOSS of your desires rather than being the SLAVE.

Continued….

Wednesday, December 14, 2011

Friday, November 11, 2011

Daddy to Daughter

One girl intended to getting married to a very prominent person. But her father had reservations.

She said...Dad; you know what… he is a lawyer. And he has this qualification. He has this expertise. And these are his degrees.

And the father said listen my daughter... If he loves you, all these abilities are in your favor..
But the day things go wrong…All this goes against you.. His legal muscle, his financial muscle, his social well-being, recognition in community, his know-how, his contact with the hierarchy … all these things play out against you…So make a CONSCIOUS DECISION on what you want to do!

- Sheikh Sulaiman Moola

Friday, June 17, 2011

SQL Profiler For Express Edition

Microsoft SQL Server family includes free Express edition, that is fully functional, however has some disappointing limitations which prevent from using it in development process. One of them is absense of profiling tools, standard SQL profiler is not included. However, now you have an ability to use express edition for tuning your system.
SQL Server Express Edition Profiler provides the most of functionality standard profiler does, such as choosing events to profile, setting filters, etc. By now there are no analogue free tools.

https://sites.google.com/site/sqlprofiler/

Friday, May 20, 2011

Wednesday, April 6, 2011

Detect if Clicked Inside of a Div Container


// Following code will enable you to detect if a click occurred inside of a particular div through JavaScript.
// An example scenario would be a calander control being displayed as a popup. we need to close the
// calendar when the user clicks outside of the calendar area. If the user clicks somewhere inside the calender
// area the calendar would remain without being closed.

function EscapeClick(e)
{
var divContainer = document.getElementById('id_of_the_containerdiv');
var target = (e && e.target) || (event && event.srcElement);

if( checkParent(target,divContainer)!= true)
{
return false;
}
else
{
//Perform the hiding function , if its a calendar control.
// OR whatever you wish.
}
}

function checkParent(t,parentContainer){
while(t.parentNode)
{
if(t==parentContainer)
{
return false;
}
t=t.parentNode
}
return true
}
document.body.onclick = EscapeClick;


Tuesday, June 29, 2010

iTextSharp - read an existing pdf, resize it and then draw it on a new one


PdfReader reader = new PdfReader("In.PDF");
Document doc = new Document(PageSize.A4, 0, 0, 0, 0);
PdfWriter writer = PdfWriter.GetInstance(doc, 
new FileStream("Out.PDF",
FileMode.Create));
doc.Open();
PdfContentByte cb = writer.DirectContent;
PdfImportedPage page = writer.GetImportedPage(reader, 1); //page #1
float Scale = 0.67f;
cb.AddTemplate(page, Scale, 0, 0, Scale, 0, 0);
doc.Close();

Friday, June 11, 2010

Add an image at a given position without fail on any page of a pdf file.

Looking for a way to add an image at a given position on a pdf ( Provided you use iTextSharp for .Net library). Here is the way to go.


Following code is an extract from here.


string pdfTemplate = @"c:\Temp\PDF\fw4.pdf";
string newFile = @"c:\Temp\PDF\completed_fw4.pdf";


PdfReader pdfReader = new PdfReader(pdfTemplate);
PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(
newFile, FileMode.Create));
AcroFields pdfFormFields = pdfStamper.AcroFields;
string chartLoc = string.Empty;
chartLoc = @"C:\Temp\PDF\IMG_3746.jpg";//pplLogoSmall.jpg";


iTextSharp.text.Image chartImg = iTextSharp.text.Image.GetInstance(chartLoc);
iTextSharp.text.pdf.PdfContentByte overContent;


iTextSharp.text.Rectangle rect;
try
{
Single X, Y;int pageCount = 0;
rect = pdfReader.GetPageSizeWithRotation(1);
if (chartImg.Width > rect.Width || chartImg.Height > rect.Height)
{
chartImg.ScaleToFit(rect.Width, rect.Height);
X = (rect.Width - chartImg.ScaledWidth) / 2;
Y = (rect.Height - chartImg.ScaledHeight) / 2;
}
else
{
X = (rect.Width - chartImg.Width) / 2;
Y = (rect.Height - chartImg.Height) / 2;
}
chartImg.SetAbsolutePosition(X, Y);
pageCount = pdfReader.NumberOfPages;
for (int i = 1; i < pageCount; i++)
{
overContent = pdfStamper.GetOverContent(i);
overContent.AddImage(chartImg);
}
pdfStamper.Close();
pdfReader.Close();
}
catch (Exception ex)
{
throw ex;
}

Happy Coding!

Friday, May 21, 2010

Inject Some Life into Your Applications—Getting to Know the Unity Application Block

Unity is just a container that stores registrations and mappings between types and can instantiate the appropriate concrete types on demand. Or, to be more precise, it is a lightweight, extensible dependency injection container with support for nested containers and facilities for constructor, property, and method call injection. Unity is available as a stand-alone download and is also included with Enterprise Library 4.0. You can use Unity with Enterprise Library to create both Enterprise Library objects and your own custom business objects, or you can use it without installing Enterprise Library.


Above was the small introduction to the UNITY DI Library provided in the article i went through. Hope you'll make use of this piece of information for dependency injection.


Happy Coding!

Wednesday, March 31, 2010

Asynchronous Tracking - Google Analytics


Asynchronous tracking is an improved way to track website visitors with Google Analytics. Unlike a traditional installation, asynchronous tracking optimizes how browsers load ga.js so its impact on user experience is minimized. It also allows you to put your Analytics snippet higher in the page without delaying subsequent content from rendering.
Although asynchronous tracking uses a different Analytics snippet and a different syntax for tracking calls, it supports the exact same tracking customizations as the traditional snippet. In fact, the asynchronous tracking syntax is also more flexible than the traditional snippet.

Friday, March 12, 2010

NHibernate + IIS6 / IIS7 Hosting Configrations in web.config

We came across a situation where our Web Application updates  the SQL2k5 DB when hosted in IIS6, But does not update when it is hosted in IIS7. After some research we realized the problem was with the modules  and how IIS6 and IIS7 handles the modules mentioned within web.config. Here I share with you how we got the application up and running with some configuration changes.



If you are hosting in IIS6 you should uncomment following,


If you are hosting in IIS7 you should uncomment the following,
Cheers!