Skip to content

Instantly share code, notes, and snippets.

View vmandic's full-sized avatar
🤠
chillin'

Vedran Mandić vmandic

🤠
chillin'
View GitHub Profile
@vmandic
vmandic / HzzoHtmlScraper.cs
Created October 13, 2018 16:01
meds-processor, part 1 of 6, snippet 2
using AngleSharp;
namespace MedsProcessor.Scraper
{
public class HzzoHtmlScraper
{
readonly IBrowsingContext _browsingContext;
public HzzoHtmlScraper(IBrowsingContext browsingContext)
{
@vmandic
vmandic / AppController.cs
Last active October 12, 2018 12:08
meds-processor, Part 1/6, snippet #1
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace MedsProcessor.WebAPI.Controllers
{
[ApiController, Route("~/")]
public class AppController : ControllerBase
{
public ActionResult Index()
@vmandic
vmandic / cloudSettings
Last active June 23, 2020 12:25
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-06-23T12:25:19.840Z","extensionVersion":"v3.4.3"}
@vmandic
vmandic / batch install vscode extensions
Created July 25, 2018 14:08
Batch install vscode extensions with PowerShell
# Script for batch installing Visual Studio Code extensions
# Specify extensions to be checked & installed by modifying $extensions
$extensions =
"DotJoshJohnson.xml",
"EditorConfig.EditorConfig",
"HookyQR.beautify",
"Leopotam.csharpfixformat",
"ecmel.vscode-html-css",
"formulahendry.auto-close-tag",
@vmandic
vmandic / C# LINQ Eurekas in range
Last active May 31, 2018 21:06
Gets double Eureka numbers for a range from a to b.
public static IEnumerable<double> Eurekas(double a, double b)
{
for (;a <= b;a++)
if (a.ToString().Select((c, i) => Math.Pow(Char.GetNumericValue(c), i + 1)).Sum() == a)
yield return a;
}

An EF Core / OData - Generic Repository 🛠 😵

This library offers an implementation of the Generic Repository Pattern for Microsoft's Entity Framework Core 2.0 ORM supporting the use of OData v4 querying service protocol.

The OData part of the library offers an additional Repository implementation named ODataEfRepository with its complementing interface type IODataEfRepository. The OData Repository exposes several methods that allow querying an IQueryable<T> with OData's query options where the queryable can be produced out of EF's DbSet<T> or any other valid IQueryable<T>. This way you can pre/post filter/select/expand EF queryable sources using OData syntax.

Beta dependency caution 💣

The library currently uses the latest Microsoft.AspnetCore.OData (7.0.0-beta2) to provide OData services and it might be buggy as it is not a stable offical release.

Dictionary<string, string> options = new Dictionary<string, string>()
{
{"$select" , "ID" },
{"$expand" , "ProductDetail" },
{"$filter" , "Categories/any(d:d/ID gt 1)" },
{"$orderby" , "ID desc" },
{"$top" , "1" },
{"$count" , "true" },
{"$search" , "tom" },
};
@vmandic
vmandic / ODataEntityFrameworkModelBuilder.cs
Last active February 2, 2023 14:00 — forked from dariusclay/ODataEntityFrameworkModelBuilder.cs
How to build OData IEdmModel from .NET Framework Entity Framework 6 model
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Data.Entity;
using System.Data.Entity.Core.EntityClient;
using System.Data.Entity.Infrastructure;
using System.Diagnostics;
@vmandic
vmandic / dotnet core .gitignore
Last active June 18, 2025 15:51
A default .NET Core project .gitignore file - or just type `dotnet new gitignore`
# From .NET Core 3.0 you can use the command: `dotnet new gitignore` to generate a customizable .gitignore file
*.swp
*.*~
project.lock.json
.DS_Store
*.pyc
# Visual Studio Code
.vscode
@vmandic
vmandic / git-commit-log-stats.md
Created February 13, 2018 14:11 — forked from eyecatchup/git-commit-log-stats.md
Some commands to get git commit log statistics for a repository on the command line.

git commit stats

Commands to get commit statistics for a Git repository from the command line -
using git log, git shortlog and friends.