Wednesday, May 23, 2012

Multiple connections on the same port socket C++

I need to accept multiple connections to the same port.
I'm using socket in C++, i want to do something like the SSH do.
I can do an ssh user@machine "ls -lathrR /" and run another command to the same machine, even if the first one still running.



How can i do that?



Thanks.





How can I make bash tab completion behave like vim tab completion?

I've been meaning to find a solution for this for YEARS.



I am sooo much more productive in vim when manipulating files than bash for this reason.



if I have



file_12390983421
file_12391983421
file_12340983421
file_12390986421


In bash and type file_1->tab , it obviously lists:



file_12390983421 file_12391983421 file_12340983421 file_12390986421


And this is a horrible boar and painful to work with.



The same sequence in vim will loop through the files one at a time.



Please someone tell me how to do this in bash, or if there is another shell that can do this, I'll switch tomorrow.





What is the best position to sit and to place your hands while you program?

Recently I've been more concerned about the way I sit while I code, I don't think I have any kind of injury yet but one of my coworkers had to take a couple of days off because of his column and I began to worry about this.
So, how do you sit? how do you place your hands? Do you recommend any keyboard in special? any chair? I have been looking into a new keyboard and maybe I' ll ask for it at work. Also my chair isn't top-notch so any budget oriented option?
Thanks, Joaquin.



related: keyboard for programmers , what is the best keyboard mouse for ergonomics or to prevent wrist pain? , What is the best physical operating environment for a developer?





dlls in SysWOW64 not found by application

I'm developing a C#/WPF app that talks to a USB device using some custom 32 bit dlls. It's developed as an x86 app, and installed with WIX. When I install the package on a 64-bit machine, the program files get installed to Program Files (x86) as I expect.



The dlls are installed to the SystemFolder using WIX. On 32-bit machines, this means C:\Windows\System32. On 64-bit, they end up in C:\Windows\SysWOW64. This is ok, but when I run my app, it is unable to find the dlls (it uses them via [DllImport...]).



So, what is the right way to make my app find the dlls, whether they are in System32 or SysWOW64?



Thanks
Tom





jQuery how to reverse a remove() event

I have this code:



$(window).resize(function() {
if($(window).height() < 768) {
$('div#navigation ul li br').remove()
} else {
}
})


Is it possible to reverse the remove event on else? I need to have those
tags in the same place as before the action.





Update with a LIMIT in zend framework

I would like to do a update and place LIMIT 1 as precaution.
Here is my code:



$vals = array();
$vals['status'] = 'closed';
$where = $write->quoteInto('id =?', $orderID);

$write->update("order", $vals ,$where);


Where can i add a LIMIT into this query?



(looks like has been asked in the past but i hope someone out there has the answer)





Sybase Check Constraint Evaluation

I'm trying to formulate some check constraints in SQL Anywhere 9.0.



Basically I have schema like this:



CREATE TABLE limits (
id INT IDENTITY PRIMARY KEY,
count INT NOT NULL
);

CREATE TABLE sum (
user INT,
limit INT,
my_number INT NOT NULL CHECK(my_number > 0),
PRIMARY KEY (user, limit)
);


I'm trying to force a constraint my_number for each limit to be at most count in table.



I've tried



CHECK ((SELECT sum(my_number) FROM sum WHERE limit = limit) <= (SELECT count FROM limits WHERE id = limit))


and



CHECK (((SELECT sum(my_number) FROM sum WHERE limit = limit) + my_number) <= (SELECT count FROM limits WHERE id = limit))


and they both seem not to do the correct thing. They are both off by one (meaning once you get a negative number, then insertion will fail, but not before that.



So my question is, with what version of the table are these subqueries being executed against? Is it the table before the insertion happens, or does the subquery check for consistency after the insert happens, and rolls back if it finds it invalid?