Dan

I'm a 27 year old software engineer living in Memphis, Tennessee. This blog is mainly a place to house snippets and tips I have found useful during the course of my work. Hopefully someone else will find these things as useful as I have :)

 
applespace

MacOS X uses vim as its default crontab editor. That’s not too big of an issue, I know how to use vim, but it is vastly overpowered for the simple task of editing a cron file. Nano suffices just fine for this, and I’m sure most Mac users have no idea what vim is, let alone how to use it.

So, here is how to switch your cron editor to nano, a much simpler command-line text editor.

  1. Press Command(⌘) + Spacebar, and type terminal into the spotlight search box in the upper right of your screen
  2. [Pic] In the terminal window, type the following exactly as it appears, yes the semicolon is important:
    EDITOR=nano;
    export EDITOR
  3. Now when you use the terminal to run crontab -e, it will utilize the much simpler nano editor instead of vim.

If you’re afraid to run commands from the terminal, I do first have to ask why you’re using cron in the first place, and then recommend CronniX, a graphical crontab editor for MacOS X.

Learn more about vim

Learn more about nano

Learn more about cron

 

I have a (slightly) older IBM ThinkPad R51e laptop that still has a ton of life in it. I once tried installing Windows 7 on it, and it ran wonderfully with Aero turned off. The only problem was that a driver for the sound device was impossible to find. Windows update didn’t have one, and a tried dozens of SoundMax drivers across the interwebz in vain.

Then, via my MSDN subscription I obtained a copy of the Windows 8 Developer Preview. Much to my surprise, the sound worked when I tried it out on the ThinkPad! I extracted the driver from the system hoping that it would be backwards compatible with Windows 7.

Success! Sound now works in Windows 7 on my Thinkpad R51e! Which is great, because honestly Windows 7 runs better than XP or Ubuntu on this laptop, but without sound, it wasn’t an option. Thanks Windows 8 Developer Preview!

Since I am such a nice guy, I’m going to share it with anyone who wants it:

Download ZIP (105 KB)

To Install:

  1. Make a folder on your desktop called “audiodriver”
  2. Extract the contents of the ZIP file to the audiodriver folder.
  3. In the start menu, right-click on “Computer”, and click “Properties”. [pic]
  4. When the system properties window appears, there will be a link in the left pane labeled “Device Manager”. Click it. [pic]
  5. Find the audio device in the list. It will have a yellow exclamation mark on it, since it has no driver. [pic]
  6. Right click the audio device, and select “Update Driver Software…” [pic]
  7. When the Update Driver Software window appears, select “Browse my computer for driver software” [pic], and navigate to the audiodriver folder on your desktop.
  8. Select “smwdmat4.inf”, and proceed. The rest of the process should be automated.

 

Thank the heavens for Google Cache and the Web Archive.

I’ve found some of my old posts on there, and can restore the ones that are available, which I will be doing over the next few days :)

 

Due to a corrupted database backup, I’ve lost all of my old posts. So, I’m starting from scratch.

Welcome to /dev/dan, the next iteration of my blog.

I might even update it once in a while ;)

 

I found this while building a project at work: http://www.gidforums.com/t-1816.html

I was pulling text strings from an Atom feed in a PHP script, and some of them contained URLs. Obviously it’s beneficial and makes the program more functional if those URLs are clickable.

Here is the code for the function:

<?php
/**
NAME : autolink()
VERSION : 1.0
AUTHOR : J de Silva
DESCRIPTION : returns VOID; handles converting
URLs into clickable links off a string.
TYPE : functions
======================================*/

function autolink( &amp;$text, $target='_blank', $nofollow=true )
{
// grab anything that looks like a URL...
$urls = _autolink_find_URLS( $text );
if( !empty($urls) ) // i.e. there were some URLS found in the text
{
array_walk( $urls, '_autolink_create_html_tags',
array('target'=&gt;$target, 'nofollow'=&gt;$nofollow) );
$text = strtr( $text, $urls );
}
}

function _autolink_find_URLS( $text )
 {
 // build the patterns
 $scheme = '(http:\/\/|https:\/\/)';
 $www = 'www\.';
 $ip = '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
 $subdomain = '[-a-z0-9_]+\.';
 $name = '[a-z][-a-z0-9]+\.';
 $tld = '[a-z]+(\.[a-z]{2,2})?';
 $the_rest = '\/?[a-z0-9._\/~#&amp;=;%+?-]+[a-z0-9\/#=?]{1,1}';
 $pattern = "$scheme?(?(1)($ip|($subdomain)?$name$tld)|($www$name$tld))$the_rest";$pattern = '/'.$pattern.'/is';
 $c = preg_match_all( $pattern, $text, $m );
 unset( $text, $scheme, $www, $ip, $subdomain, $name, $tld, $the_rest, $pattern );
 if( $c )
 {
 return( array_flip($m[0]) );
 }
 return( array() );
 }

function _autolink_create_html_tags( &$value, $key, $other=null )
 {
 $target = $nofollow = null;
 if( is_array($other) )
 {
 $target = ( $other['target'] ? " target=\"$other[target]\"" : null );
 // see: http://www.google.com/googleblog/2005/01/preventing-comment-spam.html
 $nofollow = ( $other['nofollow'] ? ' rel="nofollow"' : null );
 }
 $value = "<a href=\"$key\"$target$nofollow>$key</a>";
 }
?>

And here is how to use it:

<?php /* let's say we have a dummy string read
from a file or db $text = 'For more information,
visit our website http://www.desilva.biz or
www.gidforums.com/ to discuss this. This topic is
discussed here:   http://www.gidforums.com/t-1787.html';*/
// first we pass it through htmlentities()
$text = htmlentities( $text );
// include the 3 functions above
include_once( 'includes/the_3_functions_above_are_in_this_file.php' );
// NOW we run it through autolink()!
autolink( $text );
// display the text in a web page
echo $text."<br />\r\n";
?>

 

Any of you who have ever used a VPS/VDS (Virtual Private Server/Virtual Dedicated Server)for hosting know that many times, what you get is what the company you are doing business with has cut out as the “most compatible” configuration for most of its customers.

This works for most clients, but unfortunately there are still those who wish they had the freedom to completely individualize their VPS/VDS for their own purpose.

Enter Webbynode. Webbynode is a new kind of VPS service provider. It’s not a cookie-cutter mass-market profit-by-volume solution as you see from the likes of Godaddy, but rather a completely customizable system which allows you to configure your “Webby” exactly how you want it.

You can even easily cluster multiple “Webbies” together for redundancy and increased performance.

If you’re a VPS/VDS client, I recommend checking Webbynode out: http://www.webbynode.com/

 

© 2011 /dev/dan Suffusion theme by Sayontan Sinha