Skip to content

Instantly share code, notes, and snippets.

@swuecho
swuecho / scala-http-postgres-html-docker.scala
Created January 24, 2024 14:08 — forked from keynmol/scala-http-postgres-html-docker.scala
Sample gist showing how to run a HTTP server with Typelevel Scala libraries, and a postgres docker container
//> using dep "org.http4s::http4s-scalatags::0.25.2"
//> using dep "org.http4s::http4s-dsl::0.23.23"
//> using dep "org.http4s::http4s-ember-server::0.23.23"
//> using dep "org.tpolecat::skunk-core::0.6.0"
//> using dep "com.dimafeng::testcontainers-scala-postgresql::0.41.0"
//> using dep "com.outr::scribe-slf4j::3.12.2"
import skunk.*, codec.all.*, syntax.all.*
import cats.effect.*
import scalatags.Text.all.*
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net"
"os"
"strings"
"unicode"
function handleRequest(request) {
const { pathname } = new URL(request.url);
// Respond with HTML
if (pathname.startsWith("/html")) {
const html = `<html>
<p><b>Message:</b> Hello from Deno Deploy.</p>
</html>`;
return new Response(html, {
@swuecho
swuecho / restore_db_in_docker.sh
Created August 19, 2020 05:50
gitea postgres docker db restore
mkdir gitea
cp docker-compose.yml gitea/
cp gitea-dump-1597294525.zip gitea/
cd gitea
unzip gitea-dump-1597294525.zip
unzip gitea-repo.zip
@swuecho
swuecho / proxmox-import-disk-image.txt
Created August 12, 2020 00:56
Add import existing disk image into Proxmox
#
# The official PVE docs on how to prepare cloud-init templates:
# https://pve.proxmox.com/wiki/Cloud-Init_Support#_preparing_cloud_init_templates
#
# Additional guides and resources:
# https://dae.me/blog/2340/how-to-add-an-existing-virtual-disk-to-proxmox/
# https://pve.proxmox.com/pve-docs/qm.1.html
# use the Qemu/KVM Virtual Machine Manager to import the disk
qm importdisk 107 Univention-App-kopano-core-KVM.qcow2 local-lvm
@swuecho
swuecho / remove_tag.zsh
Created August 11, 2020 07:44
git remove tag
#for release in `seq 15 34`;
#do
#git push --delete origin release-v0.0.$release
#done
# git tag | head -n 10 | xargs git push --delete origin -
for release in `git tag`;
do
echo $release;
git push --delete origin $release
real 8m5.110s
user 164m38.999s
sys 16m41.641s
@swuecho
swuecho / xhr.js
Created November 22, 2019 14:51
make request and post form
function makeRequest(method, url) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open(method, url);
xhr.onload = function () {
if (this.status >= 200 && this.status < 300) {
resolve(xhr.response);
} else {
# modified from the python code in
# https://pizzaseminar.speicherleck.de/automatic-differentiation/notes.pdf
class Dual(object):
def __init__(self, x, a=0):
self.x = x
self.a = a
def __add__(self, other):
@swuecho
swuecho / Virtual Box Host Only Static IP.md
Created May 31, 2018 05:27 — forked from pjdietz/Virtual Box Host Only Static IP.md
VirtualBox Host-Only Adapter with Static IP

VirtualBox Host-Only Static IP

My typical setup for a development box in VirtualBox uses two NICs. The first uses NAT to allow the box to communicate with the outside world through my host computer’s network connection. (NAT is the default, so shouldn't require any setup.) The second is a "host-only" connection that allows my host and guest to interact.

To create a host-only connection in VirtualBox, start by opening the preferences in VirtualBox. Go to the "Network" tab, and addd a Host-only Network. Modify the host-only network, and disable DHCP. Make a note of the IP address. (Feel free to set the IP address as well, if you like.)

Next, assign this host-only adapter to the virtual machine. Select the VM and press "Settings". Go to the "Network" tab, and select "Adpater 2". Enable the adapter, set it to a "Host-only Adapter", and select the adpater you created above.

Temporary