How to Make OS X Yosemite Stop Adding a Number after my Computer’s Name

NOTE: Others in the Apple support forum linked below have reported that these steps do the trick for them. It does not seem to be working for me, however. How about for you?

Daily my MacBook gets a number (2), (3), or (4) added after its computer name. After running searches and culling through forums, I found a tip which seems to be working.

Apparently this can be cleared up by repairing disk permissions. Here are the recommended steps:

  1. In System Preferences > Sharing, remove the (2) [or whatever is extra; mine was iMac (2), so I removed the (2)
  2. Exit Preferences
  3. Shutdown
  4. Restart machine in Recovery mode (machine off, press and hold Command + R, power on, when Apple logo appears release keys) — may take a few minutes to boot (depends on machine generation/speed, RAM and such)
  5. Open Disk Utility
  6. Select the OS disk (mine was Macintosh HD; selected the ‘indented’ item)
  7. Run Verify Disk Permissions
  8. When finished run Repair Disk Permissions
  9. Restart

Source: Apple Support Communities Discussion Here — in the Oct 29 reply by farquaad

Open a file in Sublime Text via OS X Terminal

If you’re working in Terminal and would like an efficient command to open a file in Sublime Text 2 — as in subl filename.html — here’s how to set it up.

I’ve now edited this post to begin with my favorite method, using an alias, then added a few more notes on creating handy aliases. Last is an alternative method which requires creating a symlink to Sublime Text’s own terminal connection.

Creating an Alias

This, for me, is the easiest method. We’ll create an alias for the basic Terminal command to open a file in Sublime Text 2, which would be: open -a Sublime Text 2 newfile.html

Here’s how to set up an alias so that you only have to type: subl filename.html

From Terminal …

1. Edit the bash profile, by typing:

vim .bash_profile

2. Then type i to insert.

3. Insert this line:

alias subl='open -a Sublime Text 2'

This creates a new shorter version of the longer command. Typing subl will do what’s after the equal sign!

4. Hit the **Escape** key to stop editing.

5. Type :wq to save and quit the editor.

6. Type exit to exit the terminal session.

7. Quit Terminal and restart it.

8. Type subl filename.html to open the desired file in Sublime Text!

To create more aliases, you can now do it by editing the .bash_profile in Sublime Text. Just type: subl .bash_profile

On the Topic of Aliases

Here are a few similar aliases I set up, by adding them to my .bash_profile, to efficiently open files in Firefox, Chrome, Safari, navigate to a frequently used directory, etc.

# Open a file in Sublime Text 2
alias subl='open -a Sublime Text 2'

#Edit Bash Profile in Sublime Text 2
alias bashprof='subl .bash_profile'

# Open a file in desired browser
alias ff='open -a Firefox'
alias chr='open -a Google Chrome'
alias saf='open -a Safari'

# Open file in Firefox, Chrome, and Safari
function testall { ff $1; chr $1; saf $1; }

# Shortcuts to directories
alias home='cd ~/'
alias nodeplay='cd ~/Nodeplay'
alias github='cd ~/Github'
alias sites='cd ~/Sites'

# Change to and list contents of a directory
function cdl { cd $1; ls; }

This Lifehacker post was helpful in the quest:
Become a Command Line Ninja With These Time-Saving Shortcuts – Lifehacker

Another Approach Using a Symlink

Back to the topic of opening a file in Sublime Text 2 — it’s amazing how diverse and confusing are the opinions on this topic. The alias approach (above) seems easiest (and least frequently mentioned). Here is another method that uses a symlink, for those who prefer it.

 

1. Create a directory named bin in your user home directory.

Create bin directory

Now we need to create a symlink in this new directory …

 

2. In Terminal, enter the following line and hit return:

ln -s /Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl ~/bin/subl

This creates a symlink called subl. You’ll see it in Finder inside your newly created bin directory.

Sublime Bin Symlink

Next to add this new directory path to your Terminal bash profile.

 

3. In Terminal, open the bash profile in the vim text editor:

vim .bash_profile

 

4. Then type i to insert:

i

 

5. Type this new export path at the cursor:

export PATH=$PATH:~/bin

Sublime Export Path

 

6. Now hit your keyboard’s Escape key to stop editing.

 

7. Save the file by typing :wq and pressing Return:

:wq

[Press Return]

 

8. Exit the terminal session by typing:

exit

 

9. Quit Terminal, then restart it.

 

10. If you need a quick file to test, you can create it via Terminal:

touch newfile.html

 

11. Now open your new file in Sublime Text by typing:

subl newfile.html

This should be your result!

Sublime File Opened

 

12. To change the command for opening a file in Sublime Text …

Simply change the name of the symlink in your bin directory. For instance, you could change the symlink name to sublime, and then type sublime newfile.html in Terminal to open your desired file.

Sublime Symlink Name Change

 

Spot an update?

Let me know if you spot anything that needs updating or clarification.

 

Credit

Piecing these steps together from available online resources took a bit of work.

Helpful bits can be found in the Sublime Text docs, and in this gist by artero.

Credit for piecing together a working combo goes to @piperseth.

Custom CSS = Love Trello More

Trello with custom CSS
My Trello with custom CSS, using the Safari User CSS extension

I love working with Trello. Compare the free and cheap project management tools out there, and Trello can compete. More nimble, dextrous, and powerful than most. For free.

Effective. Elegant. User-friendly. Excellent in most every area.

In beauty, though — it’s only passible.

Having just tried and compared many alternate services, I’ve come back more committed to Trello, and determined to enjoy it more as well.

So I’ve added some custom styles — and found my love has grown.

Of course this is largely a matter of preference. But I’ve knocked off corners and borders, made avatars round, added some white space, gone largely gray-scale — and, well, see for yourself.

Do it Yourself

If you like it or would like to innovate on it, here is a Gist of my styles.

You’ll need to add the styles to your favorite browser, as user styles made specific to the domain: https://trello.com.

To help with this, use a browser extension for your favorite browser.

Browser Extensions

Further Reading and Resources

Should you leave normalize.css as a separate file? (Nope.)

The HTML5 Boilerplate has recently separated out normalize.css, giving it a separate stylesheet link in its default template file. Should you leave it like this in your production site? Is there some caching or other gain? Nope. At least probably not.

Looking at the rationale, one finds this was done to help with maintenance and versioning of the H5BP code.

For production, the recommendation is still to roll up all your CSS, including normalize.css into one minified and compressed file.

Necolas points this out in the GitHub pull request on this issue:

Benefits of disentangling normalize.css from the rest of the project’s
CSS:

Easier to track normalize.css version.
Easier to update normalize.css.
Easier to remove normalize.css if the user wants.
Clearer distinction between normalizing CSS and the additions that HTML5 Boilerplate provides.
Drawback is the additional HTTP request incurred from the extra
stylesheet referenced in the HTML. However, we already do something
similar for the JS, and anyone serious about performance is going to
employ a build process to concatenate and minify CSS/JS.

Emphasis added.

Further Notes

  • HTML5 Bones also has normalize as a separate file.
  • As pervasive as normalize is becoming, this could become a new best practice …
  • But in terms of site performance there would need to be caching benefits to overcome the need for the extra HTTP request. If I understand how browsers decide when to use a cached file, the file would need to be sourced from the same online location — as the H5BP does with Google-hosted jQuery.

Comparing Scripts in jQuery and JavaScript: A Comparison by Jeffrey Way

In a recent post, From jQuery to JavaScript: A Reference, Jeffrey Way gives an excellent run-down of how to get scripty things done in three idioms: jQuery, current JavaScript, and legacy JavaScript.

It’s an outstanding read.

Item number one gives a great introduction to JavaScript’s new Selectors API, which approximates jQuery for its ability to query the DOM in CSS-selector style.

So for instance, compare these three ways of doing things:

Selecting Elements

jQuery

$('#container');

JavaScript

var container = document.querySelector('#container');

Legacy JavaScript

var container = document.getElementById('container');

Or consider this:

Add, Remove, and Toggle Classes

jQuery

$('#box').addClass('wrap');
$('#box').removeClass('wrap');
$('#box').toggleClass('wrap');

JavaScript

var container = document.querySelector('#box');
container.classList.add('wrap');
container.classList.remove('wrap');
container.classList.toggle('wrap');

Legacy JavaScript

var box = document.getElementById('box'),
 
    hasClass = function (el, cl) {
        var regex = new RegExp('(?:s|^)' + cl + '(?:s|$)');
        return !!el.className.match(regex);
    },
 
    addClass = function (el, cl) {
        el.className += ' ' + cl;
    },
 
    removeClass = function (el, cl) {
        var regex = new RegExp('(?:s|^)' + cl + '(?:s|$)');
        el.className = el.className.replace(regex, ' ');
    },
 
    toggleClass = function (el, cl) {
        hasClass(el, cl) ? removeClass(el, cl) : addClass(el, cl);
 
    };
 
addClass(box, 'drago');
removeClass(box, 'drago');
toggleClass(box, 'drago'); // if the element does not have a class of 'drago', add one.

Credit: These examples are from the post, From jQuery to JavaScript: A Reference, by Jeffrey Way.

Which is better? — or Which is better When?

As Way points out, the question is not necessarily “Which is better?” but “Which is better when?” JavaScript’s new Selector API goes a long way toward making vanilla JavaScript nearly as easy to work with as jQuery. In cases where we can get things done without loading the jQuery library, our sites will travel lighter and perform a bit snappier.

They take-away: The jQuery library is fantastic when you need it, but in each case, we should pause to ask: “Do I really need jQuery in this case? — Or can I get it done in straight JavaScript?”

Links

iA Writer’s Typography and Color Scheme

For those who love iA’s Writer app, Justin Blanton has examined details of its visual and typographic design:

  • Background: f5f6f6 (rgb(245,246,246)) with a touch of noise
  • Font Color: #424242 (rgb(66,66,66))
  • Font: Nitti Light
  • Line Height / Leading: 1.5

Read more here: How to make any app look like iA’s Writer — Justin Blanton — Hypertext.net