Thursday, 3 October 2013

How to remove space before and ending of text?

How to remove space before and ending of text?

For example : I have a string like that: " Text is text ".
Now i want to use Javascript to remove all space before and ending of that
string to have result :
"Text is text".
How can I that with Javascript. Thank for your help.

Wednesday, 2 October 2013

getting checked value from checkbox thats taking data from database

getting checked value from checkbox thats taking data from database

I have problem to get to the checked value in checkbox. I have first query
that is taking names of the tables in database and second query that is
taking names of the columns of that tables. Names of the columns are
displayed in a checkbox, but i have problem to take that values from the
checkbox. I know I should use $_POST['kolona'] but somehow that variable
its not recognized:
if(mysqli_connect_errno())
{
echo "Error: Greška u konekciji";
exit;
}
$sql1 = "SHOW TABLES FROM db_baza";
$result1 = mysql_query($sql1);
if (!$result1)
{
echo "DB Error, could not list tables\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row1 = mysql_fetch_row($result1))
{
echo "<div id='blok'
style='width:200px;height:200px;background-color:red;margin:20px;float:left;'>{$row1[0]}"."</br>";
$tablename=$row1[0];
$sql2="SELECT column_name FROM information_schema.columns WHERE
table_name = '{$tablename}'";
$result2= mysql_query($sql2);
while($row2=mysql_fetch_row($result2))
echo "<form id='forma1' action='' method='POST'><input type='checkbox'
name='kolona[]' value='{$row2[0]}' />{$row2[0]}</br>";
echo "<input type='submit' name='submit' value='{$tablename}'/></form>";
echo "</div>";
}
if(isset($_POST['submit']))
if(isset($_POST['kolona'])
echo 1;
?>
So, I am just trying to echo number one, i will need it for other stuff
but just for the example.

Why can I not pass to_lower_copy directly to transform instead of wrapping it in a lambda?

Why can I not pass to_lower_copy directly to transform instead of wrapping
it in a lambda?

I'm trying to use boost::to_lower_copy and std::transform to lower-case a
bunch of strings. As below, Variant 1, using a lamdba works; Variant 2
also works demonstrating that that's the right template-overload the
compiler picks. But the lambda is silly – all it does is forward the
single argument along to boost::to_lower_copy. But Variant 3, using the
function template directly doesn't compile, even if I instantiate it. What
am I missing?
I have clang version 3.3 (tags/RELEASE_33/rc3), using
libstdc++-4.8.1-1.fc19.i686 and boost-1.53.0-14.fc19.i686.
vector<string> strings = {"Foo", "Bar"};
vector<string> lower_cased_strings;
transform(
strings.begin(),
strings.end(),
inserter(lower_cased_strings, lower_cased_strings.end()),
// Variant 1
// [](const string &word) {
// return boost::to_lower_copy(word);
// }
// Variant 2
// [](const string &word) {
// return boost::to_lower_copy<string>(word);
// }
// Variant 3
boost::to_lower_copy<string>
);
> clang++ -std=c++11 lowercase.cxx
In file included from lowercase.cxx:3:
In file included from /usr/include/boost/algorithm/string.hpp:18:
In file included from
/usr/include/boost/algorithm/string/std_containers_traits.hpp:23:
In file included from
/usr/include/boost/algorithm/string/std/slist_traits.hpp:16:
In file included from
/usr/lib/gcc/i686-redhat-linux/4.8.1/../../../../include/c++/4.8.1/ext/slist:47:
In file included from
/usr/lib/gcc/i686-redhat-linux/4.8.1/../../../../include/c++/4.8.1/algorithm:62:
/usr/lib/gcc/i686-redhat-linux/4.8.1/../../../../include/c++/4.8.1/bits/stl_algo.h:4949:33:
error: too few arguments to function call, expected 2, have 1
*__result = __unary_op(*__first);
~~~~~~~~~~ ^
lowercase.cxx:11:5: note: in instantiation of function template
specialization
'std::transform<__gnu_cxx::__normal_iterator<std::basic_string<char> *,
std::vector<std::basic_string<char>,
std::allocator<std::basic_string<char> > > >,
std::insert_iterator<std::vector<std::basic_string<char>,
std::allocator<std::basic_string<char> > > >, std::basic_string<char>
(*)(const std::basic_string<char>
&, const std::locale &)>' requested here
transform(
^

How to find difference between two columns data?

How to find difference between two columns data?

I have a temp table with two columns of integer data i want to find the
difference between two columns in 3rd column.
#TEMP1
Present previous
59 88
75 75
45 45
77 88
09 08
#temp2
Difference
29
0
0
11
-1
Is this possible ??

working with object in C#

working with object in C#

consider the variable ob4 as shown in figure
now : how can i reach ob4[0]->[0,2]
var o=ob4[0];
double[,] p=(double[,]) o[0,0];
the line (double[,] p=(double[,]) o[0,0];) gives the following error :
Cannot apply indexing with [] to an expression of type 'object'

Tuesday, 1 October 2013

Where is disk buffer cache situated

Where is disk buffer cache situated

I have read that The buffer cache interfaces with block devices, and
caches recently used meta-data disk blocks. The Linux kernel reads file
data through the buffer cache, but keeps the data in the page cache for
reuse on future reads.
I know that page cache is situated at main memory. Whether its true with
buffer cache also?
If buffer cache is in main memory, how access is made to it. Whether any
mechanism like paging is used for accessing buffer cache?

assign list of parent class reference with list of child class object does not work C#

assign list of parent class reference with list of child class object does
not work C#

I am new to C#. I have a parent class declared:
class PmdTable
{
}
and I have a child class
class PmdSdStageCfg : PmdTable
{
Now it complains if I do like:
List<OracleObject.PmdTable> instanceList = new List<PmdSdStageCfg>();
The error says"Cannot implicityly convert type
'System.Collections.Generic.List' to 'System.Collection.Generics.List'".
Since PmdTable is the parent class. Why this does not work?