Skip to content

Instantly share code, notes, and snippets.

@tchak
tchak / with-body.ts
Last active May 12, 2021 18:40
Remix withBody
import type { ActionFunction, Request } from 'remix';
import { BaseSchema, ValidationError } from 'yup';
type NextActionFunction<Body> = (body: Body) => ReturnType<ActionFunction>;
export async function withBody(
request: Request,
config: (router: ActionRouter) => void
) {
const router = new ActionRouter();
@nicholasohrn
nicholasohrn / http-basic-cron-request.php
Created July 1, 2014 21:22
WP Cron with HTTP Basic Authentication
<?php
if(defined('WP_CRON_CUSTOM_HTTP_BASIC_USERNAME') && defined('WP_CRON_CUSTOM_HTTP_BASIC_PASSWORD')) {
function http_basic_cron_request($cron_request) {
$headers = array('Authorization' => sprintf('Basic %s', base64_encode(WP_CRON_CUSTOM_HTTP_BASIC_USERNAME . ':' . WP_CRON_CUSTOM_HTTP_BASIC_PASSWORD)));
$cron_request['args']['headers'] = isset($cron_request['args']['headers']) ? array_merge($cron_request['args']['headers'], $headers) : $headers;
return $cron_request;
}