Knowing Your File System · May 30, 01:01 AM by Dylan Doxey
For a quick assessment of your drive space distribution and usage use the df command.
dylan@dev.doxey.org$: ~ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/root 15G 14G 661M 96% / varrun 2.0G 56K 2.0G 1% /var/run varlock 2.0G 0 2.0G 0% /var/lock udev 2.0G 40K 2.0G 1% /dev devshm 2.0G 0 2.0G 0% /dev/shm /dev/sda1 237M 24M 201M 11% /boot /dev/mapper/home 440G 7.8G 410G 2% /home
The -h switch indicates human readable mode.
Gosh, looks like I ought to move some of my junk under /home.
For a more granular display of where the bulk of your stuff is, use the du command.
dylan@dev.doxey.org$: ~ du -h --max-depth=1 52K ./.subversion 7.6G ./rep 9.5M ./sandbox 45M ./.cpan 4.0K ./.gnupg 64K ./bin 128K ./.vim 7.7G .
Again, the -h switch gives you the easier to read numeric values.
The --max-depth option let's you control the depth of the display. The default is unlimited depth.

My Other xorg.conf · Apr 28, 09:35 AM by Dylan Doxey
This is the xorg.conf from my workstation at home.
# xorg.conf (X.Org X Window System server configuration file) # # You should use dexconf or another such tool for creating a "real" xorg.conf # For example: # sudo dpkg-reconfigure -phigh xserver-xorg Section "Module" Load "glx" Load "v4l" EndSection Section "Monitor" Identifier "Primary Monitor" Vendorname "BenQ" ModelName "FP202W" HorizSync 31-81 VertRefresh 56-76 Option "DPMS" UseModes "BenQ Modes" Gamma 1.0 EndSection Section "Monitor" Identifier "Secondary Monitor" Vendorname "BenQ" ModelName "FP202W" HorizSync 31-81 VertRefresh 56-76 Option "DPMS" UseModes "BenQ Modes" Gamma 1.0 EndSection Section "Screen" Identifier "Primary Screen" Device "nVidia GeForce" Monitor "Primary Monitor" DefaultDepth 24 SubSection "Display" Depth 24 Modes "1680x1050" "1600x1024" "1600x1000" "1400x1050" "1280x1024" "1440x900" "1280x960" "1366x768" "1280x800" "1152x864" "1280x768" "1024x768" "1280x600" "1024x600" "800x600" "768x576" "640x480" EndSubSection EndSection Section "Screen" Identifier "Secondary Screen" Device "nVidia GeForce" Monitor "Secondary Monitor" Defaultdepth 24 SubSection "Display" Depth 24 Modes "1680x1050" "1600x1024" "1600x1000" "1400x1050" "1280x1024" "1440x900" "1280x960" "1366x768" "1280x800" "1152x864" "1280x768" "1024x768" "1280x600" "1024x600" "800x600" "768x576" "640x480" EndSubSection EndSection Section "Device" Identifier "nVidia GeForce" Boardname "nVidia GeForce 7 Series" BusId "PCI:02:00:0" Screen 0 Vendorname "NVIDIA" Option "TwinView" "true" Option "MetaModes" "1680x1050,1680x1050" Option "HorizSync" "DFP-0: 31-81; DFP-1: 31-81" Option "VertRefresh" "DFP-0: 56-76; DFP-1: 56-76" Option "TwinViewOrientation" "DFP-1 LeftOf DFP-0" Option "ConnectedMonitor" "DFP-0,DFP-1" Driver "nvidia" Option "NoLogo" "True" EndSection Section "ServerLayout" Identifier "Default Layout" Screen 0 "Primary Screen" 0 0 Screen 1 "Secondary Screen" RightOf "Primary Screen" EndSection Section "ServerFlags" Option "DefaultServerLayout" "Default Layout" Option "Xinerama" "false" EndSection Section "Modes" Identifier "BenQ Modes" Modeline "1680x1050" 119.00 1680 1728 1760 1840 1050 1053 1059 1080 Modeline "1680x1050" 184.27 1680 1792 1976 2272 1050 1051 1054 1096 Modeline "1680x1050" 181.61 1680 1792 1976 2272 1050 1051 1054 1095 Modeline "1680x1050" 178.96 1680 1792 1976 2272 1050 1051 1054 1094 Modeline "1600x1024" 171.97 1600 1712 1888 2176 1024 1025 1028 1068 Modeline "1600x1024" 168.40 1600 1704 1880 2160 1024 1025 1028 1068 Modeline "1600x1024" 165.94 1600 1704 1880 2160 1024 1025 1028 1067 Modeline "1600x1000" 166.71 1600 1704 1880 2160 1000 1001 1004 1043 Modeline "1600x1000" 164.46 1600 1704 1880 2160 1000 1001 1004 1043 Modeline "1600x1000" 162.05 1600 1704 1880 2160 1000 1001 1004 1042 Modeline "1400x1050" 153.77 1400 1496 1648 1896 1050 1051 1054 1096 Modeline "1400x1050" 151.56 1400 1496 1648 1896 1050 1051 1054 1095 Modeline "1400x1050" 149.34 1400 1496 1648 1896 1050 1051 1054 1094 Modeline "1280x1024" 136.57 1280 1368 1504 1728 1024 1025 1028 1068 Modeline "1280x1024" 134.72 1280 1368 1504 1728 1024 1025 1028 1068 Modeline "1280x1024" 132.75 1280 1368 1504 1728 1024 1025 1028 1067 Modeline "1440x900" 134.52 1440 1536 1688 1936 900 901 904 939 Modeline "1440x900" 132.71 1440 1536 1688 1936 900 901 904 939 Modeline "1440x900" 130.75 1440 1536 1688 1936 900 901 904 938 Modeline "1280x960" 128.13 1280 1368 1504 1728 960 961 964 1002 Modeline "1280x960" 126.27 1280 1368 1504 1728 960 961 964 1001 Modeline "1280x960" 124.54 1280 1368 1504 1728 960 961 964 1001 Modeline "1366x768" 107.78 1368 1448 1592 1816 768 769 772 802 Modeline "1366x768" 106.19 1368 1448 1592 1816 768 769 772 801 Modeline "1366x768" 104.73 1368 1448 1592 1816 768 769 772 801 Modeline "1280x800" 105.78 1280 1360 1496 1712 800 801 804 835 Modeline "1280x800" 104.35 1280 1360 1496 1712 800 801 804 835 Modeline "1280x800" 102.80 1280 1360 1496 1712 800 801 804 834 Modeline "1152x864" 103.59 1152 1224 1352 1552 864 865 868 902 Modeline "1152x864" 102.08 1152 1224 1352 1552 864 865 868 901 Modeline "1152x864" 99.64 1152 1224 1344 1536 864 865 868 901 Modeline "1280x768" 101.60 1280 1360 1496 1712 768 769 772 802 Modeline "1280x768" 99.17 1280 1352 1488 1696 768 769 772 801 Modeline "1280x768" 97.81 1280 1352 1488 1696 768 769 772 801 Modeline "1024x768" 80.71 1024 1080 1192 1360 768 769 772 802 Modeline "1024x768" 79.52 1024 1080 1192 1360 768 769 772 801 Modeline "1024x768" 78.43 1024 1080 1192 1360 768 769 772 801 Modeline "1280x600" 77.82 1280 1344 1480 1680 600 601 604 626 Modeline "1280x600" 76.04 1280 1336 1472 1664 600 601 604 626 Modeline "1280x600" 75.00 1280 1336 1472 1664 600 601 604 626 Modeline "1024x600" 62.26 1024 1080 1184 1344 600 601 604 626 Modeline "1024x600" 61.42 1024 1080 1184 1344 600 601 604 626 Modeline "1024x600" 59.86 1024 1072 1176 1328 600 601 604 626 Modeline "800x600" 48.18 800 840 920 1040 600 601 604 626 Modeline "800x600" 47.53 800 840 920 1040 600 601 604 626 Modeline "800x600" 46.87 800 840 920 1040 600 601 604 626 Modeline "768x576" 44.83 768 808 888 1008 576 577 580 601 Modeline "768x576" 43.52 768 800 880 992 576 577 580 601 Modeline "768x576" 42.93 768 800 880 992 576 577 580 601 Modeline "640x480" 30.25 640 664 728 816 480 481 484 501 Modeline "640x480" 29.84 640 664 728 816 480 481 484 501 Modeline "640x480" 29.43 640 664 728 816 480 481 484 501 EndSection

