Labels

css (1) jQuery (7) linux (38) mac (70) php (29) python (1) svn/git (9) trac (4) ubuntu (1) virtualbox (6) vista (2) windows (14)

Tuesday, 29 December 2009

One thing I love about linux

One thing I love about linux is if you delete a file it doesn't stop working.

For example, I just upgraded nginx from a 0.6 branch to 0.7 on a server, unfortunately it fluffed up a bit, does this mean the server crashes, no! As long as I don't restart the process the server keeps on ticking. Which is great it means I can restore a backup without worrying about the site being down.

Thursday, 24 December 2009

BlackMagicTicketTweaksPlugin Ticket Type Permissions


The BlackMagicTicketTweaksPlugin I adopted at Trac Hacks has been updated to include the option to deny access to ticket types depending on user permissions check it out.

Tuesday, 22 December 2009

Overriding OS X Software Install Requirements

If you ever want to override OS X software install requirements when rummaging through the packages check for an Info.plist file and a *.dist file they will have requirements for example hardware could be

MacBookPro4,1 (which is mine)

Or it might specify a specific version of OS X i.e. 10.5

Anyone that tries this and succeeds in installing the software, it's your own fault if it screws up your machine.

Monday, 21 December 2009

Trac Hacks Private Tickets Plugin - Report Patch

When using the Private Tickets plugin from trac hacks and viewing a report it shows the total number of matches not the number the user can actually see.

I've reported it as a bug and written a patch.


PDO BindParam quirk

Here's a quirk of PDO's bindParam

If you bind a variable index to the statement and change the value of the index it won't update the statement.

Automatic Trac Login

If you own website A and want users of website A to be automatically logged into your Trac website B then use the following concept:

Generate a random float between 0 and 1.

MD5 hash that number

SHA1 that hash.

Set a cookie with the name "trac_auth" and value of the SHA1 you just generated

Open a SQLite connection to the trac database (assuming you're using sqlite if not use mysql/postgresql/whatever you're using).

Run the following SQL queries:

DELETE FROM auth_cookie WHERE name=<Site A's unique identifier>

INSERT INTO auth_cookie (cookie,name,ipnr,time) VALUES (<SHA1>,<Site A's unique identifier>,<user's ip addres>,<current unix timestamp>)

And you're done.

PDO SQLite Permissions


Now you'd expect to require write permissions to the sqlite database you're writing to but you also need write permissions to the folder that contains it, otherwise when you try and write you will get the error

unable to open database file

Sunday, 20 December 2009

OS X Keychain and SSH Keys

If you connect to SSH servers from OSX you can save your password in the keychain, a way of prompting ssh to always ask for the password even if it's in the keychain is to add

IdentitiesOnly yes
To the ~/.ssh/config file

Saturday, 19 December 2009

Linux Memory Swapping


If you want to reduce the amount of swapping (or at least attempt to) your linux machine does use the following command.

sysctl -w vm.swappiness=30

(the lower the number the lass chance of swapping).

The number represents wether linux will swap or attempt to free memory, the lower the number the more chance of freeing memory. Of course if all your RAM is in use this command won't do squat.

To make the change permanent (aka after reboot) do the following

echo "vm.swappiness=30" > /etc/sysctl.d/60-swappiness.conf


To clear your swap you can type


swapoff -a; swapon -a;



Thursday, 17 December 2009

Installing apache modules after compilation


If you've already compiled an apache and want to add another module that is included in the apache source, do the following.

Go to the source you downloaded, enter the modules directory, find the mod_xxxxxx.c file of what you want to build and use the following command

apxs -i -c -n mod_xxxx.so mod_xxxx.c

i.e. to compile mod_auth_digest use

apxs -i -c -n mod_auth_digest.so mod_auth_digest.c


Converting from subversion (svn) to git

Recently I've been migrating from Subversion (SVN) to GIT. Why? Well mainly because GIT doesn't require a server running in the background and you can have local working copies containing a full history.

So here's how to do it.

First go to the directory where you want your local files to be, if this is the same as your svn working copy location then delete all files (including the .svn folder).

Create an authors.txt file which contains the svn usernames you use i.e.

joe = Joe Bloggs <joe@bloggs.com>

You must put the email part in or it won't work.

Next run the following command

git svn clone <repo url> -T trunk -t tags -b branches -A authors.txt .

Poof you're done. That clones a subversion repository setting the trunk to /trunk branches to /branches and tags to /tags

Note: if you are on a case insensitive file system and don't empty the working directory then you may get warnings about overwriting files i.e. CHANGELOG and changelog, this appears to be because svn doesn't care about case but git does (correct me if I'm wrong but this happened to me on Mac OS X with HFS+ Journaled not case sensitive file system).


Thanks to http://pauldowman.com/2008/07/26/how-to-convert-from-subversion-to-git/ for the command

Tuesday, 15 December 2009

Warning: SUID file "" has been modified and will not be repaired.


If when repairing permissions on Mac OS X you get the error Warning: SUID file "<file name>" has been modified and will not be repaired. Then to fix it download the latest Combo Update for your OS (i.e. at time of writing for me it's 10.6.2 http://www.apple.com/downloads/macosx/apple/macosx_updates/macosxv1062updatecombo.html). It should clear up most if not all the permission problems.

Thursday, 10 December 2009

JQuery element positions


Here's something handy, if you want to find the position for an element in relation to the window in JQuery use $("element").offset(); it will return a JSON object like { "left": 100, "top": 20}  which you can access by $("element").offset().left; and $("element").offset().top; handy for positioning tooltips!

Thursday, 26 November 2009

Freetype 2 OS X 10.6 build architecture problems.

If you try and build Freetype 2 on OS X 10.6 for a different architecture you must add your arch flags to the LDFLAGS environment variable as well as the CFLAGS variable.

Discussion of this problem is here

http://www.mail-archive.com/freetype-devel@nongnu.org/msg03550.html

A patch has been submitted and I have tested verifying it works, the maintainers hopefully will commit it to git soon and release it in the next version.

Tuesday, 24 November 2009

Trac Authz

I've recently been playing with trac's authz plugin.
I had a problem where trac was passing an empty resource to the plugin and hence it was finding no permission.
Details can be found here
http://trac.edgewall.org/ticket/8445

Edit... edgewall changed their links it's now http://trac.edgewall.org/ticket/8445 I'll leave the old one just in case they change it back.

Friday, 20 November 2009

PHP-FPM

I've been looking at the different ways to server PHP files.

Way back when I used CPANEL (hey everyone has to start off somewhere and it does help when the likes of awk and grep scare you), I used apache with mod_suphp or mod_php (depending on what was running, wordpress=mod_suphp)

Now I know what I'm doing (or at least I like to think I do!) I go for nginx, proxying php files back to apache with mod_php (and mod_suphp for Wordpress still...slow..poopy..need better solution).

Now another player comes into the fray, Wordpress and similar systems to update themselves require write access to themselves now if you run mod_php then the "nobody" user needs write access...ack not that wonderful having to chmod everything to 0777.

So in comes mod_suphp which elevates the PHP process to run under the script owners user (assuming it's not owned by root, that could be very bad in a web environment).

Unfortunately mod_suphp is slow.....I'd say at least 4 times slower than mod_php (that's not a real benchmark just a guess).

Looking for a replacement here comes PHP-FPM which is basically a FCGI process manager (the FPM part) for PHP. Looking at it it's promising (hopefully it'll be integrated into PHP 6). It means you can eliminate apache all together and run processes as the script owner.

I haven't tested it but when I get some free time I think I'll defiantly crank up a new server and test it.

If anyone is wondering why I didn't mention PHP and mod_fcgi or mod_fgicd then FYI they're pants! Not too stable, happen to crash and chew up memory and a pain to configure.

YASU - Hiding Emulators

When I get some time to relax (not too often) I like to play video games, now I don't like carrying around a bunch of cds/dvds so I rip my images using alcohol soft, lately I've had a problem with Dawn of War Soulstorm, it kept detecting the emulator.

The solution, download this tiny little program http://www.free-downloads.net/programs/Yasu Yasu. Click cloak and you're done! It loads up as if the disk was in.

Thursday, 19 November 2009

Git

No I'm not insulting anyone! I've just been setting up a versioning system for a new project and had a choice, CVS, SVN or GIT.

Now why use CVS when you can use SVN so it was between SVN and GIT. I knew SVN so started on that...unfortunately getting smart svn to play nice with SVN+SSH isn't that easy I keep getting a handshake failed error (currently bugging the support team on this one) since I wanted to get cracking soon I tried GIT, damn git is bloody easy to use.

Cool things I like about git

1) Local repository! You don't have to be online to commit!
2) PUSH, you can push data to the master repository whenever you want.
3) No server, yes you don't need a server daemon like you do for SVN, you can do it all through SSH

I'm sure I'll find more, I'm currently using smartgit http://www.syntevo.com/smartgit/index.html same people that do smartsvn since I do like their guis.

Monday, 16 November 2009

PHP conditional evaluation


Something I just remembered that will be useful to any aspiring PHP programmers, PHP uses "Minimal Evaluation", which means when checking an if statement (or some other conditional) it will stop once something satisfies the condition, i.e. if we have

if(isset($a) and $b==2)

if $a isn't set then the $b==2 won't be evaluated.

This is handy to suppress undefined index variables for example say we have

if($arr["index"]==1)

where $arr is an array but there is no index "index" in it, this will throw an E_NOTICE error to suppress these we can change it to

if(isset($arr["index"]) and $arr["index"]==1)

if the index doesn't exist the second part won't execute and no error will be thrown.

Sunday, 15 November 2009

Spamhaus checker

Recently I have been plagued by problems with rackspace and spamhaus (read previous posts for more info) so this afternoon I decided to create a PHP script that checks if the server is blacklisted on any of the lists, and here it is for all to use.



/*
spamhaus.org checking script


This script checks the server's ip to see if it is listed on spamhaus.org


I suggest you run this script once a day at most.


If it finds a record it will create a message and e-mail you the message and add an entry to the syslog (this will probably fail on windows but you never know I've not tested it)


You may add an ip address after the script name to test a specific ip


i.e. php filename.php 192.168.1.1


Licence


The MIT License
Copyright (c) 2009 Rowan Wookey obsidianproject.co.uk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/


/* add your email here if left empty no warning mail will be sent */
$reportTo="";
/* set the following to true to write to the syslog, this is probably a good idea since if the server IP is blacklisted it might not be able to email you a warning */
$syslog=false;
/* set the following to true to print to screen */
$printToScreen=false;

/* add your ip below*/
$ip=isset($argv[1]) ? $argv[1] : "yourserveripgoeshere";

//return codes used by spamhaus.org
$returnCodes=array(
"127.0.0.2"=>"SBL",
"127.0.0.3"=>"SBL",
"127.0.0.4"=>"XBL",
"127.0.0.5"=>"XBL",
"127.0.0.6"=>"XBL",
"127.0.0.7"=>"XBL",
"127.0.0.8"=>"Reserved",
"127.0.0.9"=>"Reserved",
"127.0.0.10"=>"PBL ISP",
"127.0.0.11"=>"PBL SH",
);



//take the server IP, split it into an array, reverse the array then glue it back together, append the spamhaus dns zone to get the host to check
$host=implode(".",array_reverse(explode(".",$ip))).".zen.spamhaus.org";
//get records as far as I know spamhaus only uses A and TXT records
$records=dns_get_record($host,DNS_A|DNS_TXT);
//no records found ok to kill script
if(empty($records)) exit(0);




//records found
$message=date("r").PHP_EOL;
$message.="Server IP found in spamhaus.org database".PHP_EOL;
foreach($records as $r)
{
//if IP is set add return code
if(isset($r["ip"])) $message.="Return code: ".$r["ip"].":".$returnCodes[$r["ip"]].PHP_EOL;
//if txt record add txt message
if(isset($r["txt"])) $message.="TXT record ".$r["txt"].PHP_EOL;
}
//if reportTo isn't empty send warning email
if(!empty($reportTo))
{
mail($reportTo,"Spamhaus.org listing",$message);
}


Oh and blogger so just filled this post with junk (lots of span tags setting the font to courier)

//write to syslog
if($syslog)
{
//open syslog witdh spamhausCheck ident, if fails prints to console, logged as mail at alert level (pretty critical in my opinion)
openlog("spamhausCheck", LOG_CONS | LOG_PERROR, LOG_MAIL);
syslog(LOG_ALERT,$message);
closelog();
}


//print to screen
if($printToScreen)
{
echo $message;
}


Wednesday, 4 November 2009

Browser compatibility

Here's a tip for any budding web designers out there when dealing with
browser compatibility.

Don't expect all browsers to render pages the same, they won't, and
they shouldn't!

Why? Well think of it this way, you have a Standard definition TV and
an HD TV, you can't expect to see HD programs on a SD TV you need the
latest HD technology for that, the same goes for web browsers, you
can't expect Internet Explorer 6 to render like Internet Explorer 7 or
8.

You can expect IE8, Opera, Safari 4, Google Chrome, Sea Monkey 2 and
Firefox 3 to render in a pretty similar fashion.

IE 7 and 8 as well as Safari 3, Sea Monkey 1 and Firefox 1/2 will
render differently (especially with regards to CSS3 which IE8 doesn't
handle too well either).

Your users won't notice if it doesn't quite look pixel perfect the
same in each browser, they won't come along and open your site in 4 or
5 browsers to make sure it looks the same.

Tuesday, 3 November 2009

Create an Awesome Command Line Calculator [Terminal Tip]


This is an article from lifehacker. Thought it was cool.




