A weekend of Linux fiddling…


Written by

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.

${execi 21600 curl http://bofh.aboutcher.co.uk | fold -w35 }

 

Fix Legend of Grimrock Error

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:

root@DebianBased:$ apt-get install libtxc-dxtn-s2tc0
root@Fedora:$ 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.

So here’s my attempt at a newer guide.

  1. Install libpng12-0 and libpng12-dev
  2. Download Wine-Gecko from the Mepis Repo for Mepis 8.0
  3. Download Wine from the Mepis Repo for Mepis 8.0
  4. Install Wine-Gecko
  5. For x64 download ia32libs from Debian Repo for Squeeze
  6. Install ia32libs
  7. Install Wine

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.

  1. Download firefox-l10n-en-gb (or your lanaguage).
  2. Download firefox
  3. Install firefox-l10n-en-gb (or your lanaguage).
  4. 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:

root@debian:$ echo "deb http://packages.mate-desktop.org/repo/debian wheezy main" >> /etc/apt/sources.list
apt-get update
apt-get install mate-archive-keyring
apt-get update
apt-get install mate-core mate-desktop-environment

and there you go, you should now have mate installed.

 

That’s all for now but I do have more stuff for another day.

X-Cart 4.5 and a CDN / Cookieless Static Domain


Written by

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.

RequestHeader unset Cookie    
Header unset Set-Cookie

Which removes any cookies on that domain.

Once the domain is all setup and ready then we have to edit x-cart a little, I’ll try and write this as simply as possible.

Edit /smarty.php

approx. line 92
from:

$smarty->assign('AltImagesDir', $alt_skin_info['web_path'].'/images');
$smarty->assign('AltSkinDir', $alt_skin_info['web_path']);

to:

if ($_SERVER['HTTPS'] != 'on') {
    $smarty->assign('AltImagesDir', "http://cdn.domain.tld".$alt_skin_info['web_path'].'/images');
    $smarty->assign('AltSkinDir', "http://cdn.domain.tld".$alt_skin_info['web_path']);
} else {
    $smarty->assign('AltImagesDir', $alt_skin_info['web_path'].'/images');
    $smarty->assign('AltSkinDir', $alt_skin_info['web_path']);
}

and approx. line 107
from:

$smarty->assign('ImagesDir', $xcart_web_dir.$smarty_skin_dir.'/images');
$smarty->assign('SkinDir', $xcart_web_dir.$smarty_skin_dir);

to:

if ($_SERVER['HTTPS'] != 'on') {
    $smarty->assign('ImagesDir', "http://cdn.domain.tld".$smarty_skin_dir.'/images');
    $smarty->assign('SkinDir', "http://cdn.domain.tld".$smarty_skin_dir);
} else {
    $smarty->assign('ImagesDir', $xcart_web_dir.$smarty_skin_dir.'/images');
    $smarty->assign('SkinDir', $xcart_web_dir.$smarty_skin_dir);
}

then edit: /include/template/plugins/function.load_defer_code.php

at approx. line 111
from:

$cacheWebFile = $var_dirs_web['cache'].'/'.$label.'.'.$md5Suffix.'.'.$type;

to:

if ($_SERVER['HTTPS'] != 'on') {
    $cacheWebFile = "http://cdn.domain.tld/var/cache".'/' .$label.'.'.$md5Suffix.'.'.$type;
} else {
    $cacheWebFile = $var_dirs_web['cache'].'/'.$label.'.'.$md5Suffix.'.'.$type;
}

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.

 

Responsive Websites and Static Headers


Written by

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.

Small yet Functional Conky


Written by

Here’s my small but functional conky config (conkyrc).

It displays:

  • Battery
  • CPU Utilisation
  • RAM Utilisation
  • SWAP Utilisation
  • Hard Drive Usage
  • eth0 and wlan0 stats
  • Public IP
  • Wireless Info
  • Clock

Some bits you might want to change according to your distro.

######################
# - Conky settings - #
######################
update_interval 2
total_run_times 0
net_avg_samples 1
cpu_avg_samples 2

imlib_cache_size 0
double_buffer yes
no_buffers yes

format_human_readable

#####################
# - Text settings - #
#####################
use_xft yes
xftfont Droid Sans:size=8
override_utf8_locale yes
text_buffer_size 2048

#############################
# - Window specifications - #
#############################
own_window_class Conky
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

alignment top_right
gap_y 40
gap_x 20
border_inner_margin 8

minimum_size 180 300
maximum_width 180
maximum_height 460

default_bar_size 92 6

#########################
# - Graphics settings - #
#########################
draw_shades no
default_shade_color 000000
default_color FFFFFF

TEXT
${font Droid Sans:style=Bold:size=8}DEBIAN LINUX $hr${font}
##############
# -   OS       - #
##############
${voffset 5}${font OpenLogos:size=35}J${font}${goto 45}${voffset -30}Name:  ${alignr}${nodename}
${goto 45}OS: ${alignr}Debian Wheezy
${goto 45}Kernel: ${alignr}${kernel}
${goto 45}Uptime: ${alignr}${uptime}
${voffset 8}${font Droid Sans:style=Bold:size=8}SYSTEM $hr${font}
##############
# - SYSTEM - #
##############
# |--SWAP
${voffset 5}${font Droid Sans:style=Bold:size=8}BATT${font}${goto 45}Rem: ${font Droid Sans:style=Bold:size=8}${battery_percent BAT0}%${font} ${alignr}${battery_bar 7,70 BAT0}
${goto 45}Status: ${font Droid Sans:style=Bold:size=8}${battery BAT0}${font}
# |--CPU
${voffset 6}${font Droid Sans:style=Bold:size=8}CPU${font}${offset -20}${goto 45}Core 1: ${font Droid Sans:style=Bold:size=8}${cpu cpu1}%${font} ${alignr}${cpubar cpu2 7,70 EEEEEE}
${goto 45}Core 2: ${font Droid Sans:style=Bold:size=8}${cpu cpu2}%${font} ${alignr}${cpubar cpu2 7,70 EEEEEE}
# |--MEM
${voffset 6}${font Droid Sans:style=Bold:size=8}RAM${font}${goto 45}RAM: ${font Droid Sans:style=Bold:size=8}$memperc%${font} ${alignr}${membar 7,70}
${goto 45}Free: ${font Droid Sans:style=Bold:size=8}${memeasyfree}${font} ${goto 115}Used: ${font Droid Sans:style=Bold:size=8}${mem}${font}
# |--HDD
${voffset 6}${font Droid Sans:style=Bold:size=8}HDD${font}${goto 45}/: ${font Droid Sans:style=Bold:size=8}${fs_used_perc /}%${font} ${alignr}${fs_bar 7,70 /}
${goto 45}Free: ${font Droid Sans:style=Bold:size=8}${fs_free /}${font} ${goto 115}Used: ${font Droid Sans:style=Bold:size=8}${fs_used /}${font}
# |--SWAP
${voffset 5}${font Droid Sans:style=Bold:size=8}SWAP${font}${goto 45}Swap: ${font Droid Sans:style=Bold:size=8}${swapperc}%${font} ${alignr}${swapbar 7,70}
${goto 45}Free: ${font Droid Sans:style=Bold:size=8}$swapmax${font} ${goto 115}Used: ${font Droid Sans:style=Bold:size=8}$swap${font}
###############
# - NETWORK - #
###############
${voffset 8}${font Droid Sans:style=Bold:size=8}NETWORK $hr${font}
${voffset 5}${font Droid Sans:style=Bold:size=8}Public${font}${goto 45}Addr:${goto 85}${font Droid Sans:style=Bold:size=8}${execi 240 curl http://automation.whatismyip.com/n09230945.asp}${font}
${if_existing /proc/net/route wlan0}${voffset 5}${font Droid Sans:style=Bold:size=8}waln0${font}${goto 45}Addr:${goto 85}${font Droid Sans:style=Bold:size=8}${addr wlan0}${font}
${goto 45}Down:${goto 85}${font Droid Sans:style=Bold:size=8}${downspeed wlan0}${font}${alignr}${downspeedgraph wlan0 8,50 EEEEEE}
${goto 45}Up:${goto 85}${font Droid Sans:style=Bold:size=8}${upspeed wlan0}${font}${alignr}${upspeedgraph wlan0 8,50 EEEEEE}
${goto 45}Total:${goto 85}${font Droid Sans:style=Bold:size=8}${totaldown wlan0}${font} / ${font Droid Sans:style=Bold:size=8}${totalup wlan0}${font}${else}${font Droid Sans:style=Bold:size=8}wlan0${font}${goto 45}Not Conencted${endif}
${if_existing /proc/net/route eth0}${voffset 5}${font Droid Sans:style=Bold:size=8}eth0${font}${goto 45}Addr:${goto 85}${font Droid Sans:style=Bold:size=8}${addr eth0}${font}
${goto 45}Down:${goto 85}${font Droid Sans:style=Bold:size=8}${downspeed eth0}${font}${alignr}${downspeedgraph eth0 8,50 EEEEEE}
${goto 45}Up:${goto 85}${font Droid Sans:style=Bold:size=8}${upspeed eth0}${font}${alignr}${upspeedgraph eth0 8,50 EEEEEE}
${goto 45}Total:${goto 85}${font Droid Sans:style=Bold:size=8}${totaldown eth0}${font} / ${font Droid Sans:style=Bold:size=8}${totalup eth0}${font}${else}${font Droid Sans:style=Bold:size=8}eth0${font}${goto 45}Not Connected${endif}
${if_existing /proc/net/route wlan0}${voffset 8}${font Droid Sans:style=Bold:size=8}WIRELESS $hr${font}
${voffset 5}${goto 45}Int:${goto 85}${font Droid Sans:style=Bold:size=8}wlan0${font}
${goto 45}SSID:${goto 85}${font Droid Sans:style=Bold:size=8}${wireless_essid wlan0}${font}
${goto 45}Speed:${goto 85}${font Droid Sans:style=Bold:size=8}${wireless_bitrate wlan0}${font}
${goto 45}Signal:${goto 85}${font Droid Sans:style=Bold:size=8}${wireless_link_qual_perc wlan0}%${font}${alignr}${wireless_link_bar 7,70 wlan0}${endif}
#############
# - CLOCK - #
#############
${voffset 8}${font Droid Sans:style=Bold:size=8}CLOCK $hr${font}
${font Droid Sans:size=20}${alignc}${time %l:%M %p}${font}
${alignc}${time %d %B %Y}

It requires openlogos font too for the debian/distro logo and curl for the public ip. The initial script isn’t mine; it’s just oen I found and them modified.

Updates and Newness…


Written by

So this afternoon, I decided to upload and release my latest function mailattch. This function takes php’s mail to a whole new level, allowing files to be attached!

There are currently limitations to it and it isn’t highly tested but everyone is welcome to use it and is release under GPL v3.

I have also pushed a little update to ldir. It’s nothing big, just a shameless link back to here; if you really don’t like it then you’re free to remove it from the function source or you can hide is with CSS via display: none; on the class .ldir_link.

That’s all for now.