Fixing Cannot find module ‘sync-exec’ error with yarn install

Error message:
clientResources\node_modules\uglifyjs-webpack-plugin: Command failed. Cannot find module ‘sync-exec’
Reason:
uglifyjs-webpack-plugin 0.4.6 defines this command 
“postinstall”: “node lib/post_install.js”
which looks like this
var execSync = require('child_process').execSync;
var fs = require('fs');

// Node 0.10 check
if (!execSync) {
execSync = require('sync-exec');
}

So if your node instance is older than 0.10, it will fallback to require sync-exec . Unlike execSync which is a builtin module, sync-exec is, or was an old module that you have to install explicitly. If your node instance does not have that installed, boom!

Continue reading “Fixing Cannot find module ‘sync-exec’ error with yarn install”

ServiceAPI + Postman, a match in heaven

No, it’s just a note-to-self.

A lot of customers have been using ServiceAPI, and to great successes. We also have very good documentation here – of which largely thanks to my colleague Mark Hall. But what if you want to play around with ServiceAPI and don’t want to write app/build/run it yourself? The answer is simple: There are many REST Clients can do the job for you, and Postman is usually regarded as the best/most popular one.

But, the documentation are for C# client, it can be quite confusing to use Postman to work with ServiceAPI for the first time (or times). If you are experienced with Postman, great! But if you are not – like me – when you use Postman from time to time and everytime it’s new, then this post can be useful to you. Today I need to do some tests with ServiceAPI, and I had to spend some time figuring out how to use Postman – so I decided it’s better to have all of those noted for future reference.

Continue reading “ServiceAPI + Postman, a match in heaven”

Choose your battles

This is the third part of the series: How to survive and thrive – a series for new developers to become better at their jobs. You can read the first two parts here and here.

In military, there is a term of “uphill battle”. That when you have to fight your way up a hill, when you enemy controls the top. It’s a very difficult fight and your chance of success is low. Any experienced military leader knows uphill battles are something you should avoid until there are no other options.

That also applies with any jobs. Including programming.

The truth is, you shouldn’t fight the battles you can’t win.
Continue reading “Choose your battles”

Beware of IContentLoader.GetChildren() for CatalogContent

This is more of a self-to-note.

If you are using IContentLoader.GetChildren<T>(ContentReference), one important thing to remember is this uses the current preferred language. Normally when you get children of a catalog, or a node, that would not be a problem, because a catalog entity – node or entry, will be available in every language supported by the catalog. So if you just want to get the children references, the language is not important. (Note that, if you just need the children references, IRelationRepository should be a faster, more lightweight way to go, but that’s another story). If you want to get children in a specific language – which is the most common case, you know that you can use the other overload of GetChildren<T>(ContentReference, ILanguageSelector) , where you can specify the language you want to load.

Continue reading “Beware of IContentLoader.GetChildren() for CatalogContent”

Things I wish I knew before playing The Witcher 3: Wild Hunt

The game was released 1 year ago – still – it’s a masterpiece to be played. If you’ve never played it, play it now – it’s easily one of the best games in years, if not decades. The storyline with twists will keep you thinking in a while (no decision is clearly better or worse, and your choices will definitely make impacts on the ending), while the graphic is still one of best in any games, and the gameplay will keep you excited. If you played it – it’s now time to replay it, with new expansions, Heart of Stones and Blood and Wine. They are some of best expansions ever released.

The Witcher 3: Wild Hunt

Truth be told, I was new to The Witcher and Wild Hunt was the first game I played in the series. Now I’m playing it again and sometimes I feel really stupid for not knowing something earlier – thing might have been much easier in my first play.

Continue reading “Things I wish I knew before playing The Witcher 3: Wild Hunt”

Unable to import .bacpac files exported from Azure

Update: I found a faster, more reliable way to import, here

Today when I tried to import a .bacpac file from a customer, I ran across this issue:

Could not load schema model from package. (Microsoft.SqlServer.Dac)

——————————
ADDITIONAL INFORMATION:

Internal Error. The internal target platform type Sql120DatabaseSchemaProvider does not support schema file version ‘2.6’. (File: D:\supportcases\something.bacpac) (Microsoft.Data.Tools.Schema.Sql)

