This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Uninstall all gems from all Ruby versions managed by rbenv | |
uninstall_gems() { | |
gems=$(gem list --no-versions) | |
for gem in $gems; do | |
gem uninstall $gem -aIx | |
done | |
gem list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Base.connection.tables.map { |table| | |
text_columns = ActiveRecord::Base.connection.columns(table).select { |c| c.type == :text } | |
text_columns.map { |col| | |
longest_record = ActiveRecord::Base.connection.exec_query("SELECT id, LENGTH(#{col.name}) as length FROM #{table} ORDER BY length DESC LIMIT 1").rows.first | |
{ | |
table: table, | |
column: col.name, | |
record_id: longest_record.first, | |
length: longest_record.last, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get secret from Kube and pipe to jq to parse and base64 decode | |
kubectl get secret name-of-the-secret -o JSON | jq '.data | map_values(@base64d)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get attachment ID from its URL | |
* | |
* @param string $url | |
* @return bool|int The Attachment ID or false if not found | |
*/ | |
function get_attachment_id_from_src($url) { | |
if (($pos = strpos($url, '/uploads/')) === false) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyTheme; | |
function setup() { | |
add_theme_support('admin-bar', ['callback' => __NAMESPACE__ . '\\admin_bar_bump']); | |
} | |
add_action('after_setup_theme', __NAMESPACE__ . '\\setup'); | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Convert ACF PHP to JSON | |
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON. | |
*/ | |
namespace ConvertAcfPhpToJson; | |
/** | |
* Add submenu item under 'Custom Fields' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disables the media attachment page by redirecting the user elsewhere. | |
* Save as 'image.php' in theme. | |
* Inspired by http://www.wpbeginner.com/wp-tutorials/how-to-disable-image-attachment-pages-in-wordpress/ | |
*/ | |
if ($post->post_parent) { | |
wp_redirect(get_permalink($post->post_parent), 301); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tabs in status bar | |
hardstatus alwayslastline | |
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]' | |
# Disable epilepsy triggers | |
vbell off | |
# Enable scrolling | |
termcapinfo xterm ti@:te@ |