Skip to content

Instantly share code, notes, and snippets.

@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
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 / ack.patch
Created January 22, 2013 13:49
patch ack 1.96 to ignore *.min.css files by default
--- ack.pl 2013-01-22 08:44:50.810396100 -0500
+++ ack-1.9.6.pl 2012-11-19 16:51:47.066613100 -0500
@@ -1645,7 +1645,6 @@
return if $filename =~ m{^core\.\d+$}o;
return if $filename =~ m{[._].*\.swp$}o;
return if $filename =~ /[.-]min\.js$/;
- return if $filename =~ /[.-]min\.css$/;
return 1;
}
@cfg
cfg / .bashrc
Last active December 14, 2015 05:59
My cygwin .bashrc
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
source ~/git-prompt.sh
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
source ~/bash_completion.d/git-completion.bash
# https://github.com/bobthecow/git-flow-completion
source ~/bash_completion.d/git-flow-completion.bash
alias ll='ls -lah'
@cfg
cfg / mintty_here.sh
Last active December 14, 2015 16:48
Add a "Open mintty here" item to Windows Explorer context menus. Basically `chere` with the addition of the Background key.
#!/bin/bash
KEY="mintty"
PROMPT="Open mintty h&ere"
if [ -z "$KEY" ] || [ -z "$PROMPT" ] ; then
echo "Key and Prompt cannot be empty"
exit 1
fi
@cfg
cfg / gist:5144185
Created March 12, 2013 16:09
Remove WordPress JetPack notifications.
<?php
/**
* Disable JetPack notifications which throw errors in Chrome:
* Unsafe JavaScript attempt to access frame with URL https://public-api.wordpress.com/rest/?notes_iframe=jetpack#http://example.com/wp-admin/edit.php?mode=excerpt from frame with URL http://bgrwp.cfgdev.com/wordpress/wp-admin/edit.php?mode=excerpt. The frame requesting access has a protocol of 'http', the frame being accessed has a protocol of 'https'. Protocols must match.
*
* @author Corey Gilmore <corey@bgr.com>
*
*/
function x_remove_jetpack_notifications() {
@cfg
cfg / gist:5707318
Created June 4, 2013 16:23
crude hack to retrieve query params using javascript. Should be using a closure, and need to have more intelligent and fully working (doesn't work properly with urlencoded names) array handling.
function getParam(p) {
if( typeof getParam.qs == 'undefined' ) {
getParam.qs = '';
getParam.params = {};
}
if( !window.location.search ) {
return false;
}
if( getParam.qs != window.location.search ) {
getParam.qs = window.location.search;
@cfg
cfg / gist:5730452
Created June 7, 2013 16:16
Download a Land Rover/Range Rover manual from Topix. Run on a page like: http://topix.landrover.jlrext.com/topix/service/document/225542 (iframe from the service manual page). Download links with cURL, assemble using Acrobat or similar.
links=[]; all=[];
function n(n){
return n > 9 ? "" + n: "0" + n;
}
jQuery('#treeroot a').each(function(ix, val){
e=jQuery(this);
h='http://topix.landrover.jlrext.com/topix/service/procedure/225542/PDF/' + e.attr('rel').split('#')[0] + '/en_GB';
t=e.find('nobr').text();
links.push(h);
all.push([t,h]);
@cfg
cfg / gist:5769768
Created June 12, 2013 22:40
Take an abbreviated number in the format of 1M, 500K and 2.5k and return 1000000, 500000 and 2500 respectively.
<?php
function number_longhand( $num ) {
$is_array = is_array( $num );
if( !$is_array )
$num = array( $num );
$num = preg_replace( '/[^\d\.BMK]/i', '', $num );
foreach( $num as $index => $n ) {