Skip to content

Instantly share code, notes, and snippets.

View ltwlf's full-sized avatar

Christian Glessner ltwlf

View GitHub Profile
@ltwlf
ltwlf / TcpServer.cs
Created September 27, 2020 11:37
TcpListener snippet for HTTP
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using UnityEngine;
using static System.Text.Encoding;
namespace DefaultNamespace
{
// source https://github.com/apollographql/apollo-client/blob/master/src/react/hooks/utils/useDeepMemo.ts
import { useRef } from 'react';
import { equal } from '@wry/equality';
/**
* Memoize a result using deep equality. This hook has two advantages over
* React.useMemo: it uses deep equality to compare memo keys, and it guarantees
* that the memo function will only be called if the keys are unequal.
* React.useMemo cannot be relied on to do this, since it is only a performance
export function transform(o: any, fn: (obj: any, prop: string, value: any) => any) {
if (o && typeof o === 'object') {
Object.keys(o).forEach((k, i) => {
o[k] = fn.apply(this, [o, k, o[k]])
if (o[k] && typeof o[k] === 'object') {
return transform(o[k], fn)
}
return o[k]
})
return o
@ltwlf
ltwlf / CdsCalculateRollup.cs
Last active February 20, 2020 08:36
CDS Calculate Rollup
using System;
using System.ServiceModel;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
namespace QuotationCalculateSum
{
public class CalculatorPlugin : IPlugin
{
import { ApolloServer, gql } from 'apollo-server-azure-functions'
import * as mongoose from 'mongoose'
import { schema } from './model'
mongoose.connect(process.env.COSMOSDB_CONNSTR, {
useUnifiedTopology: true,
useNewUrlParser: true,
auth: {
user: process.env.COSMODDB_USER,
password: process.env.COSMOSDB_PASSWORD,
@ltwlf
ltwlf / Dockerfile
Last active November 19, 2019 23:38
Base Docker Azure Function Node 10 image with SSH support
FROM mcr.microsoft.com/azure-functions/base
RUN apt-get update && \
apt-get install -y gnupg && \
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
apt-get update && \
apt-get install -y nodejs
ENV AzureWebJobsScriptRoot=/home/site/wwwroot