When you spend as much time at the terminal as I do, having a calculator at your fingertips can be a really useful feature, and the Command-Line Fu web site tells us how to create one easily.
To create the calculator, you can just enter this function on the command line to test out how it works, or add it into our ~/.bashrc file to make sure that it's always available after restarting the terminal.
calc(){ awk "BEGIN{ print $* }" ;}
To use it, you can simply type calc followed by the calculation you want to solve, making sure to use quotes around the calculation if there are spaces or special characters the shell can't handle. For instance, if you entered calc 3*99/7+18 at the prompt, you'd get 60.4286 as the answer. For more complex calculations, you can use parenthesis, but make sure to put quotes around it, like this:
calc "((3+(2^3)) * 34^2 / 9)-75.89"
It's an extremely useful tip for those of us that live at the terminal. It should work on any OS running the bash shell, including Linux, Mac OS X, or even Windows with Cygwininstalled.
Read more…


Saturday, 31 October 2009

Ubuntu 9.10

Anyone thinking of upgrading to ubuntu 9.10 should check this out from the release notes

http://www.ubuntu.com/getubuntu/releasenotes/910

Possible corruption of large files with ext4 filesystem

There have been some reports of data corruption with fresh (not upgraded) ext4 file systems using the Ubuntu 9.10 kernel when writing to large files (over 512MB). The issue is under investigation, and if confirmed will be resolved in a post-release update. Users who routinely manipulate large files may want to consider using ext3 file systems until this issue is resolved. (453579)


I think I'll stick with jaunty for now, the only reason I'd have to switch to karmic would be the performance boost from ext4 (which is best gained by creating a new ext4 partition not upgrading).

Sunday, 25 October 2009

Connecting to me.com idisk on ubuntu

This is dead easy (note it uses the command line but it's still easy)

Run the following commands in a terminal

apt-get install davfs2


mkdir -p /path/to/where/you/want/your/idisk/to/be/mounted


mount -t davfs https://idisk.me.com/<your me.com userid> /path/to/where/you/want/your/idisk/to/be/mounted

It will then ask you for your username and password. Then you can access it from /path/to/where/you/want/your/idisk/to/be/mounted

Finding the total size of a directory on Linux

du -c -h /root | grep 'total'

That's it! (That returns the size of the root directory by the way
change /root to whatever you need i.e /home)

CSS3

I'm currently designing a site which has an intended audience that uses up to date technology (yay no IE 6), which means I get to freely dabble in CSS3.

A few useful things I'm using are css nth-child selectors, i.e.

tr:nth-child(odd)
{
   background-color:#DDDDDD;
}
tr:nth-child(even)
{
   background-color:#FFFFFF;
}

This makes alternating table rows switch from grey to white, brilliant!

rgba colours, (rgb with alpha transparency) 


rgba(150,150,150,0.25);

This makes a grey background at 1/4 opacity which doesn't affect child elements unlike

opacity:0.25;

Another useful one is 

.class:first-line
{
font-varient:small-caps;
}

which makes the first line of the text small caps!

HTML Tables and Positioning

Interesting thing on css positioning with tables

The effect of 'position:relative' on table-row-group, table-header-
group, table-footer-group, table-row, table-column-group, table-
column, table-cell, and table-caption elements is undefined.


http://www.w3.org/TR/CSS21/visuren.html#propdef-position

In other words don't use position:relative on table cells, which also
means you can't then align something inside a table cell relative to
the cell.

Spamhaus blacklist

Well today was an eventful day.

I manage a server which is hosted with Rackspace. I get a complaint that addresses @hotmail.com aren't receiving email from the server so I go to check it out...in the mail logs we have...

"relay=mx3.hotmail.com[65.55.92.152]:25, delay=0.16, delays=0.08/0.01/0.06/0.01, dsn=5.0.0, status=bounced (host mx3.hotmail.com[65.55.92.152] said: 550 DY-001 Mail rejected by Windows Live Hotmail for policy reasons. We generally do not accept email from dynamic IP's as they are not typically used to deliver unauthenticated SMTP e-mail to an Internet mail server. http://www.spamhaus.org maintains lists of dynamic and residential IP addresses. If you are not an email/network admin please contact your E-mail/Internet Service Provider for help. Email/network admins, please visit http://postmaster.live.com for email delivery information and support (in reply to MAIL FROM command))" I checked spamhaus.org and it says Ref: PBL290440 xxx.xxx.xxx.xxx/27 is listed on the Policy Block List (PBL) Outbound Email Policy of Rackspace US, Inc. for this IP range: It is the policy of rackspace that unauthenticated email sent from this IP address should be sent out only via the designated outbound mail server allocated to rackspace customers. To find the hostname of the correct mail server to use, customers should consult the original signup documentation or contact rackspace Technical Support.

Big schpeel...which basically means the ip range (30 addresses) which the server I support happens to be in are fluffed.

So I go and bug rackspace tech support...now the fun begins. They check things out, turns out that one or more servers in the range (not the one I manage) has been spamming so they got added to the black list, and it will take up to a week to get the address off the list...oh yay.

So I ask for an extra IP outside the block to send mail via...DENIED! Why? Because they can only supply IPs for SSL certs, oh come on I only need it for a week.

They suggest I clone the server to another box and use that new IP..yeah right that means downtime while the new server is built and while DNS propagates which is around 2 days.

So what do I end up doing? Building a new server and have postfix relay through that...which is quite easy in the /etc/postfix/main.cf
file add the following
relayhost = xxx.xxx.xxx.xxx (replacing xxx.xxx.xxx.xxx with the IP of the new server)
Then on the new server set
mynetworks = 127.0.0.0/8, yyy.yyy.yyy.yyy (replacing yyy.yyy.yyy.yyy with the IP of the old server)
Restart both postfix services and you're done.

Monday, 19 October 2009

PHP null and MySQL timestamps

Something odd just occurred. I tried inserting a php null value into a
mysql timestamp and it had the same effect as inserting NOW(). Not
sure if this is a general rule or if it's just because of the
framework im using (yii) very odd.

Sunday, 18 October 2009

Windows IIS PHP MySQL MDM

I've just finished an interesting job, installing and configuring PHP,
MySQL and MySQL Data Manager on Windows Server 2003 x64 with IIS 6.

