Who decided indenting with spaces was a good idea?

image

I have had various discussions over the years with developers about coding standards and consistency. At the start of a new project a team will/should sit down and hash out a common coding style guideline to follow. I’ve always believed that the consistency of the codebase is more important than my own personal coding preferences, so I never complained much when a decision doesn’t go the way I’d like. 

One decision that I’ve seen many times and have never understood is the use of spaces instead of tabs to indent code. To me it seems that this is something that people have just gotten used to seeing and have very few actual reasons for preferring it. Similar to how many people pronounce words incorrectly and resist correction because the correct way “sounds weird.” So instead of making the same mistake, I’ve decided to list the reasons for using tabs instead of spaces for indentation of code.

  1. tabs are a single character that represents indentation, this makes it the “correct” choice for indentation of code.
  2. when code is indented with tabs, the indentation amount (2 spaces, 4, 8) becomes a developer preference that can be set in the developer’s IDE.
  3. tabs actually use less space on disk as only one character is stored instead of 2, 4 or 8.
  4. indentation mistakes are harder to make and easier to see (like 3 spaces instead of 4)
  5. spaces look funny (OK, that one was a joke)

It seems to me that indenting with spaces is akin to making a new paragraph in html via 2 <br> tabs. Yes it achieves the same visual result, but the <p> tag has a purpose, why would you NOT use it?

Discuss on Hacker News

How to speed up Stylus with a concat step

image

I recently ran into an issue where my Stylus grunt task was taking a long time to run (like 10+ seconds). I found that the main issue was the sheer number of styl files our project has (125 and counting) and the fact that we use nib.

Using a concat step (grunt-contrib-concat) to combine all styl files into one prior to compiling with stylus, I was able to reduce the processing time to around 3 seconds (a 70% increase in speed).

So if you use lots of stylus files and are finding it slow to process, give this technique a try.

infect.js - Infectiously simple dependency injection for any JavaScript project

When working on a large codebase there are often services, utility methods, endpoints, etc that are shared across the whole application. When a reference to one of these is needed within a module, we will often alias the global namespace to a variable to easy referencing. Dependency injection makes this easier and more maintainable.

infect.js brings the magic of DI to any JavaScript application in the form of a tiny (sub 1kb min+gz) library that can be included in your code.

Check out the github page for more details and code examples

ko.public - A New Way for Your Knockout.js Modules to Talk

As developers we know that we should be keeping out code modular. That means if you’re using a library like Knockoutjs you shouldn’t put all your code in a single viewmodel.

So what if you need those modules to be able to communicate with each other? Typically you would use a PubSub type of structure to allow cross module communication but what if there was an easier way?

As I was developing in Knockout I thought, what if there was a way for me to specify a value on 2 different viewmodels that used the same observable value? So when one is updated, the other would get that message and automatically update and push changes to the view.

Well, it turns out it is easier than I thought. A few lines of code later and I had it. I’m calling the solution ko.public, and it’s available on GitHub under the MIT license. So go nuts, and enjoy!

Project Webpage
https://github.com/amwmedia/ko.public

Example of Usage
http://jsfiddle.net/amwmedia/4PKQS/

I cannot figure out how to drag the Reveal Password link into bookmarks...

Sometimes, depending on your browser and settings, you can’t drag the bookmark. In that case you can right click on it and add it to your favorites from that menu. In internet explorer I believe you click “Add to Favorites” from the right click menu.

Thanks,
Andrew

A different take on Chromecast

image

So Google recently announced a sleek new product known as Chromecast and everyone is talking about it. The device resembled a USB thumb drive, but it plugs into your HD TV instead of your computer. The idea is that when you find a video that you want to watch, or any other piece of content that you want to consume, you can do so on your television using Chromecast. So you have a little button on your youtube app that, when pressed, sends a signal to your Chromecast, and the Chromecast goes out and streams that content down to your TV.

The idea is simple and elegant, and it got me thinking.

Keep reading

Fire Cells

image

Just posted my second particle animation up on CodePen and I really like how it came out. I added a lot more “life” to the system, making the little particles move on their own in a more cell-like fashion. Hope you enjoy it!

Oh, and Chrome is pretty much required for this to look right. :-)

Fire Cells on CodePen »

Kill Skype Home - Going Open Source!

