Skip to content

Instantly share code, notes, and snippets.

View davecarlson's full-sized avatar

Dave Carlson davecarlson

View GitHub Profile
@davecarlson
davecarlson / apirouter.ts
Last active May 11, 2023 09:22
Middleware Wrapper Function for Next.js Pages API Routes
/* Current Pages Directory Implementation */
// pages/api/test.ts
import { NextApiHandler, NextApiRequest, NextApiResponse } from "next";
interface RequestWithDb extends NextApiRequest {
db: string;
}
const withDatabase =
(fn) => async (req: NextApiRequestWithDb, res: NextApiResponse, next: NextApiHandler) => {
req.db = "database"
return fn(req, res, next);
The combiner takes a comma-separated list of files:
eg: /jsc/reset.css,main.css
To use it, add this to your Apache Config:
RewriteRule ^/jsc/(.*\.js) /path/to/combine-gzip.inc.php?type=javascript&encoding=none&files=$1
RewriteRule ^/cssc/(.*\.css) /path/to/combine-gzip.inc.php?type=css&encoding=none&files=$1
And save the included php file to a suitable location. Your cache directory will need to be writable by the web server.
@davecarlson
davecarlson / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console