Archive for Quick Tips

It’s FREE…It’s Easy…It’s EasyGPS! But doesn’t export to KML!

After doing a lot of mapping, say 500 points on my GPS, I needed a way to get them of my GPS. Doing it by hand, are you crazy or just really, really technophobic? So after purchasing a cable off eBay for a few bucks, and not sure if Garmin’s software required a license, I downloaded the free software EasyGPS. Great! I thought, until I noticed that it only exported to GPX format, and I could only use copy and paste internally in the application. Well thank god, they aren’t Microsoft[1][2][3][4][5][6][7][8] and used XML [properly]. So I built a GPX2KML Converter. Questions, comments, suggestions are welcome. Leave them in the comments.

Howto: Uncompress Many Archive Formats in Linux

Can’t remember which arguments you have to use with tar, etc.?

*.tgz use tar -zxvf
*.tar.bz2 use tar -jxvf
*.tar.bzip2 use tar -jxvf
*.zip use unzip
*.tar use tar -xvf
*.bz2 use bunzip2 -d -v
*.gz use gunzip -d -v
*.arj use unarj
*.lha use lha x
*.ace use unace
*.rar use rar x (Note: on on some systems “unrar”, others “unrar x”)
*.cab use cabextract (Note: Some .cab files need unshield (apt-get install unshield))
*.Z use uncompress
*.zoo use zoo -extract
*.chm use chmextract
*.xpi use unzip
*.jar use jar xvf
*.deb use ar xv
*.lzo use lzop -x
*.7z use 7z x

Steven.

Dealing with HTTP Proxies via cURL

Today I needed to use curl, but this time via a http proxy that required authentication:

curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, ‘proxy.mybusiness.null:8080′);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, ‘user:password’);

Easy, huh? Just add those three lines before you call curl_exec().

Steven.

SID Should Really Mean Static Identifier

I am talking about in the context of Win NT. SID is an acronym for Security Identifier. Today I needed to change the name of my main box, simple because the name, well, was crap. So thinking back to the last time I needed to change a SID, I used the newsid.exe tool from [what was then] SysInternals and I remember seeing an option for changing the name of the computer. Now I could of simply inputting my current SID, but no, I was in a rush and chose to generate a random key. Big mistake, all my EFS encrypted files (which were not that important anyway, since I don’t use EFS to secure anything important) were made usless, now I could recover them, but to save me the trouble I obtained the old SID from SAM file (C:\WINDOWS\system32\config\SAM), by viewing the security tab, which then showed me my SID. (You will need to truncate after the 7th dash, eg. S-1-5-21-xxxxxxxxxxx-xxxxxxxxx-xxxxxxxxxx|-xxxx <– .The rest is just to do with the user name. The simple way to change the computer name is Control Panel>System>Computer Name>Change.

So there a lesson learn’t, do not change the SID!

Steven

Styling Readonly and Disabled Inputs in Forms using CSS.

No preamble needed…

Readonly:

*[readonly] { /* CSS for all nodes with readonly attribute */ } input[readonly] { /* CSS for input nodes with readonly attribute */ } textarea[readonly] { /* CSS for textarea nodes with readonly attribute */ } select[readonly] { /* CSS for select nodes with readonly attribute */ }

Disabled:

*[disabled] { /* CSS for all nodes with disabled attribute */ } input[disabled] { /* CSS for input nodes with disabled attribute */ } textarea[disabled] { /* CSS for textarea nodes with disabled attribute */ } select[disabled] { /* CSS for select nodes with disabled attribute */ }

Notes:
Works with:
readonly=”[anything]”
readonly
disabled=”[anything]”
disabled

Steven

Install Gnome on Ubuntu Server.

I made my new box out of bits found in my cupboard after my last cleanup.

All I needed it for was VMware Server.

However there came a time where I needed to hook it up to my projector, and play a video.

So here is the easy way to install the default Ubuntu desktop:

apt-get install ubuntu-desktop

Yep, that’s all!

Steven

P.S:

If you don’t want it to start at boot:

nano /etc/init.d/gdm

and make line 2: exit 0

HTTP Authentication with PHP running as CGI

While developing a project using two factor authentication, with a key fob, I needed to use HTTP Basic Authentication over SSL, to prevent XSS as the project was a web based proxy. Now I had PHP5 running as a module, but PHP4 as CGI. There was the problem HTTP Authentication isn’t available under PHP running as CGI.

First you need to configure mod_rewrite:

.htaccess:

RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

What that will do is feed the base64′d user:pass into an environment variable named HTTP_AUTHORIZATION.

Then just add this above your script:

list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(’:’ , base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));

That splits up the username and password, and makes it look as if you were running PHP as a module.
So for a sample script:

// split the user/pass parts
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(’:', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));

// open a user/pass prompt
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header(’WWW-Authenticate: Basic realm=”My Realm”‘);
header(’HTTP/1.0 401 Unauthorized’);
echo ‘Text to send if user hits Cancel button’;
exit;
} else {
echo ‘Hello, ‘.htmlentities($_SERVER['PHP_AUTH_USER']).’

‘;
echo ‘You entered as your password: ‘.htmlentities($_SERVER['PHP_AUTH_PW']).’

‘;
}
?>

Steven

/bin/rm: Argument list too long.

After forgetting to add “2>&1″ to the end of my cron job that runs every minute I ended up with a lot of “mail” in my Maildir, about 600,000! So I thought that I could do a simple “rm 11*” (Each file started with a 11)

But I ran into a problem: “Argument list too long.”

So after researching this problem I found out why (It has to do with not being able to fit the supplied argument list and environment into the 128K buffer)

I also found a solution: find . -name ‘11*’ | xargs rm

Three minutes later my Maildir was clear!

Regards,

Steven Roddis

Fix: For When Cron Job Leave Mess in the Home Directory

Q: Why do I always get crap in my home directory even though my cron job looks like this:

*/15 * * * * wget http://site.com/cron.php >/dev/null 2>&1

A:

*/15 * * * * wget -O /dev/null http://site.com/cron.php >/dev/null 2>&1
This puts the output (-O) down the [unix] drain.

How to make fonts using Microsoft’s free tool!

The free tool: eudcedit.exe (Just type that in your run box)
can edit fonts, and also make them from scratch.

Recent Comments

  • Josir Gomes: Hi Steve, the meta-package ubuntu-desktop is bloated with huge softwares like OpenOffice, Evolution,...
  • hannah: your that good! ha ha, but seriously.
  • Wiras Adi: Yeah, mathematic operation in text-based CAPTCHA is very easy to break. And I don't think that many sites...
  • Gary: Phew! You saved me lots of hassle :-) The only problem I had was that $_SERVER[’HTTP_AUTHORIZATION ’]...
  • Stephen: To touch on the issue Vinay raised, I had to use the -wholename option on the find command to delete files...

Else wheres