All posts by salik

Angular JS – what the hell

I just got landed a project. A really interesting project. So interesting is this project that there is no money to fund it. Typical eh?

So the story on the this project is that it is a data visualisation project, currently being built at the University of Manitoba. A great institution and my Alma Mater BTW.

Anyway. it seems that this project made a lot of headway with the original author.  But then it was handed to another student and that student made it to a point, and then rewrote it – well attempted to – in Ruby on Rails.

When I read the “Ruby on Rails” bit I was expecting a large application, RR is a MVC framework designed to make large application a breeze to build. Turns out the application is a single page application. Mainly written in AngularJS with D3 charts. AngularJS fetched its data from the RR back end. sigh.

And to make matters even worse..the application is barely functional as compared to the earlier version. This is a typical case that switching platforms to one that allegedly makes things “easier” often doesn’t. You may look at one aspect and think “you know using a framework with a nice database ORM would help here”. And forgetting all the plumbing it takes to achieve a replication of the original.

This should be interesting as we’ve decided to bin the Ruby on Rails version and “go back to the future” and start with the more functional version. I will than use some separate components (like Doctrine) to help and perhaps some of my own classes to bespoke this app, rather than squeeze it into a MVC framework.

Are Cigar lovers being ripped off?

I suppose

I suppose that is a rehtorical title for a post. Because why would I choose to write about cigar lovers and “ripped off” in the same sentance. Of course we are being ripped off!

Humi-Jar

Recently I needed a better place to keep my cigars than in their box – I mainly smoke cigarillos. Not being that up on the cigar area I went out and bought the cheapest “solution” for a cigar humidifier – a Humi-Jar. This is sold online as a true humidifier with a humidification control pack.

Essentially what you get is a large plastic jar and a humidity controller with a bit of velcro so it sticks to the lid of that jar. That jar is large enough to hold about 20 or so cigars. The humidity controller is a small circular disk containing jelly and with adjustable opening. This is meant to allow to control of the humidity inside. No instructions in sight anywhere. I am expected entirely through research and trial and error how to use this.

Apparently one drips a bit of distilled water in the “humidity controller” and removes it from the jar it the humidity gets too high and replace it  when it gets too low. No humidity indicator is included in the kit.

Rip Off

Considering that I can buy a similar sized glass jar from Ikea for £2 – paying £17 for a plastic jar is a mighty rip off in itself.

The purported “humidity controller” is just a plastic-disk with jelly inside and adjustable openings. No instructions are provided, but after research I found that one pours in distilled water into. There is also mention of a “50/50” solution, but I’ve not been able to find out what that is.

There is no humidity indicator included so I would have to buy one and keep it inside and check daily to ensure things don’t get too wet or dry.

Frankly this is rubbish.

My Humi-Jar

I went out and got a £2 glass jar from Ikea. I just happened to be there anyway buying a table so it cost me nothing. To control the humidity I got a Boveda pack – at 69%. these are brilliant, last about 3 months and are reasonably priced. A Boveda pack control the humidity perfectly, its a kind of “set-it-and-forget-it” solution. Which is just what most cigar lovers really need.

So don’t even go near Humi-Jar, it is the biggest scam on the planet.

So if you are considering

A Simple web service with WebAPI

Hello to my first post of 2014. A new year with new opportunities – so people say.

Web Services

There are three main technologies which .Net has to supply web services.

  • WebService built in a .asmx file. I usually just use these for AJAX as part of a web application. There are limitation to this technology which makes it difficult to use by 3rd parties. Mainly that the return result is XML and not JSON and that it only accepts calls by POST.
  • WCF, this is a very flexible and powerful technology but it is also extremely complex and not really conducive to building a simple service.
  • WebAPI, a resonably simple technology based on the MVC pattern (but without the View) part.

In this blog entry I will be provding a small example of a service using WebAPI

a WebAPI Project

There are many WebAPI tutorials available on the web, like this one at MSDN. Where things get interesting is when you have multiple APIs. Then you have to do some dickering around.

For example in my project I had a API which accepted data from a Meraki device and also requests from 3rd parties for weekly update statistical data.

In this case the routing must be added in manually in global.asax


Imports System.Web.SessionState
Imports System.Web.Http
Imports System.Web.Routing
Public Class Global_asax
 Inherits System.Web.HttpApplication

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
 ' Fires when the application is started
 RouteTable.Routes.MapHttpRoute(name:="RetailerAPI", routeTemplate:="api/{controller}/{username}/{password}", defaults:=New With {.username = RouteParameter.Optional})
 RouteTable.Routes.MapHttpRoute(name:="MyAPI", routeTemplate:="api/{controller}/{id}", defaults:=New With {.id = System.Web.Http.RouteParameter.Optional})
 End Sub

End Class

In this scenario we can support two APIs which can be directed to the appropriate controller. It can accept URI of:

/api/Meraki

/api/SalesData/username/pwd

Hopefully this little tidbit of news helped you out.

Brute Force

Lately

I’ve been dealing with a lot of brute force attacks against this site. As a result I have had to block hundred of IP addresses. Luckily I’ve got security measures on the site that inform me of suspicious activity and I can take appropriate action.

As always follow best practises. Here are 10 tips to secure your Word Press site.

Saving viewstate in repeater with droplists

Viewstate

Viewstate is that wonderful feature of ASP.Net webforms which saves away the initial states of control so you don’t have to reload them on page cycle. This can have quite significant performance gains over reloading the controls, especially if they are loaded from a database.

But viewstate can also cause your page size to bloat massively. I have on occasion working on some pages with clients where the page size was 2 Megabytes. That was before images. Eeek.

Scenario

In this scenario I have a repeater with a variable number of items. Each item has a drop list which could contain several hundred items. The viewstate will become quite large in this situation because ASP.Net will store viewstate for each control.

Continue reading Saving viewstate in repeater with droplists