Skip to content

Instantly share code, notes, and snippets.

@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 ) {
@cfg
cfg / jquery-deparam.js
Created June 18, 2013 19:25
jquery-deparam: deparam function separated from jQuery BBQ v1.3pre by Ben Alman http://benalman.com/projects/jquery-bbq-plugin/
/*jslint browser: true, ass: true, eqeq: true, forin: true, newcap: true, nomen: true, plusplus: true, regexp: true, unparam: true, sloppy: true, todo: true, vars: true, white: true */
/*!
* jquery-deparam: deparam function separated from jQuery BBQ v1.3pre by Ben Alman
* http://benalman.com/projects/jquery-bbq-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// Project Home - http://benalman.com/projects/jquery-bbq-plugin/
@cfg
cfg / gist:5822755
Created June 20, 2013 13:39
wordpress admin dashboard - hooks and filters (common/useless ones removed)
filter : option_siteurl
filter : option_home
filter : option_siteurl
filter : option_blog_charset
action : plugins_loaded
filter : plugins_url
filter : default_option_embed_autourls
action : jetpack_modules_loaded
filter : jetpack_enable_open_graph
action : sanitize_comment_cookies
@cfg
cfg / gist:5823017
Created June 20, 2013 14:07
wordpress admin edit.php - hooks and filters (common/useless ones removed)
filter : option_siteurl
filter : option_home
filter : option_siteurl
filter : option_blog_charset
action : plugins_loaded
filter : plugins_url
filter : default_option_embed_autourls
action : jetpack_modules_loaded
filter : jetpack_enable_open_graph
action : sanitize_comment_cookies