Posts

Showing posts from August, 2014

large files - C# Reading only specific lines without reading line by line -

i been googling last hour , can not find answer this. i have large text file (1gb) , have file has mapped know on line x line y contains data after. my question how take lines interested in without iterating through lines in file? the main reason interested in doing way performance reasons, imagine quicker take rows 503,432 row 504,432 cycle row 1 504,432 find these rows. any tips appreciated if looking specific row number, need read rows count them anyway. can't count rows without reading file except if lines fixed length. not need save lines when read them. save linenumber need, or handle them without keeping them in memory later.

Posting from web role to another web role Windows Azure -

i have 2 web roles in solution, 1 main web app , i'd act api both web app , mobile applications. they both work independently of each other struggling post data view in web app's role api controller in api's role. this method in api controller: public void post([frombody]string value) { var post = (post)jsonconvert.deserializeobject(value, typeof(post)); addpost(post); } and here javascript view trying post from: <script> $(function () { var onpost = function () { $.post("http://localhost:8081/api/post", { "value": $('#postform').serialize() } ).success(function () { alert("success"); }).fail(function () { alert("failure"); }); }; }); </script> edit: i not getting error, nor either of alert functions being called. however, on clicking b...

ruby - Anything wrong with "throw" inside a PTY.spawn? -

this dev machine , testing purposes. i'm trying start script starts server, ignores once output meets condition. process not end, can't use backticks. -quit ing process independently (somewhere else in script). far closest i've got: require "pty" catch :ready begin pty.spawn( "bin/start" ) |stdin, stdout, pid| begin stdin.each { |line| throw(:ready) if line['worker ready'] } rescue errno::eio puts "no more output" end end rescue pty::childexited puts "child process exit" end end # === end of catch block # continue rest of script... so far works, new ruby , processes. other solutions i've seen online require pipes, forks, , process.detach . doing wrong using throw while in pty.spawn ?

java - Filters - Ignore the other requests excluding the welcome file -

i wrote filter decide user landing page before reach welcome-file. welcome-file written in such way takes input filter , navigate user specific page. my welcome-file tag is... <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> and filter configuration <filter> <filter-name>landingpagefilter</filter-name> <filter-class>com.mypack.test.filters.landingpagefilter</filter-class> </filter> <filter-mapping> <filter-name>landingpagefilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> the above format working whilst every request passing through filter, want avoid. when hit http://localhost:8000/landing should reach filter first time , later if access http://localhost:8000/landing/edit should execute relevant servlet bypassing filter. i tried <url-pattern>/*/index.jsp</url-pattern> no use. why use because ...

sql - Where Clause Case Statement; ORA-00907: missing parenthesis -

i have query , when run error message ora-00907: missing parenthesis . when replace case statement either x = g and or y = g and runs expected. select * table1, table2, table3, table4, table5, table6, table7, table8 = b , c = d , e = d , case strfldvar when 'broken_arrow' (x = g) when 'broken_box' (y = g) else -1 end , f = h , = j what doing wrong here? case expression, not predicate (i.e condition) : 'returns' typed value , can not contain predicate result (in then parts). in case (assuming else -1 means 'no match') : and g = case strfldvar when 'broken_arrow' x when 'broken_box' y else null -- never match, if g null end although think simpler replace : and ( (strfldvar = 'broken_arrow' , x = g) or (strfldvar = 'broken_box' , y = g) )

jquery - parallax, scrolling background of a single div -

<div id="first-div" style="width:960px; height:1200px;"> <div id="second-div" style="width:500px; border:solid 1px; height:30px; background:#333;"> scroll background </div> </ldiv> here div code , want move background of second div left right, when first div scroll down. detail: @ beginning second div background should white when first div scroll down ,second div's black background should appear left right using css3 or jquery.

actionscript 3 - How to remove stream video in next scene AS3 -

i making project video in scene, when go next scene video keeps appearing. how can remove it. my code far is: import flash.net.netconnection; import flash.net.netstream; import flash.media.video; import flash.events.mouseevent; var videoconnection:netconnection = new netconnection(); videoconnection.connect(null); var videostream:netstream = new netstream(videoconnection); videostream.play("short_jump.flv"); var metalistener:object = new object(); metalistener.onmetadata = onmetadata; videostream.client = metalistener; var video:video = new video(); video.attachnetstream(videostream); stage.addchild(video); video.x=200; function onmetadata(data:object):void { play_btn.addeventlistener(mouseevent.click, playmovie); stop_btn.addeventlistener(mouseevent.click, stopmovie); } function playmovie(event:mouseevent):void { videostream.play("short_jump.flv"); } function stopmovie(event:mouseevent):void { videostream.pause(); } thanks support! video....

PHP handling XML Feed with Simple XML -

i using uk met office api use weather information. xml layed out following: <siterep> <wx> <param name="f" units="c">feels temperature</param> <param name="g" units="mph">wind gust</param> <param name="h" units="%">screen relative humidity</param> <param name="t" units="c">temperature</param> <param name="v" units="">visibility</param> <param name="d" units="compass">wind direction</param> <param name="s" units="mph">wind speed</param> <param name="u" units="">max uv index</param> <param name="w" units="">weather type</param> <param name="pp" units="%">precipitation probability</param> </wx> <dv datada...

html - how to hide "image not found" icon on IE and chrome using CSS -

i have images on page. by default if given image not available, broken image indicator shown on chrome , ie. i want nothing shown alternative text in case. there way handle using css. using javascript <img src="broken.png" onerror="this.style.display='none'"/> edit: added small snipet handle images. $("img").error(function(){$(this).hide();}); example: http://jsfiddle.net/va2wd/

asp.net mvc - WebApi Action filter called twice -

my webapi filter method onactionexecuted being called twice. filter (i make simple possible): public class nhibernateactionfilter : actionfilterattribute { // [inject] // public isessionfactoryprovider sessionfactoryprovider { get; set; } public override void onactionexecuted(httpactionexecutedcontext actionexecutedcontext) { var = 5; var b = a; //new basesessionprovider(sessionfactoryprovider).endcontextsession(); } } my setup: protected void application_start() { arearegistration.registerallareas(); webapiconfig.register(globalconfiguration.configuration); //http://stackoverflow.com/questions/9521040/how-to-add-global-asp-net-web-api-filters filterconfig.registerwebapifilters(globalconfiguration.configuration.filters); } public class filterconfig { public static void registerwebapifilters(system.web.http.filters.httpfiltercoll...

rest - What is meant by PUT method idempotent in RESTful web service? -

i trying decide http method should used put or post. while looking @ posts on stackoverlflow see this post. one of answers in post says put idempotent, if put object twice, has no effect. nice property, use put when possible. can 1 me out here example. lets have scenario trying create student entry passed in student table in rdbms. so here if try put entry again , again there no effect? in put, you're setting all values of resource, when put done, know state of resource. if wait week , call put again, still know state of resource. a post, contrast, not idempotent - post subset of values. if call post today, wait week, , make same post call again, don't know state of resource - might have changed value you're not setting in post. idempotent means no matter when or how make call, end state of resource same. delete , idempotent.

asp.net mvc - Display folder name in Visual Studio open file tab -

Image
i creating asp.net mvc applications visual studio 2012 , find myself in situation, need work 2 files have same names. when both open, find hard distinguish between 2 except "mouseover" tab , see path file. so 2 files name of index.cshml see in tab home\index.cshtml , menu\index.cshtml respectively. perhaps can achieved vs extension asp.net. please let me know if such display can configured. it can achieved tabs studio add-in (commercial, developed me) , disambiguator add-in enabled. for 2 files name of index.cshml, tab names home/index.cshtml , menu/index.cshtml.

ios - Cant set the Delegate of my UITabbar -

i have simple tabbar-controller in storyboard. viewcontroller 1 has navigation controller around itself. viewcontroller 2 not have one. viewcontroller 1 shown first when app goes up. i need implement following method: -(void)tabbar:(uitabbar *)tabbar didselectitem(uitabbaritem *)item but cant set delegate of uitabbar. want set deleagte in viewcontroller 1. in ib can show delegate property cant draw line. tried set delegate programmatically. no matter set it, app crashes. have set delegate of uitabbar ? you should make app delegate delegate of tab bar. should able drag tab bar controller in storyboard appdelegate (maybe file's owner). in code, can reference tab bar controller , set tbc.delegate = self in didfinishlaunchingwithoptions: . in both scenarios, make sure first make delegate listen delegate methods adding <uitabbarcontrollerdelegate> interface declaration.

java - How do I tell Gradle to use specific JDK version? -

i can't figure out working. scenario: i have application built gradle the application uses javafx what want use variable (defined per developer machine) points installation of jdk used building whole application / tests / ... i thought having gradle.properties file, defining variable. like java_home_for_my_project=<path desired jdk> what don't want point java_home desired jdk i live many suggestions: a solution defines system environment variable i'm able check in build.gradle script a variable defined in gradle.properties overriding java_home variable build context (something use java_home=<my special jdk path defined somewhere else defined> ) something else didn't think about question: how wire variable (how ever defined, variable in gradle.properties , system environment variable, ...) build process? i have more 1 jdk7 available , need point special version (minimum jdk_u version). any answer appreciated , i...

advice needed for SQL query -

can 1 provide sql query should used pull out "columna" value has max number "columnb" value "active". means in columnb there value "active" , want pull columna value has max of value active n columnb. i looking output columna = m1 , count = 4 columna columnb m1 active m1 active m1 active m1 active m2 failed m2 failed m2 failed m3 pending m3 pending m3 pending the results request produced by: select columna,count(*) table columnb = 'active' group columna

javascript - SFTP SSH_FXP_READ Offset -

i'm writing sftp server in node.js, i've run strange issue @ final hurdle, reading files… pretty obscure topic appreciated. following version 3 sftp spec here: https://filezilla-project.org/specs/draft-ietf-secsh-filexfer-02.txt i've been testing server filezilla, coda2 , command line sftp on osx. each has been successful in functions until reading include 64 bit communication, each seems produce different weird behaviour when reading files. according spec (section 6.4), ssh_fxp_read should provide: uint32 id <- request id string handle <- file handle uint64 offset uint32 len which come through valid id , handle, offset , length different matter. i'm using 2 byte handle here simplicity. coda expected: 5 ff 0 30000 6 ff 30000 30000 7 ff 60000 30000 8 ff 90000 30000 etc until eof coda real: 5 ff 0 30000 6 ff 30000 30000 7 ff 27232 30000 8 ff 89872 30000 9 ff 87104 30000 10 ff 149872 30000 coda gets first 2 right loses it... now f...

Trouble getting array values into dojo ItemFileReadStore -

i need itemfilereadstore fill my dijit.form.filteringselect widget dojo 1.6. data inside javascript object following structure: [object] | |--> [object] |--> [object] | |-->id:85 name:somename i've tried transforming object json object gives me this: var datavalues = json.stringify(myobject); // result = [{"id":85,"name":"somename"}] i've tried using json object create store in 2 different ways: 1.var store = new dojo.data.itemfilereadstore({ data:datavalues}); 2.var store = new dojo.data.itemfilereadstore({ data: { identifier: 'id', items: datavalues } }); checking document: http://dojotoolkit.org/reference-guide/1.9/dojo/data/itemfilereadstore.html#input-data-format examples see json object has right form don't know wrong keep getting errors in console. i used dojos dojo/store/memory needs. here's reference: https://dojoto...

SQL - insert row values from second column ( to new table as column data) -

while having result set: name values product filler888 lot_number cg 00063 0 shift_supervisor covaliu l kgh_all_set 90 kgh_all_real 133.183883666992 kgh_f1_set 90 kgh_f1_real 133.183883666992 k_f1 33 screw_rpm_set 400 screw_rpm_real 399.452606201172 torque 19.6692142486572 current 71.0029983520508 kw_kg 0.0553370267152786 kw 7.36999988555908 melt_pressure 0 melt_temperature 140 pv1 141 sp1 140 pv2 160 sp2 160 pv3 160 sp3 160 pv4 160 sp4 160 pv5 160 sp5 160 pv6 150 sp6 150 pv7 150 sp7 150 pv8 154 sp8 150 pv9 150 sp9 150 pv10 160 sp10 160 pv11 180 sp11 180 i second table defined rows of 1st: create table #zsk402temp ( product varchar(25), lot_number varchar(25), shift_supervisor varchar(25), kgh_all_set decimal, kgh_all_real decimal, kgh_f1_set decimal, kgh_f1_real decimal, k_f1 decimal, screw_rpm_set decimal, screw_rpm_real decimal, torque decimal, [current] decimal, kw_kg decim...

getting source code of redirected http site via c# webclient -

i have problem site - provided list of product id numbers (about 2000) , job pull data producer site. tried forming url of product pages, there unknown variables can't put results. there search field can use url this: http://www.hansgrohe.de/suche.htm?searchtext=10117000&searchsubmit=suchen - problem is, given page display info (probably java script) , redirect straight desired page - 1 need pull data from. is there way of tracking redirection thing? i put of code, got far, find unhelpful because download source of preregistered page. public static string download(string uri) { webclient client = new webclient(); client.encoding = encoding.utf8; client.headers.add("user-agent", "mozilla/4.0 (compatible; msie 6.0; windows nt 5.2; .net clr 1.0.3705;)"); string s = client.downloadstring(uri); return s; } also suggested answer not helpfull in case, because redirection doesn't come http request - page redirected after few s...

Android json objects to array list in Parcelable class -

i don't know of title accurate, let me explain want. having long jsonobject (sadly it's not array , can't loop through it) many other jsonobjects inside of similar elements (id, name, icon), , when read through element writes value in separate class implemented parcelable. here parcelable class before explain further: public class itemsinfo implements parcelable { public int itemid; public string itemname, itemicon; @override public int describecontents() { return 0; } @override public void writetoparcel(parcel dest, int flags) { dest.writestring(itemname); dest.writestring(itemicon); dest.writeint(itemid); } public static final parcelable.creator<itemsinfo > creator = new parcelable.creator<itemsinfo >() { @override public itemsinfo createfromparcel(parcel source) { itemsinfo ei = new itemsinfo(); ei.itemname = source.readstring(); ...

javascript - form validation with radio buttons and specific errors -

i trying make form validate there radio buttons , textarea. want nothing left empty i.e form should filled. have done radio buttons part of validation if user not select radio button error particular question. can see code here detailed code. please me out. not getting error textarea. you didn't write validation 'textarea' block. have updated 1 textarea... add rest validations. function radiovalidator() { var showalert = ''; var allformelements = window.document.getelementbyid("formid").elements; (i = 0; < allformelements.length; i++) { if (allformelements[i].type == 'radio') { var thisradio = allformelements[i].name; var thischecked = 'no'; var allradiooptions = document.getelementsbyname(thisradio); var problem_desc = document.getelementbyid("problem_desc"); (x = 0; x < allradiooptions.length; x++) ...

css3 - Responsive design that manipulates multi-column content -

i implement ui 1 or 2 columns depending on screen/device width. i'm using ajax load data these 2 columns , append according item heights both columns take approx. same amount of vertical space. everything's ok if user keeps browser window size same @ time, because initial loading either fill 1 or 2 columns. problem arises when user resizes window have consolidate content accordingly: smaller size hides column 2 , it's items should inserted columns 1 in correct order larger size displays both columns , takes content column 1 , puts column 2 i can use javascript this, wondering whether it's possible same in css way? an example of google+ works 1..3 columns depending on content width. i came solution of own it possible using css maybe not feasible feasible in terms of resource consumption. when adding items on page, put all of them in column 1 adding additional css class position in column 2. responsive media queries either: hide colum...

python - Convention for "my class" in class method -

for example, have 2 class methods in class, 1 calling other. class myclass(object): @classmethod def foo(insert_name_here): print "foo." @classmethod def bar(insert_name_here): insert_name_here.foo() c short. funny words kind , myclass , such come mind, @ end of day consistency winner. what correct convention? or more generally, authoritative source finding such? there pep it? the convention call class parameter cls . see pep8 : function , method arguments always use self first argument instance methods. use cls first argument class methods.

MySQL query performance issue with MyISAM table -

folks i have table( billing_data) 60 million records. table engine myisam. have stored procedure read csv file , dump in temp table every 10-15 mins , inserted in table( billing_data). there lot of records being inserted in table. we trying run query below on same table( plus other tables in join) generate report. "select b.destination,b.release_cause_protocol_stack,b.binary_value_protocol_stack,b.release_cause billing_datas b inner join (select id carriermasters id in (99, 100, 101) ) c1 on b.carrierid_customer=c1.idinner join (select id technicalprofiles id in (83, 274, 84, 416)) t1 on b.technical_profileid_customer=t1.id inner join (select trunk trunks trunk in (90409, 90310, 30230, 30313) ) tr1 on b.origination_trunkid=tr1.trunk inner join (select id carriermasters id in (214, 215, 59, 60, 62, 292, 63, 216, 64, 61, 217, 274, 58) ) c2 on b.carrierid_supplier=c2.id inner join (select id technicalprofiles id in (223, 55, 224, 56, 225, 57, 226, 58, 227, 228, 229, 230...

c++ - Loss of data warning when copying to a data structure of smaller type -

i using visual studio 2013 , have code such following: void f() { std::vector<short> vecshort(10); std::vector<long> veclong(10); std::copy(veclong.begin(), veclong.end(), vecshort.begin()); } this gives warning: warning c4244: '=' : conversion 'long' 'short', possible loss of data the trouble real code in templates. user can instantiate templates such warning occurs, logic of code prevents actual loss of data. how can suppress warning in nice way? if weren't in std::copy put cast. edit: code used in other compilers , frowned upon me use pragmas. i think best bet use std::transform predicate (or lambda) cast (since you're asserting no loss of data converting smaller type). template <typename to> struct convert_to { template<typename from> operator()(from source) const { return static_cast<to>(source); } }; std::transform(veclong.begin(), veclong.end(), vecshort.begin(), convert...

facebook - disable automatic authentication for Google+ social sign-in -

i'm looking way avoid user automatically authenticated in web app when refreshes page. for example, user connects web app using google+ account , uses app while. later, when comes back, want app ask him click login button again, instead of automatically recognizing him authenticated. with facebook, i'm able set status property false when calling fb.init() , not automatically authenticate user upon initialization. is possible google+ sdk? thanks in advance! i found how it, in case wants know: gapi.signin.render('botaologinusuariogoogle', { 'callback': googleplussignincallback, 'clientid': '-----------------------------', 'cookiepolicy': 'single_host_origin', 'requestvisibleactions': 'http://schemas.google.com/addactivity', 'scope': 'https://www.googleapis.com/auth/userinfo.email', 'approvalprompt': "force" }); according documentatio...

Struggling to Answer Revision test on Android Activities and lifecycle -

i trying complete revision test on android mobile application development , stuck on final question- the following code part of activity reads , writes data file stored on device. app should work lifecycle methods make sure data automatically stored , displayed. code contains 4 common errors should highlight am right in thinking last 2 functions don't need protected? , edittext , listview should elsewhere? any appreciated. thanks i guess following errors: 1) edittext typecast listview illegal 2)the toast wouldn't show without .show() function in end of maketext() 3 & 4) onresume , onpause public! i no expert, guess these errors probably!

drupal - jQuery .val() not working in Shadowbox -

using answer calling jquery within / inside shadowbox (thanks rob grzyb , kannan!) , able jquery firing within shadowbox on drupal site, however, i'm unable 1 part of function: i have form in shadowbox, , i'm using .val() determine value of select field (and testing purposes, displaying value in alert box). when click 'submit' button , alert fires, alert reads first value (red) though i've selected different value (like green). on regular page, works expected , alert reads correct value. example code: <div class="color-form" style="display: none;"> <h3>what's favorite color?</h3> <form class="color"> <select name="colorurl" class="colorurl"> <option value="red">red</option> <option value="green">green</option> <option value="blue">blue</option> </select> <br /...

tcp - Weird issue with TcpClient.Connected=true when tcpclient and relative stream have been closed C# -

let's have 2 applications, server , client. i'm debugging them @ same time in 2 instances of visual studio 2010. let's on client side call: _reader.close(); //binaryreader _writer.close(); //binarywriter _ssl.close(); //sslstream taken _stream _stream.close(); //networkstream _client.getstream(); _client.close(); //tcpclient and i've checked through debugger code executed. after this, trigger, other instructions, closure of client application, infact visual studio exits debug mode , goes standard mode . in server application, since connection closed, pending _reader.read() fails, triggering exception handled in try/catch. this, according tcpclient.connected remarks should update value of tcpclient.connected accordingly. this doesn't happen: different thread in server keeps checking _client.connected it's still true. you should note that: 1) if close client usi...

mysql - lock wait time out exceeded in java jdbc transaction -

i created code adding data 3 tables. got error, lock wait time out exceeded. in database, i'm adding values takerslist, q_enrolls , test tables. i'm getting data qbank , question tables. takerlist foreign key stdid. think it's not important here. q_enroll's foreign keys qid(references question table), qbankid(references qbank) , testid(references test). @override public int add(test e, connection connection) throws sqlexception, classnotfoundexception, remoteexception { string query = "insert test values(?,?,?,?,?,?,?)"; object[] data = {e.gettestid(), e.gettestname(), e.gettestfrom(), e.gettestto(), e.gettotalquestions(), e.gettestdate(), e.getpassmark()}; try { connection.setautocommit(false); int res = dbhandle.setdata(connection, query, data); if (res > 0) { list<takerlist> list = e.getlisttakers(); takerlistmanagementmodel takerlistmodel = new takerlistmanagementmodel(); ...

qt - C++ istream tellg()/fail() on eof: behavior change; work-around? -

i upgraded compiler gcc-4.4 gcc-4.8 , 1 project fails miserably stemming following (false) assumptions: #include <sstream> #include <assert.h> int main() { using namespace std; istringstream iscan; int num; //iscan.unsetf(std::ios::skipws); iscan.str("5678"); iscan >> num; assert(iscan.tellg() == istringstream::pos_type(4)); assert(!iscan.fail()); assert(!iscan.good()); assert(iscan.eof()); assert(num == 5678); assert(false && "we passed above assertions."); return 0; } on gcc-4.4, relevant assertions pass. on gcc-4.8, tellg() returns -1 , and fail() returns !false, apparently since hit eof. my target mingw 32-bit shipped qt 5.1 (gcc-4.8). questions: is old behavior in error, per n3168 or other? (which other?) is there global, reliable, language-independent work-around? (i'm guessing not.) is there global, reliable, gcc work-around spans versions? even when above u...

sql server - Adding ghost data in a pretty way -

this kinda hard explain. our client wants able add "fictional data" or "ghost data". data shouldn't show unless explicitly defined. able "what if had delivery @ address". (which don't wanna pretend did) my first thought add boolean column tell whether entry ghost entry. means we'd have include constraint every stored procedure. or linq query we've every written , write. not solution. another idea coworker had creating duplicate table containing ghost data. way can keep them separate. problems arise once realize there's relationships table. these has duplicated too. , maintainability takes hit cause every change make in normal table have reflected in "ghost" table. ideas? you can create duplicate tables. - of course every table potentially hold ghost data need seperate table. to around problem relations need joins against unions of real , ghost data. edit: example

cocoa - Is there something similar to JOptionPane in Objective-C? -

i'm trying create simple game in objective-c. in java use joptionpane.showmessagedialog create simple window message or joptionpane.showinputdialog create simple input window... there's similar in objective-c? (or cocoa, or whatever use...) i'm not familiar joptionpane , can use uialertview both of things. default, displays message either 1 or 2 buttons. of ios 5, has style properties give uitextfield , make simple input prompt.

javascript - Adding more than one to a variable on click -

so add +1 variable use code varname++; if want increament value of say, 4 on click how should code look? this exampel code: var varname = 1; $('.button').click(function{ varname++; }); also, code revert this? i.e decrease variable specific value. you're looking += , -= : $('.button').click(function{ varname += 4; // increment 4 // varname -= 4; decrement 4 }); i'd suggest familirise javascript operators .

javascript - Select different options at an select form and show different content -

i have form 'select' different options needed. every time clicks on option different content should appear. that's solution (it works :) ), can see on length of code, complicated on. guess easier jquery? html <select onchange="optioncheck()" id="options" > <option>abc</option> <option>xyz</option> </select> <div id="showmorecontent1" class="hiddencontent">content1 goes here</div> <div id="showmorecontent2" class="hiddencontent">content2 goes here</div> js <script> function optioncheck() { selectoptions = document.getelementbyid("options"); helpdiv1 = document.getelementbyid("showmorecontent"); helpdiv2 = document.getelementbyid("showmorecontent2"); if (selectoptions.options[1].selected) { helpdiv1.classname = "visiblecontent"; } else...

java - Calling webservice using Stub -

can please me out findout correct method call webservice,below wsdl file eclipse generated below classes: emplookup emplookuplocator emplookupport emplookupportproxy emplookupportstub emplookuprequest emplookupresponse wsdl: <xsd:complextype name="list"> <xsd:sequence> <xsd:element maxoccurs="unbounded" nillable="true" name="anytype" type="xsd:anytype" minoccurs="0"> </xsd:element> </xsd:sequence> </xsd:complextype> </xsd:schema> <xsd:schema xmlns:stns="java:com.test.ws.emp" xmlns:xsd="http://www.w3.org/2001/xmlschema" attributeformdefault="qualified" targetnamespace="java:com.test.ws.emp" elementformdefault="qualified"> <xsd:complextype name="emplookuprequest"> <xsd:sequence> <xsd:element ...

testing - Branch Coverage for different kinds of loops -

i know if have if-statement so... if (x == y) { foobar++; } else { if (x == z) { foobar++; } } there 4 branches traverse in order 100% branch coverage. 2 outer if - else, 1 inner if statement , if doesn't go inner if statement. however, this... if (x == y) { foobar++; } else { while (x < z) { x++; } } are there still 4 branches needed 100% branch coverage? is, not going while loop else statement count separate branch? thank you. first of all: there no if-loops. it's called if-statement. as question: first example has 3 branches. first if creates 2 branches. inside else 2 more branches created doesn't add 4 child branches of else . if / \ 1 else | if / \ 2 3 for branch coverage of while loop gets little complicated. theoretically loop creates possibly infinte number of branches, don't know how or can run. there several practical approaches measure coverage of loops. simple 1 havin...

ruby - Loading validations from a table -

i need load model validations table , validate model. e.g. have database table called validations, has rows : validation_action validation_condition ---------------- -------------------- validates_presence_of if answer_name name validates_format_of if answer_type date in model want: class model < activerecord::base load validation_actions , lambda {if validation_condition true} ok more detail: i creating app taking surveys. storing questions in table , answers in table. need store validation each answer in question table , validate each answer before accept it. can query validation each question , run in controller want in model instead cleaner. so 2 models : questions -> table questions sas code , details questions answers -> table answers stores answers foreign key questions. i want validate input in answers model depending upon conditions defined in questions database table. please let me know if more detail needed? if u...

.net - Regular Expression Select text between spaces -

i need extract text between spaces within string. in sample below i'm looking extract text '401900 pre' group named recipe. group recipe must not return white space after letters pre. here's have @ moment. '401900 pre current user' gets printed screen. can't figure out how stop after pre. the 401900 pre text changes regularly other text elements constant. string recipe = "<operate mode> - 401900 pre current user"; regex regex = new regex(@".*<operate mode> - (?'recipe'.*\ *)"); matchcollection mc = regex.matches(recipe); foreach (match m in mc) { console.writeline(m.groups["recipe"]); } console.readline(); thanks. just include constant stuff don't want match in pattern: @".*<operate mode> - (?'recipe'.*?)\s+current user" note need make repetition inside group ungreedy , otherwise con...

Qt Creator slow because of many includes -

i'm working on qt creator project includes lot of header files (point cloud library, boost, etc.). e.g. boost has round 9000 header files. seems that amount of includes slows down ide. code completion slow, ca. 2 seconds until suggestion appears. copy , paste gets slow. when remove includes pro file getting better immediately. i've new computer (8 gb ram, core i5, ssd). normal behaviour? anyway speed application? don't include boost libraries, add libraries need, example #include <boost/accumulators/accumulators.hpp>

java - Arrays and input -

my assignment asks me write program let user input 10 players' name, age, position, , batting average. program should check , display statistics of players under 25 years old , have batting average of .280 or better, display them in order of age. i've written code input section (where it'll store them in array): static int players[] = new int [10]; static string name[] = new string [10]; static double average [] = new double [10]; static int age[] = new int [10]; static string position[] = new string [10]; //method input names of blue jays public static void inputinfo() throws ioexception{ bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); for(int = 0; < players.length; i++) { system.out.println("enter player information."); system.out.println("input first , last name: "); name [i] = br.readline(); system.out.println("input position: "); position[i]...

hibernate - Why use @Transactional with @Service instead of with @Controller -

i have seen many comments in stack-overflow articles found things either @transactional use @service or @controller "usually, 1 should put transaction @ service layer." "the normal case annotate on service layer level" "think transactions belong on service layer. it's 1 knows units of work , use cases. it's right answer if have several daos injected service need work in single transaction." [source] drawback use @transactional @service layer if had 2 methods example saveuser() , saveemail() (because store emails in database send them later - queue) create in service method saveuserandsendemail(user user) transactional. [source] it means create many methods in service layer instead of 1 save generic method follow public <t> long save(t entity) throws dataaccessexception { session session = sessionfactory.getcurrentsession(); long getgenval=(long) session.save(entity); return getgenval; } acco...

php - Proper way to download image from server using headers -

i made script creates .jpg file , saves server, want make downloadable user when open image downloaded error corrupted file, although image not corrupted because can open server (manually image viewer). these headers: header('content-description: file transfer'); header("content-type: application/octet-stream"); header("content-disposition: attachment; filename=image.jpg"); readfile('image.jpg'); i tried change content-type image/jpeg same results

c# - Width of the form can not be less than 140 pixels. Why? -

i created default windows forms application project in visual studio 2012. when run program saw width of form can not less 140 pixels. why? , how overcome strange restriction? users wouldn't able use window's minimize, maximize, , close buttons @ top. don't believe can change behaviour sizable formborderstyle. it's usability thing. if remove border, setting none example, can set whatever want programmatically doing: form.width = [...]; you can resize further forms border types: none, fixedtoolwindow, , sizabletoolwindow. toolwindows won't let go below amount well, none let above 2px. set value below that, without getting exception, won't anything.

vb.net - Refactoring case select into if statement -

i have following code: dim usefont font = e.font dim mybrush brush = brushes.black ' determine font draw each item based on ' index of item draw. if e.index = 0 or 7 or 10 or 13 usefont = new font(e.font, fontstyle.bold) else usefont = defaultfont end if ' select e.index ' case 0 'usefont = new font(e.font, fontstyle.bold) ' case 7 'usefont = new font(e.font, fontstyle.bold) ' case 10 'usefont = new font(e.font, fontstyle.bold) ' case 13 'usefont = new font(e.font, fontstyle.bold) 'end select the commented out code below old, working code. thought better rewrite make more compact , readable, cannot work out how perform same function case select, results in list items becoming bold. don't know if i'm misunderstanding or operator, , orelse not work either. can give me pointers in right direction? thanks. if e.index...

java.lang.NoClassDefFoundError: Could not initialize class play.data.format.Formatters -

i'm using play 2.1.2 , want use dynamic forms. tried in own small hello world project , worked fine, when use forms in other bigger project i'm getting exception. here code (in both project same): controller public static result signinform() { dynamicform form = form.form().bindfromrequest(); //exception on line return renderjapid(form); } routes get /sign-in controllers.authentication.signinform() when go localhost:9000/sign-in exception : caused by: java.lang.noclassdeffounderror: not initialize class play.data.format.formatters @ play.data.form.bind(form.java:320) ~[play-java_2.10.jar:2.1.2] @ play.data.dynamicform.bind(dynamicform.java:100) ~[play-java_2.10.jar:2.1.2] @ play.data.dynamicform.bindfromrequest(dynamicform.java:71) ~[play-java_2.10.jar:2.1.2] @ controllers.authentication.signinform(authentication.java:310) ~[na:na] @ routes$$anonfun$routes$1$$anonfun$applyorelse$19$$anonfun$apply$19.apply(...

python - Is it possible to use a PositiveIntegerField as a foreign key in Django? -

consider following 2 django models: class item(models.model): ''' represents single item. ''' title = models.textfield() class information(models.model): ''' stores information item. ''' approved = models.booleanfield(default=false) multipurpose_field = models.positiveintegerfield() due way models organized, forced use positiveintegerfield in information referencing item instead of using foreignkey . makes queries more difficult. i select items referenced information instance approved set true . in other words, this: information.objects.filter(approved=true) ...except query return instances of information instead of item referenced in multipurpose_field . i raw sql: select app_item.title app_item left join app_information on app_information.multipurpose_field = app_item.id app_information.approved = 1 is there way without resorting raw sql (which isn't por...

sql - PHP UTF-8 Encoding MYSQL Inserts? -

i have strange behaviour i'm experiencing. when run insert utf8 character (specifically 'ő' or 'ű' hungarian characters) inserts ? instead of character. if echo out right before passing query shows right characters. what have done: i have set every possible collation, charset in mysql tables , databases utf8. i have called mysql_query("set names 'utf8'"); i have called mysql_query("set character set utf8"); i have set website encoding with: <meta http-equiv="content-type" content="text/html; charset=utf-8" /> what works intended: phpmyadmin echoing special characters tables it's working on localhost server. non local server's default encoding iso-8859-1 can't change. if you 1 - set html page's lang encoding utf-8 includes forms 2 - use forms enter input related mysql db tables 3 - set collations utf8_unicode_ci in mysql (tables , rows collations) 4 - if have p...

python - Allowing remote access to Elasticsearch -

i have default installation of elasticsearch trying query third party server. however, seems default blocked. is please able tell me how can configure elasticsearch can query different server? any appreciated. james when elasticsearch installed , run without configuration changes default binds localhost only. access elasticsearch rest api endpoint remotely below changes has made on server elasticsearch has been installed. elasticsearch configuration change update network.host property in elasticsearch.yml per guidelines provided in elasticsearch documentation example bind ipv4 addresses on local machine, change below network.host : 0.0.0.0 firewall rules update update linux firewall allow access port 9200. please refer linux documentation adding rules firewall. for example allow access servers(public) in centosos use firewall-cmd $ sudo firewall-cmd --zone=public --permanent --add-port=9200/tcp success $ sudo firewall-cmd --reload success note : in productio...

sql - MSSQL Substring and keep the last word intact -

i have following example string: this string large, has more 160 characters. can cut substring has 160 characters cuts of last word looks kind of stupid. now want have round 160 characters, use substring() select substring('this string large, has more 160 characters. can cut substring has 160 characters cuts of last word looks kind of stupid.', 0 , 160) wich results in: this string large, has more 160 characters. can cut substring has 160 characters cuts of last word l now need find way finish off last word, in case word looks any idea whats best way approach problem? declare @s varchar(500)= 'this string large, has more 160 characters. can cut substring has 160 characters cuts of last word looks kind of stupid.' select case when charindex(' ', @s, 160) > 0 substring(@s, 0, charindex(' ', @s, 160)) else @s end

ios - understanding blocks (login with twitter) -

i'm trying understand blocks in objective-c. take example logging twitter. want main thread wait until block finished. how can achieve in following code. method showmain transitioning next view. array tweetarray empty because async block not finished. right now, i'm using method performselectoronmainthread:withobject:waituntildone:. please explain concept of blocks in detail. [account requestaccesstoaccountswithtype:accounttype options:nil completion:^(bool granted, nserror *error) { [mbprogresshud showhudaddedto:self.view animated:yes]; dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_low, 0), ^{ if (granted) { nsarray *accounts = [account accountswithaccounttype:accounttype]; // check if users has setup @ least 1 twitter account if (accounts.count > 0) { acaccount *twitteraccount = [accounts objectatindex:0]; ...