My latest xorg.conf · Apr 16, 01:12 PM by Dylan Doxey
I had to basically write this from scratch when I recently did a fresh Kubuntu install. Let's make sure that doesn't happen again.
# xorg.conf
Section "Module"
Load "glx"
Load "kbd"
Load "mouse"
EndSection
Section "InputDevice"
Identifier "The Keyboard"
Driver "kbd"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection
Section "InputDevice"
Identifier "The Mouse"
Driver "mouse"
Option "CorePointer"
EndSection
Section "Monitor"
Identifier "Left Monitor"
VendorName "DELL"
ModelName "DELL 1907FP"
HorizSync 30.0 - 81.0
VertRefresh 56.0 - 76.0
EndSection
Section "Monitor"
Identifier "Right Monitor"
VendorName "DELL"
ModelName "DELL 1907FP"
HorizSync 30.0 - 81.0
VertRefresh 56.0 - 76.0
EndSection
Section "Screen"
Identifier "Right Screen"
Monitor "Right Monitor"
Device "Video Card A"
Option "TwinView" "True"
DefaultDepth 24
EndSection
Section "Screen"
Identifier "Left Screen"
Monitor "Left Monitor"
Device "Video Card B"
Option "TwinView" "True"
EndSection
Section "Device"
Identifier "Video Card A"
BusID "PCI:1:0:0"
Screen 0
VendorName "nVidia Corporation"
BoardName "GeForce 7300 LE"
Driver "nvidia"
Option "NoLogo" "True"
EndSection
Section "Device"
Identifier "Video Card B"
BusID "PCI:1:0:0"
Screen 1
VendorName "nVidia Corporation"
BoardName "GeForce 7300 LE"
Driver "nvidia"
Option "NoLogo" "True"
EndSection
Section "ServerLayout"
Identifier "Default Layout"
Screen 0 "Right Screen"
Screen 1 "Left Screen" LeftOf "Right Screen"
InputDevice "The Keyboard" "CoreKeyboard"
InputDevice "The Mouse" "CorePointer"
EndSection
Section "ServerFlags"
Option "Xinerama" "0"
DefaultServerLayout "Default Layout"
EndSection

