This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Place this file into a WordPress directory with a proper config and run. | |
* It doesn't need the config, but it needs to load all of the HTML API and | |
* Token Map modules. This can be done by replacing the `require_once` with | |
* a `require_once` for each of the appropriate files. | |
* | |
* - With no arguments it prints the sample HTML. | |
* - If the last argument is a dash (-), it reads the HTML from stdin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs | |
import sys | |
def prepend_bom(filename): | |
with open( filename, 'r+b' ) as csv: | |
existing = csv.read() | |
if b'\xef\xbb\xbf' == existing[0:3]: | |
print("Byte-order mark already present: leaving file as-is.") | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- wp:paragraph {"content":"This paragraph has \u003cem\u003e\u003cstrong\u003eno sourced attributes\u003c/strong\u003e\u003c/em\u003e. It's content is fully stored inside the JSON attributes \u003cem\u003eand\u003c/em\u003e it still contains the rendered HTML useful for rendering it with no server is available."} --> | |
<p>This paragraph has <em><strong>no sourced attributes</strong></em>. It's content is fully stored inside the JSON attributes <em>and</em> it still contains the rendered HTML useful for rendering it with no server is available.</p> | |
<!-- /wp:paragraph --> | |
<!-- wp:image {"url":"https://wordpress.org/files/2022/08/theme-styles.png","caption":"Image captions are usually sourced from the \u003ccode\u003efigcaption\u003c/code\u003e element.","width":650,"height":406,"sizeSlug":"large","linkDestination":"none"} --> | |
<figure class="wp-block-image size-large is-resized"><img src="https://wordpress.org/files/2022/08/theme-styles.png" alt="" width="650" height="406"/><figcaption class="wp-element-captio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const counter = async ({send, receive}) => { | |
let count = 0; | |
while (1) { | |
const [action, args] = await receive(); | |
switch (action) { | |
case 'inc': | |
count++; | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { spawn, send } = require('./process.js') | |
const counter = spawn( async (receive) => { | |
let count = 0; | |
while (1) { | |
const message = await receive(); | |
if (message === 'inc') { | |
console.log(++count); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MessageChannel, MessagePort } from 'worker_threads'; | |
type ServerDescription<K extends string> = { | |
[type in K]: (...args: unknown[]) => unknown; | |
} | |
type ServerHandler<M extends ServerDescription<keyof M>, S> = <T extends keyof M>(msg: T, state: S) => [ReturnType<M[T]>, S] | Promise<[ReturnType<M[T]>, S]>; | |
class GenericServer<M extends ServerDescription<keyof M>, S = undefined> { | |
count = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.UnsupportedEncodingException; | |
import java.net.URLEncoder; | |
import java.text.Normalizer; | |
import java.util.Locale; | |
class TagHasher { | |
public static String tagHash(String tagName) { | |
try { | |
String normalized = Normalizer.normalize(tagName, Normalizer.Form.NFC); | |
String lowercased = normalized.toLowerCase(Locale.ENGLISH); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Stack; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
import com.google.gson.JsonElement; | |
import com.google.gson.JsonObject; | |
import com.google.gson.JsonParser; | |
class BlockParser { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { registerBlockType } = wp.blocks; | |
const { TextareaControl } = wp.components; | |
const { createElement: el } = wp.element; | |
const attributes = { | |
formula: { type: 'string' }, | |
rendered: { | |
type: 'string', | |
source: 'attribute', | |
selector: 'img', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main exposing (main) | |
import Browser as B | |
import Browser.Navigation as BN | |
import Html as H | |
import Html.Attributes as HA | |
import Html.Events as HE | |
import Url as U | |
NewerOlder