Append to attribute values using jQuery

Quite a productive day today, here’s another note to self containing a nice jQuery snippet that appends a string to a given attribute of a certain tag. I got the snippet from stackoverflow (of course).

<script>
  $.fn.appendAttr = function(attrName, suffix) {
    this.attr(attrName, function(i, val) {
        return val + suffix;
    });
    return this;
  };
</script>

I am doing some content work in a mixed php/perl/legacy web environment. I added some code to the part of the system that I have access to that hides the content I am working on unless I add a &preview in the URL. Because I part of the system that generates the menus, I had to add the &preview manually. This snippet allows me to stay in preview mode once I have entered preview mode.

<script>
  $( document ).ready(function() {
    if (window.location.href.match(/&preview$/).length > 0) {
        $( "a").appendAttr('href', '&preview')
    }
  });
</script>

Yay.

Advertisements

Zotero + Ulysses 3 + pandoc workflow

Ok, just a quick post as a note to self on my Ulysses 3 + Zotero workflow:

Zotero settings

Zotero has a hidden preference setting called extensions.zotero.recursiveCollections (or just recursiveCollections if using the desktop version). Setting the value of this to true, instead of the default false value, selecting a folder also displays the contents of its sub-folders. I think this behaviour makes sense for a document management system (where finding a document is more important than knowing where it resides).

To change the value of extensions.zotero.recursiveCollections, just go to about:config, find the preference name and then double click the value.

Login over SSH using SSH key

I just set this up and it works like a charm. However I imagine that I won’t be doing this every day, so I am writing this note to my future self.

How logging in on a remote server using an SSH key works (intuition)

This is sort of my non-expert, but technically viable understanding of how all of this magic works.

  1. Create a pair of keys using the command ssh-keygen – one public key, and one private key.
  2. Upload the public key (that can be used to confirm the identity something generated using of the private key I believe), to the server (each user has a ~/.ssh/authorized_keys on the server).
  3. Make sure the .ssh directory on the server is only readable by your user.
  4. Make sure the directory where you store your key pair on your local computer is also only readable by you.
  5. When logging in, point ssh to use your private key, for the correct user on the remote server.

Commands

Create your ssh key pair using

ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa -C "Enter an optional comment about your key"

You can use another name than id_rsa. A public companion with the suffix .pub will also be created. You do not have to enter a passphrase, e.g. when using the key via a script.

Protect your local .ssh directory using the following:

chmod 700 ~/.ssh && chmod 600 ~/.ssh/* 

Upload the public key via ssh:

cat ~/.ssh/id_rsa.pub | ssh user@remote-server.com 'cat - >> ~/.ssh/authorized_keys'

Protect the .ssh directory on your remote server (remote shell) using:

chmod 600 ~/.ssh/authorized_keys && chmod 700 ~/.ssh/

Login using

ssh -i ~/.ssh/id_rsa user@remote-server.com

where id_rsa is your private key.

Tweetdeck Column Terminology

Tweetdeck column terminology

Following a comment made by @segelstrom, I decided to try Tweetdeck again. However, when setting up my columns I was confused by the names of the columns, so I decided to check the documentation. I found the column descriptions and names on Twitter’s web confusing. Below are the column names and their descriptions as written on the help page as of September 23, 2013.

  • Timeline: Home timeline for a specific account (any account)
  • Interactions: Interactions for a specific account, including when the account’s Tweets are retweeted, favorited, or mentioned, and also includes when users follow the account
  • Mentions: Only includes when users mention a specific account
  • Followers: Follow activity for a specific account
  • Messages: Direct messages for a specific account
  • Search: A column for a specific search term
  • Lists: Assign or create a list to be displayed within a column
  • Tweets: Tweets from a specific account
  • Favorites: Tweets marked as favorites from a specific account
  • Trends: A column dedicated to specific worldwide trends
  • Activity: What’s happening with the accounts you follow
  • Inbox: Direct messages from all your authorized accounts in aggregate
  • Scheduled: Your scheduled Tweets

I suggest the following/need the following explanations:

  • Timeline: I think the explanation should read “Tweets from people one of your accounts follows.”
  • Interactions: I think the description of the interaction column is great.
  • Mentions: I propose the following wording of the description: “Mentions for one of your accounts”
  • Followers: I think the description should be “Shows when people follow you”, avoid using the term “activity” as you use this for your Activity column.
  • Messages: I propose a change of wording of the description to “Direct messages sent and received for a specific account.”
  • Search: No ambiguity here.
  • Lists: A note specifying that these are not lists saved on Twitter would be nice.
  • Tweets: Perhaps renaming the column to My Tweets, or at least specifying the wording of the description to: “Tweets made by one of your added accounts” (in contrast to tweets from any selected twitter user).
  • Favorites: Improve wording of description to: “Tweets one of your accounts has marked as a Favorite”.
  • Trends: The description should read: “Create a search column for a currently trending topic”, as this column does not display currently trending topics.
  • Activity: This is a strange column. First, the name of the column would be much clearer if if was Activity from people I follow, but as this is to long, perhaps Others’ activity or Follow’s activity, might work. Also, the description needs to read more like the description of the Interactions column, e.g. “Shows the activity of the people you follow, including their favorites, follows, excluding their tweets and retweets.”
  • Inbox: I propose you change the wording to “Sent and received direct messages from all your accounts.”. The name of the column could also be changed to All messages, as it does not only contain received messages. This also shows its relation to the Messages column.
    Scheduled: No ambiguity here.

Why Everyone F*cking Loves Science — and Elise Andrew

See on Scoop.itfnurlotastic bi-weekmonthly-ish

With 6.8 million followers, Elise Andrew, the founder of the “I Fucking Love Science” Facebook page, wields an influence over science geeks and fans.

See on mashable.com