Archive for the ‘coding’ Category.

Label Grid launched – is is possible to have browser based label printing software – and open source too!

I was interested to hear of the launch  of Labelgrid recently.  This is a new open source project (GPL licence) to design a web based label printing software stack to design and print labels in a browser rather than the typical client based software.  There  will be a number of challenges in this as the authors point out on their webpage, but I thin its a really interesting idea if they get it to work well, and I wish them all the best in the code development .  You can see a demo here.

  • Share/Bookmark

How to configure a SNOM 300 phone for a conference call using TRIXBOX

We use a lot of SNOM 300 VOIP phones at our sites, and have just cracked a way to make conference calls on them, which is not obvious or covered by the manual. If you are trying to do this:

  1. Login to your phone using the web GUI via http://its.IP.x.x and select function L4 – directory, (or any function you dont use)
  2. change the function tag to   F_CONFERENCE
  3. save

to make a conference call,

  1. call the first call, speak and put on hold by pressing the L1 line 1 button
  2. dial the second number and speak to them
  3. press L4 and all 3 callers are connected
  • Share/Bookmark

miserware only delivers a 2.7% power reduction

15/2/10 NOTE: this post has content that is seen as inaccurate by Miserware and you are advised to read all the text before forming conclusions to give Miserware a fair hearing.

I used a power meter to measure the electric draw of the PC using and not using miserware

I used a power meter to measure the electric draw of the PC using and not using miserware

Interested by some of Alan’s posts at the Open Sourcerer, I’ve been conducting an experiment in recent weeks with the Miserware power saving software that claims to save energy by better controlling CPU management.  I run a new (late 2009) pc with an Intel Core 2 Quad Q8200 (4x 2.33) CPU with a 450w PowerCool 80+, and have given it a go.  However, I didnt rely on the software’s own claimed power savings, I put an electric meter between the PC’s plug and the socket, and directly measured the power usage over 3 weeks, both with and without the software installed, set at my current domestic electricity rate pkwh.

Here is my data:

miserware installed? date £ of electricity used £ per day from last reading £ per day annual cost annual saving
no 19/01/10 14:00 0 pc booted up
no 20/01/10 18:00 0.16 0.1371
no 23/01/10 22:00 0.62 0.1453 0.1431 52.22 miserware installed
yes 24/01/10 08:00 0.67 0.1200
yes 26/01/10 19:00 1.02 0.1424
yes 30/01/10 08:43 1.53 0.1428
yes 08/02/10 08:33 2.81 0.1423 0.1418 51.77 Uninstalled 8 feb
no 13/02/10 05:12 3.53 0.1481 0.1481 54.07 2.3 test stopped

What I did was to run the PC without the software installed for 4 days from 19-23 Jan, installed miserware from 23 Jan to 8 Feb, then ran the PC again from 8 Feb until today.  Congratulations to the miserware support though, when I had issues installing they were right on the ball, and FOC.

The results are pretty unimpressive.  Despite a claimed 15% power saving claimed by the software (sudo grep Estimated\ energy /var/log/* )  it actually made very little difference at all.  In fact, if you average out the estimated annual usage for the 2 periods without running miserware ((52.22+54.07)/2) = 53.15 and compare that to the annual cost running miserware of £51.77, you see a 2.7% power saving thats worth about £2.30 a year.  OK, its a saving, but its not worth a lot to me.

The scary observation is that if you leave a PC on 24/7, its going to cost you over fifty quid a year at current online dual fuel electricity tariff rates!

  • Share/Bookmark

Multiple Accounts using a single Alias in Zimbra

A little back end tweak here to allow multiple Zimbra email accounts to use a single alias.

Normally, you can only assign an alias to one single user, otherwise you are presented with a similar error:

Cannot add alias:
Account user@domain already has alias aliasuser@domain

We needed to be able to allow two user accounts to send emails from the same account (alias); there may be other ways to do this, but the fix that worked for us is:

zmprov ma user1 +zimbraAllowFromAddress aliasuser@domain.com
zmprov ma user2 +zimbraAllowFromAddress aliasuser@domain.com

To run these commands, You need to connect to your zimbra server (I used SSH) and then su to the zimbra user:

su zimbra

then simply enter the commands:

zmprov ma user1 +zimbraAllowFromAddress aliasuser@domain.com
zmprov ma user2 +zimbraAllowFromAddress aliasuser@domain.com

that should be all that’s needed.

This basically then allows user1 to use the alias, and user2 to use the same alias, and as far as I can tell, there are no limits to the number accounts you can apply this to. I did actually use two test accounts first to ensure of no problems, but all worked 100%.

Thanks to Matt at Senokian for the suggestion.

  • Share/Bookmark

Gulp – our first published hack – using a nokia e90 mobile phone over bluetooth as a 3G modem on T-mobile

I think this is our first ever hack, heavily copied from here (thanks to that author) with a few little changes for the UK T-mobile network, and shows how to use a nokia e90 mobile phone over bluetooth as a 3G modem on T-mobile on ubuntu 8.10, saving yoruself the cost of buying a £150 USB 3G dongle

First Pair your Mobile to Your laptop Manually…using bluetooth manager.. if pc is not connecting to your device.. try to connect the pc from your mobile

then go to console n issue the following command

adrian@adrian-laptop:~$ sdptool search DUN

output
———-
Inquiring …
Searching for DUN on 00:1A:89:CD:14:9A …
Service Name: Dial-Up Networking
Service RecHandle: 0×1005c
Service Class ID List:
“Dialup Networking” (0×1103)
Protocol Descriptor List:
“L2CAP” (0×0100)
“RFCOMM” (0×0003)
Channel: 4
Language Base Attr List:
code_ISO639: 0×454e
encoding:    0×6a
base_offset: 0×100
Profile Descriptor List:
“Dialup Networking” (0×1103)
Version: 0×0100

NOTE THE CHANNEL NUMBER
step 2: Issue the command

hcitool scan

output
———–
Scanning …
00:1A:89:Cx:14:9A    Adrian e90

step 3: issue the command

sudo gedit /etc/bluetooth/rfcomm.conf

paste the text in it

rfcomm0 {
bind yes;
device 00:1A:89:Cx:14:9A;
channel 4;
comment “Nokia E90″;
}

USE YOUR OWN DETAILS FOR MAC ADDRESS AND CHANNEL NUMBER
save it

step 4:

issue the command

sudo gedit /etc/ppp/peers/airtel

copy this in that file

/dev/rfcomm0 115200
connect ‘/usr/sbin/chat -v -f /etc/ppp/chat-gprs’
crtscts
modem -detach
noccp
defaultroute
usepeerdns
noauth
ipcp-accept-remote
ipcp-accept-local
noipdefault

step 5:

issue the command

sudo gedit /etc/ppp/chat-gprs

copy this in the file

” ATZ OK
AT+CGDCONT=1,”IP”,”general.t-mobile.uk”
OK “ATD*99***1#”
CONNECT ”
step 6:

FINISHED

To run it,make sure you are not connected to another wifi network (reboot in needed), then  just issue this command

sudo pppd call airtel

It works, and has just saved me £150 for a 3G wireless USB dongle device.

  • Share/Bookmark

Finally, I’ve found a decent webpage design software for linux (like dreamweaver)

Apart from a couple of small SEO applications that only run on windos, the biggest problem I have come across when using linux in the past year for day to day business use is the lack of a WYSIWYG webapge editor.  At the moment I’m still remote desktop’ing onto our old windows server where we have dreamweaver installed.  I can code in html, but to be honest a split screen webpage editor is a fantastic tool, and until today I hadnt found one for linux.

I have previously posted on this issue, but got nowhere.  Bluefish installs and works fine but is not a split screen WYSIWYG webpage editor.  I couldn’t get NVU to install and I didnt like quanta.

However, today I found , http://ubuntuforums.org/showthread.php?t=842808&page=1 which linked to a great application called KompoZer, which does what I want, a WYSIWYG webpage editor.

I’ve tried it out and it seems fine to me, again, thank you to the community who wrote this very useful application.

  • Share/Bookmark

new software system, dry run results

Well we did a full dry run last Friday with the new PHP driven labels CRM system (yet to be named – any ideas?) and it didnt go as well as we hoped.  So much so that we have a list of bugs to work on before its good enough to go “live”, hopefully next weekend.

Patience is a vurtue as they say, but I’m just so keen to see the new system up and running and give us some more reliability.  Anyway, there is another week of bug fixing, and we try again next weekend.

Open source migrations take time, I knew it, and now we are proving it ourselves!

  • Share/Bookmark

Postgresql: Calculate work days (none weekend days)

Coming from a MsSQL database with access queries/macros/modules and so on, its easy to be able to work out weekend days from two given dates, ie if you have two dates you can calculate how many days between them aren’t weekdays.

In postgresql, this isnt so easy!

there aren’t many examples on the net, without creating mass functions, but i’ve come up with this:

SELECT count(*) FROM generate_series(1, (higherdate::date – lowerdate::date)) i WHERE date_part(’dow’, higherdate::date + i) NOT IN (0,6);

the higherdate and lowerdate are exactly what they sound like, the higherdate has to be after the lowerdate.

That will work out how many days between each of those dates, and return a result that doesnt include sat/suns basically giving you working days!

It doesnt take into account holidays, but I didnt need it to..

  • Share/Bookmark

Postgresql: Converting money type to numeric!

Quick post here, as I was having trouble finding any information(that worked, or indepth enough to work for what I needed).

The type money is now deprecated from postgresql, and a few of our tables contained this data type. This is fine, and worked as we wanted, until there came a time I needed to do a query such as:

select * from mytable where (mytable.charge > 0);

seems easy enough, but if myfieldname is of type money, you will get nice errors such as:

ERROR: operator does not exist: money > integer
HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts.

Doing what the Hint suggests isnt easy, and theres pretty much no good way to cast money to anything.

A few examples on the net dont work, depending on version, or can mess up the data.

After a bit of searching and messing, ive found a solution that does whats needed:

First you need to do:

set lc_monetary=’C';

to basically control the currency, ours was set to £ but doing that sets it back to $ and makes things easier to work with.

Next you need to do:

alter table yourtable alter column yourfield type numeric(16,2) using translate(textin(cash_out(yourfield)), ‘$,’, ”)::numeric;

Once thats done, you’re set and it seems to work flawlessley (in version: 8.1.9 anyway).

May be a good idea to make a copy of the table before, just incase:

create table backup_table_yourtable AS select * from yourtable;

then if you have any issues you can revert back!

  • Share/Bookmark

lessons in backing up….

Sometimes I never learn, and check that backups are working as they should be.  Last night we had a zimbra failure that resulted in the default backup schedule not being run (incremental backup at 01:00), which measn that when we had to have a fresh install today we lost all yesterdays emails, calendar changes and additions, everything.

Yesterday I spent all day writing up 3 tactical plans for the business, and lost them all becuase of this.  Fortunately I got some of the work back from a syncd copy on a PDA, but not everything.  This episode also dented our team’s confidence in Zimbra as its the second time it has happened.

We have now improved the backup regime to daily full backups and hourly incremental ones.  We did this by changing the zimbra backup cron job using WEBMIN on port 10000 on our ubuntu server using the nice GUI webpage, and it seems to work.

A lesson for other new zimbra users, the default backups just ain’t enough, so update your instalation NOW to get more backups!

Lesson learnt the hard way (again).

  • Share/Bookmark

linux admin course notes

I have just finished a rewarding 4 day course at OpenAdvantage on linux admin, very presented and run by Paul Cooper. I got a lot out of the course, but there was a wide range of attendees, from people with (literally) decades of unix experience to me, a microsoft convert making early steps in the command line environment. The course was based on the linuxIT course , for people working towards the linux professional institute exams (which I’m not taking!)

Overall, an excellent course. What I want to take away is a crib sheet of linux commands and notes I can sync into my address book, so that when I next need to run stuff on the command line its easy to hand. So here goes… Please note that these are my crib notes, not a definative linux command line crib sheet!

BASIC COMMAND LINE COMMANDS

echo “test” returns the text

CREDIT=300
echo $CREDIT returns the variable

ls -hl lists files in detail in human readable format
pwd tells you where you are in the directory structure

env shows the environment you are working in

ls -l >errors.txt redirects the output to errors.txt

set shows all variables
| Pipe symbol glues the lot together

ls f* gives all files starting with f
ls f???s.* gives all files but only with the right number of characters
ls [a-e]*.* for a range
ls my\ documents for files with a space in the name

SHORTCUTS

cntrol shift c and control shift v are copy and paste

tab gives tab completion of a predictable string
up arrowauto completes from the history of command lines submitted

home and end keys more up and down the line
man is the manual command for HELP!
eg
man ls

q to quit

alias ll=ls -l is a shortcut command

cd /media is absolute command to the media

FINDING FILES

find -name “f*.txt”

or

locate / “f*.txt”

REMOVE FILES

rmdir for directories
rm -r music removes the directory and all contents

COPY FILES

cp fil* my\ documents to copy

MOVE FILES

mv is move file

FILES SYSTEMS
ext2 is the linux old equivilant of fat32, a basic file format for linux
ext3 joural based file system – best to use

swap file partition should be double actual physical memory

lspci lists the hardware

RUNNING AS ROOT

sudo runs a single command as root
su is switch user eg
su – root

FORMAT DISKS

sudo fdisk /dev/sda runs the fdisk command

df tool for mounted and
du -h /usr as an example of finding file sizes

PERMISSIONS
user u
group g
other o

read r or 4
write w or 2
execute x or 1

character 1 is file info, 1-3 is user,4-6 is group,7-9 other

chmod u+x files.txt gives execute permision to users

PROCESSES

pstree -p shows the runningprocesses
ps ax shows all process for all users

kill pid number kills the process
or
kill -9 pid number

top gives the running processes

nohup runs outside the session

TEXT EDITOR

at is a basic text editor
control D stops it

head -5 hello.txt gives you the last 5 lines of hello.txt

grep term filename > results.txt

VI or VIM is a good embedded text editor

q! to quit

esc to go back to command line
x to save and escape

SSH

at command line you can ssh to any url

STOP AND START PROCESES
eg
sudo /etc/init.d/ssh stop

w
whoami tells you who is on a machine

SECURECOPY

scp root@ the address :whoteist.txt whitelist.txt is a secure copy

TIMING

crontab -l to list
crontab -e to edit

eg
45 14 * * * /bin/touch /home/demo/results.txt
will touch the results file at 14:45 every day

NETWORK

ifconfig gives you your network information, your IP address etc


I hope this is enough of a memory dump for future reference.  Thanks Paul for a very useful course

  • Share/Bookmark

learning how to run linux at command line with only a DOS and windows bckground

although the techies love it,probably for good reason, a lotof user interface with linux is at the command line, not the usual GUI interface that we are geneticly engineered to know and understand…. this means that if you really want to use some of the linux features and functions, you have to know how to use the command line.

I have some basic unix experience from numerical modelling research, but not enough that I didn’t have to start at square one.

I tried this website, which I was impressed with, and guided me through the basic functions well.

www.linux.org/lessons

Its worth a go , after 30 minutes I could even find and load our website files and edit them with the VI text editor.

I still prefer the GUI ubuntu interface though!

  • Share/Bookmark

The MVC fun continues…

Well.. we finally decided that we should give the MVC framework process a chance, to see if we could truly benifit from it.

I’m going to be using a simple ish MVC framework and Smarty for the templating system, this seems to be working both logically and easy for us, or fairly easy anyway.

The way im going to do this is have a main page which will control the configuration etc, and then a series of templates for each section (ill come back to this) and then modules for each section too.

What i mean by section is this.. Basically the way I see how our company runs the existing database is based on a few sections(Customers, Orders, Searching, Report).. there is more, but this is just an example, so i’ve decided to have these as our main controlling elements.

So our intranet should work on this basis: http://address/index.php?section=Customer meaning our program knows we only want to be working with whatever is involved with a Customer, the same goes for Orders, Reports and so on, keeping the whole process a lot simpler (or so i think anyway)

With this in mind, ive now got a CustomerModelController which will take aditional parameters defining which action should be performed now we’re only concerned with the customer, for instance Search for Customers.

Our intranet again shows how easy and logical this makes things:

http://address/index.php?section=Customer&action=search_for_users or add_user etc, you get the idea anyway.

These methods allow me to have custom templates for each section, and still keep my code nice and tidy, so i’ve not got 100’s of smaller functions within one big controller.

I’ve tried not to go into too much detail here, so not to confuse people/myself anymore, but if anyone wants further explanations just let me know, and ill go into more detail.

Just want to say thanks to the people who have commented on the MVC ideas so far, definately made an interesting read, cheers!

  • Share/Bookmark