Charile Rose · Mar 18, 01:34 AM by Dylan Doxey
I've taken quite a liking to watching Charlie Rose.
A conversation with Reid Hoffman of LinkedIn
http://www.charlierose.com/view/interview/10128
A conversation with Marissa Mayer, V.P. of Search Product and User Experience, Google
http://www.charlierose.com/view/interview/10129
A conversation with entrepreneur and software engineer Marc Andreessen
http://www.charlierose.com/view/interview/10093
A conversation with Evan Williams, Co-founder of Twitter.com
http://www.charlierose.com/view/interview/10118
A conversation with Jen-Hsun Huang, CEO Nvidia
http://www.charlierose.com/view/interview/10060
A conversation with Chris DeWolfe And Tom Anderson, founders of Myspace.com
http://www.charlierose.com/view/interview/10054
A conversation with Arianna Huffington
http://www.charlierose.com/view/interview/9705
A conversation with Eric Schmidt, CEO of Google
http://www.charlierose.com/view/interview/10131
A conversation with Jeff Bezos, Amazon.com
http://www.charlierose.com/view/interview/10105

Like ZipRealty.com... almost? · Dec 19, 02:19 AM by Dylan Doxey
I like ziprealty.com because it's not trying to impress you with all the wistles, bells and gadgets.
You can set some criterion, search, and look at results.
But I want more. Well, actually I want less. I want fewer things distracting me and cluttering up the page.
So I wrote this GreaseMonkey script to help out.
Features:
- Strips nearly all superfluous text and up-sell promos.
- House detail links open in another window/tab.
- House address headers link to Google Maps on detail view.
- My Homes view has a tidy list suitable for cut & paste into an email for your agent.
ZipRealty give you enough information that you can nearly do your agent's job for him/her. And why not? I enjoy browsing the houses and composing my weekend visit lists.
Happy house shopping!

Extended Characters in Your JavaScript · Dec 14, 04:42 PM by Dylan Doxey
So, there you are happily coding away on your web application for your Japanese audience. You think you've buttoned it all up, and you'll go ahead and give it a courtesy end user test before you launch it. just to be sure.
And there it is, the dreaded corrupt CJK characters in your JavaScript.
Surely you were going for something more like this.
Do not fret! There is a reliable solution.
Generally you might be inclined to do this:
var characters = prompt( 'こんにちは、世界的', '' );
And why the heck not?
This solution is fine, provided there is no confusion about character encoding anywere between your text editor and the web client's browser software.
This confusion could arise in a number of places. To mention a few:
- your code editing software
- your file transfer software
- your server file system
- your sebserver
- the client web browser.
If at any point in this chain of custody something makes an assumption about the encoding, then your wide characters may become corrupt.
The solution is to use the JavaScript Unicode escaped version of the characters that go beyond the ASCII range.
var characters = prompt( '\u3053\u3093\u306b\u3061\u306f\u3001\u4e16\u754c\u7684', '' );
Sweet! Problem solved. Now we can all go back to our stations and continue having been edified with this new insight!
Well, not quite.
Who really knows the Unicode values of the CJK text they're working with? Surely, no one.
Yes, that's right, it's another opportunity to write some code.
1 #!/usr/bin/perl
2
3 use strict;
4 use Encode qw( decode_utf8 );
5
6 if ( !@ARGV ) {
7 print "\nUsage:\n $0 some string to encode\n\n";
8 exit;
9 }
10
11 my $js_encoded = "";
12
13 my $string = decode_utf8( join ' ', @ARGV );
14
15 for my $char (split //, $string) {
16
17 my $unicode = sprintf '%0.4x', ord $char;
18
19 $js_encoded .= '\u' . $unicode;
20 }
21
22 print "\nJS Encoded:\n";
23 print " $js_encoded\n";
And there you have it. Now all you need to do is run each snippet of CJK text you want to include in your JavaScript through this program.
dylan@dev.doxey.org$: ~ ./js_encode.pl こんにちは、世界的
JS Encoded:
\u3053\u3093\u306b\u3061\u306f\u3001\u4e16\u754c\u7684
Happy computing!

