-
Add Open With Sublime Text 2 to Windows Context Menu
Just a quick tip, you can use this .bat file to add Open with Sublime Text 2 to the Windows right click context menu. I assume that you would need administrator privileges to run this command.
@echo off SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe rem add it for all file types @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f rem add it for folders @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f pause
-
ContentResult or ViewResult Response Based on Context
In .NET MVC there are times where you may want to return either a
ContentResult
orViewResult
depending on the situation. For example you may want to return anapplication/json
result for an API request but a structured view with timing information (such as when using MiniProfiler) when visiting the route in the browser.I had to find out how to construct the different types of results separately first. The main properties that need to be set for a new
read more...ViewResult
object are the ViewName and the ViewData. ViewData has a Model property where you can set the model that you would like to return with the view. TheSimpleResponse
model is a simple model that just has a JSON property that I use to display the JSON output of an API route in a nicely-formatted way. -
Custom UTC DateTime Model Binding for MVC
When working with sending UTC DateTimes via HTTP POST to a .NET Web API or MVC route, the dates are converted by the model binder into the server’s local time format before being inserted into the database or being used for whatever you want. This is because .NET MVC handles DateTime Model Binding for HTTP POST and GET differently.
The initially surprising piece of information that it transpires that it actually matters whether you have set the HTTP method to be a GET or a POST.
There are perfectly valid reasons for this that are described in MVC ModelBinder and Localization the article that this quote is from</a>, but sometimes you want to keep the DateTimes as UTC to be inserted into the database over HTTP POST. Thankfully, this is fairly easy to do by implementing custom UTC DateTime model binding.
read more... -
Enable Gzip Compression in IIS
This article is likely no longer relevent, follow the instructions at your own risk!For an API I am building, I needed to enable Gzip compression in IIS Express for JSON and came across GZip response on IIS Express.
There are just two commands to run. This example is for IIS Express but the same commands work in IIS:
cd %PROGRAMFILES%IIS Express appcmd set config -section:urlCompression /doDynamicCompression:true appcmd set config /section:staticContent /+[fileExtension='.json',mimeType='application/json'] appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json',enabled='True']" /commit:apphost
Then, restart IIS or IIS Express afterwards. Gzip compression is very beneficial, and it lowered response sizes for JSON API requests dramatically, sometimes by greater than 50%.
-
Service Timestamp Issue for DocuSign
I ran into this service timestamp issue with our server that sends Envelopes to DocuSign the e-signature service that we use at work. The Envelopes are sent through a SOAP web service endpoint, which we are sending to via a Window service hosted on an Amazon EC2 instance. We got this error out of nowhere, which can occur for any web service, not specifically DocuSign’s.
An error was discovered processing the header -- WSE065: Creation time of the timestamp is in the future. This typically indicates lack of synchronization between sender and receiver clocks. Make sure the clocks are synchronized or use the timeToleranceInSeconds element in the microsoft.web.services3 configuration section to adjust tolerance for lack of clock synchronization. Server stack trace: at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at Microsoft.VisualBasic.CompilerServices.Symbols.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) at DocuSignLibrary.Document.SendToDocuSign(Envelope Document, List`1 Recipients, Object Envelope
I found the solution in the article Automatic time update in Windows (sync with internet time a.k.a NTP server ). I checked the server time and it was about 5 minutes ahead of the correct UTC time. I have no idea how it got out of sync, or how it continues to do so, but to fix it all I had to do was right click on the clock, click Adjust Date/Time > Internet Time > Change Settings > Update Now. It fixed the service error and Envelopes continued to send, but we have no idea why the time continues to slip out of sync. If anyone else has experienced this problem let me know in the comments!
-
.NET MVC 4 Model Binding Null on Post
This was an extremely frustrating problem I came across when building an API using .NET MVC 4. I was using HTTP POST to send a model to the API using JSON, and relying on the built in Model-binding to correctly interpret the JSON and convert it to a model. However, for one particular model none of the properties were binding correctly. After a lot of head scratching and threatening my computer screen, I found this post by Anders Åberg
read more... -
Moving SVN Branches and Repos
Just a quick tip, if you need to move a SVN branch or folder around inside the repository, use the following command:
svn move https://svn_server/svn/repo/branches/folder https://svn_server/svn/repo/branches-graveyard/folder --message "Moving branch to graveyard"
This command can be useful when you need to move an old branch into archive or perform other branch administration in your SVN repository. At work we are using Visual SVN server, so I had to run the command in the
C:\Program Files (x86)\VisualSVN Server\bin
folder.One final thing, you must have a commit message when running the SVN move command otherwise it will not work. For more information visit this superuser question:
-
Visual Studio 2013 Avoid Copying Blank Lines by Dirk Strauss
This has to be one of the most annoying features of Visual Studio. Why would anyone ever need to copy blank lines? Enter key broken? Don’t know what an enter key is? Then lucky you can copy blank lines with Ctrl+C! Seriously this is how to turn it off:
Visual Studio 2013 Avoid Copying Blank Lines by Dirk Strauss
-
Run AWS Elastic Beanstalk Config Commands Only Once
This article is likely no longer relevent, follow the instructions at your own risk!The Elastic Beanstalk on Amazon Web Services is a service used to deploy your application to the cloud. Amazon then handles all of the provisioning of instances, loading assets on S3, configuring load balancers and running your server software such as IIS. Configuring what happens when you deploy using Elastic Beanstalk is fairly straightforward, and for more in-depth commands an Elastic Beanstalk Configuration File can be deployed with the application. The configuration file is YAML-based, and can be used to download and install MSIs and other packages and also run commands on the instance. You can read more about them here.
read more... -
Box-Sizing Border-Box for CSS Grids
I was working on a grid system in CSS for a style framework I’m making for work, and I ran into a few problems when styling the grid. Specifically, I was having trouble with aligning all of the columns side-by-side while simultaneously giving each column sufficient padding. There is a CSS property called
read more...box-sizing
, which has a default value ofcontent-box
. The problem with this is that for block elements such asdivs
, properties like borders and padding add width to the element, even if it already has a fixed width. This is particularly troublesome with grids, because we need to have each column the correct width regardless of padding applied to it.
<< Previous | 8 // 11 | Next >> |
Want to read regular updates? Subscribe via RSS!