Skip to content

Instantly share code, notes, and snippets.

// 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.');
@cfg
cfg / gist:3b7ebf47d0b6189bb0d95a7a7c880344
Created April 28, 2016 15:19
Excel: Format inches as Feet' Inches"
=FLOOR(A1/12,1) & """ " & ROUND( 12*((A1/12)-FLOOR(A1/12,1)), 1) & "'"
@cfg
cfg / guidv4.js
Created March 22, 2016 16:31
generate a v4 GUID in JS
// Based on http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
var guidv4=(function(_w, lut, i){
lut = []; for (i=0; i<256; i++) { lut[i] = (i<16?'0':'')+(i).toString(16); }
var r = Math.random, ui32=0x100000000, _crypto = _w.crypto || _w.msCrypto;
return function(d) {
if( _crypto && _crypto.getRandomValues ) {
try {
d = new Uint32Array(4);
_crypto.getRandomValues(d);
} catch(e) {
jQuery('div.permissionsType select[name$="permissions.type"]').val('some'); // some types
jQuery('div.permissionsType > ul li > select').val('some'); // set access for all types to to 'some'
jQuery('div.permissionsType > ul li').find('input[type=checkbox][value$="/write"]').prop('checked', 0); // uncheck all "Write" boxes
jQuery('div.permissionsType > ul li').find('input[type=checkbox][value$="/publish"]').prop('checked', 0); // uncheck all "Publish" boxes
@cfg
cfg / comments.php
Created December 3, 2015 16:51
Fix expensive comment queries
<?php
if ( defined( 'WPCOM_IS_VIP_ENV' ) && true === WPCOM_IS_VIP_ENV ) {
wpcom_vip_load_plugin( 'disable-comments-query' );
// Kill wp_count_comments lookups because they happen too frequently and are super slow.
if ( is_admin() ) {
add_filter( 'wp_count_comments', function( $counts, $post_id ) {
if ( $post_id )
return $counts;

Keybase proof

I hereby claim:

  • I am cfg on github.
  • I am cfg (https://keybase.io/cfg) on keybase.
  • I have a public key whose fingerprint is 3208 1C5B 3FB2 1376 E3AD FFE5 F0C4 6E9F BC74 2B01

To claim this, I am signing this object: