Skip to content

Instantly share code, notes, and snippets.

@stisa
stisa / nextcloud-caddy-docker.md
Created September 7, 2024 21:07 — forked from tmo1/nextcloud-caddy-docker.md
Nextcloud behind Caddy as a reverse proxy, using Docker

Introduction

This is a guide to deploying Nextcloud behind a Caddy reverse proxy, both running in Docker containers (an official Nextcloud one and a caddy-docker-proxy one), with the goal of implementing as much as possible via docker-compose files. This is much more difficult than it should be, for a variety of reasons:

  • As with Docker versions of software in general, documentation of the software does not always apply to the Docker versions, and the Docker documentation does not always include the Docker equivalent ways of doing things.

  • Docker images do not always expose the desired configuration knobs of the underlying software.

  • Nextcloud requires special configuration to run correctly behind a reverse proxy (and again, some of the instructions for this configuration requires modification for

import macros,options
type C = ref object
c: int
macro until(cond,node,body:untyped):untyped =
# Example implementation, just to prove it's possible
# Generates:
# for raw in b:
# if cond(raw): break
@stisa
stisa / jspromises.nim
Created August 25, 2017 10:33
Js promises
import jsffi
type Promise*[T] = ref object of JsObject
proc newPromise*[T](executor:proc(resolve:proc(val:T), reject:proc(reason:auto))): Promise[T] {.importcpp: "new Promise(#)".}
proc resolve*[T](val:T):Promise[T] {.importcpp: "Promise.resolve(#)",discardable.}
proc reject*[T](reason:T):Promise[T] {.importcpp: "Promise.reject(#)",discardable.}
proc race*[T](iterable:openarray[T]):Promise[T] {.importcpp: "Promise.race(#)",discardable.}
proc all*[T](iterable:openarray[Promise[T]]):Promise[seq[T]] {.importcpp: "Promise.all(#)",discardable.}
proc itoa(n:int):string =
var num = if n<0: -n else: n
var i = 0
result = ""
while num > 0:
result.add(char(48 + num mod 10))
num = num div 10
inc i # inc char count
@stisa
stisa / jspromises.nim
Created May 13, 2017 12:20
JS promises wrapper for nim
import jsffi
type Promise*[T] = ref object of JsObject
proc newPromise*[T](executor:proc(resolve:proc(val:T), reject:proc(reason:auto))): Promise[T] {.importcpp: "new Promise(#)".}
proc resolve*[T](val:T):Promise[T] {.importcpp: "Promise.resolve(#)",discardable.}
proc reject*[T](reason:T):Promise[T] {.importcpp: "Promise.reject(#)",discardable.}
proc race*[T](iterable:openarray[T]):Promise[T] {.importcpp: "Promise.race(#)",discardable.}
proc all*[T](iterable:openarray[Promise[T]]):Promise[seq[T]] {.importcpp: "Promise.all(#)",discardable.}

First suggestion:

src/
  <pkgname>.nim
tests/
docs/
<pkgname>.nimble # with srcDir = "src"

library with single module

@stisa
stisa / nimonandroid.md
Created March 23, 2017 06:50
recompile nim on android

Install glob

Apt install libandroid-glob
Apt install libandroid-glob-dev

compiler/nim.cfg

@stisa
stisa / outc.txt
Last active March 22, 2017 14:52
repr test
a | 0
b | 0
c | 0.0
d | '\0'
e | eA
f | 0000000000000010""
g | {}
h | {}
i | [nil, nil, nil]
@stisa
stisa / index.html
Created March 18, 2017 20:43
Nim js backend: input element
<html>
<body>
<input id="input" type="text" name="fname">
<script src="nimcache/t.js"></script>
</body>
</html>
@stisa
stisa / typedjson.nim
Last active March 13, 2017 09:09
Json -> SomeType conversion
import json
#TODO: handle ref,ptr,tuple
proc into[T](json:seq[JsonNode],b:var openarray[T]) =
## Seq of Omogeneous JsonNodes into an array or seq of type T
for i,el in json:
when T is bool:
b[i] = el.bval
elif T is SomeInteger: