Skip to content

Instantly share code, notes, and snippets.

View joshuaadickerson's full-sized avatar

Joshua Dickerson joshuaadickerson

View GitHub Profile
@joshuaadickerson
joshuaadickerson / magento.conf
Created August 16, 2018 20:51
Magento 2 Nginx Conf
location / {
try_files $uri $uri/ /index.php?$args;
}
location /pub {
location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
deny all;
}
alias $MAGE_ROOT/pub;
DELIMITER $$
DROP FUNCTION IF EXISTS `HTML_ENCODE`$$
CREATE FUNCTION `HTML_ENCODE`(X TEXT) RETURNS TEXT CHARSET latin1 DETERMINISTIC
BEGIN
DECLARE TextString TEXT;
SET TextString = X ;
#quotation mark
IF INSTR( X , '"' )
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Setup\Module\Di\Code\Reader;
class FileClassScanner
<?php
namespace Elkarte\Messages\Formatters;
class ForumML
{
const KNOWN_NODE_TYPES = [
'TEXT' => 1,
'NEW_LINE' => 2,
'EMPTY_LINE' => 3,
@joshuaadickerson
joshuaadickerson / Censor.php
Created March 13, 2016 18:32
Elkarte Censor as a class
<?php
/**
* $censor = new Censor($modSettings['censor_vulgar'], $modSettings['censor_proper'], $modSettings);
* $censor->censor($message['body']);
*/
class Censor
{
const WHOLE_WORD = 'censorWholeWord';
NEXT_TAG_MUST_BE
TAGS_ONLY_CONTENT
REMOVE_EMPTY
PARAM_IS_URL
EQUALS_IS_URL
NO_PARSE
FILTER_CONTENT
FILTER_EQUALS
FILTER_PARAM
BLOCK_LEVEL
<?php
final class \BBC\Types\ClosedType
{
const HAS_PARAM = false;
const HAS_EQUALS = false;
const HAS_BEFORE = true;
const HAS_AFTER = true;
const HAS_CONTENT = false;
const PARSE_CONTENT = false;
const PARSE_EQUALS = false;
@joshuaadickerson
joshuaadickerson / Router.php
Created March 13, 2016 18:28
I just found this in Notepad++ so I'm adding it to gist so I can close it. I don't know what I was working on
<?php
interface RouteInterface {
public $regex;
public $methods = array();
public $handler;
protected $data;
/**
* @param string|array $method
<?php
$message = $parser->parse($message);
function captureTrackedContent($message, $code, $pos_padding = 0)
{
$start = $pos_padding + $code[Codes::TRACKED_CONTENT]['start'];
$end = $pos_padding + isset($code[Codes::TRACKED_CONTENT]['end']) ? $code[Codes::TRACKED_CONTENT]['end'] : strlen($message);
$content = substr($message, $start, $end - $start);
@joshuaadickerson
joshuaadickerson / AbstractLogin.php
Created January 13, 2016 23:16
Mock example of what changes would be made to use tokens instead of password hashes for the login cookie
<?php
abstract class AbstractLogin
{
protected $login_cookie = 'MYSITE_LOGIN';
// This is just for mocking. This would be a database request
protected $users = [
1 => 'hashed(foopass)',
15 => 'hashed(pass)',