Lingua::Translate::Google -- published! · Nov 22, 03:27 PM by Dylan Doxey
I've published my first module on CPAN, and I hereby contgradulate myself.
This is backend module to Lingua::Translate which can be used as an alternative to the default backend -- Lingua::Translate::Babelfish.
Read more at: http://search.cpan.org/~dylan/.

Getting Your Date Straight · Oct 18, 03:14 PM by Dylan Doxey
It's been bugging me for a while, that my server from System76 was on the Devner Colorado time zone. So, I just set the time ahead by an hour using the date command.
This is simple enough to do:
dylan@dev.doxey.org$: sudo date 1018114508
Sat Oct 18 11:45:00 MDT 2008
But that "MDT" will always remind me, I was taking a shortcut and not bothering to do it the right way.
So, the right way is to read the System76 "Initial Server Setup" page... all the way to the end.
Doing that, I learned that the convenient way to choose your time zone is via an ANSI GUI interface invoked via:
sudo dpkg-reconfigure tzdata
Once you've got your time zone set appropriately, perhaps you'd like to sync up your time with an authoritative clock.
ntpdate is your handle to the Network Time Protocol.
sudo ntpdate us.pool.ntp.org
I chose us.pool.ntp.org from a list of North American time servers I found here http://www.pool.ntp.org/zone/north-america.
Happy computing!

Customizing Your Prompt · Oct 12, 01:55 PM by Dylan Doxey
So, you're on your system messing about, and then you realize, "Hey, I thought this was the development machine!" Yes, it happens. You're fiddling about with thing you shouldn't have on your production box.
I thought it would be nice if my terminal would change to a different profile depending on what machine I've initiated an SSH session with. This is certainly feasible, if you're a pretty good C++ programmer, and you feel like spending some time modifying your terminal application. This is not me.
Instead I thought I'd looking into setting up a custom prompt.
By default the prompts on all the machines I work with are like:
dylan@dev: /home/dylan$
So, what's the problem? The machine name is always right there.
I want more.
Here's a nice IBM article on how to use ANSI colors in your prompt.
http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
Here's what I've come up with for myself.
$ export PS1="\[\e[32;1m\]\u@\H\$: \[\e[37;1m\]\w \[\e[0m\]" dylan@dev.doxey.org$: /usr/home
$ export PS1="\[\e[33;1m\]\u@\H\$: \[\e[37;1m\]\w \[\e[0m\]" dylan@qa.doxey.org$: /usr/home
$ export PS1="\[\e[31;1m\]\u@\H\$: \[\e[37;1m\]\w \[\e[0m\]" dylan@prod.doxey.org$: /usr/home
Happy computing.

Mass Search & Replace · Oct 7, 10:27 AM by Dylan Doxey
So, there you are with a bunch of files. You want to search and replace a given string in all of them, and you're not sure how to go about it. If you're a former windows user, such as myself, you might be inclined to reach for the nearest GUI editor, open all of the files simultaneously, and do a search and replace on all the files that way. However, I've yet to see a GUI based editor that runs on Linux which can handle this sort of task the way that UltraEdit would.
Perl to the rescue!
Here's an example of replacing "searchme" with "replacement" in all the PHP files in the current directory.
perl -pi -e 's{searchme}{replacement}xmsg' *.php
The beauty is that you just need to supply Perl with a list of files.
For example:
perl -pi -e 's{searchme}{replacement}xmsg' `find . -name 'holey*moley*'`
That does the search and replace on all files in the current, and subdirectories of the current directory where the filename contains "holey" and "moley" in that sequence.
May the force be with you.

