Fast translation with Google Translator

March 7, 2016

via https://medium.com/@mrdoro/fast-translation-with-google-translator-and-mac-osx-817e32233b7a


Nice article about how to create a service to automatically translate selected text from any application. I use this all the time, I have a “German-to-English” service bound to Command-Alt-Ctrl-Shift-E, so I can just select text off the screen, press the shortcut, and a window with the translation will pop up. Very handy.

Using Multiple SSH Keys with Github

May 20, 2015

via http://www.freshblurbs.com/blog/2013/06/22/github-multiple-ssh-keys.html#tldr


Since Github doesn't allow us to reuse an SSH Key, the only sane solution is to jump through some hoops and generate + use multiple keys on the server itself. Let's look at some effective approaches of doing that.

Short version: define multiple hosts in the SSH config file for each repository, which use different SSH keys, then you can assign different deploy keys to each repo. But read the whole article for the full details.

Moving files between git repositories, preserving history

April 17, 2015

I needed to copy a directory between two git repositories while preserving its history. I found some good instructions at http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/, which got me started, but I figured out a way to avoid having to move all the files into their directory again (lines 5-6 in Greg’s instructions) by reversing the filter to remove everything I don’t want instead of only including the directory I want. Here are the steps (the idea is the same as in Greg’s post, so please read that to get the explanation, I’m only listing the commands here for reference):

Three levels of GIT config

April 17, 2015

via http://www.codinginahurry.com/2011/02/05/three-levels-of-git-config/

Very nice explanation, via coding in a hurry
There are 3 levels of git config; project, global and system.
      • project: Project configs are only available for the current project and stored in .git/config in the project's directory.
      • global: Global configs are available for all projects for the current user and stored in ~/.gitconfig.
      • system: System configs are available for all the users/projects and stored in /etc/gitconfig.
Create a project specific config, you have to execute this under the project's directory.
git config user.name "John Doe"
Create a global config
git config --global user.name "John Doe"
Create a system config
git config --system user.name "John Doe"
And as you may guess, project overrides global and global overrides system.

Watching for changes (Polling notifications) in Evernote

April 16, 2015

via https://dev.evernote.com/doc/articles/polling_notification.php

Useful note about how to poll an Evernote account for new content. Also a test of web clipping with Enwrite.

Polling

If your app wants to know about changes in a user's Evernote account, you'll probably consider calling the NoteStore.findNotesMetadata function periodically to search for new notes. findNotes is incredibly powerful, but it's also expensive for our servers - we need to load the user's Lucene index, perform the search across all of their notes, hit the database to pull out the results, and send those results over the network to your app. If you're building a web application, you should use webhooks instead of polling. If you have to poll, you should follow the guidelines below.

How to create a new KVM VM using command line tools

April 14, 2015

virt-install --name=hostname --arch=x86_64 --vcpus=2 --ram=4096 --os-type=linux --os-variant=rhel7 --hvm --connect=qemu:///system --network bridge:br-fabric --cdrom=/var/lib/libvirt/images/CentOS-7.0-1406-x86_64-Minimal.iso --disk path=/var/lib/libvirt/images/hostname.img,size=32 --accelerate --vnc

Find all single-note tags in Evernote

January 14, 2015
I’ve been working on cleaning up my Evernote, and noticed that I have a lot of tags assigned to a single note. I had successfully used Veritrope’s excellent Evernote empty tag remover applescript, so I made some small changes to write the attached script, which will find all single-note tags in your Evernote and list them in a new note, including links to each note. This makes it much easier to go through them and see which of those tags could be removed.

Just download the script, open it in Script Editor and run it.

Tip of the hat to Justin for his excellent collection of scripts at Veritrope!


Mac keyboard shortcuts by Matt Gemmell

May 16, 2014
Another great article by Matt Gemmell. I knew most of them, but learned a few things. The golden part for me were the third-party utilities, in particular Shortcat, which I didn’t know and is amazing:

It’s basically Spotlight but for all visible controls and objects on the screen: it’s type-to-select for *everything you can see*.


The whole article is worth a read.

Airmail tip: prevent "Save to Evernote" action from opening the created note

March 6, 2014
I’ve been trying out Airmail as my main email app. It’s quite nice, I like the built-in integrations, particularly with Evernote. By default, when you use the “Save to Evernote” action, it saves the current message to Evernote and opens the newly-created note. I went spelunking into the Airmail application directory, and found the way to disable the note-opening. Follow these steps:
  1. Quit Airmail (don’t know if this is necessary, but it can’t hurt)
  2. Open the Terminal app
  3. Run the following command in the terminal (all in a single line):
    sudo /Applications/Utilities/AppleScript\ Editor.app/Contents/MacOS/AppleScript\ Editor  /Applications/Airmail.app/Contents/Resources/Evernote.applescript
    This will ask you for your password and then run the AppleScript Editor.
    Note: in my experience, the AppleScript Editor app may open behind the terminal window - look at the Dock for its icon, and bring it to the front.
  4. In the AppleScript Editor window, find this line:
                open note window with the note
    and comment it out by inserting a # at the beginning, like this:
    #            open note window with the note
  5. Save the modified file and quit AppleScript Editor.
  6. Restart Airmail.