Nothing too taxing, just something I don't get to play with very
often, most clients I work with use Linux (since the only sane reason
I can think to use a windows server is for ASP and I don't use ASP).

Saturday, 17 October 2009

Pure-FTPD (?@?) [ERROR] Sorry, invalid address given

This is a weird error. After rebooting a server the FTP server was
throwing this.

It turns out Pure FTPD resolves hostnames for client IPs since 99% of
clients won't have anything to resolve to it throws this error.

How to fix? add -H to the command line or if you're using debian/
ubuntu use the following command
echo "yes" > /etc/pure-ftpd/conf/DontResolve

Sunday, 11 October 2009

Vista SP2 winsxs disk space

A few months ago I made a post about Vista SP1 and the winsxs disk space here http://blog.obsidianproject.co.uk/2009/04/vista-windows-winsxs-folder.html

Now for SP2 open a administrator command window and type compcln it does the same thing just for both packs.

Logwatch Date::Manip error

If you get this error when running logwatch


ERROR: Date::Manip unable to determine TimeZone.

Execute the following command in a shell prompt:
perldoc Date::Manip
The section titled TIMEZONES describes valid TimeZones
and where they can be defined.

Do the following

export TZ='+0000'

before hand (replacing +0000 with your timezone offset)

Tuesday, 6 October 2009

Importing OPML RSS feeds into Mail.app

I wanted to move from google reader to mail.app, and exported my feeds to OPML format, went to import into mail...shock horror it doesn't accept OPML but here is a good way of getting round it


  1. Export an OPML file from your favorite feed reader (Google Reader for me)
  2. Run the following command in Terminal: perl -lne 'print $1 if /"(http.*?)"/' google-reader-subscriptions.xml | pbcopy
  3. Open Mail
  4. Go to File » Add RSS Feeds...
  5. Choose the Specify a custom feed URL radio button
  6. Click in the entry box and hit Command-V to paste the feed URLs
  7. Click the Add button
It works in os x 10.6 too.

Sunday, 4 October 2009

Adobe Illustrator default unit measurements

To change the default unit of measurements in adobe illustrator from
say px (pixels) to say mm (millimetres) go to preferences> units and
display performance.

Saturday, 3 October 2009

Nginx catch all host

Here is a modified version of the nginx catch all host supplied at the
nginx wiki http://wiki.nginx.org/NginxVirtualHostExample

#catch all host
server {
listen 80 default;
server_name _;
access_log logs/default.access.log main;
server_name_in_redirect off;
return 444;
}

This one like the original will respond for any host that isn't
already specified by a server_name i.e. if someone puts the ip of the
server into the browser.

To save you having to actually show them something return 444 which
tells nginx to drop the connection as far as anyone will know nothing
is there, this is also handy if you monitor domains using http and one
of them is missing from nginx's configuration since your monitoring
tool will scream saying the site is down and you can go fix it.

Nginx IP Blocking

If you want to block an IP using Nginx it's dead easy

location /
{
deny from 1.2.3.4;
allow from 5.6.7.8;
}

Friday, 2 October 2009

JQuery reloading the DOM

Sometimes if you add an element to the DOM using JQuery you will want
to use JQuery on the new element, there is no inbuilt function that
reloads the entire DOM but you can use the live function to simulate
it see http://docs.jquery.com/Events/live

suPHP group writable - finding files

If you run suphp it doesn't like files/folders that a group writable
to find these files use the following command

find <path> /020 -exec ls -lhd '{}' \;

This will list all files/directories that are group writable

Thursday, 1 October 2009

PHP CGI and Apache Module

If you want to have both you need to compile php twice, why? Well
because you can only compile one sapi+cli at a time see http://bugs.php.net/bug.php?id=30682

SuPHP conf file

Just a note when compiling suphp with a custom prefix that the
suphp.conf needs to be in $prefix/etc/suphp.conf

Gmail/Google Apps Mail filters, not from

If you use gmail/google apps and want to filter emails NOT from
someone put a - before the email address in the from box

i.e. if you wanted to filter emails not from example@domain.com you
would type

-example@domain.com

Finding broken symlinks

I've just been moving a wordpress installation from one server to
another and a broken symlink was causing it to not work, to find all
broken symlinks use the following.


find . -type l ! -exec test -e '{}' \; -exec ls -l '{}' \;

This is what it does

find .

finds everything in and below the current directory

-type l

finds symlinks

! -exec test -e '{}' \;

tests if the file (which find passes to '{}') exists if not it
continues with the next step

-exec ls -l '{}' \;

executes ls showing the long information which will look something
like this

lrwxrwxrwx 1 <user> <group> 76 Sep 30 03:54 <symlink path> ->
<original path>

Nginx and Drupal clean urls

Here's a quick rewrite rule to allow nginx to use drupals clean urls


if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?q=$1 last;
}

Wednesday, 30 September 2009

Finding directories over 10M on linux

here is a useful command to find directories over 10M on linux

du -h path | grep '.*[0-9][0-9]M'

replacing path with were you want to search i.e /root

OS X Increasing SHM

I've just been compiling postgresql on OSX 10.6 and when adding the data to the database just after installation it was bringing up a FATAL error saying not enough shm.

This never happened to me on 10.5 but to correct it do the following, create a file

/etc/sysctl.conf

and put the following in it

kern.sysv.shmmax=16777216
kern.sysv.shmmin=1
kern.sysv.shmmni=128
kern.sysv.shmseg=32
kern.sysv.shmall=4096

That will increase the memory limit by 4 times. It fixed the problem for me

Monday, 28 September 2009

phpmyadmin blank page

Recently I installed a new installation of phpmyadmin, for some strange reason when a config.inc.php file was created it would come up with a blank page.

Now I disable eval on my systems by default since I don't use it. Oddly enough phpmyadmin uses eval to parse the config.inc.php which was causing the problem. Damn...

Saturday, 26 September 2009

PHP PDO and localhost

Recently I created a database connection using PDO with the host of localhost, the dsn looks something like this

mysql:host=localhost;dbname=test

This threw this error

PDO::__construct() [pdo.--construct]: [2002] Invalid argument (trying to connect via unix://)
How odd, the solution change the dsn to mysql:host=127.0.0.1;dbname=test strange but it works.

Monday, 21 September 2009

Snow Leopard PHP

Something I found noteworthy about Mac OSX 10.6 is that the PHP
version installed by default is 5.3

/usr/bin/php --version
PHP 5.3.0 (cli) (built: Jul 19 2009 00:34:29)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

Sunday, 20 September 2009

pecl/pear.php.net is using a unsupported protocal - This should never happen Error

I was just attempting to install APC and got this error...how to fix
delete the lib/php/.channels directory in your php installation then run
pear channel-update pear.php.net

and
pear channel-update pecl.php.net

Chroot SFTP

I found this article about using open ssh 5 to chroot users http://adamsworld.name/chrootjailv5.php
handy!

MySQL Query Cache making things slow!

I've just been playing with some queries, I had a particular query
which was taking around 4-6 seconds to run which is way too long, so I
decided to play with the cache settings, the cache wasn't really
needed since the tables get updated frequently, for some odd reason
which I'm not sure what it is when I disabled the query cache (I set
it to on demand only) it sped the query up to only taking 0.1
seconds...weird.

Friday, 11 September 2009

Mac Time Machine and IMAP Mail

Since I've started using Apple Mail I've just done by first backup
using time machine, out of curiosity I wondered if it was backing up
my mail IMAP folders, I checked the backup and yes it did! Now to me
this seems silly since IMAP mail is kept on the server and I have
around 2.5 gigs of IMAP mail. So to time machine preferences I go to
stop it backing those up!

Thursday, 10 September 2009

PHP unset() and (unset)

When unsetting a variable in PHP if you use unset() then try and call the variable you will get an E_NOTICE error saying the variable is undefined if you use (unset) you won't. Both set the variable to NULL.

Tuesday, 8 September 2009

Mail 4.0 Multiple names on one account

