Posts

Showing posts from February, 2015

c# - NUnit: Common Language Runtime detected an invalid program -

when running nunit tests in teamcity, keep getting following error. test(s) failed. system.reflection.targetinvocationexception: exception has been thrown target of invocation. ---> system.invalidprogramexception: common language runtime detected invalid program. @ system.web.razor.parser.syntaxtree.block..ctor(blocktype type, ienumerable`1 contents, string name) @ system.web.razor.parser.syntaxtree.block..ctor(blocktype type, ienumerable`1 contents) @ system.web.razor.parser.syntaxtree.syntaxtreebuildervisitor.visitendblock(blocktype type) @ system.web.razor.parser.visitorpair.visitendblock(blocktype type) @ system.web.razor.parser.parsercontext.endblock() @ system.web.razor.utils.disposableaction.dispose(boolean disposing) @ system.web.razor.utils.disposableaction.dispose() @ system.web.razor.parser.htmlmarkupparser.parserootblock(tuple`2 nestingsequences, boolean casesensitive) @ system.web.razor.parser.htmlmarkupparser.parsedocument() @ system

java - Counting the characters of a string and than placing the value inside a for loop -

i taking introductory java programming course , have been setting following exercise: write program can ask series of questions array of strings. should print line of stars under question, line of stars same length question printed above it. below code have written. starlineexercise class features method called starline, have started write below. starline method needs print many "*" characters in each of previous system.out.println commands. i have tried create string object each question, count of that, , place loop, eclipse gives me error saying count variable can not resolved. import java.util.scanner ; public class starlineexercise{ public static void main(string[] args){ scanner sc = new scanner (system.in); system.out.println ("please enter name"); starline(); string name = sc.nextline(); starline(); system.out.println("pleae enter age"); starline(); int age = sc.nextint(); system.out.println(&q

excel vba - Copying table using macros -

i have standard big table manipulate data from, when record macro copy table excel doc new excel doc, not work because when rerun macro gives error "can't execute code in break mode" or "paste method of worksheet class failed". please advise on how can table copied using code can go on doing pivot tables it.

reporting services - Repeater in SSRS -

i have created 3 datasets report. also, have taken 3 tables inside data region show data. i have 1 parameter that customer id filter data. now question want repeat 3 table data customer wise in separate page. for example: customer id 1,2,3,4,5,6 data should displayed customer id 1 table1 table2 table3 customer id 2 table 1 table 2 table 3 customer id 3 table 1 table 2 table 3 and on create group on customer id , list 3 table within group. force new page on group change (begin or after) this give report looking for.

mysql - Data truncated when trying to import CSV file -

hi here load statement: load data local infile 'c:/geoipcountrywhois.csv' table geolocation fields terminated ',' enclosed '"' lines terminated '\n'; 30 row(s) affected, 1 warning(s): 1265 data truncated column 'cn' @ row 30 records: 30 deleted: 0 skipped: 0 warnings: 1 create table `geolocation` ( `start_ip` char(15) not null, `end_ip` char(15) not null, `start` int(10) unsigned not null, `end` int(10) unsigned not null, `cc` char(2) not null, `cn` varchar(50) not null ) engine=myisam default charset=utf8 i found problem line below because of comma in korea things new field starts. 1.11.0.0,1.11.255.255,17498112,17563647,kr,"korea, republic of" i can remove commas can change load statement somehow? you should use optionally enclosed by instead of enclosed by . http://dev.mysql.com/doc/refman/5.1/en/load-data.html adding optionally statement allows csv in current form. without optio

javascript - Lock text highlighting in a website? -

i want lock copy button don't want lock save button totally right click ,so user of site can save website html file can not copy text ,how can javascript guys? you can use css: user-select: none; this makes text on site not selectable, user not able highlight , copy of it. additional information can found on site here: how disable text selection highlighting using css?

java - Abstract Class - Why is my protected method publicly accessible? -

why can access dostuff() method in main method below? since dostuff() protected, expect testclassimplementation has access it. public abstract class abstracttestclass { protected void dostuff() { system.out.println("doing stuff ..."); } } public class testclassimplementation extends abstracttestclass{ } public class myprogram { public static void main(string[] args) { testclassimplementation test = new testclassimplementation(); test.dostuff(); //why can access dostuff() method here? } } looks myprogram class in same package of abstracttestclass . if so, can access protected , public members of classes in same package. covered in java tutorials: modifier class package subclass world public y y y y protected y y y n no modifier y y n n private y n n n in order fix this, move abstracttestclass package. similar ot

In c++, if a member pointer point to some data, how to protect that data from being modified? -

class { public: a(){ val = 0; p = new int; *p = 0; } //void fun_1()const{ val = 1; } not allowed void fun_2()const{ *p = 1; } void display()const{ cout<< val <<' '<< *p <<endl; } private: int val; int * p; }; int main() { const a; a.fun_2(); } change member data in const member function fun_1()const not allowed. however, when data not directly member of object, allocated storage , assigned inside object, const function can't protect it. fun_2()const can change data p point although it's const function example. is there way protect data p point ? it's relatively straightforward cause compiler protect pointed-to object, not done automatically because isn't correct thing do. template<typename t> class constinator_ptr { t* p; public: explicit constinator_ptr( t* p_init ) : p (p_init) {} t*& ptr() { return p; } // use reassign, or define operator=(t*) t* opera

mongodb - Node Express Trouble returning object to view from query -

i'm trying to: pass user's id model query, should return user record mongo. render user object view can use fields. i'm not quite sure what's going wrong - query function finds correct user , can console.dir see fields. when try return view res.render nothing: here's route: app.get('/account', function(req, res) { res.render('account', {title: 'your account', username: req.user.name, user:account.check(req.user.id) }); }); and query function: exports.check = function(userid) { mongoclient.connect('mongodb://127.0.0.1:27017/test', function(err, db) { if(err) throw err; var collection = db.collection('test'); collection.findone({userid : userid}, function(err, user) { if (err) throw err; console.log("account.check logging found user console: "); console.dir(user); return user; }); }); } again, shows proper entry finally view: <h1>account page</h1> <hr> <p&

c++ - OpenCv depth estimation from Disparity map -

i'm trying estimate depth stereo pair images opencv. have disparity map , depth estimation can obtained as: (baseline*focal) depth = ------------------ (disparity*sensorsize) i have used block matching technique find same points in 2 rectificated images. opencv permits set block matching parameter, example bmstate->numberofdisparities . after block matching process: cvfindstereocorrespondencebm( frame1r, frame2r, disp, bmstate); cvconvertscale( disp, disp, 16, 0 ); cvnormalize( disp, vdisp, 0, 255, cv_minmax ); i found depth value as: if(cvget2d(vdisp,y,x).val[0]>0) { depth =((baseline*focal)/(((cvget2d(vdisp,y,x).val[0])*sensor_element_size))); } but depth value obtaied different value obtaied previous formula due value of bmstate->numberofdisparities changes result value. how can set parameter? change parameter? thanks the simple formula valid if , if motion left camera right 1 pure translation (in par

wordpress plugin- how to avoid potential overload on the server /database? -

i’m using wordpress(buddypress) build dating website. estimated members -6000,estimated visitors per day 500-600. major part of website kind of matching questionnaire , each time or other member answer question updating list of best matches (from members), displayed in questionnaire page in website . that means lots of simultaneous database connections /requests . now told colleague developing such questionnaire plugin wordpress /buddypress big mistake. first because processing data in real time, meaning answers sent database ,compared ,calculated , send page exceed server capacity soon. second because each request invokes loading of whole wordpress (wp-load.php). solution manage calculations outside wordpress in kind of soap web service, i ask advice : do think there chance plugin cause problem of overload ? how avoid overloading in plugin , webservice solution? creating seperate database? ill appreciate can thank you. i owner of buddypress site, yours.

ios - Universal Storyboard? -

in old xib world of ios development, able create 1 view controller , 1 xib, , use them both iphone , ipad environments. few code tweaks, xib resize , adjust fit different dimensions , aspect ratios. allowed me reduce risk of 2 layouts getting out of sync on time. is same thing possible in world of storyboards? default xcode creates 2 distinct storyboards universal app -- 1 iphone , 1 ipad. how can use 1 storyboard both? thanks! updated: size classes in xcode 6 achieve goal of universal storyboards. more info here: https://developer.apple.com/library/prerelease/ios/documentation/developertools/conceptual/whatsnewxcode/articles/xcode_6_0.html in short...you can't. there's workaroud use create ipad storyboard @ end of iphone development. you have locate iphone story board , using terminal can duplicate giving name of ipad storyboard xcode has created you. delete empty old storyboard , open newly copied 1 changinge targetruntime attribute "ios.

nginx - Why do my browsers say my server's SSL certificate has expired but OpenSSL says it hasn't? -

in nginx conf file, have ssl_certificate identified. according openssl, end date of certificate in future. when access site browser, says certificate has expired. it possible used expired certificate previously, don't understand browser getting now. suggestions should look? the certificate has 2 fields - valid , valid to. check both parameters ok, i.e. valid in past , valid in future. when visit site browser, shows lock icon either left url in address bar or in status bar. clicking on lock icon show certificate browser sees. check certificate corresponds 1 have in server config.

jsp - Eclipse Localhost to download File -

i have installed tomcat version 7.0 , have .pdf file in tomcat root folder, can directly access firefox when tomcat server running, using link: localhost:8080/filename.pdf now, have written java servlet code, when executed on eclipse produces link (localhost:8080/filename.pdf), on clicking link getting error 404, resource not found. any idea , how resolve ???

java - Using Scanner...Error: '.class' expected -

getdiscountedbill() return final amount of bill if bill >2000, bill receives 15% discount public class discount { private double bill; private double discount; private double amt; public static double getdiscountedbill(double bill) { if (bill > 2000) { discount = bill * .15; amt = bill - discount; } return amt; if (bill <= 2000) { return bill; } } public void print() { system.out.println("bill after discount :: "); system.out.printf("%.2f\n", amt); } code in main public static void main( string args[] ) { scanner keyboard = new scanner(system.in); out.print("enter original bill amount :: "); double amt = keyboard.nextdouble(); keyboard.getdiscountedbill(double); keyboard.print(); error message:error: '.class' expected keyboard.getdiscountedbill(double); change statement: keyboard.getdiscountedbill(double); with one

arrays - Java program - Counts all the words from a text file, and counts frequency of each word -

i'm beginner programmer , i'm trying 1 program opens text file large text inside , counts how many words contains. should write how many different words in text, , write frecuency of each word in text. had intention use 1 array-string store unique words , 1 int-string store frequency. the program counts words, i'm little bit unsure how write code correctly list of words , frequency them repeated in text. i wrote this: import easyio.*; import java.util.*; class oblig3a{ public static void main(string[] args){ int cont = 0; in read = new in (alice.txt); in read2 = new in (alice.txt); while(read.endoffile() == false) { string info = read.inword(); system.out.println(info); cont = cont + 1; } system.out.println(uniquewords); final int an_words = cont; string[] words = new string[an_words]; int[] frequency = new int[an_words]; int = 0;

java - How to edit a JList item text by double clicking on it? -

i have jlist populated strings. want able edit item double clicking on , edit text in jlist itself. if click item, it's highlighted , see cursor, example delete text , write else. click enter , text edited successfully. possible & how can please? need this. see list editor couple of solutions, 1 use jtable, other create custom edit action jlist.

actionscript 3 - Convert text string to hexadecimal using flash builder -

i want convert mac address hexadecimal string using flash builder.. used code var networkinterface : object = networkinfo.networkinfo.findinterfaces(); var networkinfo : object = networkinterface[0]; var physicaladdress : string = networkinfo.hardwareaddress.tostring(); txtreq.text = physicaladdress + "-" + txtserial.text var reqcode:uint = uint(txtreq.text); var reqcode1:string = reqcode.tostring(16); txtact.text = reqcode1; when run application, txtserial.text = 123 , physicaladdress = c6-17-31-a9-ef-ff ... but txtact.text got 0 . then how fix problem , in flex builder how convert ff-ff-ff-ff-ff text hexadecimal code... you should use parseint(reqcode,16) instead of reqcode.tostring(16);

vb.net - Click on a button to dispaly the next record in Ms Access Database -

i have records in dsatabase in access, table called "add form". have created form in vb delete selected record record table show in respective textboxes , user click delete delete record , either click next\previous navigate record. code next button: if inc <> maxrows - 1 inc = maxrows - 1 navigaterecords() elseif inc = -1 msgbox("this first record") end if the navigate function here : private sub navigaterecords() student_idtextbox.text = ds.tables("add form").rows(inc).item(0) student_nametextbox.text = ds.tables("add form").rows(inc).item(1) date_of_birthdatetimepicker.text = ds.tables("add form").rows(inc).item(2) addresstextbox.text = ds.tables("add form").rows(inc).item(3) e_mailtextbox.text = ds.tables("add form").rows(inc).item(4) allergiestextbox.text = ds.tables("add form").rows(inc).item(5) emergency_contact_numbertextbox.text = ds.tables(&q

regex - How do I match this string -

quick question. how match site.com/characters/ and not match site.com/characters/characters2 attempt: site.com/[a-za-z]+/? quick answer: your approach fine. should have used $ (terminating character) specify match. site.com/[a-z]+/?$

android - SimpleCursorAdapter - modify data before load into ListView -

i have simplecursoradapter populates data form sqlite database. it's working fine, "duration" column given in milliseconds , divide (duration / 1000) before displaying. possible without storing duration (in minutes) column in db? adapter: adapter = new simplecursoradapter(getactivity(), r.layout.rec_list_items, db.selectallrecords(), new string[] { "day", "hour", "minute", "duration", "link" }, new int[] { r.id.textview_day, r.id.textview_hour, r.id.textview_minute, r.id.textview_duration, r.id.textview_link }, cursoradapter.flag_register_content_observer); selectallrecords: public cursor selectallrecords() { string[] cols = new string[] {id, day, hour, minute, duration, link}; cursor mcursor = database.query(true, table,cols,null , null, null, null, null, null); if (mcursor != null) { mcursor.movetofirst(); } return mcursor; } you have couple of options h

java - Some clarifications about how ant copy some files into a folder? -

this question exact duplicate of: some clarification how ant copy files folder? 1 answer i pretty new ant (i came maven , ant nightmare me !!!) i have target: <target name="linuxdriver" description="linux driver"> <copy file="${deps.linuxdriver.dir}/${deps.linuxdriver.name}" tofile="${project.datadir}/${deps.linuxdriver.name}"/> <copy file="${deps.linuxdriver.dir}/${deps.linuxdriver.name}" tofile="${project.deploy}/data/${deps.linuxdriver.name}"/> <chmod perm="+x" file="${project.datadir}/${deps.linuxdriver.name}"/> <chmod perm="+x" file="${project.deploy}/data/${deps.linuxdriver.name}"/> </target> and have property file in there definied "variable" (are named variable?) used in

html - Unexpected DIV border lines on ipad -

Image
as can see on picture below, there's kind of black border line when @ website on ipad. know why , how read of that? many thanks, .banner2 { position: absolute; top: 40px; left: 40px; display: inline; padding: 20px; background: #fff; color: #2165cb; font-weight: 400; } .banner3 { position: absolute; top: 110px; left: 80px; display: inline; padding-top: 5px; padding-right: 20px; padding-bottom: 5px; padding-left: 20px; background: #2690cd; color: #fff; } i presume they're images can use: .banner2 img, .banner3 img{ border: 0; } if they're not images add border: 0; css styles both .banner2 , .banner3 .

erlang - Howto dump xml data with xmerl_scan even if syntax error -

when using xml file syntax error xmerl_scan:file output indicate line , column number : 1> xmerl_scan:file('failed.xml'). 2542- fatal: {endtag_does_not_match,{was,request,should_have_been,http}} ** exception exit: {fatal,{{endtag_does_not_match,{was,request, should_have_been,http}}, {file,'failed.xml'}, {line,77}, {col,8}}} the problem file failed.xml composed lot of entity original file doesn't contains 77 lines, debug not easy case. howto dump final xml analyzed xmerl_sacn debug xml ? options pass xmerl_scan ? read doc can't find solution. a solution use xmerl_sax_parser:file/2 proppose lars thorsen in erlang-questions list http://erlang.org/pipermail/erlang-questions/2013-october/075682.html

c# - Database insertion troubles because of character (') -

if try insert string in database containing character (') , face problem. sql ="insert mytable (name) values ('"&request("name")&"') " the solution beginners is sql ="insert mytable (name) values (replace('"&request("name")&"',"'","@") " for example have change when retrieving record. but, problem if have large amount of these fields might contain character (') , follow time-consuming solution every field?! or maybe of have smart , quick solution? edit: stated in comments, way suggested following. first, fetch of values , store them in variables. create insert statement using parameters insert values database. var value1 = //fetch want insert var value2 = //fetch want insert using (sqlconnection con = new sqlconnection(connectionstring)) using (sqlcommand cmd = new sqlcommand("insert mytable values (@value1, @value2)", con)) {

Database Normilzation to 3NF -

i trying complete normalization following erd ![1]: http://i42.tinypic.com/fng2a9.jpg i have completed 1nf but, stuck on normalizing further. structures below not considered 3nf? port (portid,name,country,population,passport_req,dockingfee) port_attractions (attractionid, portid, attractiondescription) passenger (passnum,name, nationality,age) passenger_address (passnum,street,city,state,zip) ship (shipnum, name,weight, yrbuilt, capacity) sailor(sailorid, fname, lname, yearsservice, nationality) cruise (serialnumber, sailingmonth, sailingday, sailingyear, returnmonth, returnday, returnyear, departureport)

php - Make array from jquery serialized string -

i have serialized string jquery: [{"id":1}, {"id":2,"children":[{"id":3}]}, {"id":4,"children":[{"id":5,"children":[{"id":6,"children":[{"id":7}]}]}]}, {"id":8},{"id":9},{"id":10} ] i want pharse in php like: $menu = array( array( 'name' => 'item 1', 'id' => '1' ,'children' => '0'), array( 'name' => 'item 2', 'id' => '2' ,'children' => '0'), array( 'name' => 'item 3', 'id' => '3' ,'children' => '2'), array( 'name' => 'item 4', 'id' => '4' ,'children' => '0'), array( 'name' => 'item 5',

c++ - Filtering non-trivial loggers in Boost.Log? -

i'm trying figure out how enable simple filter in combination boost_log_sev. for example, if set up: enum class severitylevel { foo, bar }; boost::log::sources::severity_logger_mt<severitylevel> slg; boost_log_sev(slg, severitylevel::foo) << "foo log record"; boost_log_sev(slg, severitylevel::bar) << "bar log record"; i'd able add this: slg.set_minimum_severity(severitylevel::bar); // filter out foo logs the boost.log docs jump rather filtering on trivial logs more complicated cases. first, little secret may want know reading boost log documentation, code examples more complete summaries on doc pages. if understand right should happy example http://www.boost.org/doc/libs/1_54_0/libs/log/example/doc/tutorial_filtering.cpp look set_filter line, , adapt to: sink->set_filter(severity >= severitylevel::bar); for more advanced filters asked related question on boost users mailing list: http://lists.bo

sql server - SQL grouping not working -

Image
i using ms sql server 2012 i have query uses subquery create column shows summed percent of assets. need summed column group portfoliobasecode shown below. i have tried group , partition without success. group result portfolio codes correctly group summedpct still total of portfolios , not subtotaling want. with partition following error. can use top 1 not give desired result. error msg 512, level 16, state 1, line 17 subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression. using top 1 it may placing group or partition on in wrong place in query. need way correctly group column summedpct. here query: https://dl.dropboxusercontent.com/u/29851290/cashpercent.sql here result set , desired result. the problem actual result is taking sum total of percentassets , placing them in summedpct. the result want these percent of assets grouped portfoliobasecode. note in desired result set

java - Android ImageAdapter with Gridview in Fragment -

i have adapter gridview works activity. trying place in fragment , converted things not work. when include iconfragmentsystem in activity force close when try open activity. i know activity works because can use other fragments , okay know issue lies within file. package com.designrifts.ultimatethemeui; import com.designrifts.ultimatethemeui.r; import android.content.context; import android.content.intent; import android.content.res.resources; import android.net.uri; import android.os.bundle; import android.support.v4.app.fragment; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.*; import java.util.arraylist; public class iconfragmentsystem extends fragment implements adapterview.onitemclicklistener{ private static final string result_ok = null; public uri content_uri; public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(

java - iRuntimeExceptions are considered as fault or failure? -

i writing technical paper , not sure whether write them fault or failure. because far know fault error programmer. fault/error may or may not crash program. if fault crash program failure. question if divisionbyzero exception, should write fault or failure? thanks i suggest categorize error/exception. exception can handled , of 2 types : checked handle exception in method using try/catch/finally unchecked make caller handle using throws statement. you cannot implicitly handle errors in program

php - Delete rows from different tables in CodeIgniter -

a little bit of code-snippet: $this->db->where('id', $outfit_id); $this->db->update('outfit_main',$data); //delete productsettings specific outfit (they added below new values) $this->db->where('outfit_id', $outfit_id); $this->db->delete('outfit_products'); //delete outfit_images specific outfit well. added below $this->db->where('outfit_id', $outfit_id); $this->db->delete('outfit_images'); what want is: delete rows outfit_main id = $outfit_id delete rows outfit_products outfit_id = $outfit_id delete rows outfit_images outfit_id = $outfit_id but in fact when add last 2 rows: $this->db->where('outfit_id', $outfit_id); $this->db->delete('outfit_images'); * it deletes rows outfit_main well. why?* try combining clause delete active record: $this->db->delete('outfit_main', array('id' => $outfit_id)); $this->db->dele

vb.net - VB graphics from image file shows bigger than it's original size -

i have in vb.net : public class form1 dim output new bitmap(300, 300) dim gfx graphics = graphics.fromimage(output) sub refreshscreen() handles timer1.tick gfx.drawimage(image.fromfile("wheel.png"), new point(50, 50)) gfx.fillrectangle(brushes.blue, 100, 100, 25, 25) 'some other drawings on top picturebox1.image = output end sub end class the problem "wheel.png" shows bigger in picturebox1 it's original resolution , scaled , blurred. how can fix ? change line : gfx.drawimage(image.fromfile("wheel.png"), new point(50, 50)) by : gfx.drawimage(image.fromfile("wheel.png"), new rectangle(0, 0, 225, 70)) a rectangle specify size, not worry weird scaling. have image in variable object, , accessing object .height , .width fix drawimage issue.

Uploading Large Files (> 600 MB) using mechanize python -

i trying upload large file using mechanize. files of size > 450 mb. i able use mechanize , successful in uploading files 5 mb. here code: web = mechanize.browser() web.open("http://x.om/") web._factory.is_html = true web.form = formobj[1] web.set_all_readonly(false) web.form.add_file(open(self.location, 'rb'), 'application/octet-stream', filename, nr=0, name='file[]') response = web.submit() i glad if can in procuring large files.

javascript - Recursion "maximum call stack size exceeded" - decimal to hexadecimal converter -

i'm trying make decimal hexadecimal converter without using number.prototype.tostring (this assignment not allow function). attempting use recursion try work it. works until else inside main else if makes sense. gives me error when run number above 255 (i.e. number has more 2 digits in hexadecimal). know why case? var number = parseint(prompt("give me number , turn hexadecimal!")); var digit = 1; var hexconverter = function () { if (digit === 1) { if (math.floor(number / 16) === 0) { console.log(hexdigits[number]); } else { digit = 16; console.log(hexconverter(), hexdigits[number % 16]); } } else { if (math.floor(number / (digit * 16)) === 0) { return (hexdigits[math.floor(number / digit)]); } else { return (hexconverter(), hexdigits[number % (digit * 16)]); } digit = digit * 16; } }; hexconverter(); you changing digit afte

max - How do I use a pair to find which of two functions will evaluate the largest value? Scheme -

basically there pair made of 2 functions , code has take pair input x find highest evaluation x , print evaluation. receive error : car: contract violation expected: pair? given: 4 define (max x) (lambda (x) ;i wanted lambda highest suitable function (if (> (car x) (cdr x)) (car x) (cdr x)))) (define one-function (lambda (x) (+ x 1))) (define second-function (lambda (x) (+ (* 2 x) 1))) ;my 2 functions ((max (cons one-function second-function)) 4) and functions being called? , have two parameters called x , must have different names. try this: (define (max f) ; must use different parameter name (lambda (x) (if (> ((car f) x) ((cdr f) x)) ; call functions ((car f) x) ((cdr f) x)))) now it'll work expected: ((max (cons one-function second-function)) 4) => 9

visual studio 2010 - Distance Converter for inches, feet, and yards in C# -

i new programming, silly question simple answer. application allows users type number, select unit of measurement using, select unit of measurement convert , convert it. i have 1 error in last line of code keeping working: 'cannot implicitly convert type 'int' 'string'. can please help? here's code: private void convertbutton_click(object sender, eventargs e) { int fromdistance; int todistance; fromdistance = int.parse(distanceinput.text); string measureinput = fromlist.items[fromlist.selectedindex].tostring(); string measureoutput = tolist.items[tolist.selectedindex].tostring(); switch (measureinput) { case "yards": switch (measureoutput) { case "yards": todistance = fromdistance; break; case "feet": todi

javascript - My resetActive is not working -

why resetactive call not work, background yellow pulls resetactive not. here code: $(document, "#reloadpage").on('mouseover', function() { resetactive() $("#reloadpage").css("background-color","yellow"); }); why resetactive call not work? css: #reloadpage:hover { background-color: yellow } javascript: $('#reloadpage').on('mouseover', function () { resetactive(); });

python - How to Use the Pygame Rect -

i have been experimenting pygame, , have come across problem not find answer to. in this paste , basic game framework exhibited. how can complete ballsnapleft() definition correctly? edit: not looking code completed, looking explain how 'rect' class(?) works, , how applied. edit2: have tried use x , y coordinates so, think there simpler way can work, instead of using brute coordinates. from making games python , pygame : myrect.left int value of x-coordinate of left side of rectangle. myrect.right int value of x-coordinate of right side of rectangle. myrect.top int value of y-coordinate of top side of rectangle. myrect.bottom int value of y-coordinate of bottom side. because of these attributes return integers, that's why code isn't working. also, if goal ballsnapleft() move ball position away player, ballrect.right = playerrect.left - distance change x coordinate of rect. make ball move in y coordinate like

python - How to perform a simple calculation in a CSV and append the results to the file -

i have csv contains 38 colums of data, want find our how is, divide column 11 column column 38 , append data tot end of each row. missing out title row of csv (row 1.) if able snippet of code can this, able manipulate same code perform lots of similar functions. my attempt involved editing code designed else. see below: from collections import defaultdict class_col = 11 data_col = 38 # read in data open('test.csv', 'r') f: # if have header on file # header = f.readline().strip().split(',') data = [line.strip().split(',') line in f] # append relevant sum end of each row row in xrange(len(data)): data[row].append(int(class_col)/int(data_col)) # write results new csv file open('testmodified2.csv', 'w') nf: nf.write('\n'.join(','.join(row) row in data)) any appreciated. smnally import csv open('test.csv', 'rb') old_csv: csv_reader = csv.reader(old_csv) open(

playframework - Testing play controller's interaction with an akka actor -

my play application uses akka actor handle long running computation: class mycontroller(myactor : actorref) extends controller{ def dostuff = action { implicit request => val response : future[any] = myactor ? dostuff async{ response.map{ str : string => ok(str) } } } } i trying test things working properly. have separate tests checking actor behaves , want check controller sends right msgs actor. current approach kind of this: class mycontrollerspec extends specification{ "mycontroller" should { object dummyactor extends actor{ def receive = { case _ => () } } "do stuff properly" >> { val probe = testprobe()(akka.system) val test = new controllers.mycontroller(akka.system.actorof(props(dummyactor)) val result = test.dostuff(fakerequest()) probe.expectmsg(somemsg) } } } the controller send message passed in actor when dostuf

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

sample brunch session: $ npm -v 1.2.25 $ brunch -v 1.7.6 $ bower -v 1.2.7 $ brunch new https://github.com/monokrome/brunch-with-grits.git example ... $ cd example $ ls app bower_components bower.json config.coffee node_modules package.json readme.md vendor $ ls bower_components/ backbone backbone.babysitter backbone.marionette.subrouter backbone.wreqr jquery lodash marionette underscore $ brunch build 06 oct 22:25:49 - info: compiled 9 files 3 files, copied index.html in 761ms $ bower install -s https://github.com/whyohwhyamihere/backbone.marionette.subrouter.git ... $ grep marionette bower.json "marionette": "~1.0.4", "backbone.marionette.subrouter": "https://github.com/whyohwhyamihere/backbone.marionette.subrouter.git" "marionette": { "main": "lib/core/backbone.marionette.js" $ cp bower.json bower.json.orig $ vi bower.json ... $ diff bower.json bower.json.orig 47,52d46 <

asp.net - SignalR: Sending message back only to AJAX caller from the code behind page (outside of Hub/PersistentConnection) -

i'm struggling bit. i'm trying achieve send message ajax caller (aspx page) server (aspx page's code behind) update progress of time consuming task being done @ server. i'm trying following code code behind of aspx page, doesn't seem work! _context = globalhost.connectionmanager.getconnectioncontext<messengerendpoint>(); _context.connection.send(((connection)_context.connection).identity, "hey"); any suggestions appreciated. edit: takers? @dfowler/@n.taylormullen? regards. first of all, can try (only try): context.connection.broadcast ( "hey"); if work (and think work(, problem identity , nedd open connection , save connection id on server or in client later use.

sonarqube - Sonar-Overall Coverage -

sonar gives value of overall coverage combination of line , branch coverage. not sure how important metric. value of overall coverage signifies? how better line , branch coverage? suggestions helpful. from sonar's documentation: it mix of line coverage , condition coverage. goal provide more accurate answer following question: how of source code has been covered unit tests? coverage = (ct + cf + lc)/(2*b + el) ct = conditions have been evaluated 'true' @ least once cf = conditions have been evaluated 'false' @ least once lc = covered lines = lines_to_cover - uncovered_lines b = total number of conditions el = total number of executable lines (lines_to_cover) source: http://docs.sonarqube.org/display/sonar/metric+definitions (captured 23/02/2015)

node.js - Sailsjs policies -

i having trouble figuring out sails policies, follow tutorial still can't make work. in policies.js file: module.exports.policies = { '*':true, userscontroller:{ '*':false, signin: 'skipauthenticated' } } and in authenticated.js file: module.exports = function skipauthenticated(req, res, ok){ console.log("testing"); if (req.session.authenticated){ console.log("testing"); return ok(); } else { return res.send("you not permitted perform action.", 403); } } but policy not trigger. appreciated. if take @ section entitled how protect controllers policies? describes policy name matches name of file in api/policies . problem actual policy name "authenticated" (you said authenticated.js) , policy name you're trying use in acl "skipauthenticated." so can either change policy file name skipauthenticated.js or can change acl reflect actual policy name.

c - GDB / GNU assembly: test %esi,%esi returns not equal? -

i'm working on homework assignment. we're given pre-compiled binary , have use gdb assembly dumps, traverse data structures, view values stored in memory, etc. in order puzzle out binary does. here few lines of disassembler dump function call: 0x08048e14 <+21>: test %esi,%esi 0x08048e16 <+23>: jne 0x8048e4b <fun6+76> 0x08048e18 <+25>: jmp 0x8048e5d <fun6+94> i assumed test %esi,%esi return result of "equals" (or, rather, equivalent statement expressed using register flags, believe zf set?), , jne instruction never execute, , instead program execute instruction @ line <+25> . however, after stepping through these instructions, program jumps line <+76> ! why happen? baffled. in case helps explain answer, here register flags after test instruction @ line <+21> ( zf isn't set?)(i still don't know how interpret flags): eflags 0x202 [ if ] the test instruction perfo

ios - (iOS7) Scroll to cursor in UITextView in UITableView in UIScrollView -

i have problem since updated ios7. i have base uiscrollview horizontally , there uitableview on (looks navigation style). , addchild uitextview on uitableview not on cells. and scrolled uitextview 's cursor when typing keyboard. , works until ios 6 not since updating ios7. how can solve problem? thanks. handle textviewdidchangeselection in uitextviewdelegate: - (void)textviewdidchangeselection:(uitextview *)textview { [textview scrollrangetovisible:textview.selectedrange]; } the exact solution depends on application, can handle subclassing uitextview prefer decorator pattern here (on uitextviewdelegate protocol). i hope helps.

javascript - Delay between dynamic posts -

i have js code meant display each dynamically loaded posts when clicked on: function showpost(id) { $.getjson('http://hopeofgloryinternational.com/?json=get_post&post_id=' + id + '&callback=?', function(data) { var output=''; output += '<h3>' + data.post.title + '</h3>'; output += data.post.content; $('#mypost').html(output); }); //get json data stories } //showpost when test page ' http://howtodeployit.com/devotion/ ' on mobile or windows browser, clicked on daily devotional messages , navigate between each posts, notice accessed post still shows few seconds before new post gets displayed. how refresh page or dom clears out accessed page. function start line $('#mypost').html(""); before going request clear display content. also can add waiting message $('#mypost').html("please wait..."); before showing cont

android - jtwitter authetication error ,credentials same working on twitter.com -

i getting following authertication error when post on app. 10-07 15:36:54.265: e/androidruntime(2537): fatal exception: thread-199 10-07 15:36:54.265: e/androidruntime(2537): winterwell.jtwitter.twitterexception$e401: code 215: bad authentication data 10-07 15:36:54.265: e/androidruntime(2537): @ winterwell.jtwitter.urlconnectionhttpclient.processerror(urlconnectionhttpclient.java:483) 10-07 15:36:54.265: e/androidruntime(2537): @ winterwell.jtwitter.urlconnectionhttpclient.post2_connect(urlconnectionhttpclient.java:413) 10-07 15:36:54.265: e/androidruntime(2537): @ winterwell.jtwitter.urlconnectionhttpclient.post2(urlconnectionhttpclient.java:379) 10-07 15:36:54.265: e/androidruntime(2537): @ winterwell.jtwitter.urlconnectionhttpclient.post(urlconnectionhttpclient.java:348) 10-07 15:36:54.265: e/androidruntime(2537): @ winterwell.jtwitter.twitter.updatestatus(twitter.java:2762) 10-07 15:36:54.265: e/androidruntime(2537): @ winterwell.jtwitter.twitter.upda

javascript - Custom CSS does not apply to Body element with jQuery -

my custom css not apply body element , when page loads, of elements overridden jquery css. if not put jquery css, adds 'div' tag @ end of page text 'loading' . my html: <!doctype html> <html> <head> <meta name="viewport" content="width=device-width"> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" /> <link rel="stylesheet" href="custom.css" /> <title>title</title> </head> <body> <p id="rssfeedload">loadin...</p> <p id="rssfeed"> </p> <script> //debugger; var yquery = 'http://news.google.com/news?geo=somezip&output=rss'; var yql = 'http://q

php - Undefined offset: 3 error is thrown but error location is not shown -

i getting error undefined offset: 3 in brief message this, internal server error undefined offset: 3 internal error occurred while web server processing request. please contact webmaster report problem. thank you. i know happen or how see exact location of issue can go , resolve it. using yii framework sadly doesnt display me error occurs. do need have php error logs enabled see ? internal server error occurs on server connection. , seems of input missing complete functionality. basic dont have idea on code , functionality. person working on functionality. need check last functionality worked in this. better step step debug process resolve this.

linux - storing awk results to bash ${} data format -

i got question bash , awk, so, i'm going filter processes list ps aux did filtering grep , filter again using awk display pid , path of process, save corresponding ${pid} , ${path} field. question is, when done filtering results using awk, i'm going save results on ${pid} pid numbers , ${path} process's path, got no idea @ on doing thing. if here have solution appreciated. thanks edit: here code ps aux | grep 'firefox' | awk '{print $2 " " $11}' then don't know save $2 content ${pid} , $11 ${path} , save fields txt file again... if else fail remember have disk can use. pipe result file , process file using awk or cut 2 times assign fields corresponding variables. for example: $result > tmp pid=`cat tmp | cut -f 1` path=`cat tmp | cut -f 2` rm tmp

cannot require rubygems, perhaps because of multiple ruby versions? -

i cannot require rubygems in ruby files: (although can require other modules - such rexml/document) my 01.rb file: require "rubygems" when execute ruby 01.rb , got: 01.rb:1:in `require': no such file load -- rubygems (loaderror) 01.rb:1 however output of commands on system: my ruby version (i think have multiples, causes problem, right? - should remove , re-install scratch?) mhewedy@compu10:~$ ruby --version ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] mhewedy@compu10:~$ -a ruby /usr/bin/ruby mhewedy@compu10:~$ ls -lt /usr/bin/ruby lrwxrwxrwx 1 root root 22 sep 11 07:28 /usr/bin/ruby -> /etc/alternatives/ruby mhewedy@compu10:~$ ls -lt /etc/alternatives/ruby lrwxrwxrwx 1 root root 16 sep 27 10:00 /etc/alternatives/ruby -> /usr/bin/ruby1.8 mhewedy@compu10:~$ ls /usr/bin/ruby* /usr/bin/ruby /usr/bin/ruby1.8 /usr/bin/ruby1.9.1 /usr/bin/ruby1.9.3 and here's gem env gem env rubygems environment: - rubygems version: 1.8.11

Python PyTables API Bridge for Version 2.3.1 and 3.0.0 -

did implement open source bridge make python programs work pytables 2.3.1 , pytables 3.0.0 @ same time? although pytables promises work old api until 3.1.0, encountered glitches. example, createarray takes keyword argument object , whereas new create_array relies on obj instead. calling createarray object argument (using pytables 3.0.0) automatically translated create_array(object=...) fails type error. could, of course, fix single glitch in code, wonder if implemented full wrap old api guarantee compatibility beyond 3.1.0. thanks , cheers, robert you can read migrating guide (in particular consistent create_xxx() signatures section ) , release notes aware of api changes, specially backward incompatible changes. see main think break compatibility function/method parameters have been renamed more pep8 compliant. think full bridge looking doesn't exist yet, have manage incompatibility changes hand. anyway can use pt2to3 tool making migration less painful. u

asp.net - How to inherit a UserControl from another UserControl? -

is possible inherit user control user control? the thing i'm trying achieve user control inheriting user control. have baseusercontrol.ascx, , has text "stuff". have user control, childusercontrol.ascx inheriting off of baseusercontrol.ascx. if don't change in childusercontrol.ascx, expect baseusercontrol.ascx text display of "stuff". and should able extend base user control functionalities in derived one. i have tried this , not enough in case. now childusercontrol.ascx looks lie below <%@ control language="c#" autoeventwireup="true" codefile="childusercontrol.ascx.cs" inherits="test_childusercontrol" %> <%@ register src="baseusercontrol.ascx" tagname="baseusercontrol" tagprefix="uc1" %> childusercontrol.ascx.cs below public partial class test_childusercontrol : baseusercontrol { protected void page_load(object sender, eventargs e) { } } whe

I need to parse xml and display as autocomplete in the text field in phone gap using jquery -

<!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="jquery-mobile/styles/jquery.mobile-1.3.1.min.css" rel="stylesheet" /> <link href="styles/main.css" rel="stylesheet" /> <script src="cordova.js" type="text/javascript"></script> <script src="jquery-mobile/js/jquery-1.9.1.min.js" type="text/javascript"></script> <script src="jquery-mobile/js/jquery.mobile-1.3.1.min.js" type="text/javascript"></script> <script> function loadxmldoc(url) { window.plugins.orientation.lock("portrait") var xmlhttp; var txt,x,xx,i; if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xm

java - Android - Copy assets to internal storage -

good day! i have started developing android. in app, need copy items in assets folder internal storage. i have searched lot on including copies external storage. how copy files 'assets' folder sdcard? this want achieve: have directory present in internal storage x>y>z. need file copied y , z. can me out code snippet? don't have idea how go on this. sorry bad english. thanks lot. use string out= environment.getexternalstoragedirectory().getabsolutepath() + "/x/y/z/" ; file outfile = new file(out, filename); after editing in ref. link answer. private void copyassets() { assetmanager assetmanager = getassets(); string[] files = null; try { files = assetmanager.list(""); } catch (ioexception e) { log.e("tag", "failed asset file list.", e); } for(string filename : files) { inputstream in = null; outputstream out = null; try { in = assetmanager.open(filen

Sorting array of array by value in php -

this question has answer here: how can sort arrays , data in php? 7 answers i have array named $result have contents this: array ( [1114_435] => stdclass object ( [uid] => 435 [v_first_name] => fherter [v_last_name] => herter [id] => 1114 [v_title] => morning stretch [fk_resident_id] => 435 [v_location] => front lawn [i_started_date] => 1357054200 ) [1114_444] => stdclass object ( [uid] => 444 [v_first_name] => fxyz [v_last_name] => xyz [id] => 1114 [v_title] => morning stretch [fk_resident_id] => 444 [v_location] => front lawn [i_started_date] => 1357054200 ) [1114_448] => stdclass object ( [uid] =>

creation of model object in controller yii -

can 1 tell me how create model object inside constructor in yii. had written code belo <?php class distributorscontroller extends controller { public $layout = '//layouts/column4'; public $defaultaction = null; public function __construct() { echo '<br>into constructor'; parent::__construct('distributors','distributors'); } public function actiondistributors() { $this->render("channelmask"); } } ?> but displaying "into constructor" string , view not showing in browser. you need call model controller. create model, in controller, call : distributor::model()->findall($criteria); //many models or distributor::model()->findbyid($id); // 1 model