Skip to content

Instantly share code, notes, and snippets.

@benbridge
benbridge / run_git_command_on_differences.fish
Last active November 12, 2019 18:19
Run a git command on files with differences selected using fzf.
function run_git_command_on_differences -d "Run a git command on files with differences selected using fzf."
# Return if not in a repo
# Suppress output to avoid default "no repo" message.
if ! git rev-parse --is-inside-work-tree >/dev/null
echo "No repo found."
return
end
# Return if no changes are detected (exit code is 0).
# Disable all output of the program (--quiet) and exit with 1 if there are

Keybase proof

I hereby claim:

  • I am benbridge on github.
  • I am benbridge (https://keybase.io/benbridge) on keybase.
  • I have a public key whose fingerprint is 73CD 5527 A803 7CB0 93BE BC5B 4531 48EA 2878 9853

To claim this, I am signing this object:

@benbridge
benbridge / block-dot-dirs
Created November 29, 2013 21:27
Block access to "hidden" directories whose names begin with a period.
# Block access to "hidden" directories whose names begin with a period.
RewriteRule "(^|/)\." - [F]
@benbridge
benbridge / www-enforcement
Last active December 29, 2015 14:29
Rules to force www or no www.
<IfModule mod_rewrite.c>
RewriteEngine on
# Set "protossl" to "s" if we were accessed via https://.
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
@benbridge
benbridge / svg-detection
Last active December 29, 2015 14:09
Javascript SVG detection with CSS fallback.
# Add below script to html head, before css.
<script>
function supportsSVG(){if(document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect){return true}}if(supportsSVG()){document.documentElement.className+=" svg"};
</script>
# Example scss
.svg-bg-image {
background: url(_media/image.png) no-repeat;
tabSelect: function(args) {
var queryString = greenplum.queryString();
if (typeof(queryString.selected_tabs) == 'string') {
var selectedTabs = queryString.selected_tabs.split(',');
var parentTabs = '';
for (var i=0; i < selectedTabs.length; i++) {
var index = jQuery('[href~=#' + selectedTabs[i] + ']', parentTabs).parent('li').index();
var tabs = jQuery(jQuery('#' + selectedTabs[i], parentTabs).parents('.tabs')[0]);
tabs.tabs().tabs('select', index);
var parentTabs = jQuery('#' + selectedTabs[i], parentTabs);