This error has greeted me several times before in the past when working with Msysgit on Windows. It alway appears for no apparent reason; sometimes from one boot to the next, and sometimes it suddenly starts happening while the system is running. Once the error is there, it stays consistently at the very least until the next reboot. Sometimes it only happens for specific commands like “git log”, sometimes it seems to affect every cygwin command.
Continue reading Msysgit couldn’t reserve space for cygwin’s heap
2012
You are browsing the site archives for 2012.
Yesterday, I listened to an episode of the .NET Rocks podcast featuring Scott Hanselman and Chris Sells talking about HTML and JavaScript in today’s modern web. While the episode is essentially hysterically funny and I quite like Hanselman and his (at times) extremely helpful blog posts, there is a lot in this particular episode that rubbed me the wrong way and I somehow need to get this off my chest.
Continue reading Why “Browser OS” is a stupid idea
Recently I stumbled on a piece of PowerShell syntax that confused me massively on first glance
$ some-command |% {some-expression}
It took me a while to find the documentation for that since I was of course looking in the wrong place. It looked to me like some sort of special pipe, when in fact it is just a pipe “|” followed by the ForEach-Object CmdLet which has an alias that (unfortunately) is “%”. So what was actually happening is:
$ some-command | ForEach-Object {some-expression}
For example, I used this to basically fill in some placeholders in a template file
$ Get-Content "mytemplate.txt" |% {$_ -replace "PLACEHOLDER", "42"}
I work quite a bit with Git these days and I do that cross-platform. On Windows I tend to use msysgit (with the GIT Bash) since I already know my way around the Git command line and quite frankly, I like it. One of the things I always have to Google together from different sources is how to get an SSH setup that allows me to authenticate with Github and my own repositories using public/private keys. Continue reading OpenSSH Configuration
If you need to add attributes on properties in a generated class, you can do this by using following pattern.
[MetadataType(typeof(TimeFrame_Extension))] public partial class TimeFrame { } public class TimeFrame_Extension { [XmlIgnore] public string From { get; set; } [XmlIgnore] public string To { get; set; } }
source : http://ardalis.com/adding-attributes-to-generated-classes
I’ve implemented a google map which loads the markers according the current viewport. This can result in a lot of requests if a user is panning / zooming wildly.
Here’s a pattern which cancels requests and only processes the last one:
// Globals var currentRequestID = 0; var currentRequest; var requestTimer; // Add the Event for reloading the Markers google.maps.event.addListener(map, 'idle', function () { SingleProcessMarkerLoading(map); }); function SingleProcessMarkerLoading(map) { // Clear the "Queue" clearTimeout(requestTimer); // Abort if a Request is running if (currentRequest) { currentRequest.abort(); } // Start a new Request requestTimer = setTimeout(function () { // Get the RequestID, increase for the next Request localRequestID = ++currentRequestID; // Load the markers LoadMarkersForCurrentViewport(map, localRequestID); }, 500); } function LoadMarkersForCurrentViewport(map, localRequestID) { // Get the current Bounds var bounds = map.getBounds(); // Get the Points var swPoint = bounds.getSouthWest(); var nePoint = bounds.getNorthEast(); // Get the Coordinates var swLat = swPoint.lat(); var swLng = swPoint.lng(); var neLat = nePoint.lat(); var neLng = nePoint.lng(); // Calculate an Adjustment for increasing the Viewport a little var increasePercentage = 0.1; var latAdjustment = ((neLat - swLat) * increasePercentage); var lngAdjustment = ((neLng - swLng) * increasePercentage); // Adjust swLat -= latAdjustment; swLng -= lngAdjustment; neLat += latAdjustment; neLng += lngAdjustment; // Build the Url to get the Markers for the Viewport var url = 'someurl?' + swLat + '|' + swLng + '|' + neLat + '|' + neLng; // Get the JSON-Response and process it currentRequest = $.get(url, function (data) { // Check if the Request is obsolete if (localRequestID != currentRequestID) return; // Process the Data here }); return; }
Sometimes you want to step into Source Code which comes from the core components of Microsoft. You can either decompile the .Net Libraries with .Net Reflector or ILSpy or use the Microsoft Reference Source Code Packages.
The Reference Source Code allows you to directly lookup the source or even debug into the core components of Microsoft. Just download the Packages you want, install them and you’re done. You now can Debug into (F11) the source or look it up (F12).
Alternative for Visual Studio 2010
Setting up Visual Studio 2010 to step into Microsoft .NET Source Code
Those tags are evaluated during the Render part of the page’s load cycle. See here for more information.
Displaying (<%= … %>)
Displays the given value as a string.
http://msdn.microsoft.com/en-us/library/6dwsdcf5(v=vs.100).aspx
Displaying with Encoding (<%: … %>)
Displays the given value as string but HTML-Encodes it before.
If you’re sure that the given string is already html-encoded, use it like this:
<%: new HtmlString("<strong>HTML that is not encoded</strong>") %>
http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx
Data-Binding (<%# … %>)
Those are resolved when the DataBind method of the control or the page is called.
http://msdn.microsoft.com/en-us/library/ms178366.aspx
Server-Side Comments (<%– … –%>)
Used to comment out code/controls which then won’t be processed.
http://msdn.microsoft.com/en-us/library/3207d0e3.aspx
Server-Side Includes (<!– #include file|virtual=”filename” –>)
Used to insert to content of a given file within the current position.
http://msdn.microsoft.com/en-us/library/4acf8afk.aspx
Embedded Code Blocks (<% … %>)
Used to run some code without returning anything.
http://msdn.microsoft.com/en-us/library/ms178135(v=vs.100).aspx
Expressions (<%$ … %>)
Used for expressions instead of code.
http://msdn.microsoft.com/en-us/library/d5bd1tad.aspx
Directives (<%@ … %>)
Specifies settings for the page or imports and such.
http://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx
I do need some delegates from time to time (like when using threads in a WinForms App). But I’m too lazy to declare all needed delegates, especially if they have none or only very few parameters.
Luckily, there are some predefined delegates which can be used for that.
Here’s a list of some of those:
EventHandler // Default event callbacks EventHandler<T> // Default event callbacks with custom parameter (inheriting from EventArgs) Action<T1, T2, T3, T4> // Function without return value and 0-4 parameters Func<T1, T2, T3, T4, TResult> // Methos with 0-4 parameters and one result type Predicate<T> // equivalent to Func<T, bool>
And here’s a very simple example:
private void InvokedClose() { if (InvokeRequired) { Invoke(new Action(InvokedClose)); } else { this.Close(); } }