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?

How do I enable SR-IOV for Mellanox ConnectX-3 Ubuntu 12.04.3?

How do I enable SR-IOV for Mellanox ConnectX-3 Ubuntu 12.04.3?

I have a Supermicro 2027TR-HTFRF server that I'm using as a xen server.
What I'm wanting to do is get SR-IOV operating for the Connectx-3 card so
that I can expose Infiniband to virtual machines.
Following this recipe I managed to get the I350 Ethernet to expose the VF's.
Adding /etc/modprobe.d/mlx4_core.conf containing
options max_vfs=4
Didn't create the virtual functions for the mellanox device despite the
fact that this is a valid parameter to the mlx4_core module. i.e.
The error I get is
mlx4_core: `4' invalid for parameter `max_vfs'
I also tried a value of 1 to which I got a similar error
mlx4_core: `1' invalid for parameter `max_vfs'
Output from lspci -v
06:00.0 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3]
Subsystem: Mellanox Technologies Device 0051
Flags: bus master, fast devsel, latency 0, IRQ 11
Memory at df900000 (64-bit, non-prefetchable) [size=1M]
Memory at de000000 (64-bit, prefetchable) [size=8M]
Capabilities: [40] Power Management version 3
Capabilities: [48] Vital Product Data
Capabilities: [9c] MSI-X: Enable- Count=128 Masked-
Capabilities: [60] Express Endpoint, MSI 00
Capabilities: [100] Alternative Routing-ID Interpretation (ARI)
Capabilities: [148] Device Serial Number 00-25-90-ff-ff-17-57-24
Capabilities: [18c] #19
Kernel modules: mlx4_core
So it would seem that SR-IOV is not available.
I then discovered this thread: http://community.mellanox.com/thread/1073
But I'm using ubuntu 12.04.
Next I installed mstflint using apt-get.
Then I identified what type of card it is.
mstflint -d 06:00.0 q
Unfortunately mstflint crashes.
Warning: memory access to device 06:00.0 failed: Input/output error.
Warning: Fallback on IO: much slower, and unsafe if device in use.
*** buffer overflow detected ***: mstflint terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x37)[0x7f66d91ac817]
Some of the strace output:
strace mstflint -d 06:00.0 q
...
open("/proc/bus/pci/06/00.0", O_RDWR|O_DSYNC) = 3
ioctl(3, IIOCNETDIF, 0xdf900000) = 0
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0xdf900000) =
0x7f0e0a200000
munmap(0x7f0e0a200000, 65536) = 0
close(3) = 0
open("/dev/mem", O_RDWR|O_DSYNC) = 3
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0xdf900000) =
0x7f0e092f2000
munmap(0x7f0e092f2000, 65536) = 0
close(3) = 0
write(2, "Warning: memory access to device"..., 136Warning: memory access
to device 06:00.0 failed: Input/output error.
Warning: Fallback on IO: much slower, and unsafe if device in use.
) = 136
open("/sys/bus/pci/devices/0000:06:00.0/config", O_RDWR|O_DSYNC) = 3
pwrite(3, "\375\374\373\372", 4, 88) = 4
pread(3, "\375\374\373\372", 4, 88) = 4
close(3) = 0
open("/dev/tty", O_RDWR|O_NOCTTY|O_NONBLOCK) = 3
writev(3, [{"*** ", 4}, {"buffer overflow detected", 24}, {" ***: ", 6},
{"mstflint", 8}, {" terminated\n", 12}], 5*** buffer overflow detected
***: mstflint terminated
) = 54
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7f0e0a3f9000
write(3, "======= Backtrace: =========\n", 29======= Backtrace: =========
) = 29
writev(3, [{"/lib/x86_64-linux-gnu/libc.so.6", 31}, {"(", 1},
{"__fortify_fail", 14}, {"+0x", 3}, {"37", 2}, {")", 1}, {"[0x", 3},
{"7f0e094fc817", 12}, {"]\n", 2}],
9/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x37)[0x7f0e094fc817]
) = 69
writev(3, [{"/lib/x86_64-linux-gnu/libc.so.6", 31}, {"(", 1}, {"+0x", 3},
{"109710", 6}, {")", 1}, {"[0x", 3}, {"7f0e094fb710", 12}, {"]\n", 2}],
8/lib/x86_64-linux-gnu/libc.so.6(+0x109710)[0x7f0e094fb710]
) = 59
writev(3, [{"/lib/x86_64-linux-gnu/libc.so.6", 31}, {"(", 1}, {"+0x", 3},
{"108b79", 6}, {")", 1}, {"[0x", 3}, {"7f0e094fab79", 12}, {"]\n", 2}],
8/lib/x86_64-linux-gnu/libc.so.6(+0x108b79)[0x7f0e094fab79]
) = 59
writev(3, [{"/lib/x86_64-linux-gnu/libc.so.6", 31}, {"(", 1},
{"_IO_default_xsputn", 18}, {"+0x", 3}, {"dd", 2}, {")", 1}, {"[0x", 3},
{"7f0e0946e13d", 12}, {"]\n", 2}],
9/lib/x86_64-linux-gnu/libc.so.6(_IO_default_xsputn+0xdd)[0x7f0e0946e13d]
) = 73
writev(3, [{"/lib/x86_64-linux-gnu/libc.so.6", 31}, {"(", 1},
{"_IO_vfprintf", 12}, {"+0x", 3}, {"1ae7", 4}, {")", 1}, {"[0x", 3},
{"7f0e0943c4a7", 12}, {"]\n", 2}],
9/lib/x86_64-linux-gnu/libc.so.6(_IO_vfprintf+0x1ae7)[0x7f0e0943c4a7]
) = 69
writev(3, [{"/lib/x86_64-linux-gnu/libc.so.6", 31}, {"(", 1},
{"__vsprintf_chk", 14}, {"+0x", 3}, {"94", 2}, {")", 1}, {"[0x", 3},
{"7f0e094fac14", 12}, {"]\n", 2}],
9/lib/x86_64-linux-gnu/libc.so.6(__vsprintf_chk+0x94)[0x7f0e094fac14]
) = 69
writev(3, [{"/lib/x86_64-linux-gnu/libc.so.6", 31}, {"(", 1},
{"__sprintf_chk", 13}, {"+0x", 3}, {"7d", 2}, {")", 1}, {"[0x", 3},
{"7f0e094fab5d", 12}, {"]\n", 2}],
9/lib/x86_64-linux-gnu/libc.so.6(__sprintf_chk+0x7d)[0x7f0e094fab5d]
) = 68
writev(3, [{"mstflint", 8}, {"[0x", 3}, {"40de46", 6}, {"]\n", 2}],
4mstflint[0x40de46]
) = 19
writev(3, [{"mstflint", 8}, {"[0x", 3}, {"40ee56", 6}, {"]\n", 2}],
4mstflint[0x40ee56]
) = 19
writev(3, [{"mstflint", 8}, {"[0x", 3}, {"406475", 6}, {"]\n", 2}],
4mstflint[0x406475]
) = 19
writev(3, [{"mstflint", 8}, {"[0x", 3}, {"408d00", 6}, {"]\n", 2}],
4mstflint[0x408d00]
) = 19
writev(3, [{"/lib/x86_64-linux-gnu/libc.so.6", 31}, {"(", 1},
{"__libc_start_main", 17}, {"+0x", 3}, {"ed", 2}, {")", 1}, {"[0x", 3},
{"7f0e0941376d", 12}, {"]\n", 2}],
9/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7f0e0941376d]
) = 72
writev(3, [{"mstflint", 8}, {"[0x", 3}, {"401af9", 6}, {"]\n", 2}],
4mstflint[0x401af9]
) = 19
write(3, "======= Memory map: ========\n", 29======= Memory map: ========
) = 29
open("/proc/self/maps", O_RDONLY) = 4
read(4, "00400000-0041a000 r-xp 00000000 "..., 1024) = 1024
write(3, "00400000-0041a000 r-xp 00000000 "..., 102400400000-0041a000 r-xp
00000000 08:01 220 /usr/bin/mstflint
00619000-0061a000 r--p 00019000 08:01 220
/usr/bin/mstflint
0061a000-0061b000 rw-p 0001a000 08:01 220
/usr/bin/mstflint
024a3000-024c4000 rw-p 00000000 00:00 0
[heap]
7f0e09302000-7f0e093f2000 rw-s df910000 00:05 1028
/dev/mem
7f0e093f2000-7f0e095a7000 r-xp 00000000 08:01 135350
/lib/x86_64-linux-gnu/libc-2.15.so
7f0e095a7000-7f0e097a6000 ---p 001b5000 08:01 135350
/lib/x86_64-linux-gnu/libc-2.15.so
7f0e097a6000-7f0e097aa000 r--p 001b4000 08:01 135350
/lib/x86_64-linux-gnu/libc-2.15.so
7f0e097aa000-7f0e097ac000 rw-p 001b8000 08:01 135350
/lib/x86_64-linux-gnu/libc-2.15.so
7f0e097ac000-7f0e097b1000 rw-p 00000000 00:00 0
7f0e097b1000-7f0e097c6000 r-xp 00000000 08:01 131116
/lib/x86_64-linux-gnu/libgcc_s.so.1) = 1024
read(4, "\n7f0e097c6000-7f0e099c5000 ---p "..., 1024) = 1024
write(3, "\n7f0e097c6000-7f0e099c5000 ---p "..., 1024
7f0e097c6000-7f0e099c5000 ---p 00015000 08:01 131116
/lib/x86_64-linux-gnu/libgcc_s.so.1
7f0e099c5000-7f0e099c6000 r--p 00014000 08:01 131116
/lib/x86_64-linux-gnu/libgcc_s.so.1
7f0e099c6000-7f0e099c7000 rw-p 00015000 08:01 131116
/lib/x86_64-linux-gnu/libgcc_s.so.1
7f0e099c7000-7f0e09ac2000 r-xp 00000000 08:01 135361
/lib/x86_64-linux-gnu/libm-2.15.so
7f0e09ac2000-7f0e09cc1000 ---p 000fb000 08:01 135361
/lib/x86_64-linux-gnu/libm-2.15.so
7f0e09cc1000-7f0e09cc2000 r--p 000fa000 08:01 135361
/lib/x86_64-linux-gnu/libm-2.15.so
7f0e09cc2000-7f0e09cc3000 rw-p 000fb000 08:01 135361
/lib/x86_64-linux-gnu/libm-2.15.so
7f0e09cc3000-7f0e09da5000 r-xp 00000000 08:01 30579
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f0e09da5000-7f0e09fa4000 ---p 000e2000 08:01 30579
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f0e09fa4000-7f0e09fac000 ) = 1024
read(4, "r--p 000e1000 08:01 30579 "..., 1024) = 1024
write(3, "r--p 000e1000 08:01 30579 "..., 1024r--p 000e1000 08:01
30579 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f0e09fac000-7f0e09fae000 rw-p 000e9000 08:01 30579
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f0e09fae000-7f0e09fc3000 rw-p 00000000 00:00 0
7f0e09fc3000-7f0e09fd9000 r-xp 00000000 08:01 131300
/lib/x86_64-linux-gnu/libz.so.1.2.3.4
7f0e09fd9000-7f0e0a1d8000 ---p 00016000 08:01 131300
/lib/x86_64-linux-gnu/libz.so.1.2.3.4
7f0e0a1d8000-7f0e0a1d9000 r--p 00015000 08:01 131300
/lib/x86_64-linux-gnu/libz.so.1.2.3.4
7f0e0a1d9000-7f0e0a1da000 rw-p 00016000 08:01 131300
/lib/x86_64-linux-gnu/libz.so.1.2.3.4
7f0e0a1da000-7f0e0a1fc000 r-xp 00000000 08:01 135367
/lib/x86_64-linux-gnu/ld-2.15.so
7f0e0a210000-7f0e0a300000 rw-s df910000 00:03 4026533088
/proc/bus/pci/06/00.0
7f0e0a300000-7f0e0a3f0000 rw-s df910000 00:0e 19851
/sys/devices/pci0000:00/0000:00:03.2/0000:06:) = 1024
read(4, "00.0/resource0\n7f0e0a3f0000-7f0e"..., 1024) = 570
write(3, "00.0/resource0\n7f0e0a3f0000-7f0e"..., 57000.0/resource0
7f0e0a3f0000-7f0e0a3f5000 rw-p 00000000 00:00 0
7f0e0a3f9000-7f0e0a3fc000 rw-p 00000000 00:00 0
7f0e0a3fc000-7f0e0a3fd000 r--p 00022000 08:01 135367
/lib/x86_64-linux-gnu/ld-2.15.so
7f0e0a3fd000-7f0e0a3ff000 rw-p 00023000 08:01 135367
/lib/x86_64-linux-gnu/ld-2.15.so
7fffdd53f000-7fffdd560000 rw-p 00000000 00:00 0
[stack]
7fffdd5ff000-7fffdd600000 r-xp 00000000 00:00 0
[vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
[vsyscall]
) = 570
read(4, "", 1024) = 0
close(4) = 0
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
gettid() = 4122
tgkill(4122, 4122, SIGABRT) = 0
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT (core dumped) +++
Aborted (core dumped)
At this point I'm somewhat stuck.



Update: I managed to obtain a firmware update from SuperMicro which has
SR-IOV enabled.
Also I needed to set options max_vfs= to options num_vfs=. It seems the
named parameter is slightly different. This was enough to get it working
under Ubuntu.
Installing the firmware I used this method: http://www.panticz.de/mellanox
But with the addition that I had to call insmod on each module before
calling mst start. Modprobe didn't work.

what is dconf and gvfs folders?

what is dconf and gvfs folders?

I recently installed samba but now I see the following files off my home
directory that are permissioned by root. Both folders are empty. Can I
remove them? I am not sure if this is related or not to samba or whether
it is safe to nix these.
find: `./.cache/dconf': Permission denied
find: `./.gvfs': Permission denied