I’m using SQL Server 2014, Developer edition. Searching for the error returns no matched result. However, as the file was exported by Azure v12, we can assume Microsoft should have done something to support the latest version (2.6) in Management Studio.

Continue reading “Unable to import .bacpac files exported from Azure”

What does it take to be a developer?

No I’m not talking about becoming a “developer” like Bill Gates, or Mark Zuckerberg, or even someone less “famous” like Linus Torvald or Anders Hejlsberg. Man, I’d give up many things to become one of those. To become such successful developers, you must be extremely talented, extremely determined, and of course, a sizable amount of luck. I’m talking about an average human being, trying to become a person who can enjoy his work (and hopefully, provide his family with that work). 

Somebody might think, it’s easy to be a developer today. Most problems can be found on the internet – by searching Google, or asking questions on sites such as StackOverflow. Some might even jokingly define “programming = copy and paste answer from StackOverflow”, but we all know that, it takes more than that.

I’ve been trying to answer that question. I’m not a great developer by any mean. A decent, at most (My boss has been saying that I’m doing a very good job, I truly hope he’s not just being nice). It’s been 14 years since I get into programming, 10 years since I made the final decision to be a programmer, when I chose the faculty at my university  and 6 years since I began my professional career as a developer. It’s been all natural to me – what does it take to be a decent developer?

Continue reading “What does it take to be a developer?”

Joel test scores are (somewhat) outdated – you should ask something else

Joel test scores are widely accepted as the “12 golden checks” for interviewee to ask interviewer during an interview. They were originated by Joel Spolsky – and his blog was famous among developers, they were quite well-known – and have been popularized even more with StackOverflow (where Joel Spolsky is one of the founders). StackOverflow Jobs even have a check list for recruiters when they post their job vacancies. Here’s the list:

  • Do you use source control?
  • Can you make a build in one step?
  • Do you make daily builds?
  • Do you have a bug database?
  • Do you fix bugs before writing new code?
  • Do you have an up-to-date schedule?
  • Do you have a spec?
  • Do programmers have quiet working conditions?
  • Do you use the best tools money can buy?
  • Do you have testers?
  • Do new candidates write code during their interview?
  • Do you do hallway usability testing?

The list served its purposes for a long time – and I can say it, to a point – contributed to software industry. When developers are aware of such things, companies need to adapt to attract talents – resulting in better work environments and processes (again, there are companies which do that well before the list, and there are companies do not care about it at all).

Continue reading “Joel test scores are (somewhat) outdated – you should ask something else”

Quicksilver – ServiceApi: fixing issues

From what I heard, developers seem to love both QuickSilver – as a template – and ServiceApi – as a REST server – very much. Despite of being relatively new on the field, they are being used quite frequently – QuickSilver is the preferred choice for MVC template while many sites are using ServiceApi to update the catalogs. What’s about the combination of these two? Would it be the best-of-bread for Episerver Commerce. I would say yes, but after you have fixed the issue.

The installation of ServiceApi.Commerce package to Quicksilver site should be easy and painless. Update the database and build the project, you should be expecting to have a working site.

Not quite. You should be seeing this error:

A route named 'MS_attributerouteWebApi' is already in the route collection. Route names must be unique.
Parameter name: name

It’s because

MapHttpAttributeRoutes

is called twice (as it’s called in ServiceApi as well). So naturally, let’s try by commenting that line in SiteInitalization.cs, and build it again.

This can also be solved by adding this into appSettings:
"episerver:serviceapi:maphttpattributeroutes"

Which will signal ServiceAPI to skip calling

MapHttpAttributeRoutes

A new error would show up:

Continue reading “Quicksilver – ServiceApi: fixing issues”

Never send me my password

I’m not a security expert myself, not even close, but for more than once, I’ve been greatly concerned about the risks for having accounts in several websites. I wonder myself why did the developers there go with the decisions that bad.

It’s already bad enough to use HTTP on your register/login page . It’s even worse when you send me my password in plain text. Either the one I chose or the one you randomly generated for me.

Oh please, I know what my password is
Oh please, I know what my password is

And this has happened more than once. Each time, it raises my eyebrows higher and higher. I don’t want to rant here – but it takes great deal of ignorance or laziness, or both, do do such as bad practice about securities.
Continue reading “Never send me my password”