Skip to content

Instantly share code, notes, and snippets.

View davelevine's full-sized avatar
🏠
Working from home

Dave Levine davelevine

🏠
Working from home
View GitHub Profile
@davelevine
davelevine / how-to-build-a-url-shortener-with-cloudflare-workers.md
Last active January 12, 2022 18:29
How to Build a URL Shortener with Cloudflare Workers

How to Build a URL Shortener with Cloudflare Workers

Summary

This will serve as a step-by-step guide for creating a URL shortener with Cloudflare Workers. The project is a fork of Atomic URL by Jerry Ng, although I've heavily modified it to suit my needs.

In addition to leveraging Cloudflare Workers, this project will also leverage the following...

@davelevine
davelevine / how-to-cache-b2-content-with-cloudflare.md
Last active March 1, 2024 08:04
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.

@davelevine
davelevine / rewrite-subdomain-url-for-b2-with-cloudflare-cdn.md
Last active January 15, 2023 02:14
Rewrite Subdomain URL for B2 with Cloudflare CDN

Remove B2 /file/<bucket-name> Prefix

While the article from James Ross is solid and works very well with images, I found it fell short with any streaming video with the Bandwidth Alliance (to be fair, the article mentions nothing about videos, only images). Although the URL was being rewritten, it didn't seem to be handling video properly and even short videos were taking a long time to load.

That being said, the following seems to work perfectly...

Note: None of this code is mine. I'm basically standing on the shoulders of giants.

@davelevine
davelevine / nginx.conf
Created June 27, 2021 13:04 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@davelevine
davelevine / vpn.md
Created June 27, 2021 13:04 — forked from joepie91/vpn.md
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@davelevine
davelevine / lwp-cloudflare-dyndns.sh
Created June 27, 2021 13:03 — forked from Firsh/lwp-cloudflare-dyndns.sh
Cloudflare as Dynamic DNS
#!/bin/bash
# Cloudflare as Dynamic DNS
# From: https://letswp.io/cloudflare-as-dynamic-dns-raspberry-pi/
# Based on: https://gist.github.com/benkulbertis/fff10759c2391b6618dd/
# Original non-RPi article: https://phillymesh.net/2016/02/23/setting-up-dynamic-dns-for-your-registered-domain-through-cloudflare/
# Update these with real values
auth_email="email@example.com"
auth_key="global_api_key_goes_here"
zone_name="example.com"
@davelevine
davelevine / openbox_tiling.rc
Created June 27, 2021 13:02 — forked from uriel1998/openbox_tiling.rc
Openbox tiling emulation keybinds
<!-- Keybindings for moving windows -->
<keybind key="mod4-Left">
<action name="GoToDesktop">
<to>west</to>
<wrap>yes</wrap>
</action>
</keybind>
<keybind key="mod4-Right">
<action name="GoToDesktop">
<to>east</to>
@davelevine
davelevine / clean-up-arch-linux.md
Created June 19, 2021 00:46 — forked from rumansaleem/clean-up-arch-linux.md
Instructions to clean up Arch Linux (Manjaro)

Contents

  • Clean pkg cache
  • Remove unused packages (orphans)
  • Clean cache in /home
  • remove old config files
  • Find and Remove
    • duplicates
    • empty files
    • empty directories
  • broken symlinks
### Keybase proof
I hereby claim:
* I am davelevine on github.
* I am davelevine (https://keybase.io/davelevine) on keybase.
* I have a public key whose fingerprint is 27C8 99FF 1141 A64E 7588 EAA9 7280 7837 837F C9E1
To claim this, I am signing this object: