Resizing a Xen disk image partition
1 # Stop & backup 2 xm stop sandbox 3 cp -a sandbox/ sandbox.bk 4 5 # Verify MD5 sum 6 md5sum sandbox/disk.img 7 4976347006df34843d29c939b5fc3742 sandbox/disk.img 8 md5sum sandbox.bk/disk.img 9 4976347006df34843d29c939b5fc3742 sandbox.bk/disk.img 10 11 # Create a 5Gb temp file 12 dd if=/dev/zero of=Tempfile bs=1024 count=5000000 13 14 # Append it to the existing image 15 cat Tempfile >> disk.img 16 rm Tempfile 17 18 # Resize the partition 19 resize2fs -f disk.img 20 21 # Check partition & start domU 22 fsck.ext3 disk.img 23 xm create -c sandbox.cfg
A Ruby script that deletes images that are not used anywhere
1 Dir.glob("**/*.{jpg,gif,jpeg,png}").sort.each do |image| 2 3 name = File.basename(image) 4 in_use = false 5 6 Dir.glob("**/*.{erb,css,js,html,htm}").each do |file| 7 contents = File.read(file) 8 9 in_use = contents.include?(name) 10 11 break if in_use 12 end 13 14 if !in_use 15 puts "Deleting '#{image}'" 16 File.delete(image) 17 end 18 end
A simple image replacement technique for increased usability and SEO ranking
This is currently my favorite image replacement technique. I don’t remember where I found it… Using it can improve both your site’s usability and your search engine ranking, by allowing both screen readers and search engines to find your h1 headlines. First create the h1 and the description of your page/site, for example:
1 <h1 id="logo">Viagra, Botox, you name it</h1>
Then create the CSS rule for the page title:
1 h1#logo { 2 text-indent: -9000px; 3 background: url(logo.gif); 4 width: 200px; /* Width of image */ 5 height: 50px; /* Height of image */ 6 }
People using a modern browser that support CSS will see your logo (the image), and search engines and people using less modern browsers will see the content of the h1 header tag.
Note that if you replace the text of a link then use the outline CSS property to remove the dotted border:
1 .text-replacement { 2 text-indent: -9000px; 3 } 4 5 .text-replacement a { 6 outline: none; 7 }