Posts

c - convert a pointer of array in Java -

i'm trying convert program in c java. don't know c programming, i'd understand bit btw. well i've got functions in c: static int memcmp( byte *a, byte *b, int len) { int i; (i = 0; < len; i++) if (a[i] != b[i]) return 0; return 1; } static int rfind(byte *data, int pos, int leng) { int i; (i = pos - leng; > -1; i--) if (memcmp(data+i, data+pos, leng)) return i; return pos; } that can't workout. seems function memcmp compare 2 blocks of memory. when size of data: printf("size %d \n", sizeof(data)); i got 8 result while orignal size can 32 or 40 (any documentation pointers welcome). anyone me translate bit java have gratitude (and more). thanks java doesn't have pointers, can't translate code directly. in c, can treat pointers arrays, whereas in java need use indexes same array. more or less direct translation can come with: public int rfind(byte[]...

Android getting RESULT_CANCELED when I specifically add RESULT_OK -

this problem, have main view shows 1 button, pressing button view shown. view has button, when button push current view finishs , control backs previous view. to show second view use startactivityforresult, put code here. private void startnewview() { intent = new intent(getapplicationcontext(), newview.class); startactivityforresult(it,view_id); } the view called has button event, here code button b = (button) findviewbyid(r.id.close); b.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { setresult(result_ok); finish(); } }); and finally, method onactivityresult in main view, here code protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if(requestcode == view_id && resultcode == result_ok) { tv = (textview) findviewbyid(r.id.tv); tv.settext("the...

Data model for timesheet to task and/or timesheet to project? -

let's want make simple project tracking system. manager can create project. can create tasks project. team members can record hours work each task or project whole. is following design t_timesheet table idea? timesheet_id - primary key, autoincrement project_id - not null, foreign key constraint t_project task_id - nullable, foreign key constraint t_task user_id - not null, foreign key constraint t_user hours - decimal or should this: timesheet_id - primary key, autoincrement task_id - not null, foreign key constraint t_task user_id - not null, foreign key constraint t_user hours - decimal in second option, intend have record in t_task labelled "miscellaneous items" foreign key relevant t_project record. i'll able track hours project aren't particular task. are of ideas above good? better? while believe nullable foreign keys have place in relational databases, in case tend towards second option. forces project manager explicitly ...

javascript - Can onclick take a function in a function? -

this want. onclick="pager(function2();) but doesn't seem work. take out semicolon: onclick="pager(function2())" http://jsfiddle.net/bqyvv/ you not passing function function, value. when element clicked, function2() called, , it's return value becomes argument pager() function. if function2 not return anything, pager receive undefined argument.

Can UPnP Discovery be done from Javascript? -

i'm working on webpage on want discover upnp devices, client maybe on different vlan server. so, upnp discovery needs happen on client. apparently udp not possible javascript. know if there way upnp discovery client's browser? javascript has no built-in raw networking capabilities. example, can't natively pings. can diy ping/port scanner using img tag, , setting src attribute target , testing response. but, other that, need plugin or activex. i suggest using java.

sockets - How to Broadcast to a shutdown system using java? -

we use socket.send(packet) function in java send "packet" given port. problem have send packet shutdown system using udp protocol. problem send() function first verifies whether host ip multicast or not. local area network of broadcast type. having problem using function. can please give me way ? do know how send udp packets in java? first of all, broadcasting must enabled in network. then, servers must join agreed multicast address. inetaddress address = inetaddress.getbyname( "230.0.0.1" ); multicastsocket socket = new multicastsocket( 12345 ); socket.joingroup( address ); when want activate system shutdown, send agreed message (for example, "die") multicast address. datagrampacket packet = new datagrampacket( buf, buf.length ); socket.receive( packet ); string received = new string( packet.getdata(), 0, packet.getlength() ); the servers when accept message should initiate shutdown flow.

Error while loading a file in Python-Set Up path Problem -

following error occurred while trying add or remove files in installation directory: [errno 13] permission denied: '/usr/local/lib/python2.6/dist-packages/test-easy-install-20294.pth' installation directory specified (via --install-dir, --prefix, or distutils default setting) was: /usr/local/lib/python2.6/dist-packages/ perhaps account not have write access directory? if installation directory system-owned directory, may need sign in administrator or "root" account. if not have administrative access machine, may wish choose different installation directory, preferably 1 listed in pythonpath environment variable. information on other options, may wish consult documentation at: http://peak.telecommunity.com/easyinstall.html please make appropriate changes system , try again. how change directory? or how make change accepts changes in root directory? the easiest way run command administrator privileges. looks you're using form of li...