Skip to content

Instantly share code, notes, and snippets.

@JoshyPHP
JoshyPHP / 0.md
Last active January 23, 2017 19:28
phpBB docs
  1. How to create a BBCode that handles PHP processing
  2. How to enable/disable bbcode tags
  3. How to enable/disable MediaEmbed plugins (MediaEmbed, Pipe Tables, etc.)
  4. An example case for using RegisteredVars
  5. Template parameters
<?php
include '/s9e/TextFormatter/src/autoloader.php';
$xml = s9e\TextFormatter\Utils::replaceAttributes(
'<r><MENTION id="123">@Bob</MENTION><MENTION id="345">@NotBob</MENTION></r>',
'MENTION',
function ($attributes)
{
if ($attributes['id'] === '123')
@JoshyPHP
JoshyPHP / flarum_mention.php
Last active August 29, 2015 14:25
Flarum mentions
<?php
include '/s9e/TextFormatter/src/autoloader.php';
$configurator = new s9e\TextFormatter\Configurator;
$tagName = 'MENTION';
$tag = $configurator->tags->add($tagName);
$tag->attributes->add('username');
$tag->attributes->add('id')->filterChain->append('#uint');
$tag->filterChain->prepend('mentionator::addId')->addParameterByName('mentionator');
@JoshyPHP
JoshyPHP / reparse_posts.php
Created May 29, 2015 14:20
How to reparse all the posts
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
@JoshyPHP
JoshyPHP / post.html
Last active August 29, 2015 14:06
Vanilla post, parsed and rendered
<p>@x00 Sure, a lot of people hate XML for whatever reasons. As far as I’m concerned, I couldn’t dream of a better format for storing parsed text and here’s why. This is all the code you need to transform the XML back to text:</p>
<pre><code class="">return htmlspecialchars_decode(strip_tags($xml), ENT_QUOTES);</code></pre>
<p>If the XML is loaded in a DOM, all you need is to read its textContent to get the same result. If I die, every copy of the library disappears and XML is outlawed by a planet-wide decree, any programmer would only need one look at the data to understand how to get the original text back.</p>
<p>As for the increased size due to metadata, I invite you to run your own experiment on actual data and see that this does not double. <a href="https://gist.github.com/s9e/0ee8433f5a9a779d08ef">Here’s a gist containing this post as text, XML, and HTML.</a></p>
<p>@Bleistivt If you want to add a column to your database schema, I recommend you do it for search. Because if you index the markup in t
@JoshyPHP
JoshyPHP / EmojiOne.md
Last active August 29, 2015 14:06
EmojiOne's emoji, grouped by UTF-8 representation

Block 1

  • Starts with bytes [\x23\x30-\x39], which in ASCII is [#0-9],
  • Optionally followed by \xEF\xB8\x8F (U+FE0F)
  • Ends with \xE2\x83\xA3

[#0-9](?>\xEF\xB8\x8F)?\xE2\x83\xA3

Block 2

@JoshyPHP
JoshyPHP / test.html
Last active December 24, 2015 13:39
Test Gist
<div>It's a Gist!</div>
<?php
/**
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2015 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
class s9e_renderer_ce909dab57a18a593f7b8550a36d254b58350f5f extends \s9e\TextFormatter\Renderer
{
protected $params = array('L_CODE' => '', 'L_COLON' => '', 'L_IMAGE' => '', 'L_SELECT_ALL_CODE' => '', 'L_WROTE' => '', 'S_VIEWFLASH' => '', 'S_VIEWIMG' => '', 'S_VIEWSMILIES' => '', 'T_SMILIES_PATH' => '');
<?xml version="1.0"?>
<stylesheet outputMethod="html">
<param name="L_CODE"/>
<param name="L_COLON"/>
<param name="L_IMAGE"/>
<param name="L_SELECT_ALL_CODE"/>
<param name="L_WROTE"/>
<param name="S_VIEWFLASH"/>
<param name="S_VIEWIMG"/>
<param name="S_VIEWSMILIES"/>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" encoding="utf-8" indent="no"/>
<xsl:param name="L_CODE"/>
<xsl:param name="L_COLON"/>
<xsl:param name="L_IMAGE"/>
<xsl:param name="L_SELECT_ALL_CODE"/>
<xsl:param name="L_WROTE"/>
<xsl:param name="S_VIEWFLASH"/>
<xsl:param name="S_VIEWIMG"/>