Skip to content

Instantly share code, notes, and snippets.

View sirbrillig's full-sized avatar

Payton Swick sirbrillig

View GitHub Profile
@sirbrillig
sirbrillig / bootstrap.php
Created December 5, 2017 22:41
Bootstrap for writing phpcs sniff tests
<?php
require_once(__DIR__ . '/../vendor/squizlabs/php_codesniffer/tests/bootstrap.php');
require_once(__DIR__ . '/SniffTestHelper.php');
@sirbrillig
sirbrillig / SniffTestHelper.php
Created December 5, 2017 22:19
A helper class for testing phpcs sniffs
<?php
use PHP_CodeSniffer\Files\LocalFile;
use PHP_CodeSniffer\Ruleset;
use PHP_CodeSniffer\Config;
class SniffTestHelper {
public function prepareLocalFileForSniffs($sniffFiles, string $fixtureFile): LocalFile {
$config = new Config();
$ruleset = new Ruleset($config);
@sirbrillig
sirbrillig / cpx
Last active December 1, 2017 09:08
Shortcut to run commands in vendor/bin for PHP Composer projects
#!/usr/bin/env php
<?php
$vendorBinDirectory = './vendor/bin';
$helpMessage = "Shortcut to run commands in vendor/bin for Composer projects
Usage: cpx <command>
<command> must be an executable file in the vendor/bin directory.
Read about vendor binaries here:
@sirbrillig
sirbrillig / Maybe.php
Last active December 11, 2017 22:05
A simple implementation of a `Maybe` return class in PHP.
<?php
class Maybe {
private $value;
private $error;
private function __construct($value, $error) {
$this->value = $value;
$this->error = $error;
}
@sirbrillig
sirbrillig / phpcs.xml
Last active May 19, 2021 14:17 — forked from Ovsyanka/ruleset.xml
PHPCS rules for PSR2 with tabs, same-line braces, and missing variable detection
<?xml version="1.0"?>
<ruleset name="PaytonsStandard">
<description>
Originally from https://gist.github.com/Ovsyanka/e2ab2ff76e7c0d7e75a1e4213a03ff95
PSR2 with changes:
- tabs instead of spaces (https://gist.github.com/gsherwood/9d22f634c57f990a7c64)
- bracers on end of line instead new line
- unused/undefined variable detection (https://github.com/sirbrillig/phpcs-variable-analysis)
</description>
<arg name="tab-width" value="4"/>
@sirbrillig
sirbrillig / button-2.diff
Created August 16, 2017 21:35
Button-2: Fix Headstart image size
Index: button-2/inc/headstart/en.json
===================================================================
--- button-2/inc/headstart/en.json (revision 45326)
+++ button-2/inc/headstart/en.json (working copy)
@@ -95,7 +95,7 @@
"hs_custom_meta": "_hs_first_post",
"hs_sharing": 1,
"hs_like_status": 1,
- "attachment_url": "https:\/\/headstartdata.files.wordpress.com\/2016\/04\/pexels-photo-30732.jpg",
+ "attachment_url": "https:\/\/headstartdata.files.wordpress.com\/2017\/08\/pexels-photo-30732-small.jpg",
diff --git a/index.js b/index.js
index bd240d0..afa5674 100644
--- a/index.js
+++ b/index.js
@@ -165,7 +165,7 @@ export default function request( options, fn ) {
if ( body && formData ) {
debug( 'API ignoring body because formData is set. They cannot both be used together.' );
}
- if ( body && ! formData ) {
+ if ( body ) {
diff --git a/package.json b/package.json
index 578f3fd..d4b1ba8 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,7 @@
},
"dependencies": {
"debug": "~2.2.0",
- "superagent": "^2.1.0",
+ "superagent": "visionmedia/superagent#385f1f5b403c749b57ab28699fba51814806543e",
@sirbrillig
sirbrillig / index.js.diff
Last active August 15, 2017 21:01
wpcom-xhr-request: Prevent sending body if formData is set
diff --git a/index.js b/index.js
index 9db01ce..165d708 100644
--- a/index.js
+++ b/index.js
@@ -162,7 +162,7 @@ export default function request( options, fn ) {
}
// body
- if ( body ) {
+ if ( body && ! formData ) {
diff --git a/client/lib/wp/sync-handler/index.js b/client/lib/wp/sync-handler/index.js
index b07e761..0f67c4e 100644
--- a/client/lib/wp/sync-handler/index.js
+++ b/client/lib/wp/sync-handler/index.js
@@ -54,8 +54,8 @@ export class SyncHandler {
window.syncHandler = this;
}
- this.reqHandler = handler;
- return this.syncHandlerWrapper( handler );