Skip to content

Instantly share code, notes, and snippets.

View Jacknq's full-sized avatar
💭
keep goin

Jack Jacknq

💭
keep goin
View GitHub Profile
@Jacknq
Jacknq / index.ts
Created April 14, 2023 20:45
typesript
function isAvailable<Obj>(
obj: Obj,
key: string | number | symbol
): key is keyof Obj {
return key in obj;
using System;
using System.Text.Json.Serialization;
using Couchbase;
using Couchbase.Linq;
using Newtonsoft.Json;
using couch;
using Couchbase.Linq.QueryGeneration;
using Couchbase.Linq.QueryGeneration.MemberNameResolvers;
using Couchbase.Linq.Utils;
using Couchbase.Linq.Versioning;
SELECT $ FROM post
INCLUDE categories,tags
where $.Categories[*].$id any in [ 7 , 10]
SELECT *.Categories[*], sum(*.Categories[*].id) as c
FROM post
--include $.Categories
where $.Categories!=null and Count($.Categories[*])>0 and $.$missing any !=true
@Jacknq
Jacknq / services startup.cs
Last active January 1, 2021 14:15
.net startup singleton
services.AddDbContextPool<dbContext>(options => options.UseSqlite(conn));
//.UseSqlServer(connection));
//with scoped
//services.AddScoped<DmServices>();
//with singleton
// services.AddSingleton<DmServices>(s =>
// new DmServices(new ProsperusContext(
// new DbContextOptionsBuilder<dbContext>().UseSqlite(conn).Options)));
services.AddSingleton<DmServices>(s =>
{
@Jacknq
Jacknq / mvc frombody convention
Created November 29, 2018 08:25
mvc convention
https://github.com/aspnet/Mvc/blob/a78f77afde003c4a3fcf5dd7b6dc13dd9c85f825/src/Microsoft.AspNetCore.Mvc.WebApiCompatShim/Conventions/WebApiParameterConventionsApplicationModelConvention.cs
@Jacknq
Jacknq / ts test groupby
Last active January 27, 2023 12:19
test.ts
groupBy(array: any[], property: string) {
return array.reduce((prev, next) => {
// If the group doesn't exist, create it
if(!prev[property]) { prev[property] = [next]; }
// Else, we push it in
else { prev[property].push(next); }
// Mandatory return
return prev;
}, {});
}