Skip to content

Instantly share code, notes, and snippets.

View JimBobSquarePants's full-sized avatar
💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)

James Jackson-South JimBobSquarePants

💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)
View GitHub Profile
@haacked
haacked / ModelBuilderExtensions.cs
Last active November 21, 2024 12:28
Example of applying an EF Core global query filter on all entity types that implement an interface
/*
Copyright Phil Haack
Licensed under the MIT license - https://github.com/haacked/CodeHaacks/blob/main/LICENSE.
*/
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@terrajobst
terrajobst / SplitByNamespace.cs
Created July 10, 2018 23:36
Split files by namespace
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace NetStandardCleanup
@davidfowl
davidfowl / Global.asax.cs
Last active July 8, 2024 22:23
ASP.NET MVC and ServiceCollection sample
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Microsoft.Extensions.DependencyInjection;
using WebApplication16;
using WebApplication16.Controllers;
public class Configuration
{
public MemoryManager MemoryManager { get; set; } = SharedPoolingManagedMemoryManager.Instance;
public static Configuration Default { get; }
// ...
}
public interface IDecoderOptions
public struct Fast2DArray<T>
{
public T[] Data;
public int Width;
public int Height;
public Fast2DArray(T[,] data)
{
this.Height = data.GetLength(0);
@MehdiNS
MehdiNS / bayer_matrix.cpp
Created October 31, 2016 13:49
Generate the bayer matrix of order n (of dimension 2^n x 2^n) iteratively
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
using uint = unsigned int;
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec)
{
@jbreuer
jbreuer / ContentExtensions.cs
Created May 18, 2016 14:59
An extension method to convert an IContent to an IPublishedContent.
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ContentExtensions.cs" company="Colours B.V.">
// © Colours B.V. 2015
// </copyright>
// <summary>
// The content extensions.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Project.Web.Core.Extensions
@davidfowl
davidfowl / Example1.cs
Last active September 2, 2024 12:36
How .NET Standard relates to .NET Platforms
namespace Analogy
{
/// <summary>
/// This example shows that a library that needs access to target .NET Standard 1.3
/// can only access APIs available in that .NET Standard. Even though similar the APIs exist on .NET
/// Framework 4.5, it implements a version of .NET Standard that isn't compatible with the library.
/// </summary>INetCoreApp10
class Example1
{
public void Net45Application(INetFramework45 platform)
@lukas-h
lukas-h / license-badges.md
Last active December 3, 2024 08:23
Markdown License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.

Notes

  • The badges do not fully replace the license informations for your projects, they are only emblems for the README, that the user can see the License at first glance.

Translations: (No guarantee that the translations are up-to-date)

module tweak {
function getViewUrl(viewName: string) {
return `/App_Plugins/tweaks/views/${viewName}.html`;
}
export class views {
static mediaPicker = getViewUrl("media-picker");
}