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 ); } );

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 / gist:1110167
Created July 27, 2011 19:25
Mimic PHP's empty() function in ColdFusion
<!---
See: http://coreygilmore.com/blog/2008/05/01/mimic-phps-empty-function-in-coldfusion/
--->
<cfscript>
function empty(val) {
/**
* Return TRUE if one of the following conditions
* for a defined variable is met:
* - A *trimmed* string is empty
* - An array or struct is empty
@cfg
cfg / newtweet.js
Created July 27, 2011 19:22
Scroll to the first new tweet on twitter.com
/*
See: http://coreygilmore.com/blog/2011/07/20/bookmarklet-scroll-to-the-first-new-tweet/
*/
javascript:(function(){
if( document.getElementsByClassName ) {
var t=document.getElementsByClassName("last-new-tweet")[0];
if(t) {
window.scrollTo(0, t.offsetTop + t.offsetParent.offsetTop );
}
} else {
@cfg
cfg / gist:1110157
Created July 27, 2011 19:23
Print a MySQL-style table with PHP
/**
* Out a MySQL-style table of data
* See: http://coreygilmore.com/blog/2009/02/02/print-a-mysql-style-table-with-php/
*
* @param array $data Associative array of data to output.
* @param array $header_keys Optional; Assoc array of display names to use for headers. Keys must match those of $data. Defaults to keys of $data.
* @param string $glue String to join lines with, defaults to newline.
* @return string
*
*/
@cfg
cfg / gist:1110163
Created July 27, 2011 19:25
Merge Structs in ColdFusion
<!---
See: http://coreygilmore.com/blog/2008/05/08/merge-structs-in-coldfusion/
--->
<cfscript>
function struct_merge() {
var base = {};
var i = 1;
for( i = 1; i LTE ArrayLen(arguments); i=i+1 ) {
if( IsStruct(arguments[i]) ) {
@cfg
cfg / gist:1110171
Created July 27, 2011 19:30
Generate a SecurID token and automatically connect to a Cisco VPN
-- See: http://coreygilmore.com/blog/2010/02/04/applescript-to-generate-a-securid-token-and-automatically-connect-to-a-cisco-vpn/
-----------------------------------------------
-- Automated token generation and VPN logins
-- Copyright 2010, Corey Gilmore
-- http://coreygilmore.com/
-- Last Modified: 2010-02-04
------------------------------------------------
set theConnection to "My VPN" -- the name of your VPN connection
set thePin to "" -- set to "" to prompt every time (recommended)