Friday, July 24, 2020

What was my Wifi password?

If you have a Wifi connection on your Laptop and you need to know the password for it follow the next steps in a DOS command line:

netsh wlan show profile

This will show the known profiles. Copy the name of any profile you need to know its password.
Then call the next command to see the password in clear text:

netsh wlan show profile <name> key=clear

What is my IP-number in Azure

When you send a request to somewhere that uses your ip-number to whitelist, your ip number becomes important to know.
It is pretty simple when you do this on your laptop where you can open up a browser and find your outbound ip-number in Google. When you run your request within an Azure Web App which is running on an ASP, you might want to open up a console in Azure Portal and use the following PowerShell command:

(Get-AzWebApp -ResourceGroup <group_name> -name <app_name>).OutboundIpAddresses 

See also: find-outbound-ips

Tuesday, January 7, 2014

IIFE

IIFE stands for: Immediately-Invoked Function Expression
It is a self-executing anonimous function like this:


(function($){
    $.fn.myplugin = funnction(options) {
        var settings = {};
        $.extend(settings, this.myPlugin.defaults, options);
        return this;
    };

    $.fn.myPlugin.defaults = {
        option1: 'option1',
        option2: 'option2',
        option3: 'option3'
    };
})(jQuery);


Another good example:

// Create an anonymous function expression that gets invoked immediately,
// and assign its *return value* to a variable. This approach "cuts out the
// middleman" of the named `makeWhatever` function reference.
// 
// As explained in the above "important note," even though parens are not
// required around this function expression, they should still be used as a
// matter of convention to help clarify that the variable is being set to
// the function's *result* and not the function itself.

var counter = (function(){
  var i = 0;

  return {
    get: function(){
      return i;
    },
    set: function( val ){
      i = val;
    },
    increment: function() {
      return ++i;
    }
  };
}());

// `counter` is an object with properties, which in this case happen to be
// methods.

counter.get(); // 0
counter.set( 3 );
counter.increment(); // 4
counter.increment(); // 5

counter.i; // undefined (`i` is not a property of the returned object)
i; // ReferenceError: i is not defined (it only exists inside the closure)


Source: http://benalman.com/news/2010/11/immediately-invoked-function-expression/

Tuesday, June 18, 2013

Passing Date parametere from Javascript to WCF

Having a service method that accepts two parameters will look like this:

[DataContract()]
public class ServiceRequest
{
    [DataMember()]
    Nullable<DateTime> DateTimeFrom { get; set; }
    [DataMember()]
    Nullable<DateTime> DateTimeTo { get; set; }
}

[ServiceContract()]
public interface IService
{
    [WebInvoke(UriTemplate = "getServiceCall", Method = "POST")]
    ServResponse GetBusinessObjects(ServiceRequest filter);
}
Now, To start calling this method we need to construct a Json data representing the parameters.
      var fromDate = new Date(2013, 06, 18);
      var toDate = new Date();

      var datavar = {
            DateTimeFrom: fromDate.toMSJSON(),
            DateTimeTo: toDate.toMSJSON()
      };
      var parameters = JSON.stringify(datavar); 

But, before calling the toMSJSON on date object we need to define it as follows:


// Let Date type be compatible for Microsoft WCF
Date.prototype.toMSJSON = function () {
/// <summary>Let Date type be compatible for Microsoft WCF.</summary>
var date = '/Date(' + this.getTime()  + '-0000)/';
};

Getting DateTime from WCF

// convert WCF date to Javascript
String.prototype.DateWCF = function () {
    /// <summary>convert string into Date</summary>
    var matches = this.match(/\/Date\(([0-9]+)(?:.*)\)\//);
    if (matches)
        return new Date(parseInt(matches[1]));
};
Notice that when you use a date in javascript it is representing your local date based on the settings on your systemn and browser. As a result you might pass different notation to WCF. For example, my broweser has an timezone offset of -120 minutes. So when I ask to convert 06/20/2013 02:10:04 I see 2013-06-20T00:10:04.000Z which is perfectly normal because that represents the same exact time as I meant on my browser. Thus WCF will get the correct date aswell.

Friday, April 5, 2013

Minify js and css files in Visual Studio 2012

Finally we got an integrated tool in VS2012 that does the jobin Solution Explorer:
Web Essentials
You can enable this tool using the Extensions And Updates from the TOOLS menu.


  1. First, right-click on the css file and from the Web Essentials context menu choose to Minify CSS Files. This will ensure that with every build it will generate the accompanying .min.css file too.
  2. Make sure you have the Web.Release.config beside your web.config
  3. In your .aspx or .master file put an if statement to figure out if this is running on your debug mode or release mode:
.
 <% if (HttpContext.Current.IsDebuggingEnabled) { %>
    <link href="/css/MyFile.css" rel="stylesheet" type="text/css"></link>
  <%} else {%>
    <link href="/css/MyFile.min.css" rel="stylesheet" type="text/css"></link>
  <%} %>
.

Wednesday, March 27, 2013

Do more with less



You can do more with less by reducing your design to its essence, and solving for distractions,
not discoverability. Create a clean and purposeful experience by leaving only the most relevant
elements on screen so people can be immersed in the content.

  • Be great at something instead of mediocre at many things.
  • Put content before chrome.
  • Be visually focused and direct, letting people get immersed in what they love, and they will explore the rest.
  • Inspire confidence in users. 

Desktop browsers have quite a lot of chrome (menus, options, status bars, and so on) that is
only sometimes useful. Typically, however, users open a browser to see a webpage, not to
interact with the browser. Moving commands off the browser chrome and into the app bar or
into charms helps users focus on what they care about.

Copied from Windows 8 User Experience Guidelines

Passed 70-480 exam

Yesterday morning I passed the exam in very short time (about an hour).
Amazingly, most of the questions were very familiar and the hints people provided earlier has been very helpful.

  • http://moustafa-arafa.blogspot.nl/2012/12/study-material-for-programming-html5.html
  • http://geekswithblogs.net/WTFNext/archive/2012/10/08/exam-70-480-study-material-programming-in-html5-with-javascript-and.aspx
  • http://www.techexams.net/forums/microsoft-developers-certifications/79076-70-480-programming-html5-javascript-css3.html
And a magor help from ExamCollection:
http://www.examcollection.com/microsoft/Microsoft.BrainDump.70-480.v2013-02-04.by.HakimAli.70q.vce.file.html