Skip to content

Instantly share code, notes, and snippets.

@vanodevium
vanodevium / Caddyfile
Created December 8, 2023 11:20
Caddy server: enable CORS for any domain
(cors) {
@cors_preflight method OPTIONS
header {
Access-Control-Allow-Origin "{header.origin}"
Vary Origin
Access-Control-Expose-Headers "Authorization"
Access-Control-Allow-Credentials "true"
}
@vanodevium
vanodevium / fetch-cf-object.js
Created September 29, 2023 14:11
Fetch data as object from Cloudflare
(async () => {
const fetchCloudFlare = async () => {
return fetch('https://www.cloudflare.com/cdn-cgi/trace')
.then(response => response.text())
.then(data => {
return data
.trim()
.split("\n")
.reduce(function(obj, pair) {
pair = pair.split("=");
@vanodevium
vanodevium / fetch-cf.js
Created September 29, 2023 08:47
Fetch ip and country from Cloudflare
(async () => {
const fetchCloudFlare = async () => {
return fetch('https://www.cloudflare.com/cdn-cgi/trace')
.then(response => response.text())
.then(data => {
const $data = {};
(data || "").trim().split("\n").map((el) => {
if (el.includes('ip=')) {
$data.ip = el.replace('ip=', '');
}
@vanodevium
vanodevium / latest-docker-compose.sh
Created September 15, 2023 08:25
latest docker-compose install script
#!/bin/bash
sudo curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose