Skip to content

Instantly share code, notes, and snippets.

View ehvattum's full-sized avatar

Erik Hvattum ehvattum

  • fuse.no
  • Oslo
View GitHub Profile
@ehvattum
ehvattum / Patch.ts
Last active August 9, 2023 12:48
Create a JSONPatch-ish type for any object
import { Primitive, Simplify, WritableKeysOf } from "type-fest"
/**
* Create a JSON-patch dto type for a given type.
* * Strips out readonly properties (WritableKeysOf)
*/
export type Patch<T> = PatchRoot<Pick<T, WritableKeysOf<T>>>
/** Make patch schema for all useful keys in type */
type PatchRoot<TRoot extends object> = {
@ehvattum
ehvattum / Multi_content-type.json
Created January 18, 2023 09:43
Openapi multiple content-types responses
{
"openapi":"3.0.2",
"info": {
"title":"Multi content-type generator spec",
"version":"1.0"
},
"servers": [
{"url":"https://api.server.test/v1"}
],
"paths": {
@ehvattum
ehvattum / purge.sh
Created September 28, 2021 12:21
purge old kernels from /boot
sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")
@ehvattum
ehvattum / openapi example stripper
Last active April 7, 2021 09:54
Requires jq. Strips example data from swagger/openapi specifications in json format. Useful if the example data contains constant changing data like dynamic dates.
jq 'walk(if type == "object" then del(.examples) | del(.example) else . end)' < spec-with-examples.json > spec-without-examples.json
@ehvattum
ehvattum / aint
Last active February 10, 2016 16:05
#region License
// --------------------------------------------------
// Copyright © PayEx. All Rights Reserved.
//
// This software is proprietary information of PayEx.
// USE IS SUBJECT TO LICENSE TERMS.
// --------------------------------------------------
#endregion
@ehvattum
ehvattum / I.cs
Last active February 10, 2016 15:01
I.Got()
namespace JAY_Z
{
class Problem : Exception { }
class Bitch : Problem { }
static class I
{
static void Got()
### Keybase proof
I hereby claim:
* I am ehvattum on github.
* I am hvattum (https://keybase.io/hvattum) on keybase.
* I have a public key whose fingerprint is C7F7 3929 9BE9 69EE D456 D127 FC87 1E8B 7D9F 5E45
To claim this, I am signing this object: