Skip to content

Instantly share code, notes, and snippets.

View davidnuon's full-sized avatar
🥙

David Nuon davidnuon

🥙
View GitHub Profile
@Paturages
Paturages / conf.d~auth.conf
Created October 12, 2019 09:15
Discord OAuth protected endpoints with only nginx
js_include conf.d/oauth2.js;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
location / {
auth_request /_auth_init;
}
@wpscholar
wpscholar / wp-rest-api-add-gutenberg-blocks.php
Last active March 15, 2022 01:19
Surface all Gutenberg blocks in the WordPress REST API
<?php
add_action('rest_api_init', function() {
// Surface all Gutenberg blocks in the WordPress REST API
$post_types = get_post_types_by_support( [ 'editor' ] );
foreach ( $post_types as $post_type ) {
if ( gutenberg_can_edit_post_type( $post_type ) ) {
@Kirens
Kirens / procedure.md
Created January 13, 2018 14:27
Deploying a NixOS server on DigitalOcean

Prerequisites

We'll use NixOps to deploy, so we need to install it

nix-env -i nixops

And to deploy on DigitalOcean we need to have an account and create an API access token for it.

@bsorrentino
bsorrentino / getDPI.js
Last active February 11, 2023 03:25
Get DPI from javascript (live at: https://jsfiddle.net/bsorrentino/s8c51jvt/)
//
// inspired by https://stackoverflow.com/a/838755/521197
//
function getDPI() {
var div = document.createElement( "div");
div.style.height = "1in";
div.style.width = "1in";
div.style.top = "-100%";
div.style.left = "-100%";
div.style.position = "absolute";
@JedWatson
JedWatson / KeystoneApiExample.md
Last active July 26, 2021 11:29
Example of how to scaffold API endpoints for Posts in a Keystone project (based on the yo keystone example).

This is an example of how to scaffold API endpoints to list / get / create / update / delete Posts in a Keystone website.

It's a modification of the default project created with the yo keystone generator (see https://github.com/JedWatson/generator-keystone)

Gists don't let you specify full paths, so in the project structure the files would be:

routes-index.js        -->    /routes/index.js         // modified to add the api endpoints
routes-api-posts.js    -->    /routes/api/posts.js     // new file containing the Post API route controllers