Skip to content

Instantly share code, notes, and snippets.

:shipit:
ship it

Kailey Lampert trepmal

:shipit:
ship it
Block or report user

Report or block trepmal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View file-cleanup.sh
# Find your files in /tmp older than 7 days
find /tmp -mtime +7 -user `whoami` -exec ls -lpdh {} \; | column -t
# Delete your files in /tmp older than 7 days
find /tmp -type f -mtime +7 -user `whoami` -delete
find /tmp -type d -mtime +7 -user `whoami` -empty -delete
# Find your files in /home (2 dirs deep) older than 7 days
find /home -maxdepth 2 -mtime +7 -user `whoami` -exec ls -lpdh {} \; | column -t
View wlo-widget.php
<?php
// Plugin Name: WLO Widget
// register core 'text' widget
register_wlo_widget( 'text' ); // id base
/**
* hook in
*/
function register_wlo_widget( $widget_id ) {
View curl-rest-cli.php
<?php
if ( !defined( 'WP_CLI' ) ) return;
/**
*/
class trepmal_cURL_REST extends WP_CLI_Command {
/**
* Generate cURL command for REST API
@trepmal
trepmal / debug-rest-api.php
Last active Mar 1, 2018
Intended for use alongside Debug Bar tools. Do not use in Production.
View debug-rest-api.php
<?php
/**
* Plugin Name: Debug Bar for REST API
* Description: Enable Debug Bar for REST API endpoints (add ?debug). Not for production.
* Author: Kailey "trepmal" Lampert
*/
namespace trepmal\rest_debug;
/**
View dev-plugins.php
<?php
/**
* Plugin Name: Dev Plugins
*/
add_action( 'muplugins_loaded', function() {
// Plugins to activate automatically.
$auto_activate = [
'debug-bar/debug-bar.php',
'debug-bar-extender/debug-bar-extender.php',
View mail-notice.md
<some-command> | tee some.log ; \
  ( [[ ${PIPESTATUS[0]} -eq 1 ]] \
  && (tail some.log | mail -s '<some-command> exited with error' you@example.com) \
  || (tail some.log | mail -s '<some-command> finished' you@example.com) )

breakdown:

<some-command> | tee some.log;

View bad-script.sh
#!/bin/bash
echo "mua hahah"
exit

# Uses an escape sequence to move the cursor up.
# So if you `cat` this file, it will hide the "bad" part
# But if you execute the file, the "bad" will be done.
# Try `cat -v` to expose the escape characters.
echo "gooooood file"
View backups.sh
#!/bin/bash
#
# Back up my files and databases
#
#
# backup_static_if <fullpath> <shortname>
# use directory fingerprint to avoid unnecessary backups
#
View auto-update.md

Moved

Update core (and db), plugins, and themes, logging status to syslog. Ideal for running on a cronjob

Example of syslog

Apr 26 04:07:56 vvv vagrant: [WPAutoUpdate] Local WordPress Dev | http://local.wordpress.dev
Apr 26 04:08:27 vvv vagrant: [WPAutoUpdate] Core update: WordPress updated successfully to 4.5
Apr 26 04:08:28 vvv vagrant: [WPAutoUpdate] DB update: WordPress database already at latest db version 36686
View wp-excerpt-change.php
<?php
// Plugin Name: Example. Change "Excerpt" meta box heading
namespace KDL\excerpt_change;
function filter_excerpt( $translations, $text, $domain ) {
if ( $text == 'Excerpt' ) {
return "New Excerpt";
}
You can’t perform that action at this time.