As per the previous post you know I have an IMAP account with multiple emails, what I also like is to have multiple names for these, i.e Support, Information etc etc, this is achievable in mail.app but it's a little complicated here is what you need to do.

  1. Quit Mail
  2. In finder navigate to /users//Library/Preferences
  3. Duplicate the file com.apple.mail.plist (this creates a backup)
  4. Open the file com.apple.plist it should open in property list editor
  5. Scroll down to MailAccounts and click the arrow (looks like this >)
  6. You will see a list of Item 0, Item 1 etc etc open each one and find the one that AccountName is the account you want to have multiple names
  7. Click the Item and click Add Child name it EmailAliases and make it an Array
  8. Click the EmailAliases and click Add Child, make it a Dictionary, it will be named Item 0
  9. Click the new Item 0 and click Add Child, set it to a string name it "name" (without "") set the value to whatever name you want to set it to i.e. "Support" (without "")
  10. Click the new Item 0 again and click Add Child again, set it to a string, name it "alias" (without ""), set the value to the email address to send from.
  11. Save the file and open Mail, you now can now send from the new name
  12. You may want to remove the email address you just added from the comma separated list in the account preferences in mail so you don't get a duplicate email address in the drop down list you can send from.

Mail 4.0 Multiple email address on one account

If like me you have multiple email addresses linked to a single IMAP account you may find this handy.

  1. In Mail.app click Mail > preferences > accounts
  2. Choose the account you wish to have multiple addresses
  3. Add a comma separated list of address i.e. bob@example.com, jon@example.com, fred@example.com
  4. Close the preferences and click save, you can now send from multiple addresses for one account

HTML Signatures in Mail 4.0

Since upgrading to Snow Leopard I thought I'd give Apple Mail aka Mail.app 4.0 another try. Normally I use Mozilla Thunderbird.

Firstly Mail doesn't allow you to create HTML signatures, but that doesn't mean it doesn't support them, here is how to create one.

  1. First open mail, then click Mail > preferences > signatures
  2. Click the + symbol to create a new signature then save it and quit mail.
  3. Create the html signature in whatever editor you like, then open it in safari
  4. Click file > save as in Safari
  5. Navigate to /users//Library/Mail/Signatures
  6. You will see a file with a long string of characters and numbers this is the signature you just created, click the file and press save this will overwrite this file
  7. Open mail, and you have your HTML Signature.

Sunday, 6 September 2009

iPhone/iPod touch notes syncing with mobileme

I am currently have a trial for apples MobileMe. Since I have an iPod touch and Mac it's handy to write a shopping list on the mac and then transfer it to my iPod.

Now since notes and MobileMe don't sync brilliantly (this is because notes are actually emails, one of apples weirder ideas) this is what I do.

First in mail.app go to preferences, composition and set the notes to be stored on mobileme, next create a rule saying if a message is a note move it to mobile me.

This will create a note folder on your mobile me web mail, when synced OTA this will also appear in your mail on your iPod. If you create a new note on your iPod using the notes app it will sync to the On My Mac folder when you connect it via iTunes, that's what the rule was for, highlight all notes and apply rules and it'll go to the correct place!

Monday, 31 August 2009

OS X 10.6 - Snow Leopard

I've just updated from OS X 10.5 Leopard to 10.6 Snow Leopard, the installation took around 45 minutes, and immediately after installation my hard drive was 7 GB smaller which is a blessing.

I immediately decided to launch all my applications, now on leopard, this would lock up the laptop after I launched all the applications in the adobe master collection CS4 (photoshop, dreamweaver, illustrator, flash etc...). Snow leopard managed to survive up to Opera (I was opening alphabetically), that's around 80 (yes 80!) applications open at once! So that impressed me.

Out of my 200ish applications the following have compatibility problems

  1. Cyberduck - needs updating to the latest beta to run, the stable version doesn't open
  2. Coolris - not available for snow leopard yet
  3. Techtool delux - informs you it's not tested with snow leopard hopefully a new version will be out soon
  4. iStat menus - not compatible, new version should be out soon.
One last thing of note, snow leopard only contains java 6 (both 32 and 64 bit), leopard contains java 5 as well, if you're a java developer you may want to take note of that (I use java 5 for my degree work).

All in all it's pretty, faster, but nothing too flashy, for 99 NZD for a family pack, I'd say it's worth it.

Tuesday, 25 August 2009

PHP Variable Variables and superglobals

While writing for a PHP project I needed to access one of the super globals i.e. $_POST, $_GET etc without knowing which so I planned to use a variable variable i.e

$var="_POST";
$var2=$$var;

Unfortunately this was inside a class function and low and behold it doesn't work! Unfortunately this is documented http://us2.php.net/manual/en/language.variables.variable.php so I can't report it as a bug. Luckily you can do this:

$var="_POST";
$GLOBALS[$var]

Monday, 24 August 2009

Killing processes inside netbeans

For my degree one of the questions was to create a basic ftp server in Java. Since the server is designed to always run when compiling a new version I have to kill the old process, now either I can close/reopen netbeans but that takes too long, instead if you go to window > runtime you can terminate the processes there.

Sunday, 23 August 2009

Apple Mobile Me email and Thunderbird SMTP connection fails

I've been looking for a new email address that's not one of the free ones i.e. gmail, hotmail etc since I need some sort of SLA.

So since I'm a mac user, me.com came to mind.

I set up the free trial etc etc, then went to Mozilla Thunderbird my email client of choice, and set up my account, DARN I can't send

Send Message Error

Sending of message failed.
he message could not be sent because connecting to the SMTP server smtp.me.com failed. The server may be unavailable or is refusing SMTP connections. Please verify that your SMTP server setting is correct and try again or else contact your network administrator.

How how annoying. I piddle around with the settings can't get it right.

So I go to the mobile me website, it says set up with SSL port 587, ok try that, still doesn't work. So I notice this little button on the mobile me site saying chat with support.

Cutting a long story short, I explain my problem the tech support says they don't support 3rd party clients, I get annoyed and say they must support since they have documentation, after diagnostics he says try TLS on 587, low and behold it works and I feel stupid for not trying it in the first place.

Thank You Jesus! (The rep's name was Jesus, never thought I'd say that in my life)

Friday, 21 August 2009

Using grep to not show lines

If you want to view a file without certain lines in it, i.e. an error log you can pipe it through grep and use the -v option, i.e.

cat /path/to/file | grep -v 'no such file or directory'

that will omit any lines containing no such file or directory.

Saturday, 8 August 2009

Lynx and Mac OS X

Since our net now has a bandwidth cap (20GB/month) and we hit this it's now the speed of dialup..ugh! So since most of the time I don't need fancy graphical net so I decided to check out installing Lynx on OS X.


Now if you want lynx with ssl the ssl libraries with mac os x don't seem to agree with lynx, so download openssl, compile and install it to a temporary directory then configure linx with ./configure --with-ssl=/path-to-where-you-install-openssl

And there you go! You have lynx

Friday, 7 August 2009

Growl Notify NSPortTimeoutException

Recently I've been experimenting with growlnotify to send notifications across my network and had the following error

growlnotify[5502:10b] Exception: NSPortTimeoutException
Segmentation fault

To resolve it simply stop and restart growlnotify, note the receiving computer has to have listen for incoming connections enabled under the "network" tab of the growl preference panel.

