Search found 212 matches

by chris
Fri Mar 14, 2014 6:56 pm
Forum: SQL
Topic: Solved: Increment a number in database
Replies: 2
Views: 36733

Re: Increment a number in database

You can try the following, it should work in MySQL:

Code: Select all

UDPATE table SET num= num +1 WHERE id='x';
This way MySQL is doing the counting, and not your application or script.
Doesn't have to +1, it can do any counting.
by chris
Tue Nov 05, 2013 8:34 pm
Forum: Apache
Topic: Apache won't start
Replies: 1
Views: 63927

Re: Apache won't start

I had the same problem once.

I forgot to add the "hostname" in the file:
/etc/hosts

127.0.0.1 localhost HOSTNAME
by chris
Mon Oct 21, 2013 7:18 pm
Forum: Shell
Topic: Solved: Replace a line in a file with shell
Replies: 2
Views: 75846

Re: Replace a line in a file with shell

You can use sed
It is a very useful program with lots of option (Check the man page > man sed )

sed -i "s/12345678/${REPLACE}/g" $FILE
this replaces the string 12345678 with the contents of variable $REPLACE in the file $FILE.
the -i option let you edit the file

But if you want to replace a ...
by chris
Tue Oct 15, 2013 8:44 pm
Forum: PHP
Topic: Change the timezone for a script
Replies: 2
Views: 68351

Re: Change the timezone for a script

If you want to set it for all the scripts,
you can set it in php.ini

Code: Select all

[Date]
date.timezone = Your/Timezone
by chris
Tue Oct 15, 2013 6:02 pm
Forum: PHP
Topic: Change the timezone for a script
Replies: 2
Views: 68351

Re: Change the timezone for a script

You can use the date_default_timezone_set() function

Code: Select all

date_default_timezone_set('America/Los_Angeles');
print date("Y-m-d");
date_default_timezone_set('Europe/Brussels');
print date("Y-m-d");
by chris
Wed Oct 09, 2013 7:38 pm
Forum: Shell
Topic: Solved: bash create md5 from string
Replies: 2
Views: 73125

Re: bash create md5 from string

You can pipe it using |

echo -n "test" | md5sum
(You need option -n because else md5sum will calculate the string with newline char.)

should give something like:
098f6bcd4621d373cade4e832627b4f6 -

if you don't like the - at the end
echo -n "test" | md5sum | gawk '{ print $1 }'
by chris
Thu Sep 05, 2013 7:37 pm
Forum: General
Topic: Linux warning: database /etc/mail/aliases.db is older than
Replies: 1
Views: 59343

Re: Linux warning: database /etc/mail/aliases.db is older th

this is the database postfix uses to deliver the mails.

/etc/mail/aliases is the plain text file you can update.
If you didn't update it, check it for any strange user names.
Perhaps you upgraded postfix, could have changed the date stamp of the file?

/etc/mail/aliases.db is the hashed file used ...
by chris
Sat Aug 31, 2013 1:16 pm
Forum: Shell
Topic: grep multiple words
Replies: 1
Views: 62195

Re: grep multiple words

grep has an -E option (--extended-regexp)
This allows to us regular expressions.

Code: Select all

grep -E 'right|left' name_of_file.txt
You can check for more than 2:

Code: Select all

grep -E 'right|left|up|down' name_of_file.txt
by chris
Thu Aug 15, 2013 10:59 pm
Forum: PHP
Topic: Generate random colors
Replies: 1
Views: 57474

Re: Generate random colors

I don't know of a special function,
but this is a function I use.

function random_color()
{
$r=rand(128,255);
$g=rand(128,255);
$b=rand(128,255);
$color=dechex($r).dechex($g).dechex($b);
return "#".$color;
}
by chris
Tue Jul 09, 2013 10:34 am
Forum: Servers
Topic: Linux update/install new kernel
Replies: 1
Views: 67686

Re: Linux update/install new kernel

Well most of the time your linux flavor has some automatic upgrade tools.
gentoo : emerge
debian/ubuntu : apt-get

I recommend you use those.

But if you want to do it manually,
you can download the latest kernel from https://www.kernel.org/
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux ...