Skip to content

Instantly share code, notes, and snippets.

View cweagans's full-sized avatar

Cameron Eagans cweagans

View GitHub Profile
diff --git a/classes/wp-security-utility.php b/classes/wp-security-utility.php
index e1c53dc..4f203ef 100644
--- a/classes/wp-security-utility.php
+++ b/classes/wp-security-utility.php
@@ -534,7 +534,9 @@ class AIOWPSecurity_Utility {
$current_unix_time = current_time('timestamp', true);
$previous_hour = $current_unix_time - 3600;
AIOWPSecurity_Utility::is_multisite_install() ? $tbl = $wpdb->sitemeta : $tbl = $wpdb->prefix . 'options';
- $query = $wpdb->prepare("SELECT * FROM {$tbl} WHERE option_name LIKE 'aiowps_captcha_string_info_time_%' AND option_value < %s", $previous_hour);
+ AIOWPSecurity_Utility::is_multisite_install() ? $name_col = 'meta_key' : $name_col = 'option_name';
@cweagans
cweagans / README.md
Last active March 12, 2020 03:58
Cache the output of any CLI tool

cache.sh

Caches the output of any other CLI tool in a simple filesystem-backed cache.

Installation

Put the file in your $PATH somewhere. I called mine cache instead of cache.sh, so that's what's reflected in the examples below.

Use

@cweagans
cweagans / Vagrantfile
Last active June 8, 2018 20:46
Vagrantfile
# Up to date version can always be found at https://gist.github.com/cweagans/4e879a72985905e145df
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.synced_folder ".", "/srv", type: "nfs"
config.vm.network "private_network", ip: "192.168.205.142"
config.vm.network "forwarded_port", guest: 80, host: 8085
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
0405564c3be1133fa898dee6026cc0311bb38afa486a5cf5bf59724d2f39d63592313c35d56f4931628fb273334888de5ee907a5d6fd1be13ca966f5d57b8a307f
<?php
$dispatcher = new EventDispatcher();
$dispatcher->addListener('event.name', [any PHP Callable]);
$dispatcher->dispatch('event.name'); // the callable you specified above gets called.
package main
import (
"bufio"
"fmt"
"log"
"net"
"os"
)

Keybase proof

I hereby claim:

  • I am cweagans on github.
  • I am cweagans (https://keybase.io/cweagans) on keybase.
  • I have a public key ASCpnZvox_Sn5AeHEZr6iswFpOCKb3HfXv0cmKoQFPrxMwo

To claim this, I am signing this object:

@cweagans
cweagans / PHPUnit_Extensions_PhptTestCase.patch
Last active January 20, 2017 00:51
Changes undesirable behavior in PHPUnit_Extensions_PhptTestCase for cweagans/mcrypt-polyfill tests.
diff --git a/src/Extensions/PhptTestCase.php b/src/Extensions/PhptTestCase.php
index 162c6d80..cb1cfe02 100644
--- a/src/Extensions/PhptTestCase.php
+++ b/src/Extensions/PhptTestCase.php
@@ -109,6 +109,10 @@ private function assertPhptExpectation(array $sections, $output)
$assertion = $sectionAssertion;
$expected = $sectionName == 'EXPECTREGEX' ? "/{$sectionContent}/" : $sectionContent;
+ // HACK: Get rid of filenames in expected output.
+ $expected = str_replace('%s%e' . basename($this->filename, 't'), '-', $expected);

Keybase proof

I hereby claim:

  • I am cweagans on github.
  • I am cweagans (https://keybase.io/cweagans) on keybase.
  • I have a public key ASAPmo6ViiFSyBRzFnaGu5YiSMZC2J7ktAyLRBXy4batRgo

To claim this, I am signing this object:

diff --git a/Library/Formula/ctags.rb b/Library/Formula/ctags.rb
index 87dd0ca..919717e 100644
--- a/Library/Formula/ctags.rb
+++ b/Library/Formula/ctags.rb
@@ -12,6 +12,8 @@ class Ctags < Formula
# fixes http://sourceforge.net/tracker/?func=detail&aid=3247256&group_id=6556&atid=106556
def patches
+ # rewritten PHP parser
+ { :p1 => "http://sourceforge.net/p/ctags/patches/_discuss/thread/3a930d9f/1405/attachment/0000-PHP-parser-rewrite.patch" }