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)

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;
}