Skip to content

Instantly share code, notes, and snippets.

@heartshare
heartshare / Time Machine On JuiceFS.md
Created October 11, 2022 07:02 — forked from yujunz/Time Machine On JuiceFS.md
Time machine on JuiceFS
JFS_BASE=/Users/yujunz/JuiceFS
JFS_NAME=rogerz-s3-cn-east-1-qiniu
BUNDLE=TimeMachine.sparsebundle
VOLUME=/Volumes/TimeMachine

# Mount JuiceFS
juicefs mount --cache-dir $JUICEFS_BASE/cache --batch 10 --writeback --metacache --opencache $JFS_NAME $JFS_BASE/$JFS_NAME

# Create sparse bundle
@heartshare
heartshare / How
Created October 11, 2022 06:34 — forked from c4pt0r/How
Build your own Dropbox using TiDB Cloud Free Tier + JuiceFS + AWS S3 in 2 lines.
1. Open S3 service in AWS, create bucket and get the access point, like this: https://${bucket-name}.s3.us-west-2.amazonaws.com
2. Go to https://tidbcloud.com and register a new free TiDB instance (10G), get a MySQL endpoint, and make sure the traffic filter is properly configured to allow public access.
3. Install the juicefs client locally in Distributed Mode (https://juicefs.com/docs/community/getting-started/for_distributed)
4. initialize and mount FUSE according to the following two lines:
# juicefs format --storage s3 \
--bucket https://${bucket-name}.s3.us-west-2.amazonaws.com \
--access-key ${aws-access-key} \
--secret-key ${aws-secret} \
mysql://${mysql-user}:${mysql-password}@\(your-cloud-tidb.prod.aws.tidbcloud.com:4000\)/juice \
@heartshare
heartshare / how-to-cache-b2-content-with-cloudflare.md
Created August 3, 2022 06:27 — forked from davelevine/how-to-cache-b2-content-with-cloudflare.md
How to Properly Cache Content Hosted on Backblaze B2 with Cloudflare

How to Properly Cache Content Hosted on Backblaze B2

Summary

Because I use Cloudflare to manage my domains and Backblaze for backups, it only made sense to take advantage of their Bandwidth Alliance for creating my own CDN. This has been incredibly helpful for image hosting for this knowledge base, however, I recently noticed that caching wasn't working as it should.

The Problem

The overall problem started when I was adding a parking page for a domain I recently purchased. The background image was hosted on B2 and the image was supposed to be cached by Cloudflare. However, each time the page loaded, it would pull the image from the origin instead of the cache. I checked this on my knowledge base and found it was doing the same thing.

@heartshare
heartshare / NginxLog.php
Created February 1, 2022 13:59 — forked from zwjzxh520/NginxLog.php
php写的nginx 日志分析
<?php
/**
* nginx日志文件分析。
* 根据配置的nginx日志格式,分析对应的日志内容。各变量
*/
class NginxLog {
protected static $br = "\n";
/**
opkg install wireguard bash coreutils-stat
mkdir /etc/wireguard
ln -s /proc/self/fd /dev/fd # fix /dev/fd/63 error: ... < (...)
@heartshare
heartshare / Hybrid (Windows+Linux) Docker Swarm
Created December 27, 2021 03:02 — forked from roommen/Hybrid (Windows+Linux) Docker Swarm
Hybrid (Windows+Linux) Docker Swarm
**********************
*** Pre-requisites ***
**********************
1. Set up Windows 2016 password:
gcloud beta compute --project <project_id> reset-windows-password <instance_name> --zone <zone_name>
ip_address: <ip_address>
password: <defult_password_generated>
username: <username>
3. Installing Docker:

Deploy k3s cluster on Vultr with RancherOS over ZeroTier network

How to deploy K3S cluster on RancherOS nodes connected via a Zerotier network.

Deploy master node

1. Update the master-deploy.sh with deployment vars

@heartshare
heartshare / fail2ban_report.sh
Created July 27, 2021 04:21 — forked from U039b/fail2ban_report.sh
Fail2Ban mail report
#!/bin/bash
# Weekly Fail2Ban Report
# Be sure to sudo chmod +x script_name.sh to make it executable
# Original script from https://www.mopar4life.com/fail2ban-weekly-report-script/
FAIL2BAN_PATH="/var/log/fail2ban*"
LOGFILE="/var/log/custom_fail2ban_report_$(date +%m%d%Y).log"
MAILTOADDRESS="your@domain.tld"
SUBJECT="$HOSTNAME Weekly Fail2Ban Report"
@heartshare
heartshare / docker-compose.yml
Created July 15, 2021 06:31 — forked from pantsel/docker-compose.yml
example docker-compose.yml for kong, postgres and konga
version: "3"
networks:
kong-net:
driver: bridge
services:
#######################################
# Postgres: The database used by Kong