Skip to content

Instantly share code, notes, and snippets.

View multiple_ssh_setting.md

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
View FakeDb-2
public class MemoryPersistenceDbSet<T> : IDbSet<T> where T : class
{
ObservableCollection<T> _data;
IQueryable _query;
public MemoryPersistenceDbSet()
{
_data = new ObservableCollection<T>();
_query = _data.AsQueryable();
}
View msbuild-get-date.proj
<Project
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0"
DefaultTargets="Demo" >
<Target Name="Demo">
<PropertyGroup>
<CurrentDate>$([System.DateTime]::Now.ToString(yyyyMMdd-mmss))</CurrentDate>
</PropertyGroup>
@javafun
javafun / ContentReference
Last active Feb 8, 2018
EPiServer - ContentReference Extensions
View ContentReference
using System;
using System.Collections.Generic;
using EPiServer;
using EPiServer.Core;
using EPiServer.ServiceLocation;
using EPiServer7App.EPiServerCore.ContentTypes.Media;
using EPiServer7App.EPiServerCore.ContentTypes.Pages;
using EPiServer.Framework;
using System.IO;
using EPiServer7App.EPiServerCore.Model;
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) {
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
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
/// http://shemesh.wordpress.com/2010/01/22/c-dictionary-get-key-from-value/
/// </remarks>
public static TKey FindKeyByValue<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TValue value)
@javafun
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
/// https://github.com/cymen/ApacheMimeTypesToDotNet
/// </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 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\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation