Posts

Showing posts from February, 2012

javascript - How to deserialize multiple JSON objects in C#? -

i'm passing multiple json objects frontend c# backend - how can deserialize them c# classes can used later on in application? before go farther, tied using js formdata object, contenttype: false , , processdata: false , because need pass files via ajax call; unrelated question. here's code far: frontend - function called when submit button pressed submitdata: function () { var formcollection = this.appmodel.get('formcollection').models; var formdata = new formdata(); var formjson = []; $.each(formcollection, function (index, form) { var tempjson = {}; if (form) { tempjson['id'] = form.get('id'); tempjson['number'] = form.get('number'); tempjson['name'] = form.get('name'); tempjson['attachments'] = form.get('attachments'); formjson.push(tempjson); } }); console.log(json.stringify(formjson));...

spring cloud - How to safely have a @RestController class implementing an interface annotated with @FeignClient -

given following code sample -- client library code @feignclient("string-service") public interface stringclient { @requestmapping(method = requestmethod.get, value = "/microservicestring") public string home(); } @service public class stringhystrixclient { private final springclient springclient; //.... } -- service library code @restcontroller public class stringcontroller implements stringclient { public string home(){ return "world"; } } @springbootapplication @enablehystrix @enableeurekaclient @enablefeignclients public class stringapplication { ....} if service library references client library, when application gets started, through component scanning state in filling dependencies stringhystrixclient, spring container not know because there 2 beans implementing stringclient. one solution avoid not implement stringclient in stringcontroller, code duplication interface , rest controller error prone...

android - Identifying error on the native app using appium when some field is blank -

i using appium automate native android app ui , functionality. requirement capture error message comes when username kept blank during login. error message shown red exclamation mark on username field , cannot identified uiautomator. there way capture text of error message via appium you can try find element using xpath , providing text value expect error message object possess. $driver.find_element :xpath, '//text[@text="err msg"]' if element found can retreive out other properties.

button - Method must have a return type (C#) -

been getting "method must have return type, , don't understand why. it "public helpview()" part returns error. (top of code, made block quote) web browser application, code , forward buttons. public class helpview { } list<uri> historystack; int historystack_index; bool fromhistory; //constructor public helpview() { initializecomponent(); historystack = new list<uri>(); historystack_index = 0; fromhistory = false; webbrowser1.navigated += new eventhandler<system.windows.navigation.navigationeventargs>(webbrowser1_navigated); updatenavbuttons(); } helpview not exact name of class. if meant constructor, make sure method name matches class name. if meant method, change public void helpview()

jsf - How to reference CSS / JS / image resource in Facelets template? -

i've done tutorial facelets templating . now i've tried create page isn't in same directory template. i've got problems page style, because of styles referenced relative path so: <link rel="stylesheet" href="style_resource_path.css" /> i can use absolute referencing starting / : <link rel="stylesheet" href="/project_root_path/style_resource_path.css" /> but bring me troubles when i'll moving application different context. so i'm wondering best way reference css (and js , image) resources in facelets? introduction the proper jsf 2.x way using <h:outputstylesheet> , <h:outputscript> , <h:graphicimage> name referring path relative webapp's /resources folder. way don't need worry context path in jsf 1.x. see how include css relative context path in jsf 1.x? folder structure drop css/js/image files in /resources folder of public webcontent below (just cre...

Multiplexing online audio and video streams in android -

there 2 media files hosted on external servers - audio , video. need mux them , play online stream through android mediaplayer class. the main problem, don't know, if there possible solution continuous download-mux-play process. i've seen examples of mediamuxer class usage, local files. currently, start 2 media players : //setting video mediaplayer video = new mediaplayer(); video.setdatasource("videurl"); video.prepare(); //setting audio mediaplayer audio = new mediaplayer(); video.setdatasource("audiourl"); video.prepare(); //starting both players simultaneously video.start(); audio.start(); but, of course, gives terrible synchronization between audio , video. so, question - possible mux online streams, , if yes - start research?

angularjs - Load JSON in angular service -

i'm trying use jed translating angular app. this, use angular service providing jed object. now, jed needs translations, stored in json file, when created: jed = new jed( jsondata ); alert( jed.gettext( 'i translated!' ) ); so, ajax request, app.factory( 'jed', function ( $http ) { var ret = { jed: null }; $http.get( 'i18n/de_ch/messages.json' ) .success( function ( data ) { ret.jed = new jed( data ); } ); return { jed() { // null until receive messages.json return ret.jed; } }; } ); problem jed not initialised until http request returns. possible solution return deferred object, usage ugly have check deferred object , use function callbacks, , inlined {{jed.gettext( 'quit' )}} not work anymore. is there clean way of doing this? yes, there way. make it return { jed() return ret; } }; and watch changes in...

android - Save Changed Text Of a TextView -

i have button in first activity changes background onclick , save sharedpreferences , want set 1 more code when check button set text of textview in second activity "button-checked" , when uncheck set text of textview "button-unchecked" , save text (with sharedpreferences or else). in first activity: public class mainactivity extends activity { private boolean likechek; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); final button = (button) findviewbyid(r.id.like); like.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { sharedpreferences sp = preferencemanager.getdefaultsharedpreferences(dog.this); sp.edit().putboolean("like_", !likechek).commit(); likeanalayzer(); } }); } private void likeanalayzer() { sharedpreferences sp = preferencema...

html - Submit Button Not Responding When Clicked -

i have form, submit button not seem respond. <form id="contact-form" action="exec.php" method="post" enctype="multipart/form-data"> <fieldset> <label><span class="text-form">name:</span> <input name="p1" type="text" /> </label> <label><span class="text-form">email:</span> <input name="p2" type="text" /> </label> <div class="wrapper"> <div class="text-form">message:</div> <textarea></textarea> </div> <div class="buttons"> <a class="button-2" href="#">clear</a> <a class="button-2" href="exec.php">send</a> ...

php - Error Android java.lang.NullPointerException: lock == null -

i creating first android application, getting errors on below code line, when try code in eclipse works not work in android studio. please tell me log class code shall use find out error message. if (json.getstring(key_success) != null) { error log e/buffer error﹕ error converting result java.lang.nullpointerexception: lock == null e/json parser﹕ error parsing data org.json.jsonexception: end of input @ character 0 of e/androidruntime﹕ fatal exception: main process: com.bradvisor.bradvisor, pid: 2429 java.lang.nullpointerexception @ com.bradvisor.bradvisor.register$processregister.onpostexecute(register.java:232) register.java code package com.bradvisor.bradvisor; import android.app.activity; import android.app.progressdialog; import android.content.context; import android.content.intent; import android.net.connectivitymanager; import android.net.networkinfo; import android.os.asynctask; import android.os.bundle; import android.util.log; import and...

android - Error on Fragment? -

hello developing android app , new development. facing on error says: error:(134, 19) error: recyclertouchlistener not abstract , not override abstract method onrequestdisallowintercepttouchevent(boolean) in onitemtouchlistener here code above error appears fragmentdrawer.java public class fragmentdrawer extends fragment { private static string tag = fragmentdrawer.class.getsimplename(); private recyclerview recyclerview; private actionbardrawertoggle mdrawertoggle; private drawerlayout mdrawerlayout; private navigationdraweradapter adapter; private view containerview; private static string[] titles = null; private fragmentdrawerlistener drawerlistener; public fragmentdrawer() { } public void setdrawerlistener(fragmentdrawerlistener listener) { this.drawerlistener = listener; } public static list<navdraweritem> getdata() { list<navdraweritem> data = new arraylist<>(); // pr...

sql server - SQL group by as subquery -

i have table , 1 column contain id number number + letters. know jow separate , create (new) column group new column: select a.column1 , b.column1, (left(substring(b.column1, patindex('%[0-9.-]%', b.column1), 10), patindex('%[^0-9.-]%', substring(b.column1, patindex('%[0-9.-]%', b.column1), 10) + 'x') -1)) name2 table_b b left outer join table_a on b.column123 = a.column123 a.column1='value' group b.column1, a.column1 so report looks like: name1 name2 name2 value1 1 1 value 2 2 value3 3 1 value 4 4 value 27xz 27 value 27zx 27 how group name2? the easiest way use cte or subquery: cte ( select a.column1, b.column1, (left(substring(b.column1, patindex('%[0-9.-]%', b.column1), 10), patindex('%[^0-9.-]%', substring(b.column1, patindex(...

android - HttpURLConnection set method before connection made -

just quick one, have looked around , there doesn't seem 1 else asking same questions. wondering if possible set request method before connection opened when new httpurlconnection made. thanks according docs : httpurlconnection uses method default. use post if setdooutput(true) has been called. other http methods (options, head, put, delete , trace) can used setrequestmethod(string).

objective c - Having trouble when fetching Facebook user's details with latest iOS FBSDK (July 7, 2015) -

i have followed custom ui fblogin button app.in loginhomeviewcontroller have fblogin button. here code using in viewdidload fbsdkloginbutton *loginbutton = [[fbsdkloginbutton alloc] init]; loginbutton.readpermissions = @[@"public_profile", @"email", @"user_friends"]; if ([fbsdkaccesstoken currentaccesstoken]) { [[[fbsdkgraphrequest alloc] initwithgraphpath:@"me" parameters:nil] startwithcompletionhandler: ^(fbsdkgraphrequestconnection *connection, id result, nserror *error) { if (!error) { nslog(@"fetched user:%@", result); } }]; } 1) issue when first time there no console output on safari or fb logging in want user details in view controller i.e. loginhomeviewcontroller . 2) once login done in safari or fb, when goes previous view , enter controller i.e. loginhomeviewcontroller getting user details in nslog(@"fetched user:%@", result);...

php - Zend Framework Give 404 Error From Modal -

i have work on https://www.taskguru.co.ke/job/findproscat using zendframework , show 1 user job post, view page multiple job post @ 1 page, when try add foreach loop return 404 error.. see below code , me out of problem...! controller : class jobcontroller extends zend_controller_action { public function findproscataction(){ global $objsession ; $this->view->pageheading="hire task guru"; $this->_helper->layout()->setlayout('profilepage'); $sort_by =$this->_getparam('sort_by'); $this->view->sort_by=$sort_by; $jobdata = $this->generalmethod->getallrecordfromleftjoin('jobpost',"users","jobpost.job_postby=users.user_id","1","",""); $this->view->jobdata=$jobdata; if(!$sort_by) { $sort_by=0; } $data = $this->modeljob->getfulltimejoblistpro($jobdata[0],$sort_by); $this->view->data=$data; $this->view->s...

python - List files with pyftp - proftpd vs. pyftpdlib behavior -

i have test code uses ftp stub pyftpdlib, surprise failed in production. reason proftpd returns directory name in response nlst . here response pyftpdlib ftp stub: in [10]: local_conn.login('user', '12345') out[10]: '230 login successful.' in [11]: import ftplib in [12]: local_conn = ftplib.ftp() in [13]: local_conn.connect('localhost', 2121) out[13]: '220 pyftpdlib 1.4.0 ready.' in [14]: local_conn.login('user', '12345') out[14]: '230 login successful.' in [15]: local_conn.nlst('structuredata_advanced') out[15]: ['report_20150618.csv', 'report_20150618.fin', 'report_20150619.csv', 'report_20150619.fin', 'report_20150620.csv', 'report_20150620.fin'] here response proftpd : in [16]: remote_conn = ftplib.ftp() in [17]: remote_conn.connect('a1b.7y.xx.xx', 21) out[17]: '220 proftpd 1.3.4a server (vztd3.company.com) [a1b.7y.xx.xx]' i...

spring - Why Doesn't Intercept Url Work? -

this spring security configuration: <http auto-config="true" use-expressions="true"> <form-login login-processing-url="/resources/j_spring_security_check" login-page="/login" authentication-failure-url="/login?login_error=t" /> <logout logout-url="/resources/j_spring_security_logout"/> <intercept-url pattern="/resources/**" access="permitall" /> <intercept-url pattern="/login" access="permitall" /> <intercept-url pattern="/**" access="isauthenticated()" /> <intercept-url pattern="/monitoring" access="hasrole('role_admin')" /> ....... i add this: <intercept-url pattern="/monitoring" access="hasrole('role_admin')" avoid enter in section.. can enter monitoring after loggin "normal" user... why?? the order o...

swift - Variable was never mutated -

i've been following app tutorial of making simple temp conversion app, i have these lines of code shown below // users imput : c var celsius:int = celsiusvalue.text.toint()! //formula : c f // 5f = 9c + 160 // output : f var fah:int = ( 9 * celsius + 160 ) / 5 print(fah) i'm getting couple of errors don't understand why is, 'string' not have member named 'int' which mean int not able use there no integer in string shown? value of optional type 'string?' not unwrapped; did mean use '!' or '?'? i have changed code var celsius:int = celsiusvalue.text!.toint()! as shows in error helper thing still gives me same error value of optional type 'string?' not unwrapped; did mean use '!' or '?'? so i'm confused it, i've read other threads regarding variable never mutated hasn't seemed me what's happening too long comment... ...

python - Filling in a concave polygon represented as a binary matrix -

in task, represent concave polygon matrix of ones , zeros, 1 means given point belongs polygon. instance, following simple square , u-shaped polygon: 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 however, incomplete representation, in which: (1) boundary points included, , (2) internal points missing. example, in following enlarged version of u-shaped polygon, elements @ positions (1,1), (1,6), (3,1), ..., (3,6)* "unfilled". goal fill them (i.e., change value 1 ). 1 1 1 0 0 1 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 do know if there's easy way in python/numpy? *(row, column), starting counting top left corner this known problem in image processing can solved using morphological operators . with that, can use scipy's binary_fill_holes fill holes in mask: >>> import numpy np >>> scipy.ndimage import binary_fill_holes >>> data = n...

Check the expected value substring to match either of the strings in Protractor Jasmine -

i'm trying verify substring of value match either of strings. tried ways follows : 1) expect(row.gettext()).tocontain('håkan Åström' || 'hakan astrom') in verification 2nd string not being checked throwing fail of step 2) expect(row.gettext()).tobein('håkan Åström','hakan astrom') typeerror: object # has no method 'tobein' - error seen. can 1 share solution can used. thanks try use .tomatch(regexp) . regular expression can match expected string: expect(row.gettext()).tomatch(/h[aå]kan [aÅ]str[oö]m/)

XML merge nodes with XSLT -

i have xml file that: <root> <scenario name="film1"> <case name="aaa"> <test name="test1">ok</test> </case> <case name="bbb"> <test name="test2">not ok</test> </case> <case name="aaa"> <test name="test3">not ok</test> </case> <case name="bbb"> <test name="test66">ok</test> </case> </scenario> </root> of course there more nodes scenario want group case each scenario. expect that: <root> <scenario name="fil1"> <case name="aaa"> <test name="test1">ok</test> <test name="test3">not ok</test> </case> <case name="bbb"> <test name="test2">not ok</test> <test name="test66">ok</t...

sql - how to pick string and Concatenate from other column -

i have data declare @t table (id int,val varchar(200),ad varchar(100)) insert @t (id,val,ad)values (1,'d:\documents\franchiseeupload\caste\cgc011400000192\01~hyd bbs 11 jun.pdf','01~hyd bbs 11 jul.pdf'), (1,'d:\documents\franchiseeupload\caste\cgc011400000193\01~cnm_anx3.pdf 01~cnm_anx3.pdf','01~hyd bbs 11 jul.pdf') select * @t i want pick last '\' , in need add data column output : id val ad 1 d:\documents\franchiseeupload\caste\cgc011400000192\01~hyd bbs 11 jul.pdf 01~hyd bbs 11 jul.pdf 1 d:\documents\franchiseeupload\caste\cgc011400000193\01~hyd bbs 11 jul.pdf 01~hyd bbs 11 jul.pdf try using left() , charindex() , len() , reverse() functions: select id, left(val, len(val) -charindex('\',reverse(val), 0) + 1) + ad val, ad @t

java - How to add returned values from a Supplier to a FutureList -

i want run 3 methods posted below using completablefuture asynchronous supplier that, when executor finishes futurelist should contain 3 values returned 3 methods respectively. know how use futurelist , example: futurelist = completablefuture.supplyasync() but in case, want like: futurelist.add(completablefuture.supplyasync()) please let me know how can that. methods : this.compstabilitymeasure(this.frameijlist, this.frameiklist, sysconsts.stability_measure_token); this.settrackingrepvalue(this.comptrackingrep(this.frameijlist, this.frameiklist, sysconsts.tracking_repeatability_token)); this.setviewpntrepvalue(this.compviewpntrep(this.frameijlist, this.frameiklist, sysconsts.viewpoint_repeatability_token)); compstabilitymeasure method implementation : private void compstabilitymeasure(arraylist<mat> frameijlist, arraylist<mat> frameiklist, string token) throws interruptedexception, executionexception { // todo auto-generated method stub sync...

asp.net - I couldn't add items in radiobutton list with Item.Add(item) -

i tried add radio button list items dynamically code , got error: system.web.ui.webcontrols.radiobutton' not contain definition 'items'and no extension method 'items' accepting first argument of type 'system.web.ui.webcontrols.radiobutton' found (are missing using directive or assembly reference?) my code is: radiobutton: id="lstborder" in pageload event: createed listitem objects item. lstborder.items.add(item; i didn't part if items not property in radio button list? how fix it? try in way, lstborder.datasource = item; lstborder.databind(); as per code, need add "item"(listitem) radiobuttonlist lstborder.items.add(item);

php - Magento: Placing Order doesn't redirect to success page -

i have little problem placing order button on magento. reasons when complete order , click "place order" doesn't redirect page in success page (or elsewhere) stays in checkout page products still inside (image http://i.stack.imgur.com/74i3x.png happen when click place order button) i don't know modify redirect page. this code /checkout/controllers/onepagecontroller.php /** * order success action */ public function successaction() { $session = $this->getonepage()->getcheckout(); if (!$session->getlastsuccessquoteid()) { $this->_redirect('checkout/cart'); return; } $lastquoteid = $session->getlastquoteid(); $lastorderid = $session->getlastorderid(); $lastrecurringprofiles = $session->getlastrecurringprofileids(); if (!$lastquoteid || (!$lastorderid && empty($lastrecurringprofiles))) { $this->_redirect('checkout/cart'); return; } $session-...

matlab - I want to run two or more simulink model in parallel and synchronisation. -

hi want run 2 or more simulink model in parallel , synchronisation. there way it? 1 way think creating subsystem , put models inside it. should run parallely. 1 not prefered me. want open 2 matlab instances , run 2 different model in synchronisation. possible? want programmatically. appreciable. you should use matlab script , implement synchronization logic in it. == update == you can execute simulink model calling matlab script. have define task containing next steps: first can calculate inputs in matlab. execute first model first inputs. save results variable. use variable on second model , launch second model simulation. repeat task necessary steps.

toggle - How can use the default function " toggleBoldface(sender: AnyObject>)" and toggleItalics(<sender: AnyObject>) in swift -

i have 2 buttons bold , italic.and 3 lables.need normal bold , italic functionality.i done manually using uifont(name: "helvetica-oblique", size: 18).but makes hard me. is there way using default funcions " toggleboldface(sender: anyobject>)" , "toggleitalics()".please give me demo.i read in apple document https://developer.apple.com/library/ios/documentation/uikit/reference/uiresponderstandardeditactions_protocol/#//apple_ref/occ/instm/nsobject/toggleitalics : dont know how proceed events.

angularjs - Angular - How to use a dynamic templateUrl for a directive? -

so, whatever reason, trying create slider, contents of each slide different html templates. instead of image slider, it's html slider. so in html have code, , controls slider inside html template: <slide-template></slide-template> and here entire slide module: (function() { 'use strict'; angular .module('slidectrl', []) .directive('slidetemplate', function() { return { restrict: 'e', templateurl: 'views/slides/slide-1.html', replace: true, controller: 'slidecontroller', controlleras: 'slides' } }) .controller('slidecontroller', function() { var vm = this; }); })(); i'm not sure how move forward this, i've tried looking around haven't found felt use. inside controller, have array of slide template urls , corresponding variable indicate current slide: slideurl =...

mysql - how to create 2 order by in the same column -

i want create sql req twice use of order in same column try exemple select titleen, smalldescriptionen, startdate, enddate event enddate > now() order startdate asc union select titleen, smalldescriptionen, startdate, enddate event enddate < now() order startdate desc but sql error indicated incorrect usage of union , order by #1221 - incorrect usage of union , order one order by @ end enough order complete result set select titleen, smalldescriptionen, startdate, enddate event enddate < now() union select titleen, smalldescriptionen, startdate, enddate event enddate > now() order startdate desc;

Using Javascript Read Bytes of Any Hosted File -

using java script can read file (selected using type="file") bytes bytes of file using myfile = new filereader();. this page has nice example : html5 file api read text , binary my question can similar stuff using file hosted in server http://localhost/file.bin you can't unfortunately, filereader api local files only. you have options thogh, use http/xhr request download online resource, save local server , pass local file path filereader api, can't directly url

c# - Bindingsource cannot be its own data source -

Image
i receiving error "bindingsource cannot own data source" sporadically when update datagriview bindinglist. there no rhyme or reason far can tell when comes throwing error. if has insight, appreciated. dgv_items.datasource = null; dgv_items.datasource = new bindingsource(item.objectsitem.orderby(x => x.quality), null); foreach (datagridviewrow row in dgv_items.rows) { try { if (row.cells[5].value != null) { var cell = row.cells[5].value; if (uri.iswellformeduristring(cell.tostring(), urikind.absolute)) { datagridviewlinkcell linkcell = new datagridviewlinkcell { linkcolor = color.blue, value = cell }; row.cells[5] = linkcell; } } ...

javascript - understanding how $.promise works similar to transitionEnd -

i messing around on documentation page of jquery.promise() , came across following peice of code : $("button").on("click", function () { $("p").append("started..."); $("div").each(function (i) { $(this).fadein().fadeout(1000 * (i + 1)); }); $("div").promise().done(function () { $("p").append(" finished! "); }); }); fiddle here now understand $.defer in jquery assists in asynchronous programming, understand $.done , $.fail part of $promise object . i have read interesting article here . there few examples of how $.defer can used monitor css-3 transitions. however in fiddle example provide, fail understand how $.promise picks fact transition complete. how promise pick that fadeout() complete? how below piece of code work? $("div").promise().done(function () { $("p").append(" finished! "); }); how pro...

staticresource - Is it possible to set a static resource to the same value as another in XAML? -

is possible set static resource value of static resource? possible reference static resource type of static resource should possible, can't find out how. i.e this: <!-- first value --> <color x:key="mybluecolor">#ff7db3b6</color> <!-- works --> <solidcolorbrush x:key="mybluecolorbrush" color="{staticresource mybluecolor}"/> <!-- how do this? --> <color x:key="myothernameforbluecolor">{staticresource bluecolor}</color> you can this <color x:key="mybluecolor">#ff7db3b6</color> <staticresource x:key="myothernameforbluecolor" resourcekey="mybluecolor" />