That’s it! Now the “Save to Evernote” action saves the current message to Evernote, but does not open it.

How to stop com.apple.dock.extra from "using significant energy"

March 4, 2014
I’d been having for some time a problem with `com.apple.dock.extra` appearing in the “Apps using significant energy” section of the battery menu. I just learned the solution (from http://forums.macrumors.com/showthread.php?t=1651662): remove BusyCal 1.6 (I upgraded to BusyCal 2, but left the old version around in case I had to go back to it). After removing it and restarting the Dock, the problem stopped.

From the same thread, it seems the problem was caused by BusyCal’s “animate transitions” preference. I didn’t try that, but if you are still using BusyCal 1.6 and have this problem, it’s worth trying.

Changing "message:" protocol handler from Sparrow back to Mail.app

January 25, 2012
After using Sparrow for a while, I have decided to switch back to Mail.app. However, even after setting my default email client to Mail.app, all my message: links (for example, from messages dragged from Mail.app into Things) were opening in Sparrow.

After some experimentation, I figured out what happened: I switched the default email client from Sparrow to Mail using Mail's preference panel:

Pastedgraphic-1

Apparently this switches the application for the mailto: protocol, but not for message:, nor for .eml files. The solution was to use Sparrow's preference panel to set it again as the default email client, and then disable it. Then Sparrow correctly sets all the protocol handlers back to their default values.

image from Changing "message:" protocol handler from Sparrow back to Mail.app

How to fix "texexpand error: More than one input file specified" in latex2html

January 20, 2011
There's a bug that causes problems when running latex2html on files which have spaces in the path. The workaround is to either move things to folders with no spaces, or add appropriate symbolic links.

This error had me stumped in trying to process a latex file with latex2html:

texexpand: Error: More than one input file specified.
texexpand failed: No such file or directory

The fix is simple - make sure the path of the current directory does not have any spaces.

LogParser, Event Logs, and Vista - Neil Carpenter's Blog - Site Home - TechNet Blogs

January 19, 2011

The only workaround to this is to convert the logfile to the new evtx format prior to parsing it.  You can do this in the event log viewer GUI by doing a Save As... but I find it easier to do this at the command prompt:

wevtutil epl application.evt application.evtx /lf:true

I'm trying to process Windows Event Viewer files (.evt) from some servers on my Win7 machine, which kept me giving a "log file is corrupt" error message. The trick is to convert it to the newer .evtx format before processing. Thankfully this can also be easily done using a command-line utility.

Making cygwin, Windows and emacs understand the same symlinks

September 28, 2010

Today I ran into the problem that symlinks created under cygwin using "ln -s" are not understood by Windows, and of course Windows shortcuts are seen by cygwin as regular files. Happily, this is a (semi-)solved problem. For reference, this is what needs to be done:

  1. Add "winsymlinks" to your CYGWIN environment variable. For example, in my .bashrc I have the following:

    export CYGWIN="nodosfilewarning winsymlinks"

    This makes cygwin create symlinks differently, in a form that is understood both by it and by Windows.
    This is the main step, and the only one if you just need access from the shell and from the Windows explorer. However, emacs still sees those symlinks as regular .lnk files. To fix this, follow the next step.

Hierarchical copying with cfengine3

August 27, 2010

I recently posted a snippet to perform hierarchical copying in cfengine3. As I was attempting to integrate this mechanism into my copy of cfengine's COPBL, I realized that no additional functions or body components are needed. Thanks to cfengine3's list expansion, all you need to do is include in the existing copy promise the list containing the desired list of suffixes to try. For example:

Becomes:

While this looks at first sight even longer than the original (and of course, in this case you could just specify ${sys.flavour} directly in the copy_from statement), it is much more flexible. Instead of defining different sections for each class that you want to handle (e.g. suse_9, redhat_5, etc.), the same code is able to copy the corresponding binary directory for any operating system, you just have to put the corresponding bin.* directory in your repository.

Installing AucTeX on EmacsW32 on Win7/64bit

August 17, 2010
Today I had to install AucTeX to use on my Win7/64 machine under EmacsW32. I found the basic instructions here: http://www.sturmnet.org/blog/2007/09/01/installing-auctex-in-emacsw32, but I had to modify them a bit (in particular, I am using tetex installed from cygwin instead of MiKTeX). Here are the commands I used:

$  mkdir -p /usr/local/share/texmf
$ ./configure --prefix='c:/Program Files (x86)/Emacs/emacs' --with-texmf-dir='/usr/local/share/texmf' --with-lispdir='c:/Program Files (x86)/Emacs/emacs/site-lisp'
$  make
$  make install

I then added the following lines to my C:\Program Files (x86)\Emacs\site-lisp\site-start.el file: