Skip to content

Instantly share code, notes, and snippets.

@brycefisher
brycefisher / find_deep_needle.php
Last active December 25, 2015 00:29
Like var_dump, but it prints out the whole expression "path" to the given string.
<?php
/**
* Like var_dump, but it prints out the whole expression "path" to the given string.
*
* @param mixed $haystack
* The object or array with many levels of nested arrays or objects containing your needle
* @param str $php_exp
* The php expression for the initial $haystack param
* @return str
* No return value. Prints output to stdout (assumed to be a browser).
@brycefisher
brycefisher / scan_dir_for_non_utf8.php
Created September 19, 2013 17:15
Scan a directory for NON utf8 files using PHP
<?php
// Note this is NOT recursive.
function scan_dir_for_non_utf8($dir_path) {
if ($dir = opendir($dir_path)) {
echo "opening $dir_path";
$files_scanned = 0;
while (($file = readdir($dir)) !== false) {
// Don't go up directory levels
if (in_array($file, array('.','..')))
continue;
<p>To setup this bookmarklet in your browser, you'll need to:</p>
<ol>
<li>Clone (or download) this gist using the information on this page</li>
<li>Fill in your username and password</li>
<li>Change the drupal_domain variable to the domain of your drupal install</li>
<li>(Possibly) change the path to the path to your drupal login form</li>
<li>Drag the link to your bookmark bar</li>
</ol>
<p>To use, simply click the bookmark anywhere on your drupal_domain.</p>
<a href="javascript: (function(){ var user = 'username', pw = 'password', path = '/user/login', drupal_domain = '.example.com', domain = window.location.host, frame = document.createElement('iframe'), frame_length = frames.length; if(domain.indexOf(drupal_domain) !== -1){ document.body.appendChild( frame ); frame.src = '//' + domain + path; frame.style.display = 'none'; setTimeout(function() { frames[frame_length].document.getElementById('edit-name').value = user; frames[frame_length].document.getElementById('edit-pass').value = pw; frames[fr
@brycefisher
brycefisher / .bashrc
Last active December 20, 2015 16:09
msysgit .bashrc
alias gvim='/c/Program\ Files\ \(x86\)/Vim/vim73/gvim.exe '
alias expl='explorer '
alias ga='git add '
alias gb='git branch '
alias gc='git commit -m'
alias gp='git push'
alias gs='git status '
alias dld='cd /d/MySQL/drupal && ./drupal-db-download.sh'
@brycefisher
brycefisher / .htaccess
Created June 8, 2013 07:24
Supercharge your DIY CDN with mod_expires, mod_deflate, and then lock it down a bit.
# Security
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule \.bat$ - [R=404]
</IfModule>
# Leverage Browser Caching
<IfModule mod_expires.c>
# Enable Expirations
@brycefisher
brycefisher / .vimrc
Last active December 18, 2015 05:39
Drupal Optimized Crossplatform vimrc
"-------About-----
" I use this .vimrc and the accompanying git repo of plugins,
" colorschemes, and other config files on Windows Vista,
" Windows 7, Ubuntu 12.04, and Mac OSX 10.7 on a daily basis.
"
" Pull requests and comments welcome!
"------INSTALLATION---
" $ git clone --recursive https://github.com/brycefisher/vimfiles.git ~/.vim