SELECT * FROM tablename WHERE column LIKE 'M510%'
OR column LIKE 'M615%'
OR column LIKE 'M515%'
OR column LIKE 'M612%';
Monday, April 30, 2012
Monday, April 16, 2012
Constructor overloading in Perl
Base Class: ----------- #!/usr/bin/perl use strict; use Data::Dumper; #write package name: package Person; #write constructor sub new { #declare => hash & bless it and return it. my($class)=shift; my($self)={ _name=>shift, _sname=>shift, }; bless $self, $class; return $self; } 1; Derived class: -------------- #!/usr/bin/perl #define package: package Employee; use strict; use Data::Dumper; #use parent class use Person; #Define ISA our @ISA = qw(Person); #Define constructor with child and parent both: sub new { my($class)=@_; my($self)=$class->SUPER::new($_[1],$_[2]); $self->{_id} = $_[3]; $self->{_sal} = $_[4]; return ($self); } 1; Program: -------- use strict; use Data::Dumper; use Person; use Employee; sub main { my($obj)=Employee->new("mandar","pande","111515","1"); print "$obj->{_name}\n"; print "$obj->{_sname}\n"; print "$obj->{_id}\n"; print "$obj->{_sal}\n"; } main();
Multithreading in Perl
Found few good links with examples:
http://pages.swcp.com/~breadfan/threads/threads_shared.html
http://migo.sixbit.org/papers/Perl_Threads/slide-00.html
http://pages.swcp.com/~breadfan/threads/threads_shared.html
http://migo.sixbit.org/papers/Perl_Threads/slide-00.html
Monday, April 9, 2012
Awesome use case for tr command.
Use case : Remove all whitespaces but one from the output of any of the unix command ( for e. g. free -m )
Current command output:
[root@host ~]free -m
total used free shared buffers cached
Mem: 16046 15779 267 0 20 14269
-/+ buffers/cache: 1489 14557
Swap: 4000 0 4000
with tr,
[root@host ~]free -m |tr -s " "
total used free shared buffers cached
Mem: 16046 15778 268 0 20 14269
-/+ buffers/cache: 1488 14558
Swap: 4000 0 4000
where,
-s : replace each input sequence of a repeated character that is listed in SET1( in our case it is space character " " ) with a single occurrence of that character.
In this way we can get output with only one space character as a delimiter.
Use case : Remove all whitespaces but one from the output of any of the unix command ( for e. g. free -m )
Current command output:
[root@host ~]free -m
total used free shared buffers cached
Mem: 16046 15779 267 0 20 14269
-/+ buffers/cache: 1489 14557
Swap: 4000 0 4000
with tr,
[root@host ~]free -m |tr -s " "
total used free shared buffers cached
Mem: 16046 15778 268 0 20 14269
-/+ buffers/cache: 1488 14558
Swap: 4000 0 4000
where,
-s : replace each input sequence of a repeated character that is listed in SET1( in our case it is space character " " ) with a single occurrence of that character.
In this way we can get output with only one space character as a delimiter.
How to execute a script with exit status from bash shell in background ?
=>
[root@host ~]cat /tmp/a
#!/bin/bash
sleep 1
echo 1% complete
sleep 1
echo 10% complete
sleep 1
echo 100% complete
exit 12
[root@host~] (/tmp/a > /tmp/stdout;echo $? > /tmp/ret) &
Verification :
========
[root@puneoshub ~](/tmp/a > /tmp/stdout;echo $? > /tmp/ret) & <----------- way to execute.
[1] 24110
[root@puneoshub ~]
[1]+ Done ( /tmp/a > /tmp/stdout; echo $? > /tmp/ret )
[root@puneoshub ~]cat /tmp/stdout /tmp/ret
1% complete < ----- STDOUT
10% complete
100% complete
12 < ----- RETURN
=>
[root@host ~]cat /tmp/a
#!/bin/bash
sleep 1
echo 1% complete
sleep 1
echo 10% complete
sleep 1
echo 100% complete
exit 12
[root@host~] (/tmp/a > /tmp/stdout;echo $? > /tmp/ret) &
Verification :
========
[root@puneoshub ~](/tmp/a > /tmp/stdout;echo $? > /tmp/ret) & <----------- way to execute.
[1] 24110
[root@puneoshub ~]
[1]+ Done ( /tmp/a > /tmp/stdout; echo $? > /tmp/ret )
[root@puneoshub ~]cat /tmp/stdout /tmp/ret
1% complete < ----- STDOUT
10% complete
100% complete
12 < ----- RETURN
Sunday, April 8, 2012
Perl Regex continue......
In order to match a string in a multiline string use the 'm' modifier.
For Ex:
The string is: "Hello wassup\n How u doing\n goaway"
and we have to match "How u doing", it cant be match the same way as perl doesn't check after newline if we dont tell it to.
So use:
$string =~ /How u doing/m
Continue with the perl regex ....... cheers!!!
For Ex:
The string is: "Hello wassup\n How u doing\n goaway"
and we have to match "How u doing", it cant be match the same way as perl doesn't check after newline if we dont tell it to.
So use:
$string =~ /How u doing/m
Continue with the perl regex ....... cheers!!!
Wednesday, April 4, 2012
MySQL Benchmark
How my server is performing ?
===========================
No matter the result of the expression, the result of benchmark() will always be 0. The purpose of benchmark() is not to retrieve the result of the expression but to see how long it takes to repeat the expression for a specific number of times. For example, the following command executes the expression 10 + 10 one million times:
mysql> SELECT BENCHMARK(1000000,10+10);
+--------------------------+
| BENCHMARK(1000000,10+10) |
+--------------------------+
| 0 |
+--------------------------+
1 row in set (0.14 sec)
===========================
No matter the result of the expression, the result of benchmark() will always be 0. The purpose of benchmark() is not to retrieve the result of the expression but to see how long it takes to repeat the expression for a specific number of times. For example, the following command executes the expression 10 + 10 one million times:
mysql> SELECT BENCHMARK(1000000,10+10);
+--------------------------+
| BENCHMARK(1000000,10+10) |
+--------------------------+
| 0 |
+--------------------------+
1 row in set (0.14 sec)
Tuesday, April 3, 2012
Sunday, April 1, 2012
Comparison of Different SQL Implementation
Guys,
Found a comprehensive research.
Check out this article, it expalins quite interesting things about diff DB's and also a comparison between them, which is a most faq in interviews.
http://troels.arvin.dk/db/rdbms/
Found a comprehensive research.
Check out this article, it expalins quite interesting things about diff DB's and also a comparison between them, which is a most faq in interviews.
http://troels.arvin.dk/db/rdbms/
Subscribe to:
Posts (Atom)