Skip to content

Instantly share code, notes, and snippets.

@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:1110161
Created July 27, 2011 19:24
Generic Paging Links with ColdFusion
<!---
See: http://coreygilmore.com/blog/2008/05/29/generic-paging-links-with-coldfusion/
--->
<cffunction name="paginate_links" access="public" output="false" returntype="any" hint="Return links to paginated results, heavily based on paginate_links() <http://trac.wordpress.org/ticket/3159> from WordPress <http://wordpress.org/> by Michael D Adams <http://blogwaffe.com/>">
<cfargument name="link_format" required="YES" type="string" default="" hint="Link format. Use %PAGE% for the page number placeholder (required), %SHOW% for the paging size (optional)" />
<cfargument name="prev_next" required="YES" type="boolean" default="true" hint="Show previous/next links" />
<cfargument name="prev_text" required="YES" type="string" default="&laquo;&nbsp;Previous" hint="Text for 'Previous Page' link" />
<cfargument name="next_text" required="YES" type="string" default="Next&nbsp;&raquo;" hint="Text for 'Next Page' link" />
<cfargument name="end_size" required="YES" type="numeric" default="1" hint="How many numbe
@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: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 / 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)
@cfg
cfg / bash_script_source_dir.sh
Created May 21, 2012 13:14
Get the directory the current bash script is located in.
# From discussion at http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Is a useful one-liner which will give you the full directory name of the script no matter where it is being
# called from
# Or, to get the dereferenced path (all directory symlinks resolved), do this:
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# These will work as long as the last component of the path used to find the
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\weinre]
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"="C:\\Path\\To\\srvany.exe"
"DisplayName"="weinre"
"WOW64"=dword:00000001
"ObjectName"="LocalSystem"
@cfg
cfg / gist:4511512
Created January 11, 2013 15:28
crudely extract tab delimited wordpress plugin name/directory name
$ cd /path/to/wordpress/wp-content/plugins/
$ for foo in `find . -maxdepth 1 -type d` ; do p=$(basename $foo) ; n=`grep "Plugin Name" "$p/$p.php" | cut -d':' -f2-` ; echo -e "$p\t$n" ; done
@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) {