Sunday, 2 August 2009

CSS Attribute selectors for label "for" attribute and IE7

I just discovered something really annoying. When using the label[for="something"] CSS attribute selector in IE7 it doesn't work! You have to use the DOM name htmlFor so it would be label[htmlFor="something"].

Thank god for IE conditional statements adding another stylesheet with the CSS required for IE7 fixes it.

Kudos to Microsoft for IE8, it doesn't have the problem and it's developer tools make life easier, I just wish it had an IE6 rendering mode as well as IE7.

Saturday, 1 August 2009

Winload.exe error vmware fusion boot camp

Recently after re-installing windows on my mac's bootcamp partition VMWare fusion started reporting winload.exe was missing.

To fix this, close vmware fusion, delete the
/Users/(your user)/Library/Application Support/VMWare Fusion/Virtual Machines/Boot Camp
folder, then restart vmware fusion and launch the bootcamp machine.

Tuesday, 28 July 2009

Windows Update Error 80073715

I recently reformatted my windows partition on my mac because of a DHCP error which wouldn't go away using MS support site.

Now when updating for 2 updates I got the error 80073715, the solution bizzarely enough is to uninstall the last update you install (regardless of what the last update was) bizzare I know but it works.

Thursday, 23 July 2009

iPod touch / iPhone mail reply-to

I use gmail to pool my email addresses into one account, now I have an iPod touch and wanted to send from one address that isn't the same as the login address to do this instead of choosing gmail when adding the account choose other and set the "Address" field to the address you want to send from and all the other details the same as your main address then it will be sent from the address you specified in the "Address" field

Monday, 20 July 2009

Jquery click() event and submitting a form with radio buttons

According to the JQuery documentation a click() is a mouse press down then up, then the click action by this logic the click should occur after changes to whatever has been clicked happen.

