Wednesday, February 28, 2007

Why can't I unlink a read-only file on Windows?

Every now and then when programming on windows, you run into little quirks, that make you go huh? Then you file the quirk away in your mind and move on.

Today's quirk, which I can't believe I didn't realize a long, long, long time ago. unlink on Windows doesn't remove read-only files.

References:
And the Fix:

Obviously we can't modify unlink to behave like Linux. So if unlink fails we need to remove the read-only attribute from the file to properly remove the file. Here is how to remove the read-only attribute from file programmatically in C++ on Windows:

::SetFileAttributes( "path to readonly file", FILE_ATTRIBUTE_NORMAL);

Saturday, February 24, 2007

Client does not support authentication ..

Having some fun with TurboGears. Trying out it's Python 2.3 support. Got the following error, Client does not support authentication protocol requested by server; consider upgrading MySQL client. I should be using at least Python 2.4, but doing work on an older server that only has Python 2.3 support. Not an optimal fix, but I found this one when searching on the topic.

Client does not support authentication

Login to mysql as an administrator, then, paste the following command, editing as necessary, to change the password of the user to the old format.

UPDATE mysql.user
SET password=OLD_PASSWORD('somepassword')
WHERE user='someuser'
AND host='somehost';

After you have set the passwords to the old format, flush the tables.

flush privileges;

Wednesday, February 14, 2007

685 of the best programming links

Some good programming links sorted by category and popularity. Includes: .net,ajax, c, c#, c++, flash, java, javascript, perl, php, python, ruby,sql and xml.



read more | digg story

The 10 Most Spectacularly Awful Gifts You Can Give Your Girlfriend

Here are 10 half-baked gifts you should never, under any circumstances, give your girlfriend on Valentine's Day.Though the Wind-Breaking Teddy Bear seems like it could be lots of fun.



read more | digg story

Monday, February 12, 2007

Creating a Discretionary Access Control List (DACL)

Needed to create a DACL for a Named Pipe today. Here's what I ended up with.

Microsoft Developer Documentation Links:

SECURITY_ATTRIBUTES
Creating a DACL
SDDL

Some code below, (note LocalFree needs to be used on the SECURITY_ATTRIBUTES lpSecurityDescriptor member.)

#include <sddl.h>
BOOL CreateDACL( SECURITY_ATTRIBUTES * pSA ) {
TCHAR * szSD = TEXT("D:") // Discretionary ACL
TEXT("(D;OICI;GA;;;BG)") // Deny access to built-in guests
TEXT("(D;OICI;GA;;;AN)") // Deny access to anonymous logon
TEXT("(A;OICI;GRGWGX;;;AU)") // Allow read/write/execute to authenticated users
TEXT("(A;OICI;GA;;;BA)"); // Allow full control to administrators

if ( NULL == pSA ) { return FALSE; }
return ConvertStringSecurityDescriptorToSecurityDescriptor(
szSD,
SDDL_REVISION_1,
&(pSA->lpSecurityDescriptor),
NULL );
}

Saturday, February 10, 2007

Da Bears

So Da Bears lost the super bowl but it doesn't mean they didn't have a great season. Go Bears!!
Not a Bears fan, how about Ditka? Get a Ditka shirt from www.crystalcosmos.com


Friday, February 09, 2007

One of these days

ESFP - "Entertainer". Radiates attractive warmth and optimism. Smooth, witty, charming, clever. Fun to be with. Very generous. 8.5% of the total population.
Free Jung Personality Test (similar to Myers-Briggs/MBTI)

Absolutely Must Have Software

Thursday, February 08, 2007

MySQL User Stuff

A stupid way to be easily hacked.

mysql> GRANT ALL ON *.* TO 'anybody'@'%' IDENTIFIED BY '123';
Query OK, 0 rows affected (0.14 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.16 sec)

Wednesday, February 07, 2007

Ultimate Guide to Link Baiting

http://tropicalseo.com/2007/andy-hagans-ultimate-guide-to-link-baiting-and-social-media-marketing/

Copyblogger’s title cheat sheet:

  1. Who Else Wants [blank]?
  2. The Secret of [blank]
  3. Here is a Method That is Helping [blank] to [blank]
  4. Little Known Ways to [blank]
  5. Get Rid of [problem] Once and For All
  6. Here’s a Quick Way to [solve a problem]
  7. Now You Can Have [something desirable] [great circumstance]
  8. [Do something] like [world-class example]
  9. Have a [or] Build a [blank] You Can Be Proud Of
  10. What Everybody Ought to Know About [blank]

Want an example? Let’s run through the cheat sheet Andy Hagans style:

  1. Who Else Wants Build Links and Rank High in Google?
  2. The Secret of Link Baiting (It’s all in the title!)
  3. Here is a Method That is Helping Webmasters to Link Bait Better
  4. Little Known Ways to Link Bait Like an SEO Pro
  5. Get Rid of Your Backlink Problem Once and For All
  6. Here’s a Quick Way to Rank Highly in Google by Link Baiting
  7. Now You Can Have that #1 Rank in Google
  8. Learn to Link Bait like Andy Hagans
  9. Build a Backlink Structure You Can Be Proud Of
  10. What Everybody Ought to Know About Link Baiting

Friday, February 02, 2007

Windows Code Signing (Authenticode)

signtool.exe which comes with Windows Visual Studio 2005 has totally different command line options than signcode.exe, the later being part of the original Microsoft Authenticode toolkit and came bundled with Windows Visual Studio 2003.

If your migrating your code signing from VC7 to VC8 you'll need to take your PRIVATEKEYFILE and SPCFILE that you get from Verisign, Thawte, Geotrust, etc. and create a pfx file. This pfx file will be used to sign your files.


Creating a pfx file:

pvk2pfx.exe -pvk PRIVATEKEYFILE -spc SPCFILE -pfx your_new_pfx_filename.pfx

Signing a file:

signtool.exe sign /f PATH_TO_PFX_FILE -t http://timestamp.verisign.com/scripts/timstamp.dll /v $(OutDir)\$(TargetFileName)

See signtool.exe for more options.
See pvk2pfx.exe for more options.

Note to self

Found this snippet of Python code about a dictionary proxy metaclass. No time today, so I'll have to look at it later.

Sometimes when programming in Python I just want to type:
d = {}
d.some_key = 'some data'
instead of:
d['some_key'] = 'some data'
like you can in JavaScript.

Thursday, February 01, 2007

Boost C++ Libraries

The Boost libraries found at http://www.boost.org are wonderful. Been using them for years.

Here are the build instructions:

  1. Download latest boost source
  2. Download bjam.exe
  3. Extract boost source
  4. cd into the newly created directory
  5. bjam "-sTOOLS=TOOLKIT" --prefix=PREFIX install

Replace TOOLKIT with the appropriate toolkit for your compiler. That list can be found here http://www.boost.org/more/getting_started.html#step2. Replace PREFIX with the prefix of choice Windows Default: C:\Boost. Others Default to: /usr/local on Unix. Linux, etc.

So if your using Visual Studio 2005 SP1 and want boost to be installed onto your D drive the command would be:
bjam "-sTOOLS=vc-8_0" --prefix=D:\Boost install
It's that simple. What you get from Boost? OS independent thread code, a good shared pointer implementation, and more.


Free website design tools

Trying to keep a list of free web design stuff.

Website templates:


Royalty free stock images: