So today, I was working on an older x-cart site after implementing some of the previous CDN / static domain hacks, I looked at the product images which were being displayed via the main domain. Because CleanURLs were enabled, I couldn’t just edit the thumbnail template file but rather edit the CleanURL creator function. So here’s my edits for X-Cart 4.3 and xcart 4.5.
Edit /func/func.files.php
approx. line 254 (xcart 4.3) or line 374 (xcart 4.5)
from:
The issue that needs to be then addressed is how to balance the previous edits with this one over x number of domains so the file requests can be parallel and not blocking, after looking, putting javascripts and css files on one domain, catalogue images on anotherand possibly any remaining requests manually written in via a third? in this scenario, {$skin}/{$alt_skinDir} and {$images}/{$alt_imagesDir} (being remembered from memory) could be over two domains and then the catalogue images on the third.
Ideally you want to even out the requests (no less than 5 to 10 requests) over the domains with upto 3 sub-domains maximum to reduce the number of DNS lookups but depending on what’s being serviced and checkign with online tools will help test which is the best layout.
So today, my friend asked me for some regex to get text between two given strings; I can’t do regex so I came up with a simple line of code and then turned it into a function so it can be re-used.
I thought I’d pop the code here for others too.
/***************************************************************
* @title: Lazy Regex
* @descr: Find any text between two strings.
* @author: Adam Boutcher
* @email: admin@aboutcher.co.uk
* @web: www.aboutcher.co.uk
* @usage:
* string lazy_regex (string $haystack, string $needle_first, string $needle_last)
* @Params:
* $haystack - the text you which to search
* $needle_first - Find this text as the start of the pointer.
* $needle_first - Find this text as the end of the pointer.
* @notes:
* Returns false on failure, this maybe non-bool false, use === to test (see PHP: substr).
* Returns the start and end needles including the text beween on success.
**************************************************************/
function lazy_regex($haystack, $needle_first, $needle_last) {
if ((empty($haystack))||(empty($needle_first))||(empty($needle_last))) { return false; }
return substr($haystack, stripos($haystack, $needle_first), ((stripos($haystack, $needle_last)+strlen($needle_last))-stripos($haystack, $needle_first)));
}
So this weekend I’ve been fiddling getting Linux as my main OS on my laptop again; this post is just some odds and ends I’ve done.
Conky BOFH Excuses
I wanted some BOFH style excuses being displayed on my conky, so I took an excuses list and then popped it on my webserver and it outputs a single line at random. The conky script reloads once every 6 hours.
I was getting this error with Legend of Grimrock on my fresh install on debian:
GL_INVALID_ENUM 0x0500
so I took to the internet and had a search about, turns out I’m missing a dependency that the installer doesn’t check for but there was a helpful post on their forums and I installed it, if you have the same issue then install this:
apt-get install libtxc-dxtn-s2tc0
yum install libtxc_dxtn
Debian Wheezy x64 and WINE…
So as you’ve seen my preferred distro is Debian and I have previously written a post on installing a newer version of WINE that what is in the Debian repo’s for better computability. Today I followed my own instructions and to my surprise it didn’t work, mainly because the guide was aimed at squeeze and there are some big differences in the way Debian implements multi-arch and wine depends on some 32bit libs.
Now that should all work, Wheezy’s method of installing ia32libs it to include i386 in the architecture list in dpkg which results in better compatibility but also a larger system which isn’t always wanted.
Firefox and Debian
Linux Mint also provides a small repo for Debian which includes newer or non-free software that isn’t in the Debian repo. From here you can download and install a Debian version of Firefox instead of using Iceweasel which isn’t always upto date.
Download firefox-l10n-en-gb (or your lanaguage).
Download firefox
Install firefox-l10n-en-gb (or your lanaguage).
Install firefox
You should now have firefox setup correctly even in update-alternatives and gnome etc.
Debian and MATE Desktop
This one’s fairly simple but strangely not documented on their website. If you liked Gnome2 but not Gnome3 then presumably you don’t want to have to install all of Gnome3’s libs to run the ‘classic’ or fallback desktop. This is where MATE comes in which is a fork of the Gnome2 code with some updates and changes. To install it just do the following:
So today I was working on a site based on xcart 4.5 with an aim to speed up page load times. I had previously migrated all the background images into CSS base64 encoded data to save on the number of requests and file sizes etc.
Part of x-carts SEO tools and optimisation is that it will combine all CSS files into one but while it does that, it craftily rewrites specific parts mainly so URLs are correct which plays havoc with base64 encoded CSS images as it attempts to rewrite it all, so this file needs to be separate and defined manually in the template via the <link /> tag and not with the load_defer() function.
Anyway in regards to using a cookie-less Static domain or a Content Delivery Network for CSS, Javascripts, Images etc then you need to do some minor rewriting of x-cart.
Firstly, you need to setup your domain and relevant services to have the correct resources and the domain to work. I was using apache and included the following lines in the vhosts.
We have to check for SSL so we don’t get certificate errors and alerts about unencrypted content. There isn’t much information in regards to x-cart 4.5 and CDN’s but there’s a snippet on the wiki about it in older versions.
So one of the websites I am developing has a static header, there are a few examples of this being used such as Next; the issue comes, when you require lots of information in this header but use a responsive layout, the header is then taking up real estate for your main content (even more so in landscape mode).
So this is where hiding the less vital information such as the company logo and search could come in useful; so I developed a small hacky jquery base script to do this. It isn’t perfect and it’s my first serious javascript on this site so please be kind!
The script hides a div on scroll and displays another to allow you to have a small “show div” button available at all times. if then shows and hides when the display is resizes to a desktop resolution.
Have a go of the demo and feel free to steal the code; if you find any better ways of doing it then don’t hesitate to contact me.