This is not the case (or at least not in firefox 3 I've not checked other browsers).

I had a form which contained a set of radio buttons and images, the images were surrounded by the

Saturday, 18 July 2009

EMAMP

PHP 5.1.20 for EMAMP has been released and can be downloaded via the normal EMAMP web installation, or you can download it from sourceforge https://sourceforge.net/projects/emamp/files/

Wednesday, 8 July 2009

JQuery floating table header

I've created a page for a client that lists a number of products in a table, since the table can sometimes be quite large the header falls off the top of the screen, so I've had a play with some JQuery and CSS and come up with a solution.

As the user scrolls down the page and hovers over a tag the header appears under the if the user hovers for more than a second, this is so it doesn't appear while scrolling.

CSS


#product-admin-floating-header
{
display:none;
}


JQuery


$("tr").hover(
function()
{//in
if($(this).attr("id")!="product-admin-floating-header" && $("#product-admin-floating-header").length==0 && $(this).attr("id")!="product-admin-table-header")
{
//$(this).animate({opacity: 1.0},500,"swing",
// function()
// {
$(this).after(""+$("#product-admin-table-header").html()+"");
$("#product-admin-floating-header").animate({opacity: 1},1000,"swing", function()
{
$("#product-admin-floating-header").fadeIn("slow");
});
// }
// );
}
},
function()
{//out
if($(this).attr("id")!="product-admin-floating-header")
{
$("#product-admin-floating-header").remove();
}
}
);

:hover pseudo class and spans

I was just working on a page that when hovering over an element it would change the background colour, the element in question was a span tag. The CSS I was using was

editable-element:hover
{
background-color:#EEEEEE;
border:1px solid black;
cursor:pointer;
}

which works fine and dandy in Safari 4...I noticed it did diddly squat in Firefox 3.5, the solution change it to

span.editable-element:hover
{
background-color:#EEEEEE;
border:1px solid black;
cursor:pointer;
}
It seems FF needs the element type when using :hover and alike.

Sunday, 5 July 2009

JQuery offline manual

Recently I was working on a script using JQuery while offline and wanted to reference the ajax apis...damn! I didn't have the offline manual.

So next time I was online I did a quick google and found the following.

http://charupload.wordpress.com/2007/12/07/jquery-documentation-chm/

But ahhh macs can't read chm files natively which is where http://chmox.sourceforge.net/ comes in perfect! I can now view the JQuery manual offline.

On another note, the new sourceforge layout looks way better and is so much easier to navigate.

Sunday, 14 June 2009

Komodo Edit Portable 5.1.3a Released

Komodo Edit Portable 5.1.3a builds on the 5.1.3 release adding profile corruption checking. If your computer crashes while running Komodo Edit Portable the next time you run Komodo Edit Portable you will be notified of the corruption and instructed on how to fix it, this will prevent you losing your settings. You may download it at http://www.komodoeditportable.com

Sunday, 7 June 2009

Strange Mac Book Pro Phenomonom

Something very strange happened last night while I was using my Mac Book Pro (MBP).

I was watching a film on front row, once it ended I heard a background noise as if the film was still playing. I close all my apps down but it was still there. I concentrated on the sound and realized it sounded like 2 or 3 distinct radio/tv broadcasts, some in English, some in other languages, I removed all network cables and other connections to make sure it was nothing coming down the Internet, I moved to another part of the house and it went away, I move back and it came back.

I can only conclude that because the MBP is made out of aluminum some how it was acting as an aerial for radio/tv broadcasts and piping the sound through my headphones.

I emailed apple about this lets see if they respond!

Wednesday, 3 June 2009

EMAMP Installation Guide Released

EMAMP now has an installation guide, you can view it at http://www.obsidianproject.co.uk/emamp/help here you have a step by step guide on how to download, install and configure EMAMP the guide includes screen shots.

Sunday, 31 May 2009

mod_rewrite and directories

I wanted to redirect a file in a webspace of /directory/index.html to /directory/index.php so mod_rewrite for apache comes to mind!

I've never actually rewritten a directory path before so I thought it would be

RewriteRule ^/directory/index\.html$ /directory/index.php

After trying it nothing happened.... :( oddly enough you just need to chop the first / off so the rule would be

RewriteRule ^directory/index\.html$ directory/index.php

Odd.

Sunday, 26 April 2009

Vista Windows winsxs folder

Recently while preparing my desktop for a full OS backup I noticed the folder c:\windows\winsxs was 14.6GB (note I'm on vista64 bit this will become relevant later).

After some research I found this folder keeps copies of old .dll files for programs. Since I'm on x64 this means 32 bit and 64 bit dlls...that's a lot!

Now a way to shrink this is to run a file called VSP1CLN.exe (assuming you have vista service pack 1 installed). This removes the ability to uninstall Vista Service Pack 1 and cleans up some old files, it removed 2.6GB of files..not bad. Warning running this file will disable your ability to remove vista service pack one the only way to remove it will be to reinstall windows make sure you know what you're doin!

Wednesday, 8 April 2009

PHP Compiling Oddness

I've just been compiling Easy Mac Apache MySQL and PHP and when compiling the php for the system package came across a very very odd error, when running php on a mac without xcode and not compiling with bz2 it would bring up an error unable to find libltdl.3.dylib which is a libtool dynamic library, now what's really odd is when I compile --with-bz2 the problem goes away, why I have no idea!

Friday, 3 April 2009

PHP Flush

I was writing a script that needed to show download progress so flushing content to the users browser was required...oddly enough flush() alone didn't work. I found this is a solution


ob_end_flush();
echo "Downloading...";
/* download code goes here */
sleep(3) //simulate a download
flush();
echo "Download complete";


Why does this work? Dunno but for some reason ob_end_flush(); before a flush made it work.

Wednesday, 18 March 2009

Offline php manual

When away from home sometimes I want to access the php manual but don't have any net or at least not a decent connection, so here is how to download a mirror of the php site to your mac.

Assuming you're running an apache web server set up to handle php requests use the following shell script.

#!/bin/bash
rsync -avzC --timeout=600 --delete --delete-after --include='manual/en/' --include='manual/en/**' --exclude='manual/**' --exclude='distributions/**' --exclude='extra/**' rsync.php.net::phpweb PATHTODOWNLOADTO

change PATHTODOWNLOADTO to where you want the manual to go. (Note don't run this more than say once a day or you may get ipbanned by php.net)

Friday, 13 March 2009

Oh god not again...

ok so I'm at Manchester airport and there's two rabbis on the plane....why is it everywhere I go rabbis follow. So....odd.
Sent from my BlackBerry® wireless device

Tuesday, 10 March 2009

core file debugging

Recently I recompiled apache/php with more features for future "just in case I need it" use.

One of these was suphp and eaccelerator. Now eaccelerator only works with dso or fcgi configurations of apache...bummer I'm using dso and suphp so suphp is crashing eaccelerator and creating core dumps all over the sodding place..carp...

Solutions, well firstly remove eaccelerator from suphp php.ini

Secondly core dumps shouldn't really be created all over the place so to disable them I found this post it works perfectly! Now no more core dumps!

Now to find any core dumps left use the following command

find / -regex -path /proc -prune '.*core\.[0-9]*'

the -path /proc -prune excludes the /proc folder

(this is assuming your core dumps append the pid of the file to them if not use find / -name core)

To see what made the core type file [pathtofile]

To debug it type gdb [path to executable found from above command] [path to core file]

Monday, 9 March 2009

SVN & SASL

I forgot when making all my svn posts about how to add the sasl authentication.

In the svnserve.conf file enable sasl and set a realm say...'realm' (how original)

Then run the command saslpasswd2 - c -u realm username

Replacing realm with the realm and username with the username

Vista Auto Login

On windows XP I used the power toys to enable auto login for my pc, now I am on vista I'd like to do the same, thanks to how to geek I now know how!

svn centos

Centos is based on red hat which doesn't update the version numbers of software it distributes via yum since svn requires apr 0.9.7+ and centos 4 comes with apr 0.9.4 upgrades are needed!

First download apr and apr util and subversion from the respective sites.

Extract the files.

Enter the apr directory type ./configure --prefix=[DIR TO INSTALL TO]
type make
type make install

now enter the apr-util dir and type ./configure --prefix=[DIR TO INSTALL TO] --with-apr=[PATH TO APR-CONFIG YOU JUST INSTALLED]
type make
type make install

now enter the subversion directory and type

./configure --prefix=[DIR TO INSTALL TO] --disable-mod-activation --with-sasl=/usr/lib/sasl2/ --with-zlib=/usr/local/include --with-apr=[PATH TO WHERE YOU INSTALLED APR] --with-apr-util=[PATH TO WHERE YOU INSTALLED APRUTIL]

Saturday, 28 February 2009

PHP mysql / mysqli / pdo

With more and more hosting companies adopting mysql 5.0 and php 5.2 instead of the old php 4 and mysql 4.1 I thought I'd go and benchmark some mysql/mysqli/pdo and here are my results.

The table used has approximatly one million records.

This is the results from running a SELECT * on the table 100 times.

mysql average 2.1038151192665

mysqli average 2.1223193383217

pdo average 2.1316439843178

You can see they're all pretty even but mysql wins followed by mysqli followed by pdo

Note these don't use prepared or multi query for mysqli / pdo they use plain query

Now onto insterts, adding 100k inserts one at a time has the following results

mysql average 0.00016879864931107

mysqli average 0.00013578898429871

pdo average 0.00015307459592819

On inserts mysqli wins with pdo coming second and mysql lagging behind.

Lastly updates

A simple update query which looked something like this UPDATE `t1` SET `f1`=`f1`+1 LIMIT 1 run 100k times

mysql average 0.00015682008266449

mysqli average 0.0001266986322403

pdo average 0.00013525368928909


Very similar to when running inserts mysql > pdo > mysql

The verdict with 2 points for coming first 1 point for coming 2nd and 0 points for coming 3rd we have

mysql 2
mysqli 5
pdo 2

So looks like mysqli is the fastest.

Saturday, 21 February 2009

Linux/Unix Show only hidden (dot) files

Not sure if I've posted this before but to show just hidden (file starting with a .) on linux/unix type

ls .??*

Tuesday, 17 February 2009

Repair scratched glasses

Have you ever scratched your glasses and now every time you wear them all you see is the scratch? Well I have.
Recently I read on Lifehacker a way to repair them.

Assuming you have polycarbonate glasses (new ones will be) and have a UV/Anti glare coating (probably will if you had any extras) you can use Amrour Etch Glass Etching Cream to remove the coating on the glasses which is actually what is scratched.

Since armour etch is american you can't get it in the UK or elsewhere but you can buy it off ebay like I did for around $10 which as of writing is around £7.50.

Considering a new pair of glasses could easily be £100 or £30-£50 for just new lenses it's a steal!

Debugging Javascript in Internet Explorer

As anyone who has ever tried to debug javascript in IE will know..you can't really it has a piddly little error saying "Error on line XX" but doesn't tell you what file..handy.

Anyway after a quick google I remembered the microsoft script debugger!

Download it here

Once downloaded install it then in IE go to tools > options, click the advanced tab, then uncheck "Disable script debugging (Internet Explorer)" and "Disable script debugging (other)".

Then restart IE and when something gets messed up it will alert you and ask you if you want to debug, tell it you do and it'll show you the problem line.

Vista users will have to allow the add-on so you may need admin rights.

Saturday, 14 February 2009

PHP HashBang

I've just been writing a php script and want to use a different php.ini file for the php-cli now the problem is typing

#/usr/bin/php-cli -c /pathtoinifile/php.ini doesn't work because the standard linux shell only parses one argument.

Simple solution, take the space out after the -c

#/usr/bin/php-cli -c/pathtoinifile/php.ini

That will work.

Wednesday, 11 February 2009

Genius!

I've been having a problem on and off with suPHP and cpanel, the problem was it brings up an internal server error and suphp_log says "Directory / not owned by {username}" where {username} is the user executing the script.

I'd not managed to solve it so asked my friend Simon his google skills seem better than mine he managed to find http://www.mail-archive.com/suphp@lists.marsching.biz/msg00619.html and low and behold my / and various other folders weren't owned by root! They were owned by a deleted user (602), it turns out when I installed zmanda then uninstalled it somewhere along the line the ownership got changed to the zmanda user which was then deleted.

So after running
find / -user 602 -exec chgrp root {} \;
find / -user 602 -exec chown root {} \;

All works!

Saturday, 31 January 2009

The Truth is out there!


The truth is out there! Google may harm your computer! They say so themselves...
Ok seriously I'm just joking but the image is real, google just screwed up and now is showing all sites as "This site may harm your computer"...how long will it last? XD

Wednesday, 28 January 2009

Thunderbird niggle

Just a little niggle I have with thunderbird, by default it sets the cursor under the previous message when replying to an email.

To make it go to the top do the following.

Click "tools" then "account settings" choose your account, click "composition and addressing" then where it says "automatically quote the original message when replying" there is a drop down box, set it to "start my reply above the quote" and press "ok" then the cursor will start at the top :)
Sent from my BlackBerry® wireless device

Tuesday, 27 January 2009

Google Checkout & Ensim/Parallels Pro

Ok this is part rant part useful information.

Firstly this is what I've been tasked to do.

Integrate google checkout with a site running on a shared host with Parallels Pro as the control panel (formally ensim pro).

Parallels pro runs a virtual file system but not everything is virtual it seems, i.e. apache runs on the host but php runs on the virtual file system (great huh?).

Google checkout uses basic http authentication which you should verify when it sends you xml responses.

Now since the php installation is configured as cgi php doesn't pic up the authorization variables...so we have to use .htaccess files to check the authorization...here comes the nightmare.

I set up a .htaccess with the path to the .htpasswd file like this

AuthType Basic
AuthName "Google Checkout Authorization"
AuthUserFile /home//.htpasswd

<Files "googlecheckout.php">
Require valid-user
</Files>


Then set up the .htpasswd file with a test user and password, but ack! This doesn't work...after some mooching around in the ensim control panel I find their directory password protection tool, so I give it a go and what do I find...

This is the path to the .htpasswd file

/home/virtual//fst/var/www/.htpasswd

Now as an afterthought this does make sense since the apache installation is on the root box but for god sake why couldn't someone tell me this earlier >.> and to top it off even more, they don't use the standard http encryption the passwords are..well weird.

[/end rant]

Monday, 26 January 2009

First issue with suhosin

I run suhosin on my servers and this is the first time I've found a problem, I was trying to post several large arrays...and whoops it only managed half.

Checking the suhosin logs I saw this ALERT - configured POST variable limit exceeded ahhhh not a surprise really solution..

Increase
suhosin.request.max_vars
and
suhosin.post.max_vars

In the php.ini settings note you must increase both if you don't it won't work since request and post are classified as the same thing. (well actually request is everything)

Thanks to this post for help!

(anyone noticed it's a blog day?)

Sunday, 25 January 2009

Civ4 and gamespy

Ok so I go to play civ4 over gamespy for the first time...I try logging in with my details it says "Invalid username"...um what? I've had a gamespy account for years and years...so as usual quick google and I found this turns out you have to create a new account inside civ4 using the same info as your gamespy account, then it works fine.

Mac Firefox Open With Download Location

One irritating think about firefox on OSX is that when you choose "open with" in firefox it downloads it to your default download location, normally the downloads folder.

Now I've read places that changing the default download location in safari to wherever you want (in my case /tmp) would fix this, I tried it but it didn't work.

Then I found this if you download camino go into the preferences and change the download location to /tmp (access this by pressing cmd+shift then typing /tmp) it will then close down camino and restart firefox it will download "open with" files to the /tmp folder which OSX clears regularly.

PHP & Sendmail return path problems

I was just cleaning my email accounts and noticed I have 400mb of "undeliverable" bounced emails (not surprising since DH gets oodles of people using fake emails) the odd thing was where they were, I'd set the "from" headers to go to general at dragon hearts dot net but they were ending up in the default mailing address that the php pages were running under, after a quick google I found this which brought me to ...this which basically in short says.

"If you're on a unix/linux web server when using the mail() function alter it to something like this

$fromemail='youremail@domain.com';
$to="na@na.com";
$subject="this is an email";
$headers = 'MIME-Version: 1.0' . "\r\n".'Content-type: text/html; charset=iso-8859-1' . "\r\n".'From: '.$fromemail."\r\n" .
$headers .= "Reply-To: ".$fromemail."\r\n";
$headers .= "Return-Path: ".$fromemail."\r\n";
$extra='-r
'.$fromemail;
mail($to,$subject,$message,$headers,$extra);



The $extra tells sendmail which php uses to..send mail..to add a -r flag which sets the return-path (the place bounced emails go) to your email, it's a good idea to set the return path in the headers too just in case.


Saturday, 17 January 2009

Vista Hibernation and removing hiberfil.sys

If like me you don't have oodles of disk space (I'm on a laptop) and you're using windows vista, you may have notice that hiberfil.sys is the same size as your ram in my case 3GB which is a fair bit nearly a DVD's worth. How do you disable it? Well you can try going into control panel > power options > advanced > sleep > hibernate after never. But that didn't work for me, thanks to this post i found out that if you open an admin command window and type powercfg -h off it disables it. W00t!

Thursday, 15 January 2009

Drupal Updater

I have created a new shell script to update drupal installations easier version 0.1 can be found here.

RAIDing my pc

Bad title I know. Anyway this is more for me in case I have to do it again.
First take a backup using acronis.
Second install the raid drives.
Third in the bios ensure hard drive boot is enabled and that the raid array is first.
Fourth use a bart pe cd with the win xp 32 bit drivers on to restore the backup.

Alternative way that may work is install 2nd hard drive non-raided and clone 1st hard drive over, then raid the two without clearing data.

Wednesday, 14 January 2009

Smart SVN 5 and SASL

Thanks to Alexander at Smart SVN I can now connect to svn using SASL with encryption enabled.
The problem was the default application version of java on mac osx is 5 with JDK 1.5 for the encryption it needs version 6 JDK 1.6.

To change it do the following go into Applications > Utilities > Java > Java Preferences
Then drag Java 6 (64bit) to the top in both boxes.
Now start Smart SVN and voila it works!

Tuesday, 13 January 2009

Mac Merging Folders

An annoying thing about macs finder is that it doesn't merge folders only replaces if they have the same name, now you can use the terminal mv command but another solution comes with xcode if you check this post you can use file merge to merge folders.

Saturday, 10 January 2009

iDVD Multiplexing Error

I've recently been trying out apples iDVD on my mac mini. When burning a disk image (the mac mini doesn't have a dvd burner) it would get to the end and say "Multiplexing Error". Very odd. The problem, for some reason it doesn't like making a dvd if the media is on an external hard drive, I copied what I was turning into a dvd onto the mini's main hard drive and voila! It works!

AppFresh - Mac Software Updater

In the modern world of oodles of 3rd party software, keeping it all up to date can be a pain...for windows I use secunia now for mac I've found AppFresh! It's still in beta but I've had a go and it works wonders, it keeps everything up to date :)