Skip to content

Instantly share code, notes, and snippets.

View zckkte's full-sized avatar

Zack A. Kite zckkte

  • Copenhagen, Denmark
View GitHub Profile
@zckkte
zckkte / .tmux.config
Created July 7, 2018 03:48
Vim and tmux configs
set -g utf8
set-window-option -g utf8 on
set -g default-terminal "screen-256color"
# set Ctrl-a as default prefix
set -g prefix C-a
unbind C-b
# pane navigation
bind h select-pane -L
var express = require('express')
var body_parser = require('body-parser')
var app = express()
var PORT = process.argv[2]
app.use(body_parser.json())
app.all('*', function(req, res) {
console.log({ headers: req.headers, body: req.body })
res.json({ headers: req.headers, body: req.body })
//TODO: add symbol
type List = Array<any>
type Atom = String | Number | Boolean
type Expression = Atom | List | Procedure | Function
const zip = (a: any[], b : any[], zipFunc? : (x : any, y : any) => any) =>
zipFunc ? a.map((value, index) => zipFunc(value, b[index]))
: a.map((value, index) => [value, b[index]]);
import * as R from 'ramda'
export const joinWith =
(list1 : any[], list2 : any[],
pred : (item1 : any, item2 : any) => boolean,
mapTo : (item1, item2) => any) : any[] =>
R.chain(item1 =>
R.map (item2 => mapTo(item1, item2),
R.filter (item2 => pred(item1, item2), list2 ))
using System;
using System.Linq;
using System.Reflection;
using System.ComponentModel;
namespace System
{
public static class EnumExtensions
{
public static string GetDescription<T>(this T genericEnum)
@zckkte
zckkte / IViewRendererService.cs
Last active August 1, 2023 14:35
ASP.NET Core Render Razor ViewModel to String
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.Rendering;
const matched = x => ({
on: () => matched(x),
otherwise: () => x,
})
const match = x => ({
on: (pred, fn) => (pred(x) ? matched(fn(x)) : match(x)),
otherwise: fn => fn(x),
})
match(50)
public static partial class FuncExtensions
{
public static TResult Forward<T, TResult>(this T value, Func<T, TResult> function) =>
function(value);
}
public static partial class ActionExtensions
{
public static void Forward<T>(this T value, Action<T> function) =>
function(value);
using System;
namespace Nulls
{
public struct Maybe<T> : IEquatable<Maybe<T>>
where T : class
{
private readonly T _value;
public T Value
{
public static class YCombinator<T> {
delegate Func<T, T> Recursive(Recursive recursive);
public static Func<Func<Func<T, T>, Func<T, T>>, Func<T, T>> Fix =
f => ((Recursive)(g => (f(x => g(g)(x))))) ((Recursive)(g => f(x => g(g)(x))));
}