Wednesday, September 16, 2015
Forcing git diff to compare non-text files
http://stackoverflow.com/questions/13486027/how-can-i-treat-a-file-not-a-binary-git
http://stackoverflow.com/questions/14771414/git-force-file-encoding-on-commit
It appears there is a way to customize diff. I haven’t tried it myself yet, but plan to in the future.
https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes
Here’s a tool that can be used to `git diff` MS Word files.
http://docx2txt.sourceforge.net/
Thursday, May 21, 2015
Change Mac Calendar all-day event reminder time to something other than 9am
Scenario: I'm working productively when suddenly every day I get a dump of 15 event notifications that end up blocking the view of what I'm working on. My colleagues work on EDT while I'm on PDT. By 9am, I'm already in the thick of my day. I would rather the all day events not interrupt me at that time. Five Awesome Tips And Tricks To Master OS X Calendar [Feature] provides some guidance on how to change that as the Calendar preferences are limited; they expect everyone wants to be notified at 9am.
As mentioned in the article, you can override the "trigger" time for all day events by editing
# find all files under ~/Library/Calendars/
# whose path includes LocalDefaultAlarms
# whose name does not include EventTimed
# open in favorite editor
grep -rl TRIGGER ~/Library/Calendars/ | grep LocalDefaultAlarms | grep -v EventTimed | xargs mvim -p
Simply edit the configuration files to the desired trigger time specified. Hours can be negative or positive and represent the offset from midnight of the day of the all-day event. For me, instead of being reminded at 9am the day before, I would rather be reminded at 7am instead, which turns out to be 17 hours before midnight for the all-day events.
# if you vim
:%s/PT15H/PT17H/g
If you want to get fancy, you could come up with a bash script that uses sed so the files don't even need to be opened in a text editor.
Friday, March 13, 2015
Launching a shell script as an OSX application
To tidy things up, close the terminal window when we're done.
E.g., I have a script that opens up a file in a text editor and then runs a Ruby script using that same file as input.
[~/scripts/create-reminders.rb]
#!/bin/bash
home='/Users/dvezzani/Documents/journal/02-feb-2015'
ruby ${home}/create-ics-reminders.rb > out-reminders.ics
open -a Reminders out-reminders.ics
[~/Library/Services/create-reminders.workflow]
on run {input, parameters}
tell application "Terminal"
activate
do script "sh /Users/dvezzani/scripts/create-reminders.sh; exit"
end tell
return input
end run
Then export the workflow as an Application and place in your Applications directory so that you can pull it up with Spotlight.
Other references:
Monday, February 23, 2015
Searching for text in files whose filenames have spaces
Thank you, StackOverflow!
I have been dealing with spaces in filenames and it's been a thorn in my side.
Finally, some relief:
find idmexchange/ -name "*.xml" | while read file
do
grep -l "XPRESS" "${file}"
done
The difference between word-based iteration and line-based iteration makes all the difference.
Saturday, January 10, 2015
Upgrading PHP, PhpPgAdmin after Mac Yosemite upgrade
Prepare Homebrew
brew update
brew doctor
Resolve pending issues, upgrade to latest version of XCode, etc.
Install PostgreSql
It doesn't come any easier than this.
Update PHP
First using Homebrew. I had a typo the first time. The PostgreSql extention didn't get generated. Make sure to read the caveats at the end of the process!
brew tap --repair
brew tap homebrew/homebrew-php
brew install php56 --with-apache --with-mysql --with-postgresql --with-intl
Point php.ini
to the right version.
sudo mv /etc/php.ini /etc/php.ini.pre-update
sudo ln -s /usr/local/etc/php/5.6/php.ini /etc/php.ini
Perhaps without any typos, the PostgreSql php extension gets generated. If the PostgreSql php extension doesn't get generated, these manual instructions are great. Especially if you installed PostgreSql as mentioned earlier in this document, you will need to specify where the installation directory is when you call ./configure
. It should look something like this:
./configure --with-pgsql=/Applications/Postgres.app/Contents/Versions/9.4
http://stackoverflow.com/questions/6588174/enabling-postgresql-support-in-php-on-mac-os-x
Once you know where the pgsql.so
extension resides, make sure it is included in php.ini
. E.g.,
; Mac Extensions
extension=/usr/local/Cellar/php56/5.6.4/lib/php/extensions/no-debug-non-zts-20131226/pgsql.so
Edit Apache's httpd.conf
and make sure that the php
and rewrite
modules are enabled. Also, you will likely need to update the path to the correct php module. You should use the new libphp5.so
that got generated when brew installed php.
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
Test PHP
Before going to far, take a moment to verify that php is working well with Apache.
Keep an eye on Apache's error log file during this process. Run this in a separate terminal window.
tail -f /private/var/log/apache2/error_log
Create a test index.php
file. Note, the recent versions of php require "<?php" and not simply the shortform, "<?".
echo "<?php phpinfo(); ?>" > /Library/WebServer/Documents/index.php
open http://localhost/index.php
Troubleshooting PHP
If you are having trouble simply installing php using Homebrew, this may be useful:
https://github.com/Homebrew/homebrew-php#common-upgrade-issues
The first bullet might be satisfied with
xcode-select --install
Thanks, joshlopes; https://github.com/Homebrew/homebrew-php/issues/997
Build problems with phar.php?
/bin/sh: line 1: 92714 Segmentation fault...
make: *** [ext/phar/phar.php] Error 139
I'm not clear on what SNMP (some kind of mobile protocol?) is, but there is clear evidence that it gives some general grief with installing php. I resolved it by including --without-snmp
in the call to brew install. I have updated this command in the previous instructions.
If you don't see an html page with a dump of php configuration information, it's time to have some fun debugging. What follows are somethings that I needed to do in order to stop getting a white screen.
Go through this set of steps.
If php still doesn't seem to be running with Apache, I also found this useful to get brew install php56
to succeed. Again, this seems to be fallout from installing PostgreSql the way I did.
sudo mv /usr/lib/libpq.5.dylib /usr/lib/libpq.5.dylib.pre.php56.install
sudo ln -s /Applications/Postgres.app/Contents/Versions/9.4/lib/libpq.5.dylib /usr/lib/libpq.5.dylib
sudo apachectl restart
sudo apachectl configtest
https://github.com/Homebrew/homebrew-php/issues/1489
Once you are able to view the php information in the index.php
page and you have included the pgsql.so
extension in php.ini
, installing phppgadmin
should be easy.
Install phppgadmin
brew install phppgadmin
Follow the instructions that follow after this runs.
Other
To set the timezone in php.ini
, see the php manual for a list of supported values.
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "America/Los_Angeles"
The Apache log file may complain about ServerName missing from httpd.conf. Follow the instructions to stop it from complaining.
ServerName localhost:80
Add mime-type for php in the mime-types file instead of as a command in httpd.conf
.
sudo mvim /etc/apache2/mime.types
application/x-httpd-php php
Update PATH to support pear
and PostgreSql
. Edit .bash_profile
.
# add pear package manager (php)
export PATH="/usr/local/pear/bin:$PATH"
# add postgresql app
export PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"
Location of DocumentRoot
cd /Library/WebServer/Documents
Location of Apache
cd /etc/apache2
Edit Apache configuration file
sudo mvim /private/etc/apache2/httpd.conf
Edit the php configuration file
sudo mvim /etc/php.ini
View the Apache logs
cd /private/var/log/apache2
tail -f /private/var/log/apache2/error_log
Thursday, January 8, 2015
Getting to know Atom
A new application can be as exciting as Christmas morning. I am a dedicated Vim user (specifically MacVim). I am grateful for those who have developed plugins to bring a Vim-like experience to the tools I use.
Eclipse has Vrapper and "Vrapper - Surround". I never quite made it on the Sublime bandwagon. Nic Raboy recently filled me in on this great tool. It does everything that Sublime does (almost), but faster. And because it was developed by the folks at GitHub, it provides some great integration with the well know source control giant. The name? The Atom editor.
My addiction to Vim may backfire on me one day. Apparently, that day hasn't come yet; Atom has a couple of plugins that satisfy my Vim addiction.
- open-vim
- vim-mode
The interface is slick and tasty. And I love the support for creating your own plugins using JavaScript and/or CoffeeScript.
I'll be spending the next little bit getting familiar with the documentation. The IDE also has a set of very useful developer tools that help with debugging the package scripts that are included in plugins. That's one thing Vim doesn't have!
- View > Developer > Toggle Developer Tools