Posts

Showing posts from June, 2013

Qt TCP/IP socket connection check -

i writing qt tcp/ip client. want check connection state server before send data sever. far knowledge can following methods use bool ' connectionstate ', set variable when connected sever , reset variable on disconnected() signal. before sending data server (client->write()) check value of variable. use ' client->state() == qtcpsocket::connectedstate ' way check connection state. which practice. or other method this. thanks in advance. qtcpsocket derived qabstractsocket , provides state() function. returns 1 of following enums: - enum socketstate { unconnectedstate, hostlookupstate, connectingstate, connectedstate, ..., listeningstate } so, assuming m_psocket qtcpsocket , check if connected:- bool connected = (m_psocket->state() == qtcpsocket::connectedstate); you add boolean , keep track of state, if network error occurs need ensure in-sync actual connection state.

android connection to php for sending login verification code to mobile -

i developing android app website.in website login, every time after checking username , password verification code send user filling next part of login page.in android app same functionalities able check username , password.but not sure if possible trigger php code sending verification code mobile.please tell me possible or not.i using httppost in android json parsing. sndactivation_code.php <?php set_include_path("/home2/tradeni1/php"); require_once("http/request2.php"); if(!isset($_session)) { session_start(); } if(isset($_request['user_id'])) { $id=$_session['uid']; $sql=mysql_query("insert code (`id` ,`code` ,`user_id` ,`status`) values ('' , '', '$id','0')"); $lastid=mysql_insert_id(); $code=rand(100000,999999);//"stock_".$lastid; $_session['code']=$code; $sql1=mysql_query("update code set code = '$code' id='$lastid'"); $user_res = mysql_query(&quo

mysql - Join operation for two different database tables on different server -

is there way use join operation 2 tables different databases? both databases on different server. if both databases mysql, federated engine provides functionality join mysql databases in different servers. , read limitations too. wikipedia: mysql federated storage engine mysql relational database management system storage engine allows user create table local representation of foreign (remote) table. utilizes mysql client library api data transport, treating remote data source same way other storage engines treat local data sources whether myd files (myisam), memory (cluster, heap), or tablespace (innodb). each federated table defined there 1 .frm (data definition file containing information such url of data source). actual data can exist on local or remote mysql instance. to create federated table, 1 has specify url in "connection" string: create table t1 ( int, b varchar(32)) engine=federated connection='mysql://user@hostname/test/t1' the

python - AttributeError: 'module' object has no attribute 'cache' -

import suds s = suds.client.client('http://hello-world.org/ttsoapcgi.wsdl', cache=suds.cache.nocache()) i getting: attributeerror: 'module' object has no attribute 'cache' above line. i have installed suds 0.3.7 version what's reason , how solve ? update suds version 0.4 the api used not present in suds 0.3.7 version

libgdx+box2d joints not working properly under gravity -

i trying create pendulum using box2d/libgdx connecting static , dynamic body. have tried various types of joints distance joint, rope joint , revolute joint under gravity dynamic body ends escaping down after being constrained joint. in 0 gravity joints work properly. know must doing silly. world.getbodies(p); distancejointdef djd=new distancejointdef(); djd.bodya=p.get(0); djd.bodyb=p.get(1); djd.localanchora.set(0,0); djd.localanchorb.set(0,0); djd.collideconnected=true; distancejoint pend=(distancejoint)world.createjoint(djd); pend.setlength(50); ps. have yet implemented contact listener .i have not figured out how this. putting collision listener help? if question correctly, moving body falls irrespective of type of joint applied. 1 reason why happen because may have defined both anchor , pendulum dynamic bodies, , both fall same way due gravity. i assuming not yet rendering anchor bo

java - working with JavaMailApi in jsp -

i working registration page in need send verification link mail,while executing got error , saying java.net.connectexception: connection refused: connect please me thanku register.jsp <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>registration</title> </head> <body> <%! dbcreation creation; connection connection; %> <% string uid=request.getparameter("userid"); string pwd=request.getparameter("pwd"); string fname=request.getparameter("fname"); string lname=request.getparameter("lname"); string email=request.getparameter("email"); string location=request.getparameter("location"); string encpwd=encryptpwd(pwd); system.out.println(encpwd); connection=dbcreation.getconnection(); string result; // recipient's email id needs mentioned.

php - insert variable to mysql database as utf-8 -

i have value in other language , want use utf-8 value.for use code store variable in database. <?php $fname=$_post['fname']; $lname=$_post['lname']; $mysqli = new mysqli(host, user, password, database); $stmt=$mysqli->prepare("insert user (fname , lname) values (? , ? ) "); $stmt->bind_param("ss",$fname,$lname); $stmt->execute(); ?> i set collation fname , lname column utf-8.but not know how modify database connection insert variable utf-8.i set collation of user table utf-8. try: header("content-type: text/html; charset=utf-8"); // @ top of file $mysqli->set_charset("utf8"); // before query set charset , header

c# - Can I deselect something in MS Word that had earlier been selected in the program -

i have piece of code part of event handling selecting image in word document , copying in file. after event handler done, image shown selected when return word after event has been handled. code snippet follows : foreach (word.inlineshape shape in shapes) { string filepath = "somepath"; shape.select(); word.application application = globals.thisaddin.application; application.selection.copyaspicture(); computer comp = new computer(); image image = comp.clipboard.getimage(); image.save(filepath, system.drawing.imaging.imageformat.jpeg); comp.clipboard.clear(); } i want shape should not shown selected because shape selection part of event handling. is there way deselect shape. thanx suggestions. you deselect current selection using application.selection.collapse()

java - SWT Label with horizontal line not showing correctly -

Image
i'm trying display label in 2-columned gridlayout. can't seem make work display both text , horizontal line underneath: public void foo(){ popupshell = new shell(display.getdefault(), swt.no_trim | swt.on_top | swt.modeless); //popupshell.setlayoutdata(new griddata(griddata.fill_horizontal)); popupshell.setlayout(createnomarginlayout(2, false)); label history = new label(popupshell, swt.separator | swt.shadow_out | swt.horizontal); history.settext("history"); history.setvisible(true); label fill = new label(popupshell, swt.none); fill.setsize(0,30); } public static gridlayout createnomarginlayout(int numcolumns, boolean makecolumnsequalwidth) { gridlayout layout = new gridlayout(numcolumns, makecolumnsequalwidth); layout.verticalspacing = 0; layout.horizontalspacing = 0; layout.margintop = 0; layout.marginbottom = 0; layout.marginleft = 0;

rest - Aggregated Data vs RESTful Resources for AngularJs SPA -

i working on single page app using angularjs framework . website kind of social networking , consists of various kinds of data fetched server. restful , make each entity 'resource' or implement other way 'aggregated json' response, since restful results in many calls ? if non-restful approach used, ( using $http service ), how can still maintain modular architecture of app. consider example clarification: let server return: { user: { name: .... ...., projects: [{ .... .... }], ... } } how can create modules such user , projects , each own functions , logically separate , independent. similar making single $http request , distributing response many services. appreciated. disclaimer - no means rest expert or purist this question , struggled well. couldn't justify having x number of rest calls display single form/p

java - UnsatisfiedLinkError Can't Load Library -

i working proycon decompiling .class .java, included jd-core-java-1.0.jar file in libraries directory, when compile main class throw exception exception in thread "main" java.lang.unsatisfiedlinkerror: can't load library: d:\apps\dvlpr\lib/libjd-intellij.so printed system.getproperty("java.library.path"); outputed c:\program files\java\jdk1.7.0_01\bin; c:\windows\sun\java\bin; c:\windows\system32; c:\windows; c:\program files (x86)\pc connectivity solution\; c:\python33\; c:\program files\common files\microsoft shared\windows live; c:\program files (x86)\common files\microsoft shared\windows live; c:\windows\system32; c:\windows;c:\windows\system32\wbem; c:\windows\system32\windowspowershell\v1.0\; c:\program files (x86)\windows live\shared; c:\program files (x86)\toshiba\bluetooth toshiba stack\sys\; c:\program files (x86)\toshiba\bluetooth toshiba stack\sys\x64\; c:\program files\nodejs\; c:\program files (x86)\tesseract-ocr; c:\program files\java\j

ios - How to emulate settings page -

could please tell me how emulate elasticity of settings page wherein view controller can dragged , released if suspended rubber band. eg. settings > wifi .. can drag text , down despite 1 line existing. if i'm right, want pretty bouncing effect @ top , bottom of scroll view. bouncing effect activated default on every scroll view make on ios 7. preson said, have check on uiscrollview class reference. found informations bounce property (and alwaysbouncehorizontal / alwaysbouncevertical). you might want check uitableview

c# - DirectShow.Net play video with audio -

directshow.net contains sample project dxplay plays video without audio. need modify project make play audio. have read need add audio filter , connect pin didn't find way it. here code sample sets filters up: // add filters necessary render file. function // work number of different file types. ibasefilter sourcefilter = null; hr = m_filtergraph.addsourcefilter(filename, filename, out sourcefilter); dserror.throwexceptionforhr(hr); // samplegrabber interface m_sampgrabber = (isamplegrabber)new samplegrabber(); ibasefilter basegrabflt = (ibasefilter)m_sampgrabber; // configure sample grabber configuresamplegrabber(m_sampgrabber); // add filter hr = m_filtergraph.addfilter(basegrabflt, "ds.net grabber"); dserror.throwexceptionforhr(hr); // connect pieces together, use default renderer hr = icgb2.renderstream(null, null, sourcefilter, basegrabflt, null); dserror.throwexceptionforhr(hr); could please hint me how can make play audio? if video rendered

Get the user who created a document library in SharePoint 2010 -

for auditing purposed need know create each document library in sharepoint site (not document document library) there can prefereably through powershell can automated document libraries? this cmdlet want: $web = get-spweb "http://yoursiteurl" $library = $web.lists["library name"] $author = $library.author write-host $author

web services - Preferred Communication method between systems using Biztalk -

we have 2 systems between want messages exchanged. designing application , have been given 2 choices. system 1 push messages intermediate location (ftp or sqs) , system 2 (running biztalk) reading messages location , processing it. exposing schema/orchestration web service in system 2 consumed system 1. any suggestions method better in terms of error handling , scalability. if can, go asynchronous approach, through queuing system. way, application can running independent of end. , advise service bus windows server (heavier installation), windows azure service bus (as service, in cloud, internet connection needed) or msmq (store , forward included!). these provide transactional behavior , can considered reliable. other lightweight options indeed through file exchange or ftp. web service or rest connectivity easy set up, have synchronous behavior, has benefits: you can 'real-time' ack when message delivered biztalk it's easy set , monitor so,

how to use fabricjs for synchronizing data between a and b client browers -

how can use fabricjs sync pencilbrush data between client , b client. now can use socket.io common shaps pencilbrush can't example code client --send canvas.on('object:modified', function(options){ console.info("object modified",options) socket.emit('js_object_redraw', {id:data.target.id,object:data.target}); },false); client b --recieve socket.on('client_js_object_redraw', function (data) { console.info("client_js_object_redraw:",data) console.info("data.target.type",data.object.type) var ele = canvas.getobjects() (var i=0;i<ele.length;i++) { var cur_object = ele[i] if (data.id == cur_object.id){ canvas.remove(cur_object); draw_object_by_type(data) } } }); function draw_object_by_type(data){ if(data.object.type=="rect"){ draw_rect(d

java - Align the label column of different DesignGridLayout -

Image
consider 2 jpanel instances using designgridlayout , following: jframe demoapplicationframe = new jframe(); jpanel singledesigngridlayout1 = new jpanel(); designgridlayout layout1 = new designgridlayout(singledesigngridlayout1); layout1.row().grid(new jlabel("short lbl1")).add(new jtextfield("")); layout1.row().grid(new jlabel("short lbl2")).add(new jtextfield("")); jpanel singledesigngridlayout2 = new jpanel(); designgridlayout layout2 = new designgridlayout(singledesigngridlayout2); layout2.row().grid(new jlabel("a bit longer label")) .add(new jtextfield("")); layout2.row().grid(new jlabel("another long label here")) .add(new jtextfield("")); demoapplicationframe.getcontentpane().add(singledesigngridlayout1, borderlayout.north); demoapplicationframe.getcontentpane().add(singledesigngridlayout2, borderlayout.south); executing code, create window: is possible align column lab

php - Want to render superfish_menu_tree in main_menu_tree place dupal -

sir, have main menu rendered in page.tpl.php <div class="menu_wrapper"> <nav id="main-menu" role="navigation"> <a class="nav-toggle" href="#">navigation</a> <div class="menu-navigation-container"> <?php print drupal_render($main_menu_tree); ?> <div class="clear"></div> </nav> in here rendered main_menu_tree, want replace page superfish menu. use block_load follows, replace <?php print drupal_render($main_menu_tree); ?> with <?php $block = block_load('superfish', 1); $output = render(_block_get_renderable_array(_block_render_blocks(array($block)))); print $output; ?>

linux - debconf or perl error during apt-get install -

i use linux mint 16 , error when installing package apt-get install: reading package lists... done building dependency tree reading state information... done sqlitebrowser newest version. 0 upgraded, 0 newly installed, 0 remove , 26 not upgraded. 1 not installed or removed. after operation, 0 b of additional disk space used. want continue [y/n]? y use of uninitialized value in concatenation (.) or string @ /usr/share/perl5/debconf/dbdriver/file.pm line 44, chunk 3. use of uninitialized value in -e @ /usr/share/perl5/debconf/dbdriver/file.pm line 46, chunk 3. use of uninitialized value in pattern match (m//) @ /usr/share/perl5/debconf/dbdriver/file.pm line 47, chunk 3. use of uninitialized value $directory in -d @ /usr/share/perl5/debconf/dbdriver/file.pm line 48, chunk 3. use of uninitialized value $directory in concatenation (.) or string @ /usr/share/perl5/debconf/dbdriver/file.pm line 49, chunk 3. debconf: dbdriver "config"

Java http request client example -

Image
i new in computer networking , have exercise create java http client example. the exercise instruction: socket soc = new socket(host, port); datainputstream in = new datainputstream(soc.getinputstream()); bufferedwriter out= new bufferedwriter(new outputstreamwriter(soc.getoutputstream())); out.write(httprequest); out.flush(); string httpresponse= in.readutf(); and code: import java.io.bufferedwriter; import java.io.datainputstream; import java.io.ioexception; import java.io.outputstreamwriter; import java.net.socket; import java.net.unknownhostexception; public class mytest{ public static void main(string[] args) throws unknownhostexception, ioexception{ string host = "gg.gg"; string httprequest = "get / http/1.1 host:gg.gg "; int port = 80; socket soc = new socket(host, port); datainputstream in = new datainputstream(soc.getinputstream()); bufferedwriter out= new bufferedwriter(new

monitoring - Liferay JMX beans -

i need plan monitoring of liferay 6.1 running on glassfish 3.1.2. far determined glassfish mbans want monitor. the question is: does liferay provide mbeans in addittion provided app server (liferay specific mbans) ? if so, there industry standard liferay mbeans worth monitor in general ? references existing liferay docs welcome (actually may suffice whole answer). far not find in official docs. thanks ! i doubt you'll find "industry standard" mbeans, liferay platform used in many different ways: e.g. might want monitor messageboards caches if have forum-like installation suffers performance in area. if don't have enough content of specific type, doesn't make sense monitor cache. that being said, top of head remember caches available monitoring. my recommendation browse through mbeans , figure out if given values make sense installation , usecase. have quite descriptive names. also, keep in mind in general production you'll monit

Maude in eclipse start error -

i trying run maude in eclipse(windows 7)but when start maude error: bash: /cygdrive/c/program files (x86)/maudefw/maude.ico: no such file or directory bash: line 0: exec: /cygdrive/c/program files (x86)/maudefw/maude.ico: cannot execute: permission denied it seems has selected maude icon in eclipse preferences instead of real executable (i.e. maude.exe). however, guess have similar error, since path maude.exe must not have 'spaces'. advice copy maudefw folder c: (or proper letter in case).

how to compile head file in robovm ios? -

we developing game on robovm ios. we must use third framework. , third framework must use header files , static library. if develop xcode, can copy header files , static library. developing on eclipse , robovm, can copy staic library, can't copy header files!! so, if have no header files, third framework happen running exception!! how solve it? information appreciated! thanx in advance!! to use third party ios framework in robovm, must first create objective-c - java binding. you not need copy header files need use them create bindings. i'm trying maintain bindings famous ios frameworks , sdks on here: https://github.com/blueriverinteractive/robovm-ios-bindings also @ bottom of page, i've started write tutorial on how create new bindings frameworks.

azure - Query Parameters for microsoft wsfed common endpoint to login.microsoftonline.com -

i using owin wsfederation package waad sign-in on windows azure. my problem want pass id=501358 https://login.microsoftonline.com/login.srf , don't know if that's possible. redirecting users https://login.windows.net/common/wsfed again redirects login.microsoftonline.com not pass query strings along. make more clear: i redirecting to: https://login.windows.net/common/wsfed?wtrealm=https%3a%2f%2fdemo009.s-innovations.net&wctx=blablabla&wreply=https%3a%2f%2flocalhost%3a44309%2f&wa=wsignin1.0 based on the wsfederationmessage that gets redirected to: https://login.microsoftonline.com/login.srf?wa=wsignin1.0&wreply=https%3a%2f%2flogin.windows.net%2fcommon%2fwsfed&wp=mbi_fed_ssl&wctx=blablabal i want &site_id=501358 added login.microsoftonline.com/login.srf , understanding wctx pass state around when comes site.

unix - ksh: grep command for multiple string. If all the strings found then only return the result -

is there way grep 2 strings in ksh , return true if both string found? we can use egrep command if of string found. matching string , return true string present. grep "string1" "sring2" file.txt not working. kindly help. in advance. edit: please note if grep not used other option can use purpose. first string present in 1st line of file , string2 present in other line of file. you can try grep "string1.*string2" file in test string1 must come before string2 in same line bee true. or can do: grep string1 file | grep string2 this true if string1 , string2 found using awk awk '/string1/ && /string2/' file to search on line awk '/string1/ {f1=1} /string2/ {f2=1} end {if (f2 && f1) print "found"}' file to exit status (cred adrian) awk '/string1/ {f1=1} /string2/ {f2=1} end {exit !(f1 && f2)}' file this give exit status 0 of both pattern found,

phpmyadmin - Error creating MySQL function (1064) -

phpmyadmin: 3.5.7 mysql: 5.5.29 i want users able compile several different lists posts in database. following function supposed used add post 1 such list. checks if list id supplied user matches given user id, checks if list not full, adds post list. delimiter // create function addtofav(inputkid int, inputuid int, listid int, listlimit int) returns varchar(300) begin declare resultmsg varchar(300); declare listexists int; set listexists = (select count(*) fav_lists fav_list_id=listid , uid=inputuid , active=1); if 1 > listexists set resultmsg = 'list non-existant'; else declare listsize int; set listsize = (select count(*) fav_links fav_list_id=listid , active=1); if listsize = listlimit set resultmsg = 'list full'; else if listsize > listlimit set resultmsg ='dberr: list on limit'; else replace fav_links (kid, fav_list_id, active) values (inputkid, listid, 1); set resultmsg ='succ

contextmenu - Eclipse Editor plug-in key binding not shown in menu for command -

i have key binding triggers command in custom eclipse editor plug-in: <key commandid="my.plugin.ui.mycommand" contextid="my.plugin.ui.mycontext" schemeid="org.eclipse.ui.defaultacceleratorconfiguration" sequence="m1+m2+o"> </key> i using newly defined context mycontext able overwrite existing key binding organizing imports. mycontext child context of org.eclipse.ui.contexts.window . when creating menu entry command, keyboard shortcut not shown next label because context binding not org.eclipse.ui.contexts.window child. the desired presentation of default binding when right-clicking .java files: organize imports __ _ __ _ __ _ ___ ctrl+shift+o is there way show bindings custom contexts? did try activate context in view's create part control method. platformui.getworkbench().getdisplay().asyncexec(new runnable() { @override public void run() {

php - Write to file and send AJAX response at once -

update: i used solution write data file. seems can't echo data while ajax waiting response. use fwrite. $filehandle = ''; $filehandle = fopen("export.txt","w"); fwrite($filehandle, $export); original: hi there, maybe logic wrong. make ajax call data url. worked far. but want add file export also. $handler = new myhandler(); // step 1: data url $dataajax = $handler->getdata($_post['data']); // step 2: write data text file provide download $handler->writetotext($dataajax); echo json_encode($dataajax); now console shows me "parsererror" because json data contains string wanted write file. that's bad , unwanted. below test how want write data txt file: function writetotext($data) { header("content-type: text/plain"); header("content-disposition: attachment; filename=export.txt"); header("pragma: no-cache"); header("expires: 0"); $title = "";

osx - NSActivityindicator for a web browse -

i want circular activity indictor should come when web view start loading , should disappear when load complete i have tried -(void)webviewdidstartload;(nsurl*) { [nsprogressindicator startanimation:self]; } please should type in .h , .m first thing should add uiactivityindicatorview (this standard loading animation in ios) in storyboard / xib / viewcontroller (anything you're using). then, in .m file of uiwebviewdelegate, should following : - (void) viewdidload { [super viewdidload]; // instantiate here activity view if you're creating programmatically // hide it, user must not see if web view not loading self.activityindicatorview.hidden = true; self.activityindicatorview.hideswhenstopped = true; // hide when animation stopped } - (void)webviewdidstartload:(uiwebview *)webview { self.youractivityindicatorview.hidden = false; [self.youractivityindicatorview startanimating]; } - (void)webviewdidfinishload:(uiwebvi

sql - What is the efficient query to find out Nth highest salary -

i beginner.. know sql queries find out 3rd highest salary or nth highest salary. need efficient query. these queries know.. please suggest other queries instead of these.. this query not efficient per subject teacher select * employee emp1 (n-1) = ( select count(distinct(emp2.salary)) employee emp2 emp2.salary > emp1.salary ); and query not efficient select max(salary) employee salary not in (select max(salary) employee ); any hint? you try this: select * employee order salary desc limit n,1 and performance pov if had index on salary column update: since mysql tag gone use oracle alternative mentioned mhasan rownum

css - !important doesn't work, doesn't extend 100% -

why doesn't "!important work"? <img src="images/logo.png" id="logo"> css: html { background-color: #ffffff; } body { margin: 0 auto; width: 1080px; } #logo { width: 100% !important; } but still #logo doesn't extend 100%, 1080px. your body of width: 1080px , nothing of width: 100% can go beyond this.

C++ Class generates no matching function and known conversion errors -

i've been learning box2d & c++ , managed create simple simulation in testbed, i'm trying take simulation out of testbed , integrate sdl shell. however class, formerly worked in testbed generating errors when try instantiate , i'm bit confused why worked in testbed throwing out variable conversion errors. this class: class ball { public: bool m_contacting; b2body* m_body; float m_radius; public: // ball class constructor ball(b2world* world, float radius) { m_contacting = false; m_body = null; m_radius = radius; //set dynamic body, store in class variable b2bodydef mybodydef; mybodydef.type = b2_dynamicbody; mybodydef.position.set(0, 20); m_body = world->createbody(&mybodydef); //add circle fixture b2circleshape circleshape; circleshape.m_p.set(0, 0); circleshape.m_radius = m_radius; //use class variable

contiki - Unreadable output results when typing "make login" -

i want test hello world application in z1 mote . unfortunately, when try visualize results in terminal using command: make z1-reset & make login , unreadable result: ������������������������󠰮����à������������������������������頲�� i run test in ubuntu 12.04 using contiki 2.7 , msp430-gcc 4.6.3 there necessary drivers zolertia z1 motes forgot install? in advance. best regards. i faced same problem few weeks ago working on z1 ...what u should update gcc-version 4.7.0 you can follow these steps upgrade msp430-gcc: update msp430 version 4.7.0 follow http://wiki.contiki-os.org/doku.php?id=msp430x after finish install msp430 version 4.7.0, move folder mspgccx /opt/tmp/ /opt/ run export path=/opt/mspgccx/bin:$path on terminal temporary, permanent need put in bash_rc or bash_profile. then can compile contiki code. someone shared me , did work me..hope works =) read steps carefully, little tricky. luck.

java - Today epoch time irrespective of current time -

i trying epoch time of today's date. stuck parseexception on formatting date. snippet:- simpledateformat df = new simpledateformat("dd/mm/yyyy"); string str = df.format(calendar.getinstance().gettime()); date date = df.parse(str); long epoch = date.gettime(); log.i("epoch" , string,valueof(epoch)); how 1 can today's epoch time? if you're interested in current time since jan 1 1970 utc in milliseconds, use system.currenttimeinmillis() . no need format , parse strings in process. to unix epoch timestamp it, convert seconds dividing 1000. based on comments , own answer seem interested in epoch timestamp in timezone. use calendar that, no need format , parse strings here either: calendar c = calendar.getinstance(); // today c.settimezone(timezone.gettimezone("utc")); // comment out local system current timezone c.set(calendar.hour, 0); c.set(calendar.minute, 0); c.set(calendar.second, 0); c.set(calendar.millisecond, 0); l

What methods can I use to return a struct to a Python Ctypes call to the function in a shared object? -

i have following c file compiling shared object. load .so shared object via ctypes in python. can call function ctypes, , function prints correct temp , humidity, can't seem struct main code. how can struct c function , how can retrieve fields within python. #!/bin/python ctypes import * class hmtemp(structure): _fields_ = [ ("temp", c_double) , ("humidity", c_double) ] dhtlib = 'libdht4py.so' hlibc = cdll(dhtlib) hmtemp = hlibc.readdht() print hmtemp.temp #define bcm2708_peri_base 0x20000000 #define gpio_base (bcm2708_peri_base + 0x200000) /* gpio controller */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <dirent.h> #include <fcntl.h> #include <assert.h> #include <unistd.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> #include <bcm2835.h> #include <unistd.h> #define maxtiming

Running Python package unit tests in PyCharm -

i 'ported' python package i'm writing pycharm , having bit of trouble running unit tests whole package ide. in __init__.py package have load_tests function goes on modules in package , loads relevant tests. runs splendidly with: $python -m unittest my_package however, when try running pycharm (by selecting top directory in projects window , hitting ctrl+shift+f10 ) no tests found in run window, and ...\python.exe ...\pycharm\utrunner.py .../my_package/ true testing started @ ... process finished exit code 0 empty test suite. in console window. i took quick @ pycharm's utrunner.py , seems looking modules pattern (that start test ). preserve present vanilla approach. how can configure pycharm use load_tests __init__.py while modifying code little possible? by way, test suites individual modules run fine pycharm. using pycharm 3.1 community edition, python 2.7. thank in advance. this answer has been written considering pycharm 3.4. ha

spring - Display Tag Issue -

i have collections of data display how display data using <display> tag in jsp file. i have written <display:table name="user" pagesize="10" export="true" sort="list"> <display:column property="firstname" title="first namee" sortable="true" headerclass="sortable" /> <display:column property="lastname" title="last name" sortable="true" headerclass="sortable" /> <display:column property="email" title="email" sortable="true" headerclass="sortable" /> </display:table> it working data not displayed

java - Webview with JavaScript interface -

i building mobile application should interacted java javascript. i found solution in link passing array of values android activity javascript in webview . problem when declare webview showing error none of methods in added interface have been annotated @android.webkit.javascriptinterface; not visible in api 17 what should remove error? new core java. please suggest me , me solve problem. from docs: caution : if you've set targetsdkversion 17 or higher, must add @javascriptinterface annotation method want available web page code (the method must public). if not provide annotation, method not accessible web page when running on android 4.2 or higher. please take here http://developer.android.com/guide/webapps/webview.html

javascript - undefined error for callback function in jquery -

i'm trying perform actions using jquery diferred in script. when execute script produces error typeerror: func(...) undefined . function defined , accepting calls. here script: verify: function(func, $this, verpass) { console.log('in verify'); var data = {}; data.url = 'service/verifier.php'; data.data = {pass: verpass}; data.async = true; this.fetch(data).always(function() { var result=true; if (result) { console.log(func); func().then(function(){ //here i'm getting error( fiddle line no:149) $('#loader').children('.infocont').empty().append($('<span/>').css({'color': '#000', 'background': '#35cc83', 'display': 'inline-block', 'margin': '0 0 0 -115px', 'padding': '0 2

html - Expand table cell rendered as table row to fit table width using CSS -

Image
html gets table data rendered each column being rendered table row . i need extend cell end of table, how expand if td added part of table row without changing html purely css . <table border="0" cellpadding="0" cellspacing="0" class="tablestyle"> <tr> <td class="column"> sample 1 </td> <td class="column"> sample 2 </td> <td class="column"> sample 3 </td> <td class="column"> sample 4 </td> </tr> </table> <style type="text/css"> .column { width: 25%; background-color: green; display: table-row; } .tablestyle { border: 1px solid red; width: 100%; } </style> expected result maybe can use width: 100% , display: tab

how does the cpu knows that the data in memory is data or a command? (C programming) -

i expect that data begins @ example 0x100 (memory location) , before it's commands... not sure! help! okay, detail question: see memory long array 1 byte space. space filled hex numbers. variables can fill memory example 0x0000 - 0xffff. how know example 0x002f command (for example 'mov') or number data? the cpu doesn't know. it's conventions. when start computer or embedded device starts executing bootloaer flash storage. in turn, bootloader loads startup code persistent storage memory , starts executing (typically os kernel) @ address loaded it. in turn, kernel load additional modules , init code @ known memory locations , execute there. at point, memory virtualization enabled, , executable files loaded in memory , each associated process , address space. executable header , os conventions define code , data segments locations. but code segment may contain embedded data, , dynamically allocated memory may contain code, instance in just-in-

datatable - Refuse page break in BIRT -

i'm designing report can have 1 or n elements in datatable. if report has 1 element, won't have page break. if report has more 1 element, want after every element page break. got variable (true or false) asl in condition if there more elements. i'm using eclipse birt version 4.3.1 thanks in advance if have footer row or that, can add following oncreate script row: if(vars["trueorfalsevariable"] == true){ this.getstyle().pagebreakafter = "always"; } and, of course, else if want force no-page-break (but should work automagically if element small enough).

c++ - make for ( rowIdx = 1...) work using cuda threads -

i have in c++ for ( rowidx = 1; rowidx < (nbrows - 1); rowidx++ ) in order using cuda ,how should handle it? because in cuda do: if (rowidx < arraysize) ... if set rowidx=1 before calling if (rowidx < arraysize) , doesn't work. ----update ---------------------------- a simple example illustration. __global__ void test_func(int *a_in,int *b_in,int *c_out) { size_t rowidx = blockidx.x * blockdim.x + threadidx.x; rowidx=1; if (rowidx <array_size) c_out[rowidx]=a_in[rowidx]*b_in[rowidx]; } //fill matrices (int i=0;i<array_size;i++){ a_in[i]=i; b_in[i]=i+1; c_out[i]=0; } if use rowidx=1 ,then taking first result correctly.the rest zeros. for simple replace of loop given functionality provided in example, kernel can looks way. __global__ void test_func(int *a_in,int *b_in,int *c_out) { size_t rowidx = blockidx.x * blockdim.x + threadidx.x; if (rowidx > 0 &&

c# - Does async/await affects tcp server performance? -

i creating tcp server in c# 5.0 , using await keyword when calling tcplistener.accepttcpclientasync , networkstream.readasync however when check cpu usage of server process explorer have following results: tcp sync version: 10% cpu usage tcp async version: 30% cpu usage half of usage kernel usage. moreover, measured how many time received data adding counter inside while of network stream, , async version loops 120,000 times while sync version loops 2,500,000 times. in term of message received/second async version 15% slower sync version when receiving messages 3 different clients. why async version use lot more cpu sync version? is because of async/await keyword ? is normal async tcp server slower sync counterpart? edit: here example of async tcp server code public class asynctcplistener : itcplistener { private readonly serverendpoint _serverendpoint; // custom class store ipaddress , port public bool isrunning { get; private set; } privat

mysql update doesn't work before using header() on php -

i have code here, send numeric value database. php code: <?php $ctr =1 <form method = 'post'> $radio =$ctr; <input type 'radio' name = '$radio[ctr]' /> $ctr++; <input type ='submit' name='submit'> </form> if(isset($_post['submit'])) { for($ctr=1; $ctr<$countme; $ctr++) { score++; } enter code here $insert = mysql_query("update `tblname` set `score` = '".$score."' number = '$number'); if ($insert){ header('location:somefile.php');} } ?> now problem is, update query seems not working, header() work insert 0 value database. i'd tried changing header() echo statement , database updated right value. what think problem? code doesn't return error. in advance. this not correction, creation… <?php?> code should @ top of page, because header() no output if printed on page. also, you're missing mysql_connect() , aware of that? , fi

c# - How to initiate T type object of Generic class -

this question has answer here: how create instance generic type in c# 1 answer i have generic proxy class contains t type object class. wants create object of t. class proxy<t>: iclient { t _classobj; public proxy() { this._classobj = //create new instance of type t } } if t class , guarantees has new() operator: class proxy<t> : iclient t : class, new() { t _classobj; public proxy() { this._classobj = new t(); } } otherwise, or if t struct , can do: class proxy<t>: iclient t : struct { t _classobj; public proxy() { this._classobj = default(t); // null reference-types e.g. classes } } update: for call method on t there different situations. but, according question , comments, assume t class , has new() operator. also, implements igetdataimplementer h

google cast - Chromecast - Chrome Sender - How do you connect to existing media session? -

i have receiver sets src on videoelement directly (ie. i'm not setting sender chrome.cast.session.loadmedia() method). the videoelement has been passed chromecast media manager: mediamanager = new cast.receiver.mediamanager(videoelement); when connect sender (or sender connected), want media status updates. using chrome api sending. unfortunately, when video loads , begins playback on receiver logs message: [cast.receiver.mediamanager] not sending status there no on going load request. how tap media session sender without initiating load event? it may worth mentioning session.media[] appears empty , if setup: session.addmedialistener(sessionmedialistener); the sessionmedialistener() never called today there no way initiate media session receiver side. load command triggers session creation need ask sender send load command after has launched receiver. note can override behavior of load command whatever want (like set src element yourself...) sess

Can we retrieve our machine serial number in our chrome extension? -

can retrieve our machine serial number in our chrome extension? for example can serial number in windows executing following command in shell wmic bios serialnumber how can fetch serial number in chrome extension? no. chrome extensions designed protect user privacy greatest practical extent, , 1 component of user privacy controlling ability of code "fingerprint" user. read eff's discussion of fingerprinting more. i didn't mark question duplicate, same answer applies this question .

c++ - How to delete folder containing files and sub folder properly in a MFC application -

i have mfc application facing problem folder delete. when deleting folder along containing files, shows deleted application file list shows in windows explorer remains not-accessible.when close application folder vanishes windows explorer. why happening? have seen removedirectory() in following code returning zero. if not deleted, why goes away after closing application. function follows: void someclass::deletefilefolder(cstring filepath) { cfilefind finder; cstring strwildcard(filepath); strwildcard += _t("\\*.*"); cstring str = ""; bool bworking = finder.findfile(strwildcard); while (bworking) { bworking = finder.findnextfile(); if (finder.isdots()) { cstring sfile = finder.getfilename(); if(sfile !="." && sfile !="..") { cstring sfile = finder.getfilename(); str = finder.getfilepath(); bool bdel = deletefile(str); } } else if (finder.isdir

How do I create a user defined function for mysqli_num_rows in php OOPs? -

i have tried best find out result on own, have failed. here's source code have tried @ level best. <?php class database { private $connect; private $dbuser; private $dbhost; private $dbpassword; private $dbdatabase; private $numrows; private $results; public function connect($host, $username, $pass, $db) { $this->dbhost = $host; $this->dbuser = $username; $this->dbpassword = $pass; $this->dbdatabase = $db; return $this->connect = mysqli_connect($this->dbhost, $this->dbuser, $this->dbpassword, $this->dbdatabase); } public function disconnect($connect) { return mysqli_close($this->connect = $connect); } public function select($table, $where = array(), $orderby = null) { if (count($where) === 3) { $operators = array('=', '<', '>', '>=', '<=', 'like');

javascript - Submenu CSS dropdown menu disappears in CSS dropdown menu when mouse moves off of <li> -

well not in js, think 1 can solving problam. got sub menu sub menu also. simple: <div class="dr_nav"> <ul> <li><a href='#'>home</a> <ul> <li><a href='#'>list example #1</a></li> <li><a href='#'>list example #2</a> <ul> <li> <a href='#'>list example child #1</a> </li> </ul> </li> <li><a href='#'>list example #3(hover)</a></li> </ul> </li> </ul> </div> but! thing want, when hovers on "list example #2" , "list example child #1" appears (in css put display:none it) stay visible if move out coursor parent "list example #2". hope can me this. my css bit hard , unorganized: .dr_menu { margin: 0; padding: 0; list-style: none; position: relative; z-index: 999; } .dr_menu>ul {

.net - Using FluentMigrator with an existing database -

i'm looking migrations framework work existing project uses .nettiers, older orm requires codesmith generate data access code. we have experience of roundhouse, , have had success in using it. able automatically deploy schema changes when running deployments out of octopus deploy. easy since collection of sql scripts. i have been interested in moving fluentmigrator. fm dsl , found this question quite useful, there couple of things don't grok: what right way import existing database schema [*]? what right way deploy migrations production environment [**]? [*] assumption generate single script using sql server tools , use executeembeddedsql initial migration. correct? [**] there appears 3 main ways run migrations (command line, nant runner, msbuild runner). need access database can run. imagine want deploy prod environment. developers , build server has no access environment. how run these runners against environment? our usual deployment process produce colle