Skip to content

Instantly share code, notes, and snippets.

@gocs
gocs / README.md
Last active September 4, 2024 03:05
Run blocks md simple form (form as a service) locally

Run blocks md simple form (form as a service) locally

npm init -y
npm install blocksmd fs-extra live-server

create a directory named src and add a file named index.md with the following contents:

image

@gocs
gocs / lstun.sh
Last active August 1, 2024 14:01
get all pid with tcp port filtered by ipv4, command, user, and listening tcp connections
#!/usr/bin/env bash
# show pid and port from matcher
MATCHER=$1
if [ -n "$MATCHER" ]; then
sudo lsof -aPn -i4 -cnode -u${USER} -sTCP:LISTEN | grep $MATCHER | awk '{print $2 "|" $9}';
exit 0;
fi;
# show all ssh tunnel tcp connections
@gocs
gocs / DarkTheme.svelte
Last active June 23, 2024 16:06
Dark Theme in Tailwind Svelte
<script>
import { onMount } from "svelte";
import { writable } from "svelte/store";
const theme = writable("light");
onMount(() => {
const storedTheme = localStorage.getItem("theme");
if (storedTheme) theme.set(storedTheme);
@gocs
gocs / NetGraph.svelte
Created June 12, 2024 04:30
svelte go net stat
<script>
import { onMount } from "svelte";
import { writable } from "svelte/store";
const messages = writable([]);
let width = 1000;
let height = 200;
let gap = width / 100;
<script lang="ts">
import { createQrPngDataUrl } from "@svelte-put/qr";
import { onMount } from "svelte";
import JSZip from "jszip";
const qrs = [
];
let srcs: string[] = [];
onMount(async () => {
<div class="wrap">
<img src="http://placehold.it/1200/1200" alt="testsetse" />
</div>
<style>
.wrap {
width: 1200px;
height: 1200px;
position: relative;
overflow: hidden;
@gocs
gocs / heat.md
Created April 29, 2024 18:38
heat

image

@gocs
gocs / ui.go
Created February 26, 2024 09:29
sample embeded static pages handler
package ui
import (
"embed"
"fmt"
"io/fs"
"net/http"
)
//go:embed all:public
@gocs
gocs / Dockerfile
Last active March 12, 2024 01:17
dockerized lux (annie)
FROM alpine:latest
WORKDIR /lux
RUN apk add --no-cache \
curl ca-certificates openssl \
perl curl ffmpeg \
tar gzip jq; \
apkArch="$(apk --print-arch)"; Arch=""; \
case "$apkArch" in \
@gocs
gocs / main.go
Last active September 20, 2023 04:30
unverified tls wss dial
rootCAs, err := x509.SystemCertPool()
if err != nil {
return nil, err
}
// rootCAs := x509.NewCertPool()
pemData, err := os.ReadFile(certfile)
if err != nil {
return nil, err
}