See Understanding vertical-align, or “How (Not) To Vertically Center Content”. Just in case this ever vanishes it is cached here: https://www.jj5.net/file/2018-08-09-193156/vertical-align.html
Category Archives: Programming
NetBeans: Window –> Reset Windows
See NetBeans Search Results Files Open in Output Panel Instead of Main Panel. Happened to me too! Easy fix is to click Window -> Reset Windows!
Debugging JINJA in Salt Stack
So I was trying to figure out how to report the template source file within the template itself and I found myself wanting to know what was available in the JINJA globals for a Salt Stack JINJA template.
Turns out you use the show_full_context() function, like this:
Context is: {{ show_full_context() }}
You can parse the output to see what top-level items are available. In my case I found the ‘source’ setting for the JINJA template in use.
Hot tip: if you’re using Vim to inspect the show_full_context() output, try using ‘%’ or ‘]}’ to move between matching braces.
Bonus: while I was learning about reporting the JINJA context I discovered that you can call Salt functions from JINJA templates, like this:
# The following two function calls are equivalent.
{{ salt['cmd.run']('whoami') }}
{{ salt.cmd.run('whoami') }}
pwned
I wrote the below BASH function today. It’s good because it performs super well compared to the alternative commands (which are commented out below above the new commands):
own() {
echo "Taking ownership..."
#chown -R jj5:jj5 .
find . \! -user jj5 -or \! -group jj5 -execdir chown jj5:jj5 "{}" \;
[ "$?" = 0 ] || { echo "Could not take ownership in '$PWD'."; exit 1; }
echo "Fixing directory permissions..."
#find . -type d -execdir chmod u+rwx "{}" \;
find . -type d -and \( \! -perm /u=r -or \! -perm /u=w -or \! -perm /u=x \) -execdir chmod u+rwx "{}" \;
[ "$?" = 0 ] || { echo "Could not fix directory permissions in '$PWD'."; exit 1; }
echo "Fixing file permissions..."
#find . -type f -execdir chmod u+rw "{}" \;
find . -type f -and \( \! -perm /u=r -or \! -perm /u=w \) -execdir chmod u+rw "{}" \;
[ "$?" = 0 ] || { echo "Could not fix file permissions in '$PWD'."; exit 1; }
}
The basic premise is don’t do work which doesn’t need to be done!
NetBeans PHP “Invalid include path”
So I migrated my projects from a Debian 8 (Jessie) system to a Debian 9 (Stretch) system. The default NetBeans installed by apt-get install netbeans on Strech was 8.1, and it didn’t include PHP support, so I manually installed NetBeans 8.2.
When I opened my old projects I got an error about an invalid global PHP include path.
So initially I edited ~/.netbeans/8.2/build.properties to change the php.global.include.path settings (to remove /usr/share/php5, because in Stretch I’m running PHP 7.0). But that didn’t work. Each time I ran NetBeans the build.properties file was overwritten with the old php5 directory.
So then I found ~/.netbeans/8.2/config/Preferences/org/netbeans/modules/php/project/general.properties. In there I edited the phpGlobalIncludPath and removed the /usr/share/php5 directory.
Then when I reopened NetBeans all of my projects opened properly without an error! Everything is easy when you know how!
Navigate to matching brace in NetBeans
So I wanted to know the keyboard shortcut to navigate between matching braces in my PHP (and other) code in NetBeans. I’m running NetBeans 8.2. So I searched and found General Editor Features which said “to find a shortcut for a specific command, type the command name in the Search field.” So the Search field they’re talking about is on the Keymap screen under Tools -> Options. After creating myself a custom Keymap Profile based on the NetBeans default settings I searched in the ‘Search:’ box for ‘match’ and found ‘Insertion Point to Matching Brace’ which is Ctrl+OPEN_BRACKET. Everything is easy when you know how!
Exclude hidden .svn files from grep query
To exclude .svn directories from a recursive grep, use the –exclude option, for example:
$ grep --exclude='*.svn*' -R 'your.*search' .
HTML <table> CSS width not working
If your table isn’t automatically adjusting to the width specified by your CSS, make sure you haven’t set display: inline-block; on the <table> element.
Migrating from Firebug to Firefox Developer Tools
See Migrating from Firebug and Firefox Developer Tools to get started. Also of interest was Web Console Helpers.
Hitchhiker’s Guide to the GDB
Found an interesting article: Hitchhiker’s Guide to the GDB.