Skip to content

Instantly share code, notes, and snippets.

@shagamemnon
shagamemnon / cloudflare-workers-base64.js
Created October 2, 2020 07:23
Decode Base64 encoded text in Cloudflare Workers
/* Demo: https://cloudflareworkers.com/#6168c0dbeb076f1e3ac7eb102082361f:https://www.google.com/ */
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
function fromBinary(msg) {
const ui = new Uint8Array(msg.length)
for (let i = 0; i < msg.length; ++i) {
ui[i] = msg.charCodeAt(i)
@soheilhy
soheilhy / nginxproxy.md
Last active May 16, 2024 08:59
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@ejdyksen
ejdyksen / patch-edid.md
Last active July 26, 2024 11:46
A script to fix EDID problems on external monitors in macOS

patch-edid.rb

A script to fix EDID problems on external monitors in macOS.

Instructions

  1. Connect only the problem display.

  2. Create this directory structure (if it doesn't already exist):

@branneman
branneman / better-nodejs-require-paths.md
Last active June 29, 2024 16:00
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@turtlesoupy
turtlesoupy / nginx.conf
Created July 8, 2012 21:16
node.js upstream nginx config
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;