Skip to content

Instantly share code, notes, and snippets.

View jrsouth's full-sized avatar
👷‍♂️
Buildin' stuff

jrsouth

👷‍♂️
Buildin' stuff
View GitHub Profile
@jrsouth
jrsouth / dotdigital-full-text-search.php
Created February 23, 2024 17:15
Full-text search of all Dotdigital campaign content
<?php
// @TODO: Take from CLI?
$searchString = 'sideBoxMiddleAd';
$verbose = false; // Bit of extra output, mostly so you can see progress
$apiRegion = 'r1';
@jrsouth
jrsouth / devtools-basics-wip.md
Last active July 14, 2021 12:24
An intro to dev tools (work in progess)

Stuff that everyone should know about "dev tools"

A quick introduction to (what shouldn't be considered) the dark arts.

We'll mainly focus on the parts that can be useful to everyone.

What's a dev tool?

Your web browser contains a large array of tools primarily created for the benefit of developers, allowing them to inspect, test, and manipulate what's happening within a page in THEIR browser.

@jrsouth
jrsouth / get_threads.sh
Created November 26, 2013 09:19
Mysql thread list
#!/bin/sh
SEARCH="tmp"
if [[ $# -eq 1 ]]
then
SEARCH=$1
elif [[ $# -gt 1 ]]
then
echo -ne "ERROR: Use without arguments to search for threads using tmp tables, or specify a single argument to search for in the 'state' field.\n"
@jrsouth
jrsouth / killmysqlprocs
Created November 8, 2013 12:41
Kill mysql processes/threads
mysql -N -B -e "select concat('KILL ',id,';') from information_schema.processlist where time > 1" | mysql
@jrsouth
jrsouth / mysqldump_commands
Created October 29, 2013 15:31
MYSQL dump commands
mysqldump --force --add-locks --single-transaction --quick --routines --extended-insert --log-error=mysqldump.error --databases lalrorg_live_drupal7 lalrorg_live_civicrm_audit lalrorg_live_civicrm | gzip -3 > live_snapshot_20131028_1552.sql.gz
mysqldump --force --single-transaction --quick --routines --extended-insert --log-error=mysqldump.error --databases lalrorg_live_drupal7 lalrorg_live_civicrm | gzip -3 > live_snapshot_20131029_1530_d7-civi.sql.gz
pv -p -t -e $DB_SNAPSHOT_CIVI | gzip -cd | mysql -u $USER -p$PASS $CIVI_DB
@jrsouth
jrsouth / up-down-monitor.php
Created October 24, 2013 12:55
Monitor Scripts
<?php
$search = 'Patient information'; // String to search for in the raw HTML
$url = 'http://leukaemialymphomaresearch.org.uk';
$repeat_delay = 1; // Time in hours between repeat notifications (you will get notifications more often if the site repeatedly goes up and down)
$peak_start = 6; // Time to start peak monitoring
$peak_end = 11; // Time to start off-peak monitoring
$timeout_peak = 10; //timeout in seconds during peak times
@jrsouth
jrsouth / threatboard.sh
Created October 23, 2013 13:20
SQL `watch` commands
watch -t -n 5 'echo -e "THREAT BOARD\n`date`\n\n TOP\n---------------------";top -b -n 1 | head -12 | tail -6; echo -e " \n df -h\n---------------------"; df -h | sort -g -k5; echo -e " \n free -m\n---------------------"; free -m; echo -e " \n MySQL\n---------------------"; mysql -e "SELECT COUNT(ID) AS \`NUMBER OF THREADS\` FROM INFORMATION_SCHEMA.PROCESSLIST;" | sed "$!{:a;N;s/\n/: /;ta}"; mysql -t -e "SELECT ID, USER, HOST, DB, STATE, COMMAND, TIME, SUBSTRING(INFO, 0, 20) AS QUERY FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY TIME DESC;";'
@jrsouth
jrsouth / Database Stats
Created August 29, 2013 09:50
SQL Snippets
SELECT table_schema "DB Name",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "Size in MB",
COUNT(table_name) "Tables"
FROM information_schema.tables
WHERE table_schema = "eximstats"
GROUP BY table_schema