Converting RGB to hex just involves understanding the decimal representation of RGB. See below for a small perl procedure.
my $r = shift;
my $g = shift;
my $b = shift;
my $dec = 0;
$dec += 256*256*$r;
$dec += 256*$g;
$dec += $b;
return sprintf(“%.6x”, $dec);
If you want to get source code from GitHub it’s easy enough to click ‘Download’ if you just want an archive. However if you’re on GitHub you might want to use the proper git client.
Get git if you haven’t already:
Once that’s installed just run the following from a command line:
git clone git://github.com/username/project.git
To get the connect-auth source tree use:
git clone git://github.com/ciaranj/connect-auth.git
Enjoy your new source.
Got a script with ^M at the end of each line because the file came from a dos machine? With perl you’ll get something like:
/usr/bin/perl^M: bad interpreter: No such file or directory
First of all open this file in vi in binary mode:
vi -b yourscipt.file
Then after typing colon type the following:
NOTE. To get the ^M do NOT use ^ and M. Use control+V then immediately control+M.
Then [enter]. Then to save and exit:
I certainly don’t profess to be a MySQL performance tuning expert. What I am is a long-time MySQL lack of performance sufferer. In fact, writing this I’m in the process of waiting for several table deletes and MySQL WorkBench has frozen (again).
Anyway, here’s some thoughts:
- If you have heavy writes bear in mind this severely affects locking for MyISAM tables. One thing that sucks with MySQL table engines is you trade off performance (MyISAM) against granular locking (InnoDB).
- Try to avoid tables getting too large to manage. If you’re storing historical data write an archive / cull script early on to keep the database manageable.
- Use SHOW PROCESSLIST to see what’s running if you’re experiencing problems. Processes marked ‘locked’ or ‘freeing items’ are bad.
- If you get into trouble and need to delete all the rows in a table, use TRUNCATE TABLE [tblname] rather than DELETE FROM. This is significantly quicker. (Thanks Rainer for that one.)
- Most obviously – use indexes judiciously. Adding indexes slows down insert speed to allow better retrieval rate. If the tables are too index heavy the insert speed will slow down such that it causes more locking.
Not very generic, but at least easy to understand:
123.456789 becomes 123.45