Call Java Class static methods from javascript.

This may be a useful tip if you want to call a Java class static methods from javascript.

The syntax is ,


Make sure jar files loaded and if there are any variables, pass it as javascript array.

var args = [ <param1>, <param2>……. ]



Posted in Uncategorized | Leave a comment

Wireless and Powerline adapter speed.

Yes, its noticeable. Compare the results below.


Screen Shot 2017-09-11 at 9.17.43 pm

With Tp-link powerline adapter

Screen Shot 2017-09-11 at 9.16.35 pm

If you have a NAS at home, and dont have an ethernet connection use powerline adapter. In my case 1 GB file was transferred with 2 min and 15 sec.

Posted in Uncategorized | Leave a comment

Integrate LDAP to ASP.NET Web Application

With VS 2017 its very simple, follow the steps.

  1. Create ASP.NET web appcreate_proj.PNG
  2. Select authentication with “Individual User Accounts”create_proj_2.PNG
  3. Change AccountController as below,
  4. [AllowAnonymous]
    public ActionResult Login()
    return View();

    public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
    if (ModelState.IsValid)
    if (Membership.ValidateUser(model.Email, model.Password))
    FormsAuthentication.SetAuthCookie(model.Email,                   model.RememberMe);
    return RedirectToAction(“Index”, “Home”);
    ModelState.AddModelError(“”, “The user name or password provided is incorrect”);
    model.Password, model.RememberMe, shouldLockout: false);

    return RedirectToLocal(returnUrl);

    private ActionResult RedirectToLocal(string returnUrl)
    if (Url.IsLocalUrl(returnUrl))
    return Redirect(returnUrl);
    return RedirectToAction(“Index”, “Home”);

    public ActionResult LogOff()

    return RedirectToAction(“Index”, “Home”);

  5. Most important port is configuring the WebConfig file for AD connection
  6. Make sure the Forms Authentication module is available
  7. <modules><modules> <remove name=”FormsAuthentication” /> <add name=”FormsAuthentication” type=”System.Web.Security.FormsAuthenticationModule” /> <remove name=”ApplicationInsightsWebTracking” /> <add name=”ApplicationInsightsWebTracking” type=”Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web” preCondition=”managedHandler” /> </modules>

  8. Add connection string as below,
  9. <connectionStrings><connectionStrings> <add name=”ADConnectionString” connectionString=”LDAP://<your AD server>” /> </connectionStrings>

  10. Authentication mode and membership as blelow,
  11. <authentication mode=”Forms”><authentication mode=”Forms”> <forms name=”.ADAuthCookie” loginUrl=”~/Account/Login” timeout=”45″ ¬†slidingExpiration=”false” protection=”All” /> </authentication> <membership defaultProvider=”MyADMembershipProvider”> <providers> <add name=”MyADMembershipProvider” type=”System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” connectionStringName=”ADConnectionString” connectionUsername=”<AD username>” ¬† connectionPassword=”<ADUserPassword>” ¬†attributeMapUsername=”<value as below 12>” /> </providers> </membership>

12. “attributeMapUsername” can either be “distinguisedName” or “sAMAccountName”

13. That’s all !

Posted in Uncategorized | Leave a comment

Mirroring a Git repository

Cloning a repository locally and changing git remote didn’t work for me. Here is a clean way to¬†achieve the same.

  1. git clone –bare https://bitbucket……/your-repo.git
  2. cd your-repo.git
  3. git push –mirror¬†https://bitbucket……/mirror-repo.git
  4. cd ../
  5. rm -rf  your-repo.git


Posted in Uncategorized | Leave a comment

Mongo Aggregate query using date part of ISODate.

Most of the time we only need date part of  iso date in any document during an aggregation. Here is how to get the date part for aggregation,

  1. Project ( $project ) as a new filed, say “considered_date”
  2. Group with the field


{$match : {  any filtering with $match }}
,{$project : { _id :1 , any project fileds
, “considered_date” : ¬† ¬† ¬†{“$concat” : [
{“$substr” : [{“$dayOfMonth” : “$date_1”}, 0, 2]}, “-“,
{“$substr” : [{“$month” : “$date_1”}, 0, 2]}, “-“,
{“$substr” : [{“$year” : “$date_1”}, 0, 4]}
]} } }
,{$lookup : { any lookups}}
//,any other filtering
,{$group : { _id : { “filed 1″:”$field1”, “date”:”$considered_date” }, “count”:{$sum:1} }}

Posted in Uncategorized | Leave a comment

Remount without reboot

  1. Mount with follwoign command :

    mount -t cifs //server/foldertomount  /mnt/mount_location -o username=xxx,password=yyyy,domain=yourdomain

  2. nano /etc/ftab
  3. add //server/foldertomount /mnt/mount_location cifs gid=users,file_mode=0777,dir_mode=0777,auto,username=xxx,password=yyy,domain=yourdomain 0 0
  4. run mount -a

Reference : Click to view

Posted in Uncategorized | Leave a comment

First Omega2+ project ( Hello World -blinking LED )

Refer below link for the complete tutorial ,


Script File


  1. Make sure Omega2+ firmware is updated.
  2. chmod +x


## Simple script to blink a LED on the Onion Omega using gpioctl

## the variable that will hold the pin number, where the LED lamp is connected


## declare the LED_PIN as output

gpioctl dirout-low $LED_PIN

while true


## set LED_PIN to HIGH (turn LED on)

gpioctl dirout-high $LED_PIN

## sleep for 1 second (equivalent to Arduino’s delay(1000)

sleep 1

## set LED_PIN to LOW (turn LED off)

gpioctl dirout-low $LED_PIN

## sleep for 1 second (equivalent to Arduino’s delay(1000)

sleep 1


Posted in Uncategorized | Leave a comment