Recently, the local mains electrical sub-station failed. After the power cut and numerous brown-outs my ONN DTR160 PVR (Personal Video Recorder), based upon the Vestel T816, failed to start up. The display just kept saying, 'Starting...'.
I removed the mains power and removed the cover. I disconnected the 160Gb EIDE (Western Digital) Hard Drive from its power and IDE connectors. I switch on the PVR and then shortly got TV channels and 'HDD failure' on the display. If it had not started then in all likelyhood it would have been the Power Supply.
Finding that the HDD was the failure, I took it out and decided to hook it up to my Linux Kubuntu PC. If you don't have Linux yourself, there are Live Linux CD/DVD that you can download and burn to disk. Booting from these, you have access to a range of tools that I have discussed before on this Blog.
I started GParted (Partition Editor) and selected the last device that was 160GB sized. This showed two partitions, a small boot and a larger storage partition. Both of ext2 filetype but the main partition had a Exclamation icon next to it, signifying that the partition was corrupt. I could at this point have tried to repair the partition with other tools but, as I did not have any programs I wanted to keep, I decided to format the partition. DO NOT format the smaller boot partition!
Replacing the HDD back into the PVR it started! I went through the Installation Setup which, formatted the HDD again and I was left with a working PVR again. :-)
Currently known variations include: Alba ALDTR160 (Argos) • Digihome DTR80 and DTR160 (Argos) • Hitachi HDR082, HDR162, HDR163 & HDR253 (Argos) • Logik LPVR168
(Currys/Dixons) • ONN DTR80 and DTR160 (Asda) • Sharp TU-R162H &
TU-R252H • Wharfedale DTR160 HDMI and DTR250 HDMI (Argos) • Wharfedale
LP160DTRHDMI and LP250DTRHDMI (Argos)
Sunday, 2 December 2012
Thursday, 29 November 2012
TIP: How do I type the copyright symbol ©?
Mac
Simply enter Option + G.
M$ Windows
Whilst Num Lock is on, hold down the ALT key, keep depressed and type on the Numeric keypad '0169'.
Linux
This works on (k)ubuntu at least, using a UK keyboard.
AltGr + Shift + C keys.
Addendum
The above Linux solution did not work in GIMP for me when I was trying to create a Watermark for my photos. The solution was to do the above in something like Kate (text editor), highlight and copy it to the Clip board and then paste it into GIMP's text editor window.
Simply enter Option + G.
M$ Windows
Whilst Num Lock is on, hold down the ALT key, keep depressed and type on the Numeric keypad '0169'.
Linux
This works on (k)ubuntu at least, using a UK keyboard.
AltGr + Shift + C keys.
Addendum
The above Linux solution did not work in GIMP for me when I was trying to create a Watermark for my photos. The solution was to do the above in something like Kate (text editor), highlight and copy it to the Clip board and then paste it into GIMP's text editor window.
Wednesday, 28 November 2012
MySQL Correct character case of names
Sometimes a client will pass you some data with forenames, surnames or, both with people's names all in upper-case, lower-case or, a jumbled mess. This looks a bit unprofessional when you are doing mail shots or e-mail mailings.
The below code shows how you can select the forename field, correcting the data's case. It sets the first character to upper-case and the rest, lower-case.
Code:
Alternatively, if you want to correct the data in the database table, you would...
Code:
If the table contains a lot of data then, you may wish to run the UPDATE code over night, out of hours!
The below code shows how you can select the forename field, correcting the data's case. It sets the first character to upper-case and the rest, lower-case.
Code:
SELECT CONCAT(UPPER(LEFT(forename, 1)), (SUBSTRING(LOWER(forename), 2))) As fname
FROM table1;
FROM table1;
Alternatively, if you want to correct the data in the database table, you would...
Code:
UPDATE table1 SET forename = CONCAT(UPPER(LEFT(forename, 1)), (SUBSTRING(LOWER(forename), 2)));
If the table contains a lot of data then, you may wish to run the UPDATE code over night, out of hours!
Monday, 26 November 2012
Hello!
I've been Blogging for some years now, using phpBB2. Mainly posting Hint 'n Tips on Technical stuff but, that old forum software (phpBB) is vulnerable to attack (XSS).
So, I am moving my old postings to here and I will blog my knowledge here from now on.
I will blog about:-
Amateur Radio - although I am taking a break from the hobby just now.
Computing - in general, Linux, Ubuntu, M$ Windows, Postfix (Email server), MySQL (Database server).
Gran Canaria - a beautiful Canary Island with its rich variety of micro climates and friendly locals. A Photographers dream. A lot of routes/treks for walkers.
Photography - My interest in Landscapes and Wildlife.
The picture in the background is one of mine of Anfi Del Mar, Arguineguin, Gran Canaria where my wife and I have a time share.
So, I am moving my old postings to here and I will blog my knowledge here from now on.
I will blog about:-
Amateur Radio - although I am taking a break from the hobby just now.
Computing - in general, Linux, Ubuntu, M$ Windows, Postfix (Email server), MySQL (Database server).
Gran Canaria - a beautiful Canary Island with its rich variety of micro climates and friendly locals. A Photographers dream. A lot of routes/treks for walkers.
Photography - My interest in Landscapes and Wildlife.
The picture in the background is one of mine of Anfi Del Mar, Arguineguin, Gran Canaria where my wife and I have a time share.
Saturday, 15 September 2012
linux BASH - replacing text in a file
If you want to replace some text within a file, that is too large to open in a GUI application then, this is when you fall back on the command line tools like sed.
But to make the change permanent, you have to add -i to the command:
Code:
Sed can also use regular expressions, so it's a very powerful tool.
The above searches for 'Hello' and replaces it with 'hello'.
Thanks to Eric_T for this which, I put here as a reminder to myself.
Code:
A Note About Bash Escape Character
A non-quoted backslash \ is the Bash escape character. It preserves the literal value of the next character that follows, with the exception of newline. If a \newline pair appears, and the backslash itself is not quoted, the \newline is treated as a line continuation (that is, it is removed from the input stream and effectively ignored). This is useful when you would like to deal with UNIX paths. In this example, the sed command is used to replace UNIX path "/nfs/apache/logs/rawlogs/access.log" with "__DOMAIN_LOG_FILE__":
Code:
The $_r1 is escaped using bash find and replace parameter substitution syntax to replace each occurrence of / with \/.
Thanks to Vivek Gite
http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/
Very useful for replacing repetitive text string within a .csv file!
But to make the change permanent, you have to add -i to the command:
Code:
Syntax:
sed -i 's/<old_word>/<new_word>/g' <file>
sed 's/<old_word>/<new_word>/g' input.txt > output.txt
sed -i 's/Hello/hello/g' input.txt
sed -i 's/<old_word>/<new_word>/g' <file>
sed 's/<old_word>/<new_word>/g' input.txt > output.txt
sed -i 's/Hello/hello/g' input.txt
Sed can also use regular expressions, so it's a very powerful tool.
The above searches for 'Hello' and replaces it with 'hello'.
Thanks to Eric_T for this which, I put here as a reminder to myself.
Code:
#!/bin/bash
OLD="xyz"
NEW="abc"
DPATH="/home/you/foo/*.txt"
BPATH="/home/you/bakup/foo"
TFILE="/tmp/out.tmp.$$"
[ ! -d $BPATH ] && mkdir -p $BPATH || :
for f in $DPATH
do
if [ -f $f -a -r $f ]; then
/bin/cp -f $f $BPATH
sed "s/$OLD/$NEW/g" "$f" > $TFILE && mv $TFILE "$f"
else
echo "Error: Cannot read $f"
fi
done
/bin/rm $TFILE
OLD="xyz"
NEW="abc"
DPATH="/home/you/foo/*.txt"
BPATH="/home/you/bakup/foo"
TFILE="/tmp/out.tmp.$$"
[ ! -d $BPATH ] && mkdir -p $BPATH || :
for f in $DPATH
do
if [ -f $f -a -r $f ]; then
/bin/cp -f $f $BPATH
sed "s/$OLD/$NEW/g" "$f" > $TFILE && mv $TFILE "$f"
else
echo "Error: Cannot read $f"
fi
done
/bin/rm $TFILE
A Note About Bash Escape Character
A non-quoted backslash \ is the Bash escape character. It preserves the literal value of the next character that follows, with the exception of newline. If a \newline pair appears, and the backslash itself is not quoted, the \newline is treated as a line continuation (that is, it is removed from the input stream and effectively ignored). This is useful when you would like to deal with UNIX paths. In this example, the sed command is used to replace UNIX path "/nfs/apache/logs/rawlogs/access.log" with "__DOMAIN_LOG_FILE__":
Code:
#!/bin/bash
## Our path
_r1="/nfs/apache/logs/rawlogs/access.log"
## Escape path for sed using bash find and replace
_r1="${_r1//\//\\/}"
# replace __DOMAIN_LOG_FILE__ in our sample.awstats.conf
sed -e "s/__DOMAIN_LOG_FILE__/${_r1}/" /nfs/conf/awstats/sample.awstats.conf > /nfs/apache/logs/awstats/awstats.conf
# call awstats
/usr/bin/awstats -c /nfs/apache/logs/awstats/awstats.conf
## Our path
_r1="/nfs/apache/logs/rawlogs/access.log"
## Escape path for sed using bash find and replace
_r1="${_r1//\//\\/}"
# replace __DOMAIN_LOG_FILE__ in our sample.awstats.conf
sed -e "s/__DOMAIN_LOG_FILE__/${_r1}/" /nfs/conf/awstats/sample.awstats.conf > /nfs/apache/logs/awstats/awstats.conf
# call awstats
/usr/bin/awstats -c /nfs/apache/logs/awstats/awstats.conf
The $_r1 is escaped using bash find and replace parameter substitution syntax to replace each occurrence of / with \/.
Thanks to Vivek Gite
http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/
Very useful for replacing repetitive text string within a .csv file!
Wednesday, 22 August 2012
Convert a Tab separated to Comma separated file
If you want to replace some text within a file, that is too large to open in a GUI application then, this is when you fall back on the command line tools.
Sometimes I get a Tab separated (.tsv/.txt) file and I need to convert it to a Comma separated (.csv) file before I can import it into a database table.
On a Linux server:
Code:
Substitute 'input' for the original filename and 'output' for the desired output filename.
Sometimes I get a Tab separated (.tsv/.txt) file and I need to convert it to a Comma separated (.csv) file before I can import it into a database table.
On a Linux server:
Code:
tr -s '\t' <input | tr '\t' ',' >output
Substitute 'input' for the original filename and 'output' for the desired output filename.
Tuesday, 14 August 2012
MySQL distinct count of data across multiple tables
You want to do a unique count of data across multiple tables.
Below is an example of getting a count of unique email addresses across two tables. Actually, I am looking for Females, aged 25 to 45 in the East Midlands, UK. I don't want duplicates because, I would not want to email the same person twice!
Code:
I hope that makes sense. So, you have multiple selects, joined by the 'UNION', wrapped by the outer query which counts the distinct email addresses of the tables it embodies (as many as you want).
The 'As SubQueryAlias' at the end is needed to pull it together or, SQL will throw an error.
Below is an example of getting a count of unique email addresses across two tables. Actually, I am looking for Females, aged 25 to 45 in the East Midlands, UK. I don't want duplicates because, I would not want to email the same person twice!
Code:
SELECT COUNT(DISTINCT email) As East_Midlands
FROM (
SELECT email
FROM table_a
WHERE (gender = 'F' OR LOWER(title IN ('ms', 'miss', 'mrs')))
AND str_to_date(date, '%d/%m/%Y') BETWEEN '1967-01-01' AND '1987-08-13'
AND (SUBSTRING(postcode,1,2) IN ('CB','CO','DE','DN','IP','LE','LN','NG','NR','PE') OR postcode LIKE 'S[1-9]%')
UNION
SELECT email
FROM table_b
WHERE (gender = 'F' OR LOWER(title IN ('ms', 'miss', 'mrs')))
AND str_to_date(DOB, '%Y%m%d') BETWEEN '1967-01-01' AND '1987-08-13'
AND (SUBSTRING(postcode,1,2) IN ('CB','CO','DE','DN','IP','LE','LN','NG','NR','PE') OR postcode LIKE 'S[1-9]%')
) As SubQueryAlias;
FROM (
SELECT email
FROM table_a
WHERE (gender = 'F' OR LOWER(title IN ('ms', 'miss', 'mrs')))
AND str_to_date(date, '%d/%m/%Y') BETWEEN '1967-01-01' AND '1987-08-13'
AND (SUBSTRING(postcode,1,2) IN ('CB','CO','DE','DN','IP','LE','LN','NG','NR','PE') OR postcode LIKE 'S[1-9]%')
UNION
SELECT email
FROM table_b
WHERE (gender = 'F' OR LOWER(title IN ('ms', 'miss', 'mrs')))
AND str_to_date(DOB, '%Y%m%d') BETWEEN '1967-01-01' AND '1987-08-13'
AND (SUBSTRING(postcode,1,2) IN ('CB','CO','DE','DN','IP','LE','LN','NG','NR','PE') OR postcode LIKE 'S[1-9]%')
) As SubQueryAlias;
I hope that makes sense. So, you have multiple selects, joined by the 'UNION', wrapped by the outer query which counts the distinct email addresses of the tables it embodies (as many as you want).
The 'As SubQueryAlias' at the end is needed to pull it together or, SQL will throw an error.
Subscribe to:
Posts (Atom)