28
Fiddler, Visual Studio and Localhost working together!
0 Comments | Posted by Dann in Uncategorized
I found two new tricks to make all these things work together for debugging a Visual Studio Asp.Net web project on Localhost. Here they are:
- Disable IPv6 – This stops the “Fiddler: No connection could be made because the target machine actively refused it” message. (Credit to Mike Ormand) This happens as visual studio will not allow external connections to the “test” server it creates, so all requests must be local.
For some reason it treats fiddler IPv6 connections as external, and therefore nothing works through the fiddler proxy.
- Instead of using localhost, use localhost. <- notice the fullstop / period on the end of the localhost. This makes it look external, so the requests show up in your Fiddler GUI.
And there you go! A working Fiddler session off the Localhost.
24
Employers: Codility for testing your applicants!
0 Comments | Posted by Dann in Uncategorized
This is about Codility Candidate Testing
I just did a test on Codility and it’s great! In fact, this is sooo much than PreVisor (http://select2perform.com) which I had to use the other day.
You can write your code in any language (as long as its in Java, C#, C++, Javascript, Ruby, Pearl, Python, Pascal, C and I think a few more)
Maybe I like it because I did so well
You have a simple test system initially so you can check if your code compiles and fits the initial test. Then you submit it to the hard core tests which tries to break it, and you get a score.
The analysis is very cool:
And I know why i failed test 4. Should have used double instead of int. But that’s why you use TDD, ‘cause those mistakes are easily made.
I needed the outlines of most countries for a simple GIS project that I’m doing. I managed to find a world simple shapes file from http://mappinghacks.com/ called TM_WORLD_BORDERS_SIMPL-0.2.zip
This was in a shapes format used by ARC GIS and the likes, but I needed it in an easy to consume manner i.e. XML
So taking it, feeding it through MapWindow GIS and a shareware plugin “Shape2Earth” (a shapefile to KML converter) I received a KML file out the other side.
As it was a bit bloated, I built a console app using some hideous code turned it into a nice usable XML doc.
Here’s an example of the result showing the UK, France, etc, produced in DeepEarth:
Deciphering should be pretty easy. Here is the rundown:
A country has a name and ISO3 tag and one to many polygons.
Each polygon has one outer bound (outer island) and zero to many inner bounds (inner islands) for where the country isn’t (as in Swaziland inside South Africa).
Easy stuff. Here’s the zipped download:
Let me know where you use it!
There is no licence except where mappinghacks.com applies one, but I couldn’t see one there. Tell me if I’m wrong.
Just made a quick and dirty Ubiquity command for StackOverflow searches.
Download from GitHub: Ubiquity StackOverflow Search
Don’t know Ubiquity?
It’s like a Command Line for the web but… it’s really cool! Trust me. Watch the clip below. Sure it starts out dull, but then so does District 9. Then bam, explosions and stuff! It’s not 0.1 anymore either, so ignore that bit.
The link to get it is https://mozillalabs.com/ubiquity/
Then go to about:ubiquity and read the Commands. There are lots!
29
Is Firefox using all your CPU? It’s probably Adobe Flash
0 Comments | Posted by Dann in Tips
But how do you fix it? The weird thing is that to fix it, you install another program: Adobe Shockwave
Don’t know how or why, but it fixes the high CPU usage where Firefox sits at 99% or 100%
Strange huh?
You should probably update Adobe Flash while you’re at it anyway. Do it first, that way it’s all associated nicely.
21
Godaddy Hosting – Medium Trust vs Inversion of Control
0 Comments | Posted by Dann in ASP.Net, godaddy
Whatever I think of Godaddy, they haven’t caused me too much pain yet, just minor inconvenience. This time it’s my precious StructureMap.
StructureMap, I like it and alot of people do, but it just won’t work under Medium Trust! So it’s either time to change Hosts, or change IoC container. Pretty obvious which one is the easier choice here.
So what choice do you have? Well not much. So the answer is:
Here’s a nice manual to go with it.
And what’s not able to be run in medium / partial trust:
Windsor Castle
Spring.Net
StructureMap
There was someone who was explaining how to download and build Spring.Net to allow it to run under Medium Trust, but that seems pretty likely to cause issues when you hack code (try to ignore my NHibernate post when I say that).
It may be the same for the other 2, but off the bat, Unity wins.
*Caveat: Unity is restricted in what it can do when run without ReflectionPermission (which is what Medium Trust disallows), but typically this won’t affect much from the normal IoC behaviour. The restrictions are explained on this MSDN doc, but it’s to do with internal and private constructors and properties. If it’s public you should be sweet.
13
NHibernate, IoC and removing that damn Log4Net dependency
0 Comments | Posted by Dann in ASP.Net
Ok, so Log4Net is not that bad. It is a very good logging system, etc…
So how do you perform IoC with the NHibernate logger? Well, you can’t. Unless you are ready to HACK CODE.
That’s the brilliant thing about open source. Take it and modify until its the shade of green that suits you.
The First Warning
If you modify the DLL for NHibernate, then all associated DLL’s break.
For me this means FluentNHibernate wont like you. So you will have to rebuild that too for the new NHibernate DLL.
According to the bug report for exactly this issue, in the future log4net will be removed as a dependency (yay). For the logger interface Commons.Logging has been “sort-of” chosen. Meaning: you should use the ILog interface from Commons.Logging for your Log interface! Make’s it a bit more future proof.
What I did to have IoC : 2nd Warning – This is not a concise walkthrough
- Download the source code of
- NHibernate – Under the Browse Files you will find a SRC version.
- FluentNHibernate – Download from GitHub
- Commons.Logging
- Create a new Interface called ILog that is inside the NHibernate project. This is because it will be used as an adapter for the Commons.Logging. It’s probably best to put under a smart namespace like NHibernate.Logging.ILog
- Create a LogManager class that does the same thing as the log4net LogManger, but using the Commons.Logging assembly. I know this is vague, but my implementation wasn’t very good. The idea is that when NHibernate is called, the LogManager is setup using the Commons.Logging.ILog object that was returned by my IoC object factory.
- Remove the References of log4net from the projects
- Replace all namespaces of log4net with the namespace of your new Interface and LogManager (say NHibernate.Logging).
- Remove all Log4Net residue, like Cfg calls and XML setup arguments.
- Build and everything should be happy.
This is a direct quote from the Wikipedia page on Global.asax. Just thought it would be nice to a quick list to refer to.
- Application_Init
- Fires when the application initializes for the first time.
- Application_Start
- Fires the first time an application starts.
- Session_Start
- Fires the first time when a user’s session is started.
- Application_BeginRequest
- Fires each time a new request comes in.
- Application_EndRequest
- Fires when the application terminates.
- Application_AuthenticateRequest
- Indicates that a request is ready to be authenticated.
- Application_Error
- Fires when an unhandled error occurs within the application.
- Session_End
- Fires whenever a single user Session ends or times out.
- Application_End
- Fires when the application ends or times out (Typically used for application cleanup logic).
I had some time trying to work out the details on the ol’ neufbox, so here is a hint for getting it to be in English which makes life easier for non-francophones:
- Hold down the green button on top of the neufbox until it starts flashing purple (takes about 5 seconds)
- Go to the neufbox Configuration Page Maintenace –> Personnalisation page.
– usually http://192.168.1.1/6_3 - Click the “Continuer” button (should still be flashing purple on the box)
- Change the language to Anglais (English) and click “Valider”
Done!
A handy list of ActionResult’s that I found on StackOverflow thanks to Chris.S and his reference to the MSDN doc.
ContentResult
Writes a string value directly into the HTTP response.
EmptyResult
Does not write to the HTTP response.
FileContentResult
Takes the contents of a file (represented as an array of bytes) and write the contents into the HTTP response.
FilePathResult
Takes the contents of a file at the given location and writes the contents into the HTTP response.
FileStreamResult
Takes a file stream produced by the controller and writes the stream into the HTTP response.
HttpUnauthorizedResult
A special result used by authorization filters when authorization checks fail.
JavaScriptResult
Responds to the client with a script for the client to execute.
JsonResult
Responds to the client with data in JavaScript Object Notation (JSON).
RedirectResult
Redirects the client to a new URL.
RedirectToRouteResult
Renders the specified view to respond with an HTML fragment (typically used in AJAX scenarios).
PartialViewResult
Renders the specified view to respond with an HTML fragment (typically used in AJAX scenarios).
ViewResult
Renders the specified view and responds to the client with HTML.
