Posts

Showing posts with the label bash

Quick and dirty way to run PHP with a double-click

I’m doing more with Things integration and PHP is a quick-and-dirty, but way more powerful than BASH , way to do what I’m trying to do. But tweaking permissions, bang-bash lines, etc., is more than I wanted to deal with. So I’m wrapping some PHP code in a BASH script with a .command extension. This may not be the best way to do this, but, again, quick-and-dirty. #!/usr/bin/env bash clear PHP= `php --version` EXIT= $? if [[ $EXIT -ne 0 ]] then echo "PHP not installed, running brew install php..." brew install php fi UUID= "`uuidgen`" DIRECTORY= "`dirname " $0 "`" cat > /tmp/ $UUID .php << 'FNORD_EOF' <?php print "Hello, world. Running in directory: " . $argv[1] . "...\n"; print_r($argv); ?> FNORD_EOF php /tmp/ $UUID .php "$DIRECTORY" rm /tmp/ $UUID .php

Integrating with the Things app

Image
As part of my never-ending quest to Realize My Potential™, I’ve long been using the Things app ( on my iPhone ; on macOS ) for a variety of things, but especially including keeping track of tasks I need to do. One thing that’s always bugged me, though, is you can’t attach files to Things entries. My hacked together solution, for now, is to keep a folder on a cloud service, and to create UUID-named directories under that folder, and to include a note in the Things entry that includes the UUID so I can easily find the files I need to reference for that task. It’s a kludge, but it’s a workable one. Things has a basic API . (There are other ways of interfacing with Things, but this is the one I’m currently using / exploring.) From Terminal, I ran: open "things:///version" Which caused this to pop up: Easy so far. I of course enabled it. Next step: Actually add a task to the Inbox. (This is even more of a kludge, it doesn’t properly URL encode the user input, but I’m not likely to...

Monitoring and restarting Derby

Image
A terminal window It’s a crude but working hack; I’ve been spinning a similar script since the mid-90s (then monitoring the PPP connection that kept an entire dorm connected, very slowly, to the Internet). Bash script . Every hour (run via cron) it just checks the process list to see if the Derby instance is up and, if not, spawns a new screen session with the Derby instance running in the background. (Every hour is fine for this application, which only hits the database periodically. I’d tweak it to run in a constant loop if the Derby instance was more critical. I’d also question why I was running something critical on Derby in such a context, too.