I have really enjoyed all the comments and positive feedback I’ve gotten about Kill Skype Home (KSH)! A day or two after releasing KSH I started receiving requests to publish the source. To be honest I had mixed feelings about it. On one hand, I have nothing to hide, and I want everyone to feel comfortable using KSH on their computer. On the other hand I spent a fair amount of time figuring out what I thought would be the best way for this program to work, and coding it.

So I started to research OS licenses, and what they meant. So I’m going to give this whole “Open Source” thing a shot. I’m releasing KSH under the GPL and starting a sourceforge project. Seeing as how I have no experience with sourceforge, I’ll ask that you bear with me as I figure it all out.

I’d love to hear your comments about this move and general thoughts on open source vs closed source projects.

KillSkypeHome on SourceForge

Everyone is a genius. But if you judge a fish on its ability to climb a tree, it will live its whole life believing it is stupid.
Albert Einstein

Kill Skype Home (KSH) - Get rid of that annoying “Skype Home” popup

Kill Skype HomeWith the new Skype update has come an annoying little window called Skype Home that pops up automatically when Skype starts. I don’t like things that serve no purpose and I don’t like things that pop up automatically. Now, when you combine the two, it’s just too much. So, of course, I had to write an app that fixes this issue. This script is designed to start with windows, kill the Skype Home window when it finds it, then closes itself so it no longer uses any system resources. For those of you who don’t leave skype running all the time, I’ve added “Persistent mode” which keeps KSH running and watching for Skype Home to pop up.

Keep reading

Reveal Passwords gets full Internet Explorer 6+ support

Hello, Just wanted to post a quick update to let everyone know that I have updated Reveal Passwords with full IE 6+ support. It took a fair amount of trial and error, but I’m very happy with the end product. So go check it out and update your Bookmarks!

Reveal Passwords

Reveal hidden passwords in all major browsers

image

Do you, or someone you know, use the browser’s built-in ability to remember passwords to the point that you/they forget what the password actually is? Do you feel held hostage by your browser, praying each night that tomorrow the magical dots will still be there to let you into your mail account? Those little dots that mock you, declaring with each page visit “I know your password, but I’m not going to tell YOU what it is!" Well, my friend, the day of reckoning has come!

Ok, so I went a little overboard there. I’ve written a bookmarklet that will allow you to reveal what is hidden behind your browser’s password mask. Simply drag the following link into your bookmarks. Then anytime you see a password field, you can click your bookmark to reveal the secret password beneath.

This script has been tested in:

  • Internet Explorer 6+
  • Firefox 3.6
  • Chrome
  • Opera 11
  • Safari

Reveal Passwords [Donate]

Having trouble dragging the bookmark?

I love the smell of Pandora in the morning

image

If you are like me, you use your phone as an alarm clock. It’s convenient because no matter where you are, it’s always with you…ready to yank you from your sweet slumber. Today I’ll show you how to make a very basic alarm clock for Android using Pandora and Tasker. It is, in my humble opinion, absolutely the best way to wake up in the morning. Ok, fine, the smell of bacon and eggs would be better. So if anyone can figure out a way to rig up an alarm clock that starts making you breakfast, please contact me right away!

Read on for all the dirty details…

THE PROBLEM
Normally a cell phone alarm clock will wake you up with some horrendously annoying sound. Yes, true, most phones will let you pick a music ring tone or even an mp3 to wake up to. But that simply ruins whatever song you pick. No matter what song you choose, it will ever after be associated with the awful feeling of morning grogginess.

THE SOLUTION
Below I’ve listed a very basic Tasker alarm profile that will simply start your Pandora app at the designated time, and close the app when the profile exits. Remember, profile exit events are triggered when the condition is no longer true, so if you want Pandora to stop at 7:00 AM, you need to set your exit event for 6:59 AM. I then set my phones annoying “beep beep beep” alarm for 7:00 AM so that in case I sleep heavily on a particular morning, I will still be forced out of bed.

Please note, due to changes in the Android platform, phones running 2.2 or higher will NOT be able to kill the Pandora app by merely performing a “Kill App” task. This profile gets around the problem by pausing the music, going to the home screen, and then killing the app. I’ve found this to be very reliable but please let me know if you have any trouble with it.

Have a better way to wake up in the morning? Tell me about it in the comments!

Loading... No More Posts Load More Posts