johnkors

John Korsnes

Varying Azure Instances Between Environments When Deploying With Octopus Deploy

| Comments

Octopus Deploy is a great tool for doing release management for .NET platforms. If you’re doing any kind of .NET-apps I really recommend you do try it out. Lately I’ve been using it at work for deployments to Azure Cloud Services. Octopus handles both deploying your app to your server, but also setting the correct configuration parameters for the environment you are deploying to. In Azure Cloud Services the relevant config file is by default ServiceConfiguration.Cloud.cscfg as well as the usual web.config.

JavaScript Arrays: Truth or Dare

| Comments

Okay, I kind of like this one.

JavaScript Arrays #1
1
2
3
4
5
6
7
8
9
10
11
12
13
describe("Empty JavaScript Arrays", function(){
  it("are truthy when standalone", function(){
    [].should.be.ok;
  });
  it("are false compared to a boolean using ==", function(){
    ([] == false).should.be.true;
    ([] == true).should.be.false;
  });
  it("are neither true nor false when compared to a boolean using ===", function(){
    ([] === false).should.be.false;
    ([] === true).should.be.false;
  });
});

Another way of showing the relationship between empty arrays and true/truthy values:

JavaScript Arrays #2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// standalone truthfulness
if([]){
  console.log("Is written to console!");
}

// ==
if([] == false){
  console.log("Also written to console");
}
if([] == true){
  console.log("not this one though");
}

// ===
if([] === false){
  console.log(".. but is NOT written to console..");
}
if([] === true){
  console.log(" and neither is this written to console");
}

Empty arrays boolean evaluation summarized:

  • truthy when by itself (when not compared to a bool)
  • false when compared to a bool using the == operator. JavaScript coerces the empty array to it’s boolean equivalent, which is what happens when we compare using the == operator.
  • NEVER true when compared to either true nor false using the value and type comparison : ===.

Funny side note:

1
[] == ![] // true

The right side ![] converts the array to a boolean true and flips it to false. Then the == operator, since the types are different, converts the left side to a primitive value (by calling [].valueOf()) and ultimately ends up with 0. The right side false also gets converted to a zero, so in the end they compare equal.

Puh.

Sublime Text 2 and Jade Highlighting

| Comments

Since Sublime Text 2 does not support Jade syntax highlighting out of the box, you have to add the feature yourself. Adding Jade support is easy though. I found the following tip on StackOverflow. Sublime Text 2 supports the same format as TextMate when it comes to syntax definition files. First, navigate to the Sublime Text Packages folder, on OSX found at

1
/Users/{yourusername}/Library/Application Support/Sublime Text 2/Packages

Create a folder called Jade. Now download the syntax files into this folder, either by using Curl or just directly. One example is found here.

Downloading using Curl:

1
Curl -O https://raw.github.com/miksago/jade-tmbundle/master/Syntaxes/Jade.tmLanguage

Re-open any open Jade file in Sublime Text 2, and there you go. Quite easy.

Credits