Skip to content

Instantly share code, notes, and snippets.

View khalidabuhakmeh's full-sized avatar
👨‍⚖️
talking & listening to developers

Khalid Abuhakmeh khalidabuhakmeh

👨‍⚖️
talking & listening to developers
View GitHub Profile
@khalidabuhakmeh
khalidabuhakmeh / wyam_macos_test.txt
Created November 14, 2018 18:48
Wyam .NET Core Running On MacOS .NET 2.1.403
/Users/khalid.abuhakmeh/projects/oss/Wyam/tests/core/Wyam.Configuration.Tests/Wyam.Configuration.Tests.csproj : warning NU1701: Package 'AutoFixture 3.50.6' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project. [/Users/khalid.abuhakmeh/projects/oss/Wyam/Wyam.sln]
Build started, please wait...
Build started, please wait...
Build started, please wait...
Build started, please wait...
Build started, please wait...
Build started, please wait...
Build started, please wait...
Build started, please wait...
Build completed.
var multi = new MultiKeyDictionary<string,string>(StringComparer.OrdinalIgnoreCase) {
{ new [] { "Wonder Woman", "Batman", "Flash", "Cyborg", "Superman" }, "Justic League" },
{ new [] { "Captain America", "Iron Man", "Hulk", "Black Widow" }, "Avengers" },
{ new [] { "Tinky Winky", "Dipsy", "Laa-Laa", "Po" }, "Teletubbies" }
};
multi.TryGetValue("tinky winky", out var value); // Teletubbies
image: Visual Studio 2017
environment:
IGNORE_NORMALISATION_GIT_HEAD_MOVE: 1
cache:
- packages -> **\packages.config, nuget.config
- tools -> build.cake
install:
@khalidabuhakmeh
khalidabuhakmeh / Bound.cs
Created September 16, 2018 17:20
ASP.NET Core Bound<T> Concept
/*
I wish ASP.NET Core had the concept of a `Bound` class. The Bound
class would be accessible to developers and be hydrated by the model binder to not only give
you the value the caller sent, but allow you to understand if the user expressed the intent
to give you that information.
There are multiple reasons why a value may not have been bound:
1. Failed Deserialization
public class UserShoppingCart
// Clearly state what the incoming request will be
// and what the response will be (the response is more for clarity)
: Endpoint<UserShoppingRequest, UserShoppingResponse> {
public ShoppingCartIndex()
:base("cart/{id}", HttpAction.GET)
{
// define how this endpoint should
// be configured
public controller Home {
// GET home/something
GET Something() {
// c# code here
// assumes you are returning IActionResult
return Ok();
}
// POST home/something
public class Authorize {
public string[] Roles {get;set;}
public overload Roles=(string roles)
{
Roles = String.Split(new [] { ',' }, roles);
}
}
var authorize = new Authorize() {
@khalidabuhakmeh
khalidabuhakmeh / json_query.cs
Created September 29, 2017 14:01
I want a DSL (possibly LINQ) that generates a SQL Server JSON query based on models (maybe even the EF context). The underlying relationship of the tables is still relational.
var result = json.People.Select(p => new {
p.FirstName,
p.LastName,
p.Addresses.Select(a => new {
a.StreetAddress,
a.City,
a.ZipCode
}),
PhoneNumbers = p.PhoneNumbers.Select(pn => new {
p.Number,
@khalidabuhakmeh
khalidabuhakmeh / donuts.js
Created August 12, 2017 23:51
Using Google Maps and Places API To Find Donuts
// This example requires the Places library. Include the libraries=places
// parameter when you first load the API. For example:
// <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">
var map;
var infowindow;
function initMap() {
var search = "harrisburg, pa";

There are designers on our team that primarily work on their MacBook Pros. They do their CSS, Js, and HTML work without ever opening Visual Studio. It would be nice if they could at least adopt Razor when developing the views and components. I want to build a utility that can render a snippet / partial view / view without the need to run the application.

> razor-render .

This command would do the following.

  1. Figure out a layout if applicable
  2. Determine the model of all the views and "stub" it