Skip to content

Instantly share code, notes, and snippets.

View Eonasdan's full-sized avatar

Eonasdan Eonasdan

View GitHub Profile
@Eonasdan
Eonasdan / MinecraftSounds.java
Created October 28, 2015 21:33
strongly typed class file of Minecraft default sounds
public class MinecraftSounds {
public static String AmbientCaveCave = "ambient.cave.cave";
public static String AmbientWeatherRain = "ambient.weather.rain";
public static String AmbientWeatherThunder = "ambient.weather.thunder";
public static String GamePlayerHurtFallBig = "game.player.hurt.fall.big";
public static String GamePlayerHurtFallSmall = "game.player.hurt.fall.small";
public static String GameNeutralHurtFallBig = "game.neutral.hurt.fall.big";
public static String GameNeutralHurtFallSmall = "game.neutral.hurt.fall.small";
public static String GameHostileHurtFallBig = "game.hostile.hurt.fall.big";
public static String GameHostileHurtFallSmall = "game.hostile.hurt.fall.small";
@Eonasdan
Eonasdan / Routing-Areas.tt
Last active April 3, 2016 20:14
Creates a strongly typed MVC urls: see http://vikutech.blogspot.com/2014/11/strong-typed-mvc-routing-on.html. Routing-Areas.tt is an enhancement to the original attempting to check if the route is in a Area. Routing-JsonResults.tt limits the generation to JsonResult Actions
<#@ template debug="true" hostSpecific="true" #>
<#@ assembly name="System.Core" #>
<#@ Assembly Name="EnvDTE" #>
<#@ import namespace="EnvDTE" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".ts" #>
module Routing {
<#
@Eonasdan
Eonasdan / css steal.html
Created September 26, 2016 19:27
CSS Steal
<script>
(function () {
var CSSSteal = function () {
var api = {}, html = null, styles = [], indent = ' ', elements = false, args = arguments;
var requirements = function () {
if (args.length === 0) {
throw new Error('CSSSteal expects at least one argument (DOM element)');
}
@Eonasdan
Eonasdan / Amazon Book to public library search.md
Last active January 17, 2018 21:28
Search local public libraries from Amazon using these Bookmarklets

Amazon Book to public library search

image

Each of the sections below allow you to click on a bookmark/favorite to quickly search your local public library for a book you are looking at on Amazon. The goal is to save money (and bookshelf clutter :)) so you can check out a book (see what I did there?) instead of buying it first.

##Quick Guide

Here's how you use these. It's probably going to be easiest to copy the bookmarklet code by clicking "Raw":

@Eonasdan
Eonasdan / ExceptionHandlerMiddleware.cs
Last active February 9, 2018 21:33
Borrowed ExceptionHandlerMiddleware from Microsoft.AspNetCore.Diagnostics/Internal/DiagnosticsLoggerExtensions.cs that takes area into effect.
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
@Eonasdan
Eonasdan / Packages XML to C# paste
Created December 31, 2016 04:06
parsing package.config for nuget package explorer
/// <remarks/>
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class packages
{
private packagesPackage[] packageField;
@Eonasdan
Eonasdan / AddClassHelper.cs
Last active February 15, 2018 16:58
MVC core tag helper for my Bootstrap 4 datapicker https://github.com/tempusdominus/bootstrap-4. Easy to modify for BS3.
/// <summary>
/// Adds <paramref name="newClass"/> to <paramref name="output"/> or appends it.
/// </summary>
/// <param name="output"></param>
/// <param name="newClass"></param>
public static void AddClass(this TagHelperOutput output, string newClass)
{
var classAttribute = output.Attributes.FirstOrDefault(a => a.Name == "class");
if (classAttribute == null)
{
@Eonasdan
Eonasdan / SerializeViewModel.cs
Created March 1, 2018 15:56
a C# MVC helper to take an model object and convert it to a serialized object
public static HtmlString SerializeViewModel(this HtmlHelper helper, object viewModel, JsonSerializerSettings serializer = null)
{
if (serializer == null)
{
serializer =
new JsonSerializerSettings {ContractResolver = new CamelCasePropertyNamesContractResolver()};
}
return new HtmlString(JsonConvert.SerializeObject(viewModel, serializer));
}
@Eonasdan
Eonasdan / ReSharper Magic Tricks - Live Templates.dotSettings
Last active March 9, 2018 13:03
My Exported Custom Live Templates, Structural Search and Replace and Code Inspectors for ReSharper. See my blog post: http://www.eonasdan.com/home/resharper-magic-tricks. To import these settings, save the file, open VS, ReSharper Menu, Manage Options, Import from File. You can also import from the raw git
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=14EE3F794AD14C4CB6DD37A9E2006F57/@KeyIndexDefined">True</s:Boolean>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=14EE3F794AD14C4CB6DD37A9E2006F57/Applicability/=Live/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=14EE3F794AD14C4CB6DD37A9E2006F57/Reformat/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=14EE3F794AD14C4CB6DD37A9E2006F57/Shortcut/@EntryValue">ajax</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=14EE3F794AD14C4CB6DD37A9E2006F57/ShortenQualifiedReferences/@EntryValue">True</s:
@Eonasdan
Eonasdan / !ReadMe
Last active July 14, 2018 14:42
SQLite EF Style Migrations
Note: IFileService is not completely necessary unless you’re doing Xamarin Forms and need.