NVM (Node Version Manager)
Mike Milano — April 9, 2012 - 1:47am
I was trying to get a Tilestream server running tonight and I ran into a problem. It wanted an older version of node.
After a little looking around on how to run multiple versions of node on my system, I came across Node Version Manager (nvm)
You can install different versions of node, and then activate them as a specific version is needed.
Drupal 7 Ubercart - Programmatically Capture Pre-Authorized Payments from Authorize.net
Mike Milano — March 15, 2012 - 6:07pm
I'm working with Drupal 7, Ubercart, and the Authorize.net payment gateway.
The goal here is to pre-authorize the payment at check-out, and capture the payment once the items have been shipped. I'm using order status to trigger when that happens, but I wanted to just show an example of how to capture that pre-authorized transaction.
-
Important notes:
How to Read Line Number x of a Large File with Awk
Mike Milano — February 9, 2012 - 12:00pm
The Situation: You have a 600 GB database dump that produces an error on line 7500 when you attempt to import it.
This size is generally too large to work with in vi. Emacs will generally handle large files like this OK, but maybe it isn't available or your emacs fu isn't quite there.
You can easily achieve the solution with Awk, which is usually available by default on most Linux systems.
awk NR==7500 mysql-dump-file.sql
Bash: Command Line Shortcuts
Mike Milano — January 30, 2012 - 1:15am
Here's a few shortcuts that may increase your productivity in the command line.
Navigate around the current command
ctrl+a -- Go to the beginning of the line.
ctrl+e -- Go to the end of the line.
ctrl+w -- Delete last word.
ctrl+k -- Delete everything after the cursor.
esc+f -- Move cursor forward one word.
esc+b -- Move cursor back one word.
Recall the last command with !!
Twisted, Long Polling, & JSONP
Mike Milano — December 30, 2011 - 10:06pm
I recently decided to use Twisted as the framework for a new project. In short, this app listens to and parses incoming events from multiple servers, as well as issues commands back to them.
Once I had Python doing its job managing the data, the next step was to expose the data in memory from the Twisted app to an existing PHP/Drupal UI. Twisted makes it pretty simple to attach an HTTP server to your app, so I did just that.
Why JSONP?
Controlling the Image Choice When Sharing with Facebook
Mike Milano — November 10, 2011 - 5:40am
Recently I had a client who wasn't happy with the images Facebook was providing as options when a user shared one of their product pages with Facebook.
You can give Facebook hints on what images you would like them to use.
Just add this code to your page for the images you would like to be in the selection:
<link rel="image_src" type="image/jpeg" href="http://example.com/images/my-image.jpg"/>
In my case, the image I defined here was the first choice that appeared on Facebook.
You can define more than one image for the available options.
Printing or Rendering a Node Field or Profile2 Field in Drupal 7
Mike Milano — October 20, 2011 - 1:17pm
When overriding a node template or user profile, you should not be drilling down the field array and printing the output unless you have a very good reason to do so. i.e. (do not do this) print $node->field_zipcode['und']['0']['value'];
The Drupal 7 field api offers us the field_view_field() function to get a renderable array of the output for a field entity.
Fixing file system permissions
Mike Milano — June 7, 2011 - 4:51pm
Have you ever shelled into a file system where a bunch of files were executable that should not be? Or maybe permissions are generally a mess?
Typically within a website file system, files should be 644 (owner read/write, group & all just read) and directories should be 755 (owner read/write/execute, group and all just read/execute).
If you don't have any special needs for individual files to be executable, or you just want to start fresh, you can use this method.
Colorbox: New Lightbox Module for Drupal 7
Mike Milano — April 10, 2011 - 10:53pm
I came across this module tonight since Lightbox2 wasn't updated to D7 yet.
It's pretty nice and I'm happy I ran into the problem that had me searching for new tools.
Adding a CCK Field to a Custom Form
Mike Milano — October 8, 2010 - 1:19am
Recently I wanted to add a CCK combo field into a custom form. Why would you need to do this? Well, my reason was to re-use a combo field with the 'add another item' functionality. Using the node form was not an option.
In this example we have a CCK combo field named "guests". Each guest has a first name, last name, and email address. The content type the guests field is in is my_event.
When adding this code to your form function, the guests field will display just as it does on the node form.
<?php // include the content file
