Posts

Showing posts from January, 2010

WCF can not read XML -

i received xml value android. on .net have coded: try { var reader = operationcontext.current.requestcontext.requestmessage.getreaderatbodycontents(); if (reader.read()) { result += reader.readstring(); } but got error character not attended '<' any ideas ? getreaderatbodycontents returns xmldictionaryreader . that-> https://stackoverflow.com/a/1708681/1923256

mysql - SQL Query with Alias and Re-use it. how its work? -

i have query using alias 'as' example: select (table_a.name) name_a table_b id = 1 what im trying re-call/re-use name_a next column like: select (table_a.name) name_a, (name_a+"me") name_b table_b id = 1 how can that?? thx advance. have nice day you cannot reference select list alias in same select list. mysql documentation on select list aliases says: a select_expr can given alias using alias_name. alias used expression's column name , can used in group by, order by, or having clauses. you need wrap aliased select expression subquery , can use aliased expression in outer query. or refer field under original name.

java - Adding multiple on click listeners for several buttons -

how can make user can have several buttons on click listeners. tried 2 buttons, said had defined on-click listener not make on click listener result. code have far is: import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.support.v4.app.fragmentactivity; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmenttransaction; import android.view.view; import android.widget.linearlayout; public class mainactivity extends appcompatactivity { private view btnrender; private linearlayout container; private view btnrendered; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); btnrender = (view)findviewbyid(r.id.btn_render); container = (linearlayout)findviewbyid(r.id.fragment_layout); btnrendered = (view) findviewbyid(r.id.btn_rendered); //set event handling button

python - Advice about Azure IoT hub and raspberry pi -

currently i'm creating iot hub device reads sensor multiple times each second. achieve 3 4 reading each second. the sensor returns true or false , when true want time-stamp , other information send azure iot hub. device raspberry pi 3 i advice. best language create program with? can send messages every time or slow? i made sample program python , used gpio event detect if pin changed. , when changed, send message iot hub. have feeling isn't fast enough? thank time in advance! hope can give me advice it sounds bit missing here windows 10 iot core operating system raspberry pi. pi 3 officially still in preview mode, still works doing you've described. i've been using on new pi3 few months now. there loads of sample projects can hands on things sensors using c# language. here's couple of links started windows 10 iot core. https://developer.microsoft.com/en-us/windows/iot http://www.purplefrogsystems.com/paul/2016/06/controlling-your-windo

android - how to generate signed wear apk with jenkins without copying it to under handheld project -

i want generate , run wear apk jenkins. in www.developer.android.com, named "package manually". but don't want copy wear apk under handheld project. want operation processes automatically, not manually. link: https://developer.android.com/training/wearables/apps/packaging.html#packagemanually how can fix problem? thank advance.

datetime - How to calculate difference between two date(date object) in Java -

this question has answer here: calculating difference between 2 java date instances 43 answers i have 2 date in form as: date1 = tue jan 01 00:00:00 npt 2013 date2 = tue sep 30 00:00:00 npt 2014 now need find difference between these 2 dates. how can in java or in groovy. convert dates miliseconds , operate them: long diffinmills = date2.gettime() - date1.gettime(); in seconds diffinmills / 1000 in minutes diffinmills / (1000*60) in hours diffinmills / (1000*60*60) in days diffinmills / (1000*60*60*24)

loading data to hive dynamic partitioned tables -

i have created hive table dynamic partitioning on column. there way directly load data files using "load data" statement? or have depend on creating non-partitioned intermediate table , load file data , inserting data intermediate table partitioned table mentioned in hive loading in partitioned table ? no, load data command copies files destination directory. doesn't read records of input file, cannot partitioning based on record values. if input data split multiple files based on partitions, directly copy files table location in hdfs under partition directory manually created (or point current location in case of external table) , use following alter command add partition. way skip load data statement altogether. alter table <table-name> add partition (<...>)

python - Sorting a list with entries in string format -

in python, have list items (strings) this: "1.120e+03 8.140e+02 3.234e+01 1.450e+00 1.623e+01 7.940e+02 3.113e+01 1.580e+00 1.463e+01" i want sort list based on size of first number in each string (smallest largest). in above case "1.120e+03" . i can think of couple of ways it, involve creating new lists , couple of loops guess isn't efficient (or elegant). there quick way this? if sorting more once, suggest create class data , override methods comparing such __lt__ .

c# - How to connect ASP.NET website to different databases? -

Image
i preliminary apologize possibly asking question has been answered, in case please lead me relevant post, not discover myself answer. i have asp.net website - after publishing - should able connect different databases according user's wish. in login page there should list of databases user choose , connect 1 according individual credentials. how login page should look: the code login page: public partial class login : page { protected void page_init(object sender, eventargs e) { list<string> conns = new list<string>(); foreach (connectionstringsettings conn in system.configuration.configurationmanager.connectionstrings) { conns.add(conn.name); } listbd.datasource = conns; listbd.databind(); } protected void page_load(object sender, eventargs e) { registerhyperlink.navigateurl = "register"; for

java - Unsuccessful to use Marionette, the next generation of FirefoxDriver -

according mozilla developer network , there no firefoxdriver firefox 47, instead use marionette. i followed instructions in link, doesn't work expected. using java, firefox 47 , mac osx capitan i installed selenium driver npm install selenium-webdriver suggested in link i set marionette executable downloading file geckodriver-0.8.0-osx.gz , unrar it, , changed name wires instructed in link. , ensured executable chmod +x wires i used marionette this, mozilla developer desiredcapabilities capabilities = desiredcapabilities.firefox(); capabilities.setcapability("marionette", true); webdriver driver = new firefoxdriver(capabilities); but when run test, same exception normal firefoxfriver org.openqa.selenium.firefox.notconnectedexception: unable connect host 127.0.0.1 on port 7055 after 45000 ms. is successful use marionette? missing mozilla's instructions. thanks i had same problem , solved updating selenium version 2.53.1 . hope help

optimization - C++ Operator overloading styles, which is better for optimisation? -

there 2 ways overload binary operators in c++: member function, or non-member function. since member function style can included in .h file, , non-member style in .cpp file, have thought member function style make easier compiler optimise. is there difference in performance between member , non-member operators? do member , non-member operators result in identical code (in compiler)? the declaration member or not member has nothing optimization. compiler smart enough produce equally optimized code in both cases if changes. , anyway, low level optimization make sense precision compiler, version , configuration , can change one. for question of readability , maintanability, operator should member... unless cannot. if can, allows declare inside class definition coherent oop: operates on objects of class, let's try make method on class. simply there cases not possible. example, output streams injector ( << operator) can accept second operands of class, ca

python - Pytest - run multiple tests from a single file -

i'm using pytest (selenium) execute functional tests. have tests split across 2 files in following structure: my_positive_tests.py class positive_tests: def test_pos_1(): populate_page() check_values() def test_pos_2(): process_entry() validate_result() my_negative_tests.py class negative_tests: def test_neg_1 populate_page() validate_error() the assertions done within functions (check_values, validate_result, validate_error). i'm trying find way run tests single file, main test file like: my_test_suite.py test_pos_1() test_pos_2() test_neg_1() then command line execute: py.test --tb=short "c:\pycharmprojects\my_project\mytest_suite.py" --html=report.html is possible this? i've been searching , haven't been able find out how put calls tests in single file. you don't have run tests manually. pytest finds , executes them automatically : # tests/test_positive.py def test_pos_1(): populat

php - upload image, curl+multipart/form-data -

i need multipart/form-data , uploading image curl. i have code generating , sending data: $boundary = '----webkitformboundarylzi2dppfuicxxqt0'; $eol = "\r\n"; $postdata = ''; $postdata .= '--'.$boundary.$eol; $postdata .= 'content-disposition: form-data; name="scrid"'.$eol.$eol; $postdata .= $scrid.$eol; $postdata .= '--'.$boundary.$eol; $postdata .= 'content-disposition: form-data; name="file"; filename="'.$filepath.'"'.$eol; $postdata .= "content-type: {$imginfo['mime']}".$eol.$eol; $postdata .= $img.$eol; $postdata .= '--'.$boundary.'--'; $headers = array( "content-length: " . strlen($postdata), "content-type: multipart/form-data;boundary=----webkitformboundarylzi2dppfuicxxqt0", "x-requested

javascript - TypeError: Cannot read property 'getTime' of undefined -

i getting problem when trying use daypilot calendar in angularjs. https://code.daypilot.org/63034/angularjs-event-calendar-open-source when downloaded sources , use it not working , throwing error angular.js:9563 typeerror: cannot read property 'gettime' of undefined @ loadevents (daypilot-all.min.js:11) @ update (daypilot-all.min.js:11) @ object.fn (daypilot-all.min.js:11) @ h.$digest (angular.js:12031) @ h.$apply (angular.js:12279) @ g (angular.js:7991) @ c (angular.js:8196) @ xmlhttprequest.y.onreadystatechange (angular.js:8137) source code of downloaded code is <!doctype html> <html> <head> <meta charset="utf-8"> <title>daypilot: angularjs event calendar</title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script> <script src="js/daypilot/daypilot-all.min.js" type="text/javasc

datetime - Convert time from dd/mm/yyyy hh:mm:ss to unix timestamp in bash script -

i have browsed through similar threads , helped me come closest want didn't answer question. i have date in format dd/mm/yyyy hh:mm:ss ( $mydate = 26/12/2013 09:42:42 ) want convert in unix timestamp via command: date -d $mydate +%s but here accepted format one: yyyy-mm-dd hh:mm:ss so did transformation: echo $mydate| awk -f' ' '{printf $1}'| awk -f/ '{printf "%s-%s-%s\n",$3,$2,$1}' and have ouput: 2013-12-26 which good, try append hour part before doing conversion: echo $mydate| awk -f' ' '{printf $1; $hour=$2}'| awk -f/ '{printf "%s-%s-%s %s\n",$3,$2,$1,$hour}' but have this: 2013-12-26 26/12/2013 it seem not keep variable $hour . i new in awk, how ? in awk can use regex field separator. in case instead of using awk twice may want following: echo $mydate| awk -f' |/' '{printf "%s-%s-%s %s",$3,$2,$1,$4}' with use both space , / separators. first

python - using undetermined number of parameters in scipy function curve_fit -

first question: i'm trying fit experimental datas function of following form: f(x) = m_o*(1-exp(-t_o*x)) + ... + m_j*(1-exp(-t_j*x)) currently, don't find way have undetermined number of parameters m_j, t_j, i'm forced this: def fitting_function(x, m_1, t_1, m_2, t_2): return m_1*(1.-numpy.exp(-t_1*x)) + m_2*(1.-numpy.exp(-t_2*x)) parameters, covariance = curve_fit(fitting_function, xexp, yexp, maxfev = 100000) (xexp , yexp experimental points) is there way write fitting function this: def fitting_function(x, li): res = 0. el in range(len(li) / 2): res += li[2*idx]*(1-numpy.exp(-li[2*idx+1]*x)) return res where li list of fitting parameters , curve_fitting? don't know how tell curve_fitting number of fitting parameters. when try kind of form fitting_function, have errors "valueerror: unable determine number of fit parameters." second question: there way force fitting parameters positive? any appreciated :)

time - Calculating an interval from a timestamp in SAS -

i have data: data beforehave; input id time_event $ activity $; datalines; 12345 07:03:875 activity1 12345 07:04:004 activity1 12345 07:05:062 activity1 12345 07:07:357 activity2 12345 07:10:743 activity2 23145 07:12:737 activity1 23145 07:14:065 activity2 23145 07:15:037 activity2 ; run; i want data looks counting time between steps resetting counter 0 every time first activity 1 appears; data beforehave; input id time_event $ activity $ time_taken; datalines; 12345 07:03:875 activity1 00:00:000 12345 07:04:004 activity1 00:00:029 12345 07:05:062 activity1 00:01:058 12345 07:07:357 activity2 00:01:295 12345 07:10:743 activity2 00:03:386 23145 07:12:737 activity1 00:00:000 23145 07:14:065 activity2 00:01:672 23145 07:15:037 activity2 00:00:972 ; run; i think need take time particular activity occurred time first activity1 occurred id . have thought of doing in terms of intermediate step whereby create field updates pull across time_event of fist activity

Html Css how positioning playing cards correctly on page? -

i creating memory card game , cards don't seem displaying on page correctly. this: [image of end result][1]. using css place 4 playing cards on page: 2 cards top , bottom, can't seem find have done wrong , footer not displaying underneath cards. appreciated... here code instructions: https://jsfiddle.net/ray1234/zeqks3kq/2/ <!doctype html> <html> <head> <title>memory game</title> <link rel="stylesheet" type="text/css" href="css/main.css" > </head> <body> <nav class="clearfix"> <a href="#">instructions</a> <a href="#">games</a> </nav> <h1>memory game</h1> <h2>instructions</h2> <h3>my game fun play, want play again , again. game fun because it's easy play. game awesome because of how built.</h3> <p>concentration, known match match, memory, pelmanism, shinkei

asp.net - Issue with RedirectAction -

i have formcontroller index action , simplecontroller corticonindex action. i redirecting corticonindex index action. problem is, have put breakpoint @ return redirecttoaction() , corticonindex() . so,only first time can see execution f11 second time controller not going corticonindex() . how redirecttoaction() work? is 1 time execution or can execute multiple time?? formcontroller [httppost] public actionresult index(formcollection formcollection) { return redirecttoaction("corticonindex", " simplecontroller"); } simplecontroller public actionresult corticonindex() { var viewmodel = this.model.getviewmodel(payload); return view(corticonresponsemodel.viewname, viewmodel); } how redirecttoaction() work? it sends http 302 response browser of web site along location header . browser browser. normally, use location header submit request server. but, entirely out of application's control, there no guarantees.

java - I am getting exception Neither BindingResult nor plain target object for bean name 'studentRegistration' available as request attribute in spring -

i new spring. creating project registration basic requirement other project.but getting exception given below neither bindingresult nor plain target object bean name 'studentregistration' available request attribute java.lang.illegalstateexception: neither bindingresult nor plain target object bean name 'studentregistration' available request attribute @ org.springframework.web.servlet.support.bindstatus.<init>(bindstatus.java:144) @ org.springframework.web.servlet.tags.form.abstractdataboundformelementtag.getbindstatus(abstractdataboundformelementtag.java:168) @ org.springframework.web.servlet.tags.form.abstractdataboundformelementtag.getpropertypath(abstractdataboundformelementtag.java:188) @ org.springframework.web.servlet.tags.form.abstractdataboundformelementtag.getname(abstractdataboundformelementtag.java:154) @ org.springframework.web.servlet.tags.form.abstractdataboundformelementtag.autogenerateid(abstractdataboundformelementtag.j

javascript - jquery calculate multiple box keyup function -

here html code: <tbody> <?php $x = 1; while($x < 26){ ?> <tr> <td><?php echo $x; ?></td> <td> <?php $sql_produk = mysql_query("select stok.id id, jenis_barang.nama, stok.stok stok left join jenis_barang on jenis_barang.id = stok.jenisbarang_id toko = '$administrator_id' group stok.jenisbarang_id")or die(mysql_error()); ?> <select class="form-control select2me" name="produk_<?php echo $x; ?>"> <option value="0">select...</option> <?php while($row_produk = mysql_fetch_array($sql_produk)) { ?> <option value="<?php echo $row_produk['id'] ?>"> <?php echo $row_produk['nama'] ?> (stok tersedia: <?php echo $row_produk['stok'] ?>) </option> <?php } ?> </select> </td> <td><input clas

javascript - USB PORT: How to Do i read data from usb port through browser windows -

i have created device sends data computer usb device. how access data in browser data being received doclight application can not response in browser. i have tried many ways did not found information http://php.net/manual/en/book.dio.php https://github.com/emergingtechnologyadvisors/node-serialport how read serial port data javascript kindly use tried following code. i did similar thing. way browser through backend. node-serialport (with arduino, edison etc). if using browser however, had usb device create csv, uploaded webpage giving access data logged. here project using node-webkit interface arduino board. it's not documented you'll able see working node-serialport implementation.

python - Import Error: No module named numpy Anaconda -

i have similar question question. have 1 version of python 3.5 installed on windows 7 64-bit system. installed anaconda3.4 via official website - suggested in question. installation went fine when want import(i typing python command line ) import numpy import error:no module named numpy then exit , type pip install numpy requirement satisfied (use --upgrade upgrade): numpy in d:\program fi les\anaconda3\lib\site-packages i know super basic question, i'm still learning... thanks you need install numpy using pip3 install pip3 : sudo apt-get install python-pip python3-pip then install numpy using pip3 sudo pip3 install -u numpy

android - Automatically accept all SDK licences -

since gradle android plugins 2.2-alpha4 : gradle attempt download missing sdk packages project depends on which amazingly cool , know jakewharton project . but, download sdk library need to: accept license agreements or gradle tells you: you have not accepted license agreements of following sdk components: [android sdk build-tools 24, android sdk platform 24]. before building project, need accept license agreements , complete installation of missing components using android studio sdk manager. alternatively, learn how transfer license agreements 1 workstation another, go http://d.android.com/r/studio-ui/export-licenses.html and problem because love install sdk dependencies while doing gradle build . i looking solution automatically accept licenses. maybe gradle script ? have ideas ? thanks! [edit] a solution execute: android update sdk --no-ui --filter build-tools-24.0.0,android-24,extra-android-m2repository and install manually, gradle&#

java - Create and deploy Vaadin 7 Portlet in Liferay 7 -

with liferay 6.x easy develop , deploy vaadin 7 portlets. because of changes in liferay 7, portlets won't work. didn't single "hello world" vaadin portlet run. i've read article "sampsa sohlman" ( link ), won't work newest version of liferay. my question: there chance example vaadin 7 liferay 7 "hello world" portlet? i'm grateful every answer! liferay's message board thread has answer :) https://web.liferay.com/community/forums/-/message_boards/message/76582064 in nutshel (copying important above source) need build: https://github.com/sammso/vaadin/tree/manifest-fix then need build : https://github.com/sammso/com.vaadin.liferay you can try older version https://github.com/sammso/com.vaadin.liferay/tree/7.6.7 still old package paths etc. https://github.com/sammso/vaadin/tree/manifest-fix @ https://github.com/vaadin/vaadin , released on next version. in order build current version need manually edit

android - Is it possible in realm to change the primary key later..? -

i set temporary primary locally , save object realm, , later server assigns unique key object , want update primary key object. so possible reassign primary key object? , happens when reassign primary key object? save object old primary key? it possible change value of primary key realm 1.2.0. it prohibited change primary key value since realm 2.0.x.

c - Calculation of Bit wise NOT -

how calculate ~a manually? seeing these types of questions often. #include <stdio.h> int main() { unsigned int = 10; = ~a; printf("%d\n", a); } the result of ~ operator bitwise complement of (promoted) operand c11dr §6.5.3.3 when used unsigned , sufficient mimic ~ exclusive-or uint_max same type , value (unsigned) -1 . @eof unsigned int = 10; // = ~a; ^= -1;

android - Custom Listview inside scrollview with horizontal gridview -

i have integrated listview inside scrollview in android. listview customised. each listview item horizontal gridview. whole screen consists of image @ top , below listview , each listitem horizontal gridview. when scrolling screen vertically works fine. once scroll item of lisview horizontally, app starts lagging , no scroll works properly . i want develop ui same of wynk music app home screen (dynamic listview each listview item horizontal gridview). find code below : main activity layout: <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:weightsum="3" android:background="@color/white" android:gravity="center_vertical" style="@style/base.widget.appcompat.light.actionbar.tabtext" > <imageview