Comments/Feedback
If you have comments or thoughts about my blog, you can contact me at my lab here:
http://lab.westernwillow.com/contact
Franco's blog
Easy exporting of Drupal 7 custom fields for use in module code.
ok, down and dirty, you need the devel module installed and working, but this code will produce two arrays you can paste into your :
_my_module_installed_fields() and _my_module_installed_instances()
Functions.
eg:
/**
* Returns a structured array defining the fields created by this content type.
*
* @return
* An associative array specifying the fields we wish to add to our
* new node type.
*/
function _my_custom_module_installed_fields() {
$t = get_t();
PASTE GENERATED CODE HERE
}
Midnight Commander on OS-X
As a die hard terminal man, I have found my Macbook Pro to be a pain because of my linux habits. I found myself asking; How do i select files and access the menu in Midnight Commander on OS-X
Google is my friend :)
On a Mac the insert key may be triggered by the <ctrl>+<t> shortcut. So you may use this key combination to select files in the Midnight Commander.
When using this Norton Commander clone, you may also want to access the menu. But the function keys are preassigned to OS-X functions. So how do you get them to work with Midnight Commander?
Get lists of NIDs from DB filtering by fields without having to do joins - Hello "Entity Field Query"
New with D7 is the Entity Field Query. Use it like this!
<?php
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'article')
->propertyCondition('status', 1)
->fieldCondition('field_news_types', 'value', 'spotlight', '=')
->fieldCondition('field_photo', 'fid', 'NULL', '!=')
->fieldCondition('field_faculty_tag', 'tid', $value)
->fieldCondition('field_news_publishdate', 'value', $year. '%', 'like')
->range(0, 10)
->addMetaData('account', user_load(1)); // Run the query as user 1.
Setting the maximum upload size or php memory for Drupal 7
There are 3 main ways to do this:
1) custom PHP.INI file
2) .htaccess
3) settings.php
I may come back and document the other 2 in this post at a later date but for now I will cover the custom PHP.INI approach.
I tend to use this approach in a hosting environment and becuase if you need additional memory to install drupal as is the case if you install a profile like Commerce Kickstart, then the changes set in the settings.php are not used until after the install.
First I create a blank file in the drupal directory called php.ini
Charts and Graphs in Drupal 7

I have been struggling to find a solution to creating graphs from views in Drupal 7 for some time and recently while working on the SPARCS project and at long last I have done the hard work to get it going.
If you want to just create a simple graph easily, use the CHART module. This will use the google charts api and draw simple but many different graphs:
drush dl chart
drush en chart_views
Restore a LVM image to LVM direct from gzip to LVM with a progress bar
By piping commands together you can save yourself the trouble of filling your harddisk with the uncompressed logical volume manager (LVM) image and pipe the image direct to a logical volume.
Assumptions:
the LV is here: /dev/lg_storage/lv_harddisk (16 gigs)
the compressed image is: disk_backup.gz (2 gigs - 16 gigs uncompressed)
you have pv installed (apt-get install pv)
as root do:
pv disk_backup.gz | gzip -d | dd of=/dev/lg_storage/lv_harddiskthis will give you:
0.88GB 0:02:09 [84.41MB/s] [=========> ] 41% ETA 0:04:30
Check if port XXX is listening on your server
I use two approaches with the same tool, netstat.
sudo netstat --listenthis gives output like:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:webmin *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:postgresql *:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
Fix slow SSH response on your Ubuntu Server
By default, ubuntu will force each connection to have a reverse-dns lookup before establishing the session, this is great when doing a forensic audit of which IP address/FQDN logged into your server, but for day to day internal lan use, this added security measure is a PITA when you dont have a reverse dns as all it does is delay the establishment of the SSH session.
Things i like to do to Ubuntu to make it rock.
This post will be an ongoing work:
I like to have a few standard tools I like to use:
sudo apt-get install nano mc htop ncduI also like the desktop to default to list view not icons:
In nautilus, go to Edit -> Preferences and select "list view", instead of "icon view" (in the "default view" section).
Find and eliminate rogue or ghost KVM Virtual machines under Cloudmin
I simply love managing my KVM virtual machines on ubuntu using cloudmin. But if you are like me you will have renamed a few virtual machine hostnames before you realize that doing so can orphan the VM processes under cloudmin and that these rogues will persist even after a reboot, or even a reinstall.
Tags in Blog Tags
Recent blog posts
- Easy exporting of Drupal 7 custom fields for use in module code.
- Midnight Commander on OS-X
- Get lists of NIDs from DB filtering by fields without having to do joins - Hello "Entity Field Query"
- Setting the maximum upload size or php memory for Drupal 7
- Charts and Graphs in Drupal 7
- Restore a LVM image to LVM direct from gzip to LVM with a progress bar
- Check if port XXX is listening on your server
- Fix slow SSH response on your Ubuntu Server
- Things i like to do to Ubuntu to make it rock.
- Find and eliminate rogue or ghost KVM Virtual machines under Cloudmin
