Skip to content

Instantly share code, notes, and snippets.

@cfg
cfg / dyndns.js
Created June 17, 2014 19:23
Hack to dump a dyndns zone in pseudo-BIND format.
jQuery('#adv3 tr.notranslate').each( function( i, el ) {
el = jQuery( el );
dom = el.find('td').eq(0).text();
ttl = el.find('td').eq(1).find('input').val();
type = el.find('td').eq(2).text().trim();
val = el.find('td').eq(3).find('input').val();
console.log( "%s\t\t%s\tIN %s\t%s", dom, ttl, type, val );
});
@cfg
cfg / list_itunes_backups.php
Created January 14, 2015 18:40
Hack to enumerate all iTunes backups and write a CSV with the basic information for each backup.
#!/usr/local/bin/php
<?php
$plists = array(
'Manifest.plist' => array(
// ":Version",
":WasPasscodeSet",
":IsEncrypted",
":Date",
":Lockdown:ProductType",
@cfg
cfg / vip-dns.js
Created January 30, 2015 21:41
Hack function to bulk import DNS on WP VIP
/**
* Paste this into the console on your /wp-admin/admin.php?page=domains page
* Make sure the 'Edit DNS' tab is selected
* Add entries using add_record( 'example.com', 'A', '127.0.0.1' );
* or add_record( 'example.com', 'MX', '10 mail.example.com' );
* MX records values should be the Priority<space>mailserver
*
*/
add_record = function( record, type, value ) {
var valid_types = {
@cfg
cfg / spotify-track-numbers.js
Created April 8, 2015 15:06
quickly add track numbers to a spotify web playlist
// add jquery to collection-app-spotify frame
jQuery('.tracklist-playlist tbody tr').each( function(ix, el) { var r = jQuery(el); r.find('.tl-cell.tl-save').html( r.index() + 1 ); } );
function parse_str(str, array) {
// discuss at: http://phpjs.org/functions/parse_str/
// original by: Cagri Ekin
// improved by: Michael White (http://getsprink.com)
// improved by: Jack
// improved by: Brett Zamir (http://brett-zamir.me)
// bugfixed by: Onno Marsman
// bugfixed by: Brett Zamir (http://brett-zamir.me)
// bugfixed by: stag019
// bugfixed by: Brett Zamir (http://brett-zamir.me)
@cfg
cfg / slack_emoji.js
Last active May 23, 2019 16:56
Crudely extract custom emoji from a Slack web instance. Load the web interface for the Slack instance and paste this into the developer console.
jQuery('#main_emo_menu').click();
jQuery('button[aria-label=Custom]').click();
jQuery('.p-emoji_picker__list').css('min-height', '900px');
jQuery('.p-emoji_picker__list_container').parents('.ReactModal__Content.ReactModal__Content--after-open.popover').css('top', '0px');
jQuery('.p-emoji_picker__list_container').css('max-height', '100%');
jQuery('.p-emoji_picker__content .p-emoji_picker__input_container').hide();
var emoji = [];

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:

@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;
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 / 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) {