Skip to content

Instantly share code, notes, and snippets.

@cfg
cfg / gist:4538719
Last active August 22, 2017 13:32
wordpress action/hook logging
<?php
/**
* Log all filter and action calls.
*
* Actions and filters are logged to two separate global variables $_x_wp_filters and $_x_wp_actions respectively.
* Hardcode loading this in wp-settings.php to generate a complete tree of filters/actions.
* Add `require_once( '/path/to/hook-logging.php' );` after `require_once( ABSPATH . WPINC . '/plugin.php' );`
*
*/
function x_all_hook_logging($args) {
@cfg
cfg / ga_spreadsheet_onedit_timetimestamp.js
Created April 12, 2017 17:17
Google Sheets: Add a "last modified" timestamp to a row when a cell in a specific column is changed. Quick, hacky code, per usual.
function onEdit( evt ) {
var ss = SpreadsheetApp.getActiveSheet();
var sheet_name = 'Bug List';
if ( sheet_name !== ss.getName() ) {
return;
}
var status_col = 8; // column number that contains the status type
var lastmod_col = 10; // column number where the timestamp should go
@cfg
cfg / gist:4585f041cd069d3f2639e53fc33ae281
Created April 4, 2017 18:17
Extracting 2FA seeds from Authy
Open chrome://extensions, debug Authy main.html
Set a breakpoint in Authy app.js in this function:
d.prototype.getOtp = function() {
return this.isEncrypted() ? "------" : this.otpGenerator.getOtp(this.decryptedSeed, this.digits)
}
Can use a conditional breakpoint, where this.getName() == 'your.account.display.name'
console.log( "otpauth://totp/%s:%s?secret=%s&issuer=%s", encodeURIComponent( this.getAccountName() ), encodeURIComponent( this.getName() ), encodeURIComponent(this.decryptedSeed), this.getAccountName() );
@cfg
cfg / WWDC Line hax
Created November 9, 2016 15:38 — forked from b3ll/WWDC Line hax
// June 11, 2012
// https://twitter.com/b3ll/status/212169466665111552
-(BOOL)isBlocked
{
return false;
}
-(int)epicWWDCLineHacks
{
@cfg
cfg / print_stormchat.js
Created September 13, 2016 19:19
Make a StormChat print friendly
jQuery('#bottom-bar').remove();
jQuery('#contact-list').remove();
jQuery('html').css('overflow', 'auto');
jQuery('#chat-room').css({ 'height': 'auto', 'width': '100%', 'overflow-y': 'auto' });
// Browse to https://my.slack.com/team#active and open the developer console
x=[];
jQuery('#active_members_list .team_list_item.member_item.active').each( function(ix, el) {
el = jQuery(el);
if( el.find('.member_image.bot').length ) {
return; // skip bots
}
var details = {
name: el.find('.member_name').text(),
tel: el.find('.member_data_table a[href^=tel]').text(),
@cfg
cfg / floatsign.sh
Created July 25, 2016 15:35 — forked from mediabounds/floatsign.sh
A small bash script to re-sign iOS applications.
#!/usr/bin/env bash
# Copyright (c) 2011 Float Mobile Learning
# http://www.floatlearning.com/
# Extension Copyright (c) 2013 Weptun Gmbh
# http://www.weptun.de
#
# Extended by Ronan O Ciosoig January 2012
#
# Extended by Patrick Blitz, April 2013
@cfg
cfg / sshkey.bash
Created July 22, 2016 18:57
Attempt to locate the SSH public and private key used for a host/user@host.
#!/usr/bin/env bash
HOST="$1"
[[ -z "$HOST" ]] && (>&2 echo "Usage: $0 [user@]hostname") && exit 1
OUT="$(ssh -o ConnectionAttempts=1 -o ConnectTimeout=2 -o StrictHostKeyChecking=no -o "PreferredAuthentications=publickey" -T "$HOST" -v true 2>&1 | grep -B3 "Authentication succeeded (publickey)" )"
RET="$?"
if [[ "$RET" -ne "0" ]] ; then
(>&2 echo "ERROR (errno: $RET): Unable to connect or authenticate to $HOST")
@cfg
cfg / vaultpress_import_sql.sh
Last active July 22, 2016 15:15
Import individual MySQL .sql files that weren't dumped using --opt or --extended-insert (like from a VaultPress dump. Show some *very* basic detail about file size, number of lines (correlates roughly to # of rows), and timing.
#!/usr/bin/env bash
VP_DB="set_to_your_dbname"
[[ ! -d "done" ]] && mkdir done
[[ ! -d "error" ]] && mkdir error
echo "To prevent any writes to the database during the import, you should disable the site. Add this to your wp-config.php:"
echo "if( DB_NAME == '$VP_DB' ) die( 'This site is is disabled during import.' );"
read -p "Press Enter to continue. "
time for VP_SQL_FILE in *.sql ; do
@cfg
cfg / tinymce_replace_hidden_nbsp.js
Created June 16, 2016 20:14
Simple/hacky bookmarklet to replace hidden nbsp (\u00A0) characters in a WordPress tinymce editor
javascript:(function() {
if( !window.tinymce ) { alert('tinymce was not found, aborting.' ); return; }
var el = tinymce.get('content');
if( !el ) { alert('Unable to find the WP Edit box - aborting.' ); return; }
var matches = el.getContent().match( /\u00A0/g );
if( ! matches || matches.length === 0 ) { alert('No hidden non-breaking spaces were found.' ); return; }
if( matches && matches.length >= 1 ) {
if( confirm( 'Found ' + matches.length + ' non-breaking space character' + ( matches.length === 1 ? '' : 's' ) + ' replace them with a normal space?' ) ) {
el.setContent( el.getContent().replace( /\u00A0/g, ' ' ) );
alert('Done - save the post and run this again.');