Skip to content

Instantly share code, notes, and snippets.

View msbuild-get-date.proj
DefaultTargets="Demo" >
<Target Name="Demo">
View hosts.ps1
# Powershell script for adding/removing/showing entries to the hosts file.
# Known limitations:
# - does not handle entries with comments afterwards ("<ip> <host> # comment")
$file = "C:\Windows\System32\drivers\etc\hosts"
function add-host([string]$filename, [string]$ip, [string]$hostname) {
javafun / MimeTypeHelper.cs
Created Jun 26, 2014
Get mime type from extension and vice verse
View MimeTypeHelper.cs
/// <summary>
/// Thanks for cymen's mimetype collection
/// </summary>
private static Dictionary<string, string> mimeTypes = new Dictionary<string, string>
{ "123", "application/vnd.lotus-1-2-3" },
{ "3dml", "text/vnd.in3d.3dml" },
{ "3g2", "video/3gpp2" },
{ "3gp", "video/3gpp" },
View QueryStringExtenions.cs
public static T GetValue<T>(this NameValueCollection collection, string key)
if(collection == null)
throw new ArgumentNullException("collection");
var value = collection[key];
if(value == null)
javafun / IDictionaryExtensions.cs
Created Jun 26, 2014
Find dictionary key by value
View IDictionaryExtensions.cs
public static class IDictionaryExtensions
/// <summary>
/// Get key by value from dictionary
/// </summary>
/// <remarks>
/// Thanks for shemesh's neat solution
/// </remarks>
public static TKey FindKeyByValue<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TValue value)
View NiceUrl
var root = CurrentPage.AncestorsOrSelf(1).First();
var url = umbraco.library.NiceUrl(root.Id);
var withDomain = umbraco.library.NiceUrlWithDomain(root.Id);
View launch_sublime_from_terminal.markdown

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\

You can find more (official) details about subl here:


View EnumDropdownExtenstions.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace System.Web.Mvc.Html
View ImportedFilePathResolver.cs
public class ImportedFilePathResolver : IPathResolver
private string currentFileDirectory;
private string currentFilePath;
/// <summary>
/// Initializes a new instance of the <see cref="ImportedFilePathResolver"/> class.
/// </summary>
/// <param name="currentFilePath">The path to the currently processed file.</param>
public ImportedFilePathResolver(string currentFilePath)
javafun / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console