February 17, 2010 at 7:18 am · Filed under Programming
Today I needed to manually remove a service from windows. I found this command line approach, which worked great for me. Be sure to use the service name and not the display name:
You can find the service name by going to Control Panel -> Administrative Tools -> Services, right click the service and choose properties, the service name is shown there.
January 10, 2010 at 5:59 pm · Filed under Programming
Today I wrote a class to iterate words in a string. One challenge was finding my way backwards in a string. Specifically, given a starting position inside the string, I wanted to find the previous “word” and return it. However, since this needs to work localized (not just a-z), and the definition of a “word” is configurable, it was no simple matter of looking back for the previous space character.
So here is what I came up with; a method that finds the next or previous word given a starting position in the string:
/**
* Abstracted method for finding the next/prev word. This method assumes that
* $pos is greater than zero and less than the length of $text (check before calling)
*
* @param string $text the string of text to find next/prev word in
* @param int $pos the position of first character in current word
* @param string $wordPattern the regex definition of a word without any matching parens
* @param string $reverse looks backward instead of forward (finds last word in string)
* @return mixed false if no more words or array( "the word matched with junk", "the word only")
*/
private static function nextWordMatch($text, $pos, $wordPattern, $reverse = false) {
// we get the substring of text, starting at the current position
if( $reverse ) {
// in this case, we look at everything before $pos; we reverse it so that
// we can run a simple regex on it rather than trying to deal with craziness
// of looking backwards in string
$text = substr($text, 0, $pos-1);
}
else {
// in this case, we look at everything after $pos
$text = substr($text, $pos);
}
// we escape the preg character just in case
// we add in two sets of match parens, one for the word and one for the whole match
// when looking backwards, we need to look from the end rather than the start
$wordPattern = str_replace('@', '\\@', $wordPattern);
$pattern = "(({$wordPattern})".self::NON_WORD_CHARS.")";
if( $reverse ) { $pattern = "@{$pattern}\$@"; }
else { $pattern = "@^{$pattern}@"; }
// perform the match now and figure out what to do with it
preg_match($pattern, $text, $matches);
if( count($matches) < 3 ) { // remember that the first match is the raw text, so we add one
// we didn't find any words, so return false
return false;
}
// strip off the raw text, leaving our two matches
return array_slice($matches, 1);
} |
Here is the default value for $wordPattern and the constant NON_WORD_CHARS used in the example:
private $wordPattern = '\b[\w]+(?:[-\']\w+)*\b';
const NON_WORD_CHARS = '\W*'; |
August 20, 2009 at 9:11 am · Filed under Programming
It takes a bit of surfing, but you can find some really nice graphics on this site at a fraction of the usual cost: http://graphicriver.net/category/graphics/backgrounds/nature
August 20, 2009 at 9:09 am · Filed under Programming
This compilation is awesome, covering things like fluid horizontal and vertical layouts, sprites, and many other excellent techniques for CSS: http://www.smashingmagazine.com/2009/07/20/50-new-css-techniques-for-your-next-web-design/
July 31, 2009 at 8:56 am · Filed under Programming, Tools

Mindomo is a great, free product for mind mapping. You can utilize it online for free to create some great looking and functional maps.
There is also a pro version at the great price of $6/month, which provides a desktop version, allowing you to store the files locally and organize with folders and sharing capabilities.
With the upcoming addition of collaboraiton, and there continual efforts to improve the product, it’s quickly becoming a great brainstorming and outlining tool.
September 8, 2008 at 2:02 pm · Filed under Programming
I wanted to validate my xhtml code for the new site design, and ran into the following fun errors from w3c:
Line 25, Column 15: there is no attribute "src".
Line 26, Column 18: there is no attribute "wmode".
Line 27, Column 17: there is no attribute "type".
Line 28, Column 18: there is no attribute "width".
Line 28, Column 31: there is no attribute "height".
Line 28, Column 38: element "embed" undefined.
Read the rest of this entry »
August 6, 2008 at 3:02 am · Filed under Programming
I wanted to drop all mysql tables from a db that had a certain prefix, such as xx_.
Well this turned out to be an adventure…
The First Attempt
The first solution I found was to use sed/grep sort of logic:
#mysqlshow -u username -p dbname xx\\_% |sed 's/[|+-]//g'|sed 's/[ ]*$/,/'>droptables.sql |
(xx\\_% is how you tell it to show tables starting with xx_)
This produced a semi-useful list. But I had to manually edit out the extra commas and line feeds to get a pure list, then add “DROP TABLE ” to the beginning of the list. Then feed this into mysql as follows:
#mysql -u username -p dbname < droptables.sql |
I wasn’t real happy with that answer, naturally, so I researched more…
A Better Solution
I came across an alternative in this command:
mysqldump -u username -p --add-drop-table --no-data dbname | grep "^DROP.*\`xx_" | mysql -u username -p dbname |
(replace xx_ with the prefix you want to remove, to do all tables, try just “grep ^DROP”
You can test it first by cutting off the last “| mysql…” bit and see the output, which is useful for debugging, before you go blowing away your tables.
December 19, 2007 at 1:48 am · Filed under Programming
I’ve had the pleasure of converting to Outlook for my work…
I can forgive the functionality issues, but the stupid, dumb, Nazi usability constraints that M$ enforces… oh my. Like, for instance, I can’t sort my mail by flags (called Follow Ups, another great choice for obscurity) or by read/unread. The columns are there, but clicking on them produces an alert saying it’s “not allowed”. Why? Because I might hurt myself if I did?
And I can’t subscribe to an ICS calendar in outlook? Are they just not part of the internet or what? It’s not like they don’t understand, because I can “import” one, but then it just becomes part of my calendar and never again gets updated; more Embrace and Exterminate nazi-ism.
*sigh*, with how hard they try to fail, it’s impossible to understand why the world won’t accomodate.
November 22, 2007 at 2:14 am · Filed under Programming
I’m setting up a new hosting server for several clients. I purchased a download of Virtualmin Pro and checked it out as a total management solution. Although it supports Ubuntu Edgy (6.06.1), it does not support 7.1.
So I did what any good programmer would do… I tried it anyways. It failed. So I fixed the bug and tried it again. That one failed. So I went to the forums and got another suggestion and tried that one. It failed, burned down, fell over and sank into the swamp. So Installed 6.06.1 and the FOURTH ONE STAYED.
So don’t try virtualmin with 7.1, unless you’re glutton for punishment too…
November 22, 2007 at 2:08 am · Filed under Programming
Tried to burn an ISO image in Feisty… although the CD-ROM drive is detected and it recognizes when I put a CD in, it won’t run. It shows a message like the following:
Please insert a rewritable or blank CD.
I hit the forums and found this very relevant discussion.[/url] Apparently the forums hit the forums… because their solution pointed to [url=http://www.xcdroast.org]www.xcdroast.org, who had this to say:
Linux Kernel 2.6.8 broke CD-Writing:
I had several reports that the last 2.6.x kernel broke CD-Writing using the ATAPI driver. Don’t update if you want to continue to use X-CD-Roast, or switch back to SCSI-emulation.
Update: When started from a root shell burning still works, but non-root mode is disabled by this kernel.
So the solution is to run the programs as root. I was able to burn my cd using:
root@Tiki:~# cdrecord dev=/dev/cdrw1 driveropts=burnfree -v -data /home/kato/Desktop/tmp/ubuntu-6.06.1-server-i386.iso |
Looks like others used sudo k3d with comparable success.
I didn’t bother trying to figure out which program the “Write to Disk” command traces back to. But it looks like K3d already has a fix. Maybe Ubuntu will provide a fix soon, too…
Next entries »