Skip to content

Instantly share code, notes, and snippets.

@drakkhen
drakkhen / gist:ae5022facb63edfb69eb
Created May 14, 2014 13:41
Using S/MIME by default when GPGMail is installed
[drakkhen@sherbourne ~]$ defaults write org.gpgtools.gpgmail SignNewEmailsByDefault -bool YES
[drakkhen@sherbourne ~]$ defaults write org.gpgtools.gpgmail DefaultSecurityMethod -int 2

Keybase proof

I hereby claim:

  • I am drakkhen on github.
  • I am drakkhen (https://keybase.io/drakkhen) on keybase.
  • I have a public key whose fingerprint is 4917 BDB5 42B6 641B CD81 B3FA 3C0F D8A7 FE18 81E5

To claim this, I am signing this object:

@drakkhen
drakkhen / gist:11373776
Created April 28, 2014 14:27
battery_status
#!/bin/bash
plugged_in=`ioreg -c AppleSmartBattery | grep ExternalConnected | sed -e 's/^.* //'`
perc=`ioreg -c AppleSmartBattery | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f", $10/$5 * 100)}'`
perc_int=${perc/.*}
if [ $plugged_in == "Yes" ]; then
is_charging=`ioreg -c AppleSmartBattery | grep IsCharging | sed -e 's/^.* //'`
if [ $is_charging == "Yes" ]; then
@drakkhen
drakkhen / gist:6271075
Last active December 21, 2015 07:28
How I manage lots of email with Mail.app.

A lot of people complain about Mail.app.

I use Mail.app for work. While I'm typically not a pack-rat, I do like to keep an archive of most messages for business reasons. It does pretty well until I have over 10k emails in a single folder and then it can sometimes run into problems. At least, that has happened with our Exchange provider -- maybe it's not an issue with IMAP; I don't know.

Here is my strategy to manage lots of email in Mail:

  • My Inbox only contains email which I need to act on (need to read, need to reply to, need to create to-do list items on, etc.)
  • As soon as I'm done with an email in my Inbox (read it, replied to it, created to-do-lists items for it), I hit control-command-a to move it to the Archive folder on the server.
  • The Archive and Sent folders contain "recentish" messages and reside on the server so they are available on my phone.
  • On my workstation I have a local folder (i.e., not on the server) called "Attic". Inside Attic are sub-folders for each year.
@drakkhen
drakkhen / deploy.rb
Created May 3, 2013 03:43
Force capistrano to check your local systems time drift before deploying
before "deploy", "check_time"
task :check_time do
offset = `ntpdate -q ntp.ubuntu.com | tail -n 1 | awk -Foffset\ '{print $2}' | awk '{print $1}'`.strip
if offset.to_f > 1.0
puts "Your clock is off by #{offset} seconds! Type `sudo ntpdate ntp.ubuntu.com` and try again."
exit(1)
end
end
@drakkhen
drakkhen / gist:5473067
Last active December 21, 2020 14:30
Workaround for Ubuntu guest suspension warning in VMware Fusion

I see this error when I try to suspend an Ubuntu 10 guest in Fusion:

The request to Suspend this virtual machine failed because the corresponding VMware Tools script did not run successfully.

If you have configured a custom suspend script in this virtual machine, make sure that it contains no errors. Attempting the operation again will ignore the script failure. You can also submit a support request to report this issue.

As the dialog states, the second time you try to suspend the VM it ignores the non-zero return code of the script and it seems to work. But it's annoying.

The problem appears to not be VMware actually, but Ubuntu (or Ubuntu's service script). I tried to figure out where exactly Ubuntu's initctl configuration/scripts is broken to no avail but found a work-around that I'm happy with.