Skip to content

Instantly share code, notes, and snippets.

@cweagans
cweagans / abraham-twitteroauth-fix-twitter-upload.patch
Created April 26, 2024 08:17
Fix uploading files to Twitter when they originate from an S3 bucket
diff --git a/src/TwitterOAuth.php b/src/TwitterOAuth.php
index 37114c5..4988dbb 100644
--- a/src/TwitterOAuth.php
+++ b/src/TwitterOAuth.php
@@ -330,21 +330,20 @@ class TwitterOAuth extends Config
* Private method to upload media (not chunked) to upload.twitter.com.
*
* @param string $path
* @param array $parameters
*
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

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 / notes.md
Created November 24, 2015 22:20
Drupal.org Composer followups
  • Decide on subdir or subdomain for metadata
  • composer.json parsing -> project dependency
  • Decide on metadata structure (for caches)
  • Figure out how caching composer metadata works
  • Create project_composer project on d.o
  • Check HTTP auth support in Composer
  • Get decision on contrib semver
  • Define composer.json -> metadata merge rules
  • Translate submodule dependencies to package dependencies in composer metadata
  • Open issue on Packagist for federated metadata
@cweagans
cweagans / -
Created November 3, 2015 15:56
diff --git a/docroot/modules/custom/pc_editorial/pc_editorial.module b/docroot/modules/custom/pc_editorial/pc_editorial.module
index 30de354..0edaeb0 100644
--- a/docroot/modules/custom/pc_editorial/pc_editorial.module
+++ b/docroot/modules/custom/pc_editorial/pc_editorial.module
@@ -1,5 +1,7 @@
<?php
+use Drupal\Core\Form\FormStateInterface;
+
function pc_editorial_entity_type_alter(array &$entity_types) {

The annoying thing is not that they're calling and asking for money. It's that the frequency with which they do so is abusive, and that they're marketing the most to the wrong group of people (i.e. people that just graduated, who are statistically likely to be digging themselves out of a gigantic student loan). Alienating your donor pool before they're even able or willing to donate is not a good long-term strategy for - you know - getting donations.

The actual communications themselves are not really conducive to getting donations, either. Instead of reaching out with the equivalent of "Hi, money plz. kthxbai.", send a monthly email newsletter with what the Boone fund is actually doing with that money, along with any future initiatives that they want to pursue, and information about their fundraising goals and progress toward those goals. Then - as a FOOTNOTE - ask for money to help further these goals. It shouldn't be a header. It shouldn't be the subject of the email. It shouldn't be the opening line on t