The popular open-source contract for web professionals by Stuff & Nonsense
- Originally published: 23rd December 2008
- Revised date: March 15th 2016
- Original post
grep -P "^\s+\`" foo.sql | \ | |
sed -E 's/\([0-9]*/(/' | \ | |
awk '{print $1 "\t" $2}' | \ | |
sort | \ | |
uniq -c | \ | |
sort -n -r > db-common-column-names | |
# 300 MiB SQL file: 0.4 seconds |
#!/bin/bash | |
# BE CAREFUL TO SPECIFY FILENAMES WHEN COMMITTING! | |
IGNORE_FILENAME=.svnignore | |
svn status | awk '{print $2}' | while read FILE ; do | |
grep -x $FILE $IGNORE_FILENAME > /dev/null | |
STATUS=$? | |
if ! $(exit $STATUS) ; then |
<?php | |
// Put this in wp-config.php and replace https://example.com/ with the URL of the production site. | |
define( 'RH_USE_REMOTE_MEDIA_URL', 'https://example.com/' ); | |
// Put the rest of this in functions.php or a custom plugin or somewhere else. | |
if ( defined( 'RH_USE_REMOTE_MEDIA_URL' ) && ! empty( RH_USE_REMOTE_MEDIA_URL ) ) { | |
add_filter( 'wp_get_attachment_image_src', array( $this, 'filter_wp_get_attachment_image_src' ) ); | |
add_filter( 'wp_calculate_image_srcset', array( $this, 'filter_wp_calculate_image_srcset' ) ); | |
add_filter( 'wp_get_attachment_url', array( $this, 'filter_wp_get_attachment_url' ) ); | |
} |
<?php | |
/** | |
* Properly format a user-entered URL for use in an href or src attribute. | |
* | |
* @param string $url User-entered URL | |
* @return string Formatted URL | |
*/ | |
function url_esc(string $url) : string | |
{ |
# Output URLs of the website whose DOCUMENT_ROOT is the current directory. | |
# Reads from hosts file and Apache config | |
alias localurl='grep "$(grep -r -C3 $(pwd) /etc/httpd/vhost.d/ | grep -ioP "servername(.*)|serveralias(.*)" | awk '\''{print $2}'\'')" /etc/hosts | awk '\''{print $2}'\'' ' |
#!/usr/bin/env bash | |
get_hosts="cat ~/.ssh/config | grep Host\\\\s | awk '{ print \$2 }' | sort -u" | |
if [[ $# -eq 0 ]] ; then | |
eval "$get_hosts | nl -ba" | |
exit; | |
fi | |
host_num=$1 |
grep -roE "do_action\s*\(\s*['\"](\w+)" . | awk -F"'|\"" '{print $2}' | sort -u |
Log into MySQL databases via preconfigured aliases. Note that the alias name 'foo' is to be identified in the config file as 'clientfoo'.
$ cat ~/.bashrc
my() {
/usr/bin/mysql --defaults-group-suffix="$@"
}
whois $(dig stackoverflow.com | grep -P "IN\s*A(AAA)?\s*\d" | awk '{print $5}' | head -n1) | grep -i country |