Skip to content

Instantly share code, notes, and snippets.

@noobnooc
noobnooc / cloudflare-worker-proxy.js
Last active October 3, 2024 11:42
cloudflare-worker-proxy
// Website you intended to retrieve for users.
const upstream = 'api.openai.com'
// Custom pathname for the upstream website.
const upstream_path = '/'
// Website you intended to retrieve for users using mobile devices.
const upstream_mobile = upstream
// Countries and regions where you wish to suspend your service.
@bellbind
bellbind / pem.js
Last active September 17, 2024 20:19
[nodejs]Example of RSA usages with node-forge
// RSA with node-forge
"use strict";
// npm install node-forge
const forge = require("node-forge");
new Promise((f, r) => forge.pki.rsa.generateKeyPair(
2048, (err, pair) => err ? r(err) : f(pair)))
.then(keypair => {
const priv = keypair.privateKey;
@heyman
heyman / gist:3744010
Created September 18, 2012 16:12
Generic Django JSON view class with JSONP support
try:
import simplejson as json
except ImportError:
import json
from django.views import generic
from django.http import HttpResponse
class JsonView(generic.View):
"""