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
[
{
"id" : "1483228800-2017-01-01-test-search-excerpt",
"site" : "Test",
"title": "Test Search Excerpt",
"url": "http://localhost:4000/2017/01/01/test-search-excerpt.html",
"categories" : [],
"tags" : [],

Note that Title in the result ends with a ), but in the highlight result it is missing. What going on?

Mapping

{
  "content-search-sites-20-01-2017-16-12-22": {
    "mappings": {
      "searchindexdocument": {
        "properties": {
public class Document {
public string Id {get;set;}
public string Site {get;set;}
}
I would like the value of `Site` to be the document `_type`. How do I accomplish that via inference in NEST? `InferMappingFor<T>`.
@khalidabuhakmeh
khalidabuhakmeh / gist:6ac74be331b9585df961eccac3e5ac9f
Created December 21, 2016 21:34
This query seems make suggestions from documents that either have the authors "Julie Pace and Catherine Lucey" OR tagged with "general". Is there a way to do an AND on context?
POST jekyll/_suggest?pretty
{
"title-author-suggestion" : {
"prefix" : "Donald",
"completion" : {
"field" : "Suggest",
"contexts" : {
"Authors" : "Julie Pace and Catherine Lucey",
"Tags" : [ "general" ]
}
@khalidabuhakmeh
khalidabuhakmeh / self_loathing.md
Last active June 15, 2016 13:01
A Mad Libs version of "Why you can't be a good .NET developer " (http://codeofrob.com/entries/why-you-cant-be-a-good-.net-developer.html ). Fill in your language and oppressor of choice.

It's Not Self Loathing

There is a reason this mentality exists and it isn't one of self loathing. The reason why people "leave" ___________ is because it is impossible to be a good ___________ developer. To work in a development shop with a team is to continually cater for the lowest common denominator of that team and the vast majority of software shops using ___________ have a whole lot of lowest common denominator to choose their bad development decisions for.

Tangible examples? I remember well the insistence of one boss that we use ___________ because some developers would find it hard to use ___________. I remember the steadfast committal to ___________ because the "new concepts" in ___________ were going to take too long for the team to become productive in. There is now this furore over ___________ and the new thing in the tiny 0.001% of people that care are whether they persist in using ___________ or switch to more productive environments. Of course ___________ gets it right here and points out

[config]
command = deploy.cmd

Problem

We would like to secure sites hosted on IIS that may / or may not be written with ASP.NET. Additionally, these sites may not be applications we have complete control over (OSS project).

Proposed Solution

An OpenID Connect HttpModule client that can be added to any IIS hosted application via web.config and offer crude authentication. Crude authentication means setting a few basic rules in app settings: endpoints and claims. This would work with an ASP.NET application, NodeJs application, etc. Anything that can be hosted on IIS.

How This Problem Came About

@khalidabuhakmeh
khalidabuhakmeh / ItsAllOk.cs
Created December 11, 2015 13:07
OctoKit is totally fine.
using System;
using Octokit;
using System.Linq;
public class Program
{
public static void Main()
{
var client = new GitHubClient(new ProductHeaderValue("test"));
public static class SearchExtensions
{
public static IQueryable<T> Search<T>(this IQueryable<T> value, object search)
{
if (search == null)
{
return value;
}
var filterProperties = search
For<HttpContext>().AlwaysUnique().Use(ctx => HttpContext.Current);
For<HttpRequestMessage>().AlwaysUnique().Use(ctx => ctx.GetInstance<HttpContext>().Items["MS_HttpRequestMessage"] as HttpRequestMessage);
For<UrlHelper>().AlwaysUnique().Use(ctx => new UrlHelper(ctx.GetInstance<HttpRequestMessage>()));