Skip to content

Instantly share code, notes, and snippets.

View greggles's full-sized avatar

Greg Knaddison greggles

View GitHub Profile
<?php
// A standalone script to generate CVE json from Drupal.org's API.
// The intended output requires manual involvement at this point.
// usage: php advisory-to-cvejson.php
// Function to fetch JSON data from a URL
function fetch_json_data($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@greggles
greggles / gist:d4e208847671e0719568fef87ff2517e
Created November 7, 2024 16:08
gemini counting letters in strawberry
greggles@Gregs-MacBook-Pro ~/c/drupalorg (7.x-3.x)> python3 strawberry.py
The letter 's' appears 1 times.
The letter 't' appears 1 times.
The letter 'r' appears 3 times.
The letter 'a' appears 1 times.
The letter 'w' appears 1 times.
The letter 'b' appears 1 times.
The letter 'e' appears 1 times.
The letter 'y' appears 1 times.
@greggles
greggles / covid19apps.md
Last active November 10, 2020 18:23
Some information on covid19 apps in the USA 🇺🇸

List of Coronavirus Apps

  • State
  • App links with rating + number of reviews
  • Consulting provider, if known
  • Technologies (GPS, GAEN, TCN, etc.)
  • Date launched
  • Screenshots (followup)
  • What is their diagnosis key server?
```
ddev exec drush config-import -y --source=../config/default
+------------+--------------------------------------------------------------------------+-----------+
| Collection | Config | Operation |
+------------+--------------------------------------------------------------------------+-----------+
| | core.entity_form_display.paragraph.two_column_paragraph_group.default | Delete |
| | core.entity_view_display.paragraph.two_column_paragraph_group.default | Delete |
| | core.entity_form_display.paragraph.three_column_paragraph_group.default | Delete |
| | core.entity_view_display.paragraph.three_column_paragraph_group.default | Delete |
| | field.field.paragraph.three_column_paragraph_group.field_paragraph_group | Delete |
<?php
print "<pre>";
$urls = [
[
'url' => 'https://badssl.com/',
'expected_http' => 200,
'expected_curl_errno' => 0,
'expected_curl_error' => '',
@greggles
greggles / gist:f6110e6a593109a7227c
Last active January 14, 2016 21:35
Mac: Check a ticket sales website every 30 seconds and when tickets go on sale, play a sound and open chrome to buy the tickets
# This url happens to be for a Tedeschi Trucks Band concert.
# You can go to any concert you want.
# But you *should* go to a Tedeschi Trucks Band concert at least once in your life.
watch -n 30 "curl -s https://events.applauze.com/events/3083244 | grep -i 'Coming Soon' || open -a Google\ Chrome https://events.applauze.com/events/3083244 ; say 'tickets are for sale' "
@greggles
greggles / gist:df1faa38ab27798e8e38
Last active November 12, 2015 18:37
Which database methods in Drupal are used most often?
# Grep for db_select and grab the next 5 lines
# grep and sed those lines to find db methods
# isolate the methods
# count them.
# I ran this in the core: modules/ directory, would be interesting to see results from a mix of sites/all/modules/ directories
➜ grep -hr -A 5 "db_select" . | grep "\->" | sed 's/^[ ]*//' | sed 's/\$[a-z]*//' | grep "^-" | awk -F\( '{print $1}' | sort | uniq -c | sort -rn
184 ->condition
168 ->fields
87 ->addField
70 ->execute
@greggles
greggles / find-drupal-files-by-where-they-are-being-used.php
Last active March 5, 2016 00:17
Finds Drupal files by name and lists out where they are being used (i.e. what nodes or users are associated with it)
<?php
// Save this, edit it and then...
// Run this with something like drush -v @sitename scr filename.php
// If a file is found and known to be in use, the use will be listed as an array of data.
// Edit the "card-1.xls" part.
$fid = db_query("SELECT fid FROM {file_managed} WHERE filename = 'card-1.xls'")->fetchField();
if ($fid) {
$file = file_load($fid);
@greggles
greggles / gist:dc14aba7222c2cece348
Created May 1, 2015 21:25
Find code style errors in modules in the subdirectory
find . -type d -d 1 -exec phpcs --standard=Drupal --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt' --report-file={}_new.txt {} \;
# typical output:
# mani:contrib-patched greggles$ ls -lS *.txt
# -rw-r--r-- 1 greggles staff 10970 May 1 15:21 password_policy_style_issues.txt
# -rw-r--r-- 1 greggles staff 4887 May 1 15:21 code_coverage_style_issues.txt
# -rw-r--r-- 1 greggles staff 2681 May 1 15:21 quantcast_style_issues.txt
# mani:contrib-patched greggles$
diff --git a/sites/all/modules/custom/card_member/card_member.form.inc b/sites/all/modules/custom/card_member/card_member.form.inc
index 6b6fe25..f62abf5 100644
--- a/sites/all/modules/custom/card_member/card_member.form.inc
+++ b/sites/all/modules/custom/card_member/card_member.form.inc
@@ -13,11 +13,11 @@ function card_member_notifications($form, &$form_state, $account, $category = 'a
array(':uid' => $account->uid))->fetchField();
$default_values = isset($result) ? unserialize($result) : '';
$mail_choices = array(
- 'Activation Outreach',
- 'Training Outreach',