SourceTree comes with its own embedded Git and Mercurial. These are not available outside on regular command lines by default, but seems you can make them so by adding the following two paths to your
If you try to run for example
SET time_zone = 'Europe/Oslo' on the default MySQL database that comes with WAMP you might get an error saying the time zone doesn’t exist.
Apparently this is because the time_zone tables for some reason are empty.
How to fix
- Go to dev.mysql.com/downloads/timezones.html
- Download the POSIX standard Time zone description tables, version 2011n zip archive
- Extract the files and overwrite the ones in C:\wamp\bin\mysql\mysql5.6.17\data\mysql, or whatever your equivalent path would be
- Restart MySQL
Setting the time zone should now work
I wrote this small PHP script to work as a proxy and as far as I can see it works pretty great. Short and easy to follow as well, so that’s always fun
So basically the script just pipes through whatever headers it gets to the the target URL an pipes back whatever headers it gets in the response. Seems to work, but let me know of weaknesses and easy improvements if you see any
$request_headers = getallheaders();
foreach($request_headers as $key => &$value)
$value = $key.': '.$value;
$url = $_SERVER['QUERY_STRING'];
$limit = 20;
$curl = curl_init();
CURLOPT_URL => $url,
CURLOPT_HTTPHEADER => $request_headers,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HEADER => TRUE,
CURLOPT_NOBODY => TRUE,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_MAXREDIRS => $limit--,
$headers = trim(curl_exec($curl));
$url = curl_getinfo($curl, CURLINFO_REDIRECT_URL);
while($url and $limit > 0);
$headers = trim(substr($headers, strrpos($headers, "\r\n\r\n")));
foreach(explode("\r\n", $headers) as $h)
- The Cookie and Host headers sent from the browser are removed so they don’t mess up the request.
- CURL wasn’t acting properly where I deployed this. It didn’t follow redirects, and curl_exec output content to the browser even with return transfer set to true. So it has a manual workaround for following the redirects and uses output buffering to make sure nothing goes to the browser before we want to.
Had to implement a webshop section for an ASP.NET MVC website project which was to be reused by another one. Solving it was a bit finicky, so documenting it roughly here in case I need to do it again in the future. Not sure I remember all the steps, but hopefully it’ll be enough to reproduce the effect:P
The main problem here is the way razor views are compiled run-time and that is solved by using the Razor Generator VS extension to pre-compile the views and the belonging RazorGenerator.Mvc Nuget package to enable the web application to find them during run-time.
Don’t know if the solution I ended up with is the best, but it worked fairly great. If you have better/cleaner solutions please leave a comment
Continue reading ASP.NET MVC Areas in separate projects/assemblies
Areas in an ASP.NET MVC web application doesn’t use the layout of your web application by default. The reason (as far as I understand) is that your _ViewStart.cshtml which is usually located in ~/Views/ is only visible by views in that folder and its sub-folders.
So the solution, turns out, was more or less just to move that file up a level.
- Move ~/Views/_ViewStart.cshtml to ~/_ViewStart.cshtml.
- Cut or copy the following elements from ~/Views/Web.config and merge them into ~/Web.config. I say merge, because configSections for example probably already exists, so put the sectionGroup inside it. Don’t know if the Web.config handles multiple configSections…
<sectionGroup name="system.web.webPages.razor" ...>
All areas should now use the the same layout as the rest of your application.
- Set the Build Action of your js and css file to Embedded Resource
- Add this extension method to a static class.
public static IHtmlString RawResource(this HtmlHelper html, Type type, string resourceName)
using (var s = type.Assembly.GetManifestResourceStream(resourceName) ?? new MemoryStream())
using (var r = new StreamReader(s))
s.Position = 0;
return new HtmlString(r.ReadToEnd());
- Make sure the extension method is available in your view
- Use the method in your view
Easy peasy. And slightly hackish and ugly… let me know if you have smoother, cleaner bundling approach
If you’re having problems figuring out the right name of your embedded resource, see my post on how to use embedded resources for how to list them all out.
In Unix you have the touch command which you can use to update a files timestamp. No such thing in Windows. But instead, apparently, one can do this:
REM Updates the timestamp of the file
copy /b filename.ext +,,
REM Creates a new empty file
echo $null >> filename.ext
If you need it more than seldom there are also some more tricks in the StackOverflow sources below.
Windows equivalent of the Linux command ‘touch’?
Equivalent of Linux `touch` to create an empty file with PowerShell?