Skip to content

Instantly share code, notes, and snippets.

@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):
"""
@bellbind
bellbind / pem.js
Last active December 13, 2022 02:55
[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;
@noobnooc
noobnooc / cloudflare-worker-proxy.js
Last active June 25, 2024 09:44
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.