How to fork & patch npm modules

“With now more than 3000 modules, there are huge gaps in the quality of things you find in the npm registry. But more often than not, it’s easy to find a module that is really close to what you need, except if it wasn’t for that one bug or missing feature.” – Felix Geisendörfer

Today I read “How to fork & patch npm modules” from Debuggable by Felix Geisendörfer.

Npm is one of my favorite package managers, mostly because of the way it handles dependencies – each library is allowed to use its preferred version of a dependency. This works great when you want to fork an existing package as shown in the linked blog post. It’s really easy to modify where your dependencies are located. See how Felix customized his package.json to refer to a forked version of the xmlbuilder dependency in his own GitHub repository instead of the original npm package:

"dependencies": {
    "request": "1.9.8",
    "xmlbuilder": "https://github.com/felixge/xmlbuilder-js/tarball/4303eb2650a4b819a980b1dc9d2965862a1e9faf",
    "stack-trace": "0.0.5",
    "traverse": "0.4.4",
    "hashish": "0.0.4"
},

You just substitute the GitHub tarball URL (the final segment of the URL is just the SHA hash for the commit, of course) in the place of the previous npm version string. Next, create a pull request on GitHub and submit your changes upstream (if applicable)!

Beautiful Resumes with Markdown and LateX

“If you call failures experiments, you can put them in your resume and claim them as achievements.”
– Mason Cooley

I’ve been working on updating my resume recently to apply for some part-time or full-time web development positions with a local agency. While I love freelancing, there’s something special about having a core group of colleagues for support and creative collaboration. I thrive when given the opportunity to focus on the software. With that said, I’m extremely privileged to have been my own boss these past five months – it’ll be hard to give that up.

Working with a trusted friend, I’ve been revising my resume and trying to show my skills and experience in the most flattering way possible. Although my friend is extremely skilled, having personally helped hundreds of web developers get jobs in their field, I wanted to take the design and typography a step further than is possible with your typical Word ’97 document.

As I perused the Internet, gathering resume advice from hackers around the world, I came across the advice to generate my resume using LateX. I’ve used LateX in the distant past, but it was not a pleasant experience. Then I stumbled upon Mike White’s Markdown to LateX Resume Generator.

First, install the dependencies:

Now go ahead and clone the repository with Git and change directory:

$ git clone https://github.com/mwhite/resume
$ cd resume

Now build the default resume (contained in resume.md):

$ make

Now you have an awesome PDF resume generated with LateX – view the demo.

You can go ahead and start hacking the resume.md file, rename it, add your skills and/or completely re-arrange it. When you’re ready to generate the HTML and PDF versions, just run make again.

6 Questions To Determine If A Company Is Really Agile

I am a proponent of the Agile software development method. If you want to measure a potential employer’s “Agile-ness”, try asking these 6 questions (via Ithaqua on the Something Awful forums):

Yup. I’ve had the pleasure of working for two places that actually did Agile properly now.

Here are some questions to determine if a company is really Agile, or just pretending to be:

1) How long are your sprints/iterations? Why?
2) How do you do QA?
3) How do you come up with estimates for projects / tasks?
4) How do you handle urgent bugs?
5) How do you handle last-minute feature requests?
6) Do you do daily stand-up meetings? Who attends? How long do they last?”

The Disappointing Browser Support of the New HTML5 Number Input

Edit on 2013/01/09: I think the CSS3 property box-sizing: border-box could fix this issue.

I was creating a landing page for a client today and I thought I’d try an element of the HTML5 specification-in-the-making:

<input type="number" />

Basically what the number input does is provide client-side restrictions on the input as well as a browser built-in “spinner” on the field.

The issue I have is that the size must be controlled through CSS. WebKit (Chrome) claims to implement this input type, but the way it sizes the box doesn’t appear to be accurate with respect to the width and padding attributes. While this inconsistent sizing behavior may be acceptable on larger forms where the inputs are over 100 pixels, on smaller input fields, it’s simply unusable to me. The new interface takes up more space, so you either make it crammed and unusable in WebKit (not enough room to view the input), or you have a huge input field on older browsers which default to the type=”text” method.

Use jQuery for your number spinners and be certain they’ll behave how you want (assuming Javascript is enabled), at least until browsers give you an HTML/CSS-only way to have tiny inputs look consistent in newer browsers and still provide a properly sized fallback.

I would still recommend it on larger forms, if you don’t wish to use jQuery. It seemed to work fine in Chrome otherwise.

GoDaddy: Disable Auto-Renew On SSL Certificates

Edit on 2011/07/24: The steps have been updated by Jason in the comments below.

This post describes how to disable auto-renew on your GoDaddy SSL certificates. But first, some background:

Domain name registrar Go Daddy has served me well as the registrar for my domain names and SSL certificates. They’re the leading domain registrar in the world, about four times the size of their closest competitor.

Unfortunately, I find little reason to recommend them nowadays. Their customer service leaves something to be desired, and I recently heard that they’re making .co the default setting for all new domain registrations. To me, this is slightly deceptive. GoDaddy is not informing people the TLD they registered under is controlled by the Republic of Columbia. I don’t have a problem with that in itself — I own a .me domain, controlled by a country that’s only 4 years old. It’s simply something I feel many people would object to, given an informed decision.

My latest grievance though, is that I realized they automatically turn on auto-renew for all SSL certificate registrations. This isn’t something that’s prompted or clearly told to the user. It’s just assumed. Luckily, I noticed today while managing my domains. After a bit of searching around, I figured out the convoluted process to disable it.

Much thanks to James at DNForum.com for the post that reveals the secret incantations necessary:

  1. Login to GoDaddy
  2. Click My Account on the top listing
  3. Click “Renewals” on the left side of the page
  4. In the menu that pops up, click “Payments & Renewing Items”
  5. This brings up the page “Payment Profile” where all auto-renew items are listed
  6. Click the “Auto” column header and look for any items turned “On”
  7. Check the box next to any “On” items and click “Auto Renew ” at the top
  8. On the right side of page, check “Disable Auto Renew” then “Save Changes”.

If you manage a GoDaddy domain name, check it out for yourself. This is the only way to do it, and it sure ain’t simple. A bit deceptive, in my opinion.

Backing Up and Restoring a MySQL Database

This mini-guide will explain how to make backups of your MySQL Database, and how to restore the data.

This task is usually done when migrating your data to another server, but you should take care to make backups of your data on a routine basis as well. Maintaining backups in another location is a great way to ensure your data is safe in the case of an unexpected event.

This guide assumes that you have shell access to the machine hosting the database. Users managing their database from a control panel should refer to the documentation provided by the hosting company.

The syntax for a complete database backup is as follows:

mysqldump -u[username] -p[password] [database name] > [backup file]

You will then be asked to enter the user’s password and hit enter. So to backup a database named wp_database, using the username wp_user, and the password wp_password, saved to the file wp_backup.sql, you would enter:

mysqldump -uwp_user -pwp_password wp_database > wp_backup.sql

Enter the password at the prompt and the file containing your database will be created.

To only backup certain tables from your database, just list them after the database name. For example, to only backup the tables named wp_comments and wp_posts, you would use:

mysqldump -uwp_user -pwp_password wp_database wp_comments wp_posts > wp_backup.sql

Restoring your database from a backup is just as easy, the syntax for the command is:

mysql -u[username] -p[password] [database name] < [backup file]

So to restore a database named wp_database, using the username wp_user, with the password wp_password, from the file wp_backup.sql, you would use:

mysql -uwp_user -pwp_password wp_database < wp_backup.sql

It’s that easy.

How to enable On-Screen Keyboard in Ubuntu 10.04 (Lucid Lynx)

Turning on the on-screen keyboard in Ubuntu Linux is a little more complicated than it should be. These tips should work for any version of Ubuntu within the last few years, but I’m using Ubuntu version 10.04 Lucid Lynx.

The simple way to enable the on-screen keyboard is to run the program from the Terminal:

$ onboard

However, if you cannot use the keyboard, you cannot type. On to method 2:

  • Go to System -> Preferences -> Assistive Technologies in the Ubuntu menu.
  • Select “Enable assistive technologies”.
  • Click “Preferred Applications”.
  • Under Mobility, select onBoard from the drop-down menu. Check “Run at start”.
  • Log out and log back in, and the On Screen Keyboard is now enabled.

If you want to enable the on-screen keyboard at the login screen, please read my VMware Lucid Lynx guide, it’s explained as part of that tutorial.

Set up VMware with Ubuntu 10.04 Guest VM

This is a guide on setting up a VMware Guest VM running Ubuntu Linux 10.04 (Lucid Lynx).

VMware Workstation is an excellent tool for any developer, allowing you to run multiple operating systems simultaneously. I prefer to do the majority of my development in Linux, but I occasionally fall-back to Windows software on occasion. The new Long Term Support (LTS) release, Ubuntu 10.04, came out last April. I went ahead and set up a new virtual machine.

There were quite a few surprises along the way, so this is a quick installation guide. For the record, I was using VMware Workstation 7.0.0 at the time.

I will only touch on the VMware-specific aspects of the setup. The rest is basic Ubuntu administration and covered elsewhere.

  • Download Ubuntu 10.04 from the Ubuntu Download Page.
  • Install the Guest OS in VMware. I went with the automatic installation.
  • After the OS is booted up, the keyboard will not work properly at the login screen. You will see an icon with a man standing inside a circle, click this icon and then click “Universal Access Preferences”. Enable the On Screen Keyboard. If you are having trouble, see the screenshots in this guide by Internet Techies.
  • The On Screen Keyboard doesn’t show up properly at first, so reboot the VM.
  • Use the On Screen Keyboard to log in. Once you’re past the login screen, the keyboard should be working.
  • In order to fix the keyboard issues at login, run
    sudo dpkg-reconfigure console-setup

    I selected the option for “Logitech Generic Keyboard”. Now the keyboard should work at the login screen — feel free to restart the VM and test it out.

  • Next, I discovered there was an issue with the Shared Folders. The folders you make available in VMware are usually made available by VMware Tools at /mnt/hgfs/ in Ubuntu, but this wasn’t working. Any time I have issues with VMware Tools, I’ve found the solution is to just re-install it. First, uninstall VMware Tools with:
    sudo vmware-uninstall-tools.pl
  • Go back to your host machine. Bring up VMware Workstation, select your running VM, select the VM menu option at the top, and select the option to Install VMware Tools. This will automatically mount a CD in the guest Ubuntu OS, containing an archive of the installation files. In my case, the archive was called:
    VMwareTools-8.1.3-203739.tar.gz
  • Extract the folder contained in the archive, vmware-tools-distrib, to a location of your choice, I chose my Desktop.
  • First, make sure that you have all the build requirements installed:
    sudo apt-get install build-essential linux-headers-$(uname -r) psmisc
  • Then run the install script in the folder:
    ~/Desktop/vmware-tools-distrib$ sudo ./vmware-install.pl

    Hit enter at various times to accept the defaults &mdash; they all worked fine for me.

  • Restart your VM and everything should be good to go!

Vim Tip: Save a file with sudo-user permissions

Sometimes you need to save a file that you edited in Vim with sudo-user permissions, but you forgot to start Vim that way. The obvious strategy is to just save a temporary file and re-open the file using “sudo vim”. However, this one-liner trick uses the “tee” command to get around that. Just type this command into Vim, courtesy of skinp @ commandlinefu.com:

:w !sudo tee %

That’s it! If you want to quiet the output of the command, you can instead do:

:w !sudo tee % > /dev/null

WordPress: Best CMS for blogging

What is the best Content Management System for blogging? There are so many choices, one can easy get stuck in analysis paralysis, so I’m here to make the decision for you. In reality, it doesn’t matter that much which CMS you choose, as long as you can get on with it and start writing!

I recently decided to expand this website, Chris M. Welsh. I’m going to start posting entries with tutorials, opinions, and the latest news in web development.

My needs for the site were simple. I wanted to maintain some static pages and post updated content in the form of a blog. I considered starting a project in Django or Pylons, two web frameworks written in the Python programming language. I have a passion for coding websites from the ground up, with complete control over everything. However, my time is worth money, and I needed to treat myself just like a client and evaluate my options objectively. I wanted the site to be:

  • quick to deploy and customize
  • easy to maintain

I chose WordPress, an open-source CMS written in PHP. What else is great about WordPress besides the two things above?

  • great editing and publishing system
  • excellent theme and template community
  • RSS, pingback support
  • comment spam filtering

…and much more. It may not be as super-customizable and complex as Drupal, but I almost consider that a good thing. It’s an excellent, easy-to-use option for most people who only require basic functionality.

In the past, I’ve heard about security vulnerabilities in WordPress. Fortunately, things have pretty much stabilized over the past couple of years, but there are still protective measures you can take. I will post soon about increasing the security of your WordPress installation. The most important thing is to keep your installation up to date, and WordPress makes this very easy for you.

There’s a reason why WordPress is the most popular blog software in use today, with tens of thousands of new installations every day.