Every once in a while you need to have access to a json api from another domain.

Thankfully there’s a mechanism to allow this. This Mechanism is called CORS

So before any JSON request is allowed a Options requst will be sent to the corresponding ressource and expects a „Access-Control-Allow-Origin“ header to be present.

There can be different values set for this which is explained in the linked article.

To enable this globally for a NancyFX Module you have to put the following code into it.

Hopefully this will help some folks out there

Well tonight I encountered an interesting Problem. My Apple Mail refused to connect to my mailserver. At first I thought maybe my security constraints are the cause for this but I couldn’t be more wrong. After some digging in the logs which continously showed the following

I rand some google searches and found out that the main problem is the gmail XOAuth2 mechanism. If you have multiple Accounts registered in Apple Mail with the the checkbox enabled for „Automatically detect and maintain account settings“ the program somehow thinks every mailserver uses XOAuth2. Well after unchecking this for incomming (IMAP) and outgoing (smtp) it worked again without any change required on the corresponding mailserver.

 

WHY YOU NO TEST YOUR FUCKING MAILSHIT APPLE?

As I needed to export some data to an xlsx (Excel 2007+) file I first used the Microsoft OpenXML library called DocumentFormat.OpenXML.

At first it look good but had some major performance issued while using the object oriented style. I switched over to the OpenXMLWriter (SAX) but this introduces another class of problems like corrupted files. The Documentation is a pile of shit and after some while i gave up and reimplemented my export with NPOI.

To have it a little simpler i wrote some helper functions to do the cell and row injection. The result is as follows.

 

 

I had to implement a copy to clipboard functionality for our Control Panel which lists Orders.

Since I’m a total enemy of flash I pursued a solution suitable for my needs and here it is.

This is based on http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript but I removed most of the styling and simply put the textarea outside of the viewport.

 

>> The Code!!

First create the helper function in your controller (this can be move to a helper service as well if you wan’t)

 

And now simply bind it to your Element like this

This solution currently supports the following browsers.

Desktop:

  • IE 9+
  • Firefox 41+ (below that you have to enable copy in the user.js but since it’s enabled by default in the next Stable I don’t really care)
  • Chrome 42+
  • Opera 29+
  • Safari has no support for this sadly 🙁

Mobile:

  • Chrome for Android 42+
  • Firefox Mobile 41+

I’m quite happy with this and maybe someone will find this useful.

 

Well it has been a long while again, but I’ve been crazy busy at work.

I worked on a couple of interesting Single Page Applications written with Angular and I really like it because the Framework is so simple to use and very well documented with a crapload of nice plugins and extensions from the community. Anyhow I needed to implement some sort of internationalization and angular has a nifty extension called angular-translate which I used for that. In the process we created an i18n self hosted service in c# with nancy with a simple rest api where I can get a list of available languages for specific domains. Domains in this context are just language sections so that I only have to request and transfer the sections actually in use. The angular plugin has a nice way of supporting it with „partials“

so include the partials-loader and url-loader for angular-translate and set it up the following way:

 

This sets up the angular-translate plugin to work with partials which are loaded on demand from an rest service.

Since we are lazy we wanted to have some sort of automatically adding missing translations to the system.

The registered function in useMissingTranslationHandler handles this for us.

The handler is implemented as a angular factory and sends missing translations to a Model which hols a queue to bulk insert the translations to the i18n service.

This is done since we would exceed the allowed number of ajax connections on large applications at the first startup

I’m quite happy with this solution even though I think it has some room for Improvement.