Custom OfType()-like method

Here's my version of Enumerable.OfType() method:

Copy & Paste the following codes in LinqPad. And, in LinqPad's Language dropdown > choose "C# Program" and press F5 to run:
void Main()
{

    var userprofileList = new UserProfile { FirstName = "John" , LastName = "Doe" };
    var userprofileList1 = new UserProfile { FirstName = "Juan" , LastName = "Dela Cruz" };
    var countryList = new Country{ Population= 105, City = "Cebu"};

    var arrlist = new ArrayList();
    arrlist.Add(userprofileList);
    arrlist.Add(countryList);
    arrlist.Add(userprofileList1);
    arrlist.Dump();
 
    var filteredList = arrlist.OfType<UserProfile>();
    ("OfType() result.").Dump();
    filteredList.Dump();
 
    var myFilteredList = arrlist.Cast<object>().ToList().FilterArr<UserProfile>();
    ("Custom type-filtering FilterArr() method result.").Dump();
    myFilteredList.Dump();
}

public static class Extensions
{
 public static List<X> FilterArr<X>(this IEnumerable<dynamic> source) where X : class
 {
  var filterList = source.Where(itm => itm is X).Cast<X>();
  return filterList.ToList();
 }
}

public class UserProfile
{
     public string FirstName { get;set; }
     public string LastName { get;set; }
}

public class Country
{    
     public int Population { get;set; }
     public string City { get;set; }
}


Lazy Loading (Load On-Demand)


A simple mock-up for Lazy Loading (Load On Demand using vertical scroll-bar):

Running Sample in: http://jsfiddle.net/clemskie/VL2BL/

HTML:

<div id='container' style='border: solid 1px gray;height:100px;overflow:auto;'>
    <table id='theTable'>
        <thead>
            <th>ID</th>
            <th>NAME</th>
        </thead>
        <tbody></tbody>
    </table>
</div>
<button onclick='MyPageController.loadInitialDisplay();'> Reset
</button>


JAVASCRIPT:

window.MyPageController = {
    recordsPerPage: 5,
    rowCtr: 0,
    container: $('#container'),
    theTable: $('#theTable'),
    clearTable: function () {
        $(theTable).children('tbody').remove();
    },
    loadInitialDisplay: function () {
        this.container.scrollTop(0);
        this.rowCtr = 0;
        this.clearTable();
        this.loadNextSetOfRecords();
    },
    loadNextSetOfRecords: function () {
        for (var i = 1; i <= this.recordsPerPage; i++) {
            this.rowCtr++;
            var tr = $('');
            var tdID = $('<td />', {html: this.rowCtr});
            var tdName = $('<td />', {html: 'Name' + this.rowCtr});
            tr.append(tdID, tdName);
            $(theTable).append(tr);
        }
    }
};

function scrollHandler(container) {
    var st = container.scrollTop;
    var scrollHeight = container.scrollHeight;
    var containerHeight = container.clientHeight;
    if (st >= scrollHeight - containerHeight) {
        MyPageController.loadNextSetOfRecords();
    }
}

$(function () {
    MyPageController.loadInitialDisplay();
    MyPageController.container.on('scroll', function(event){
          scrollHandler(this);
    });
});






How to add new items in the "Send To" menu of Windows Context Menu (desktop - right click)

How to add new items in the "Send To" menu of Windows Context Menu (desktop - right click)
1) Create a shortcut for the application or folder.
2)  Go to the following path below.
For Windows 7 / Windows Server 2K8:
- C:\Users\[Administrator]\AppData\Roaming\Microsoft\Windows\SendTo
For Windows XP / Windows Server 2K3:
- ????

3)  Copy the created shortcut in the above location.
4) Verify that the created shortcut appear under the "Send To" menu of Windows Context Menu (desktop - right click).

Debug .Net Assemblies deployed in GAC in a Deployment Machine

How to debug a .Net assembly deployed in GAC in a deployment machine:
1) Go to Start Menu > Run
2) Type the following based on the deployment location:

C:\Windows\assembly\GAC_MSIL
C:\Windows\assembly\GAC_32
C:\Windows\assembly\GAC

3) Find the directory of the assembly
4) Open/Navigate until you locate the .dll file.
5) Create a backup of the file on the same location.
6) Copy the latest .pdb and .dll files of the project in the same location.
7) Attach your project to a process that run/call your assembly/API.
    - For ASP.Net project, attach your project to w3wp.exe process.
8) You can now start debugging.



Barcode and QRCode Encoder / Decoder (using ZXing.Net)

- A simple project that encodes (a barcode in CODE_128 format) and decodes most of the 1D barcode-format (All_1D = UPC_A | UPC_E | EAN_13 | EAN_8 | CODABAR | CODE_39 | CODE_93 | CODE_128 | ITF | RSS_14 | RSS_EXPANDED)


Here's the details of the project:
Third-Party Project References:

===============================
ZXing.Net Assembly Info:

The sample mentioned in this blog was using the old version of ZXing.Net below:
Site: http://zxingnet.codeplex.com/
version: 0.12.0.0
timestamp: Sun Sep 22, 2013 at 3:00 PM

-------------

[1/11/2018]
New Updates for ZXing.Net Assembly:
It is now moved to: https://github.com/micjahn/ZXing.Net
===============================

C# .Net Project Info:
===============================
Version: .Net 3.5
Download Site:  http://www.4shared.com/zip/VxMrVCpq/BarCodeReader.html
===============================

Code Snippet:
private void btnScanCode_Click(object sender, EventArgs e)
{
   BarcodeReader br = new BarcodeReader();
   br.Options.PossibleFormats = new List(new[] { BarcodeFormat.QR_CODE, BarcodeFormat.All_1D });
   Bitmap bm = (Bitmap)Bitmap.FromFile(@"..\..\QRCodes\okinawajapan.jpg");
   Result rs = br.Decode(bm);
   lblQRResult.Text = rs == null ? string.Empty: rs.Text;
}


private void btnWriteCode_Click(object sender, EventArgs e)
{
   BarcodeWriter bw = new BarcodeWriter();
   BitMatrix bitMatrix = new BitMatrix(100, 100);
   Bitmap bmp = bitMatrix.ToBitmap(BarcodeFormat.CODE_128, "OKINAWAJAPAN");
   bmp.Save(@"..\..\QRCodes\okinawajapan.jpg", ImageFormat.Jpeg);
}


Move Left or Right

This is a simple animation using plain javascript and html.


move.html
<html>
<head>
<title>Dagan2x</title>
<script language="JavaScript">
var slideSpeed = 0;
function move(location) {
var span1 = document.getElementById('span1');
if(location == "left")
{
slideSpeed = -5;
}
else
{
slideSpeed = 5;
}

slide();

}

function slide()
{
if(slideSpeed != 0)
{
span1.style.left = (span1.offsetLeft + slideSpeed) + "px";
setTimeout('slide()',20);
}
}

</script>
</head
<body>
<span id="span1" style="position:absolute;">Modagan Ko!</span>
<br />
<br />
<button onmouseover="move('left');" onmouseout="slideSpeed=0;" onclick="slideSpeed=0;"><< Left</button>

<button onmouseover="move('right');" onmouseout="slideSpeed=0;" onclick="slideSpeed=0;">Right >></button>
</body>
</html>

display Syntax:

display: inline | block | list-item | run-in | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | none | inherit

* inline
The element opens a new inline box on the same line as the previous content, and behaves as an inline element.
* block
The element opens a new box, and behaves as a block-level element.
* list-item
The element is opened similarly to block, but has a list marker added to it.
* run-in
Creates either block or inline boxes, depending on context. Properties apply to run-in boxes based on their final status (inline-level or block-level).
* inline-block
The element is created as a block box, but is placed inline, similar to a replaced element.
* table, inline-table, table-row-group, table-column, table-column-group, table-header-group, table-footer-group, table-row, table-cell, and table-caption
These cause the element to behave like the corresponding table element.
* none
The element should not show up on the page, including all child elements and the box.
* inherit
The element should have the same display setting as the parent.


display Browser Support:

* Chrome 1, 2, 3, 4, 5
* Firefox 1, 2, 3
* Internet Explorer 4, 5, 6, 7, 8
* Netscape 4, 6, 7, 8
* Opera 3, 4, 5, 6, 7, 8, 9, 10
* Safari 1, 2, 3, 4, 5