Skip to content

Instantly share code, notes, and snippets.

View magoz's full-sized avatar

Magoz magoz

View GitHub Profile
<?php
/**
* Sync Groups from WordPress to Discourse
*
* First creates 'groups' meta_key (which should be customized to your needs)
* Then it monitors for changes in the 'groups' meta_value and connects to Discourse API to sync groups
*
* WordPress References
* https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/meta.php?order=name#L235
* http://wordpress.stackexchange.com/questions/16835/how-to-hook-update-post-meta-and-delete-post-meta
@magoz
magoz / cloudSettings
Created February 13, 2018 07:58
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-02-13T07:57:29.097Z","extensionVersion":"v2.8.7"}
// Processing code by Etienne JACOB
// motion blur template by beesandbombs
// opensimplexnoise code in another tab might be necessary
// --> code here : https://gist.github.com/Bleuje/fce86ef35b66c4a2b6a469b27163591e
int[][] result;
float t, c;
float ease(float p) {
@magoz
magoz / narrowing.ts
Created January 25, 2025 10:44
Narrowing Error and Result
type User = {
id: string
name: string
}
// This works because error is an Error. Internally, object is a non-primitive type (it's a class instance),
// and TypeScript can use it as a reliable discriminant.
// When you check if (r.error), TypeScript knows that an Error object is always truthy,
// making it a reliable way to narrow the type.
const narrowWithError = (id?: string) => {