Posts

Showing posts from May, 2010

java - How to display search item in Jtable? -

i not able search particular item database , put jtable here code using: try{ string filename="stock.mdb"; string database="jdbc:odbc:driver={microsoft access driver (*.mdb)};dbq="; database += filename.trim()+ ";driverid=22;readonly=false}"; conn=drivermanager.getconnection (database, "", ""); statement sta= conn.createstatement(); string str=search.gettext(); string sql="select '"+str+"' stockdb"; resultset rs= sta.executequery(sql); table.setmodel(dbutils.resultsettotablemodel(rs)); system.out.println("search updated"); }catch(exception e) { system.out.println(e); } what wrong it? do see problem code? variable names should not start upper case character ("table" should "table"). your select statement isn't doing search. selecting column name. when search should have "

ajax - Pass session ID to multiple PHP scripts within on HTML page -

i have single html page uses carousel style log in system. each step in sign works off of different php script. there 3 forms on page appear user progresses through sign up. progress need keep user id first step in variable in order update parts of account later on. the forms executed via ajax , first php script calls session_start(); and sets session variable $_session['user_id']=$account_id; as progress through form put @ top check if session variable passing through if (empty ($_session['user_id'])) { $message = 'cant find session id';} and not. don't have session_start() @ top of other php scripts. am misunderstanding how pass variable? session_start(); needs called @ beginning of each page load in order make $_session available. don't worry, won't reset session. in simplest terms, session_start() tells php expecting session exist, , needs run code give access it.

jsp - Comparing different format dates in javascript -

i have got date objects in jsp. 1 coming java page , other 1 coming same jsp. formats of dates are: wed may 07 00:00:14 cdt 2014 07-may-2014 now how compare these 2 dates, please help. don't know how convert these in javascript same format. can please help? why don't export date in java in same format javascript uses? simpledateformat sdf = new simpledateformat("dd-mmm-yyyy"); or simpledateformat sdf = new simpledateformat("eee mmm dd hh:mm:ss z yyy"); that way easier compare using: var n = date1.localecompare(date2);

javascript - Forcing people to open a webpage in Chrome or IE -

can force users click on webpage in firefox/safari open in chrome or ie javascript? assuming have browsers downloaded. no. if other browsers present on user's system. choice browser use. even popping message advising site works better in browser x pretty poor experience user , pretty bad form developer.

java - Making a method that will call a second from a qualified name -

i need method call second 1 second class. e.g class commandclass = class.forname("foo.class"); method method = commandclass.getmethod("method", string.class, string.class); method.invoke(method, "param1", "param2"); but have tried put in method harder thought. public method can called class parameters of type. just pass arguments needed method , call code. // pass "null" paridentifiers , parameters if it's method without public static void invokemethod(string classname, string methodname, class<?>[] paridentifiers, object[] parameters) { try { // code class<?> commandclass = class.forname(classname); method method = commandclass.getmethod(methodname, paridentifiers); method.invoke(method, parameters); } catch (nosuchmethodexception | securityexception | classnotfoundexception | illegalaccessexception | illegalargumentexcept

abstract - Create dynamic Type Java -

explain problem: i have super abstract class called first , have lot of class inherit it. want build method "say" "create arraylist of 1 of types inherit first class", i'm not able find solution. example: public abstract class first{ public first(){ } } public class firstone extends first{ ........... } //it's pseudo-code public class myprogramclass{ public creatingmethod(typethatinheritfromfirstclass x ){ return arraylist<typethatinheritfromfirstclass>; } } i insert creatingmethod in program class,but can anywhere(i prefer in first class static method, it's example) thank time you use type token : public class somegenerics { public static void main(string[] args) { list<subfirst1> list1 = creatingmethod(subfirst1.class); list<subfirst2> list2 = creatingmethod(subfirst2.class); } public static <t extends first> list<t> creatingmethod(class<t>

c# - Visual Studio 2013 interprets my file as a form file -

Image
i create simple cs file 1 class: using system; using system.collections.generic; using system.linq; using system.net; using system.text; using system.threading.tasks; namespace bed { public class timeoutwebclient : webclient { protected override webrequest getwebrequest(uri uri) { webrequest w = base.getwebrequest(uri); w.timeout = 30 * 1000; return w; } } } suddenly visual studio has interpreted form class.. did go wrong? these versions use: microsoft visual studio ultimate 2013 version 12.0.21005.1 rel microsoft .net framework version 4.5.50938 i'm not sure how happened how fix it: right-click on project , choose 'unload' right-click on project , choose 'edit' find in file 'timeoutwebclient' i expect find this: <itemgroup> <compile include="timeoutwebclient.cs"> <subtype>form</subtype> <

javascript - return a PHP object to an ajax call -

i'm learning php oop, , getting used of these objects. when create object in php file called via $.ajax function, want deliver answer back. how supposed send object ajax call ? before oop, putting array, json_encode() array, , worked perfectly. how adapt using oop? thanks lot answers romain example: on client side $.ajax( { url:"test.php", type:"post", datatype:"json", success:function(json) { // json template } }); on server side : test.php require_once("bdd.php"); function loadclass($class) { require $class.".class.php"; } spl_autoload_register('loadclass'); $personnem = new personnemanager($db); $perso = $personnem->get("123456"); $perso = serialize($perso); // ???????????? header('content-type: application/json'); echo json_encode(array("result",$perso)); either use serialize or __tostring create json-representation of data can send dow

How to make list out of objects in Prolog? -

i can add single object list code , query: makelist(a, b, c, x) :- append([1, 2, 3],a, x). ?- makelist(a, b, c, x). x = [1, 2, 3|a]. however rather usual separator comma (,) there's vertical line separator (|) , cannot add object same list: makelist(a, b, c, x) :- append([1, 2, 3],a, x), append(x,b, x). ?- makelist(a, b, c, x). false. there several misunderstandings. first, lists , elements confused leads "dotted pair" |a] . then, seems role of variables not clear you. in goal append([1,2,3],a,x) both a , x supposed lists. however, set a a not list. problem behind append/3 accepts term second argument. see this, @ answers: | ?- append([1,2,3],a,x). x = [1,2,3|a]. so a can anything, should rather list. | ?- = a, append([1,2,3],a,x). = a, x = [1,2,3|a]. note append/3 insists first argument list (or partial list). once have bad list, can no longer append further. is: | ?- = a, append([1,2,3],a,x), append(x, _, _). no note did not us

javascript - Jquery server control click event is not firing -

there server control button on web form, inside updatepanel control. <asp:button runat="server" text="save details" id="btnsave" width="130px" clientidmode="static"></asp:button> script in external file. $(document).ready(function () { $('<%= btnsave.clientid %>').click(function () { alert('msg'); }); }); all other scripts running fine 1 not firing. you're missing # selector: $(document).ready(function () { $('#<%= btnsave.clientid %>').click(function () { // ^ add # here alert('msg'); }); });

matlab error during signal analysis -

i have set of data. amplitude vs time in seconds. need t6o find out frequency components in signal. time period = 1 second , sampling rate 5000 samples per second when perform fft of signal "undefined function 'fft' input arguments of type 'timeseries' " why ? please timeseries must vector complex(real) coefficients. there error related type of timeseries , make sure it's vector (that is, has 1 row (or 1 column)).

oracle11g - Stored procedure with mulitple queries in ORACLE -

i have stored procedure named edit_emp inside stored procedure have 10 update queries. now error in 5th update statement - happen rest of update query? terminate in 5th update line or execute rest of update queries? exception when others then // dbms_output.put_line ('error'); continue ; just add exception handler in ur procedure

vim - How to determine whether a set command failed to run in _vimrc? -

i added set commands _vimrc file, how can check whether set command executed or not? care status because there may different handling based on status of previous set command. you try raise value of verbose option until find value allows catch every error thrown every option (and set verbosefile=somefile because life miserable if don't) suspect want can't done in manageable manner , not worth hassle. here couple of idioms you, though: try , catch errors try set option=value catch /^vim\%((\a\+)\)\=:exxx/ set option=othervalue endtry see :help :try , :help :catch . note raising verbose maximum value didn't allow me catch e596 error supposed thrown invalid font point remains valid: hard find silver bullet solution. also, guifont can take coma-separated string value can give n fonts , let vim use first 1 works. do if feature present if has('mouse_sgr') set ttymouse=sgr endif see :help has() . if gave concrete ex

c++ - DevIL image not rendering correctly -

Image
i using opengl, can load tga files properly, reason when render jpg files, not see them correctly. this image supposed like-- and looks like.. why stretched? because of coordinates? here code using drawing. void renderer::drawjpg(gluint tex, int xi, int yq, int width, int height) const { glbindtexture(gl_texture_2d, tex); glbegin(gl_quads); gltexcoord2i(0, 0); glvertex2i(0+xi, 0+xi); gltexcoord2i(0, 1); glvertex2i(0+xi, height+xi); gltexcoord2i(1, 1); glvertex2i(width+xi, height+xi); gltexcoord2i(1, 0); glvertex2i(width+xi, 0+xi); glend(); } this how loading image... imagename=s; ilboolean success; ilinit(); ilgenimages(1, &id); ilbindimage(id); success = illoadimage((const ilstring)imagename.c_str()); if (success) { success = ilconvertimage(il_rgb, il_unsigned_byte); /* convert every colour component unsigned byte. if image contains alpha channel can replace il_rgb il_rgba */ if (!success)

nuget - Creating folder with contents in project root -

i developed tool besides dll requires strong named folder 2 files in solution. using nuget gui created folder , populated files, when install package, dll created folder 2 files not. how can fixed? nuget has set of conventions define folders inside nuget package result in different actions being taken when package installed or uninstalled. in order folders created inside project, when nuget package installed, folders need inside content directory. if @ jquery package, has content\scripts folder files inside it. scripts folder created inside project, along files, when install jquery nuget package. \content \scripts \jquery-2.1.0.js

html - PHP emailto form not processing? -

i have used php form on contact page doing second 1 , used same documents , changed them when click submit goes blank page. have looked through previous page , can not find difference in code yet, , driving me mad! im not pro nay stretch challenge myself out wifes business. <?php if(isset($_post['email'])) { $email_to = "karly@kbwflowers.com.au"; $email_subject = "mothers day order form"; $arrangement = ""; $your_name = ""; $your_contact_number = ""; $email_from = ""; $mums_name = ""; $mums_contact_number = ""; $delivery_address = ""; $delivery_suburb = ""; $delivery_date = ""; $card_message = ""; $base = ""; $payment_method = ""; $total = ""; $email_message .= "your name: ".clean_string($your_name)."\n";

visual studio - Store Options Disabled in VS2013 -

am doing wrong here? have basic windows phone 8.0 silverlight application , these options disabled. project > store the functionality you're referring exclusive silverlight 8.1 or windows runtime (universal apps) projects.

excel - Recorded "Macro" updates Pivot table's filter, where VBA script does not -

my final end goal give function year , based on year, set filter of "years" in pivot table. if record "macro" of myself doing (manual filtering, filtering none-the-less), can run "macro" without issues. if take exact same code + , error catcher (that doesn't catch errors) , return number (nothing calculated on number), however, , put in vba function, fails. here "macro" sub blank() activesheet.pivottables("tmed_ptable").pivotfields("years") = 2 .pivotitems.count .pivotitems(i).visible = false next end end sub and here vba code function updatepivot(tmedyear integer) integer on error goto errorout activesheet.pivottables("tmed_ptable").pivotfields("years") = 2 .pivotitems.count .pivotitems(i).visible = true next end goto endout errorout: msgbox "error: "

java - Calling SwingUtilities.invokeAndWait in a loop -

Image
i trying save .png image of jframe . in jframe , have 2 plot3dpanel objects. because of synchronization fault, left-size frame invisible while saving .png. therefore, use following code: try { swingutilities.invokeandwait(new runnable() { public void run() { new visualserializer(p[i], q[i], folder + "c" + i).run(); } }); serialize(p[i], folder + "p" + i); serialize(q[i], folder + "p" + i); } catch(exception e) { e.printstacktrace(); } but now, compile error cannot refer non-final variable inside inner class defined in different method however, need filenames different. also, need iterate through array of objects. can prevent error? one way make final copies of variable needs passed anonymous inner class, instance if i problem: final int index = i; swingutilities.invokeandwait(new runnable() { public void run() { new visualserializer(p[index], q[index], folder +

regex - Javascript Validate number, nonrepeating, nonsquential -

i trying validate input. the input must numeric, 9-digits long. we need prevent 000000000, 111111111, 222222222, 123456789, 234567890, 098765432, 987654321, 010101010, 121212121, 000000001, 000000010 , on type inputs. the thing can think of testing each possibility. monstrous amount of code, or regex like: var input="111111111"; var regex = /000000000|11111111|222222222|123456789|234567890|098765432|987654321|010101010|121212121|00000001|000000010/; // , on , on , on....... var found = input.match(regex); console.log(found); does have better way this? you can avoid repeated sequences , numbers 111811111 with: \b(?!(?:(?=(\d))((\d+)\3)\2*\1|(\d{3})\4{2}|(?=\d*(\d)(?!\5)(\d))(?:\5*\6\5*|\6*\5\6*))\b)\d{9}\b you can test: 123456789, 012345678, 876543210 etc. with: if ( parseint(s) + parseint(s.split("").reverse().join("")) % 111111111 == 0 )

Manipulate Windows Services with .NET / C# like Powershell -

what library in .net allow stop, uninstall, unregister, install, , start windows services .net? using .net 4/4.5. what get-service powershell call behind scenes? how can access same objects/api .net? you can use servicecontroller of (start, stop, pause , forth). requires add serviceprocess.dll . can't though, use command prompt calls sc create examples here: https://stackoverflow.com/a/21187278/885318

Ruby on Rails Allow Tracking / Indexing of protected pages -

i need allow indexing of user protected pages facebook sharing. basically, have ror app offers coupons , need users able share coupon on facebook. problem user must have account view coupon details on each coupon's page. want them able share coupon (title, price only) link coupon, link coupon redirect sign page if user not have account. therefore, when facebook (and other indexing robots) go pull info coupon url, redirected sign page , index sign page info instead of coupon page info. any way allow indexing of each coupon page crawlers, redirect actual users sign page? found post ... ended using second answer given. in coupons controller's show method, updated before_filter like: if ( !request.env["http_user_agent"].match(/\(.*https?:\/\/.*\)/) && !user_signed_in? ) redirect_to new_user_registration_path end therefore when request made view coupon, allow robot through index page, redirect non-signed-in users either register or login. us

javascript - Implementing AJAX call on checkbox in Rails to update db -

rails newbie here. i trying make checkbox called "active" act form when checkbox checked/unchecked , use ajax automatically update database changed attribute (without submit button). using instructions here: http://trevorturk.com/2010/08/24/easy-ajax-forms-with-rails-3-and-jquery/ can't seem make work correctly. in view: <%= form_for @post, :remote => true |f| %> <%= f.label :active %> <%= f.check_box :active, :class => 'submittable' %> <% end %> in posts_controller.rb def update if @post.update(post_params) flash[:notice] = "your post edited." redirect_to post_path(@post) else render :edit end end then made file called 'archive.js.erb' in views/posts folder code: $('.submittable').live('change', function() { $(this).parents('form:first').submit(); }); i've tried code, , problem seems on live method on javascript. works if change click function: $(docu

Operator overloading problems C++ -

i have polynomial class , have overloaded +,-, , * operators, << operator. seems work fine until try output expression such poly1+poly2 rather single polynomial object. here addition operator code: polynomial operator+ (const polynomial& poly1, const polynomial& poly2){ vector<int> final_coeffs; if (poly1.degree()>poly2.degree()) { (int i=0; i<=poly2.degree(); i++) final_coeffs.push_back(poly2.coefficient(i) + poly1.coefficient(i)); (int i=poly2.degree()+1; i<=poly1.degree(); i++) final_coeffs.push_back(poly1.coefficient(i)); } else { (int i=0; i<=poly1.degree(); i++) final_coeffs.push_back(poly1.coefficient(i) + poly2.coefficient(i)); (int i=poly1.degree()+1; i<=poly2.degree(); i++) final_coeffs.push_back(poly2.coefficient(i)); } return polynomial(final_coeffs); } and here << operator code (i have correctly working print

sql - How to get the records back from two tables with same primary key if any of the other column fields are changed -

my previous question confusing. sorry carelessness. here, posted question again more information. my table , table b has same column names(name,id,age,date,class,...) different number of rows. table b duplicate table of table , has fewer rows. want know how can retrieve records if have same primary key(id) , of other column fields (name, age, date, class,...) different. however, there 1 condition. although records have same primary key, if date changed, records should not retrieved.only when 2 tables have same primary key, date different , of column fields changed, records should retrieved. since there around 200k records, , around 100 columns, use advanced sql, since sql long if use select.. from... where , don't know sql use. tablea : name age id date ------ --- -- ---------- david 11 1 11/01/2014 claire 16 2 13/03/2014 max 15 3 20/02/2014 john 14 4 19/09/2014 james 12 5 16/06/2014 tableb : name age id date ----- --- -

python - How can I download all Google App Engine Data? -

i've been following these instructions download datastore entities 1 file. https://developers.google.com/appengine/docs/python/tools/uploadingdata#python_downloading_and_uploading_all_data appcfg.py download_data --url=http://your_app_id.appspot.com/_ah/remote_api --filename=<data-filename> my remote api setup , when run command , stops feedback in console. .............[info ] kind1: no descending index on __key__, performing serial download [info ] kind2: no descending index on __key__, performing serial download [info ] kind3: no descending index on __key__, performing serial download ..........[info ] [workerthread-1] backing off due errors: 1.0 seconds [info ] resetting backoff 0.0 i'm aware reference properties broken if there's else go on help.

Camel SQL component - simple select query result -

i'm working apache camel , i've been facing problem sql component. perform insert query simple select query wouldn't return anything. datasource configured , have no errors. read result of select query list> have blank results. here's camel route: from("direct:start") .to("sql:select * infos id=1 ?datasourceref=mydatasource") .beanref("mbean","monitor") .to("log:result"); and here method i'm trying use process result: public object monitor(exchange exchange){ list<map<string,object>> l= (list<map<string,object>>) exchange.getout().getbody(); map<string,object> map = l.get(0); object str = map.get("msg"); exchange.getin().setbody(str); return str; } i'm stuck .. try this. worked me. public void process(exchange exchange) throws exception { list<hashmap> out = (arraylist<hashmap>) exchange.g

Python - make string equal length -

i have rna sequence of varying length. max length of sequence 22. sequences shorter. if sequence shorter add "0" end of line till length becomes 22. how in python? input aagauguggaaaaauuggaauc cagugguuuuaugguag cucuagaggguuucug uucauucggc and expected ouput should example in last line not contain 22 characters need make 22 adding 0 uucauucggc000000000000 but per commands getting out put aagauguggaaaaauu 00000 addtional characters used justification came down , not in same line use str.ljust method: >>> s = 'foobar' >>> s.ljust(22, '0') 'foobar0000000000000000'

sip - Does Asterisk 1.8.* support the key exchange RSA and DSS protocols? -

based on other topics know asterisk 1.8.* supports md5 protocol authentication i want know if astrisk 1.8.* support key exchange rsa , dss protocols sip clients/servers? if mean referring sip challenge/response authentication method rsa , dhs (i'm guessing meant diffie-hellman dhs rather dss) aren't applicable since what's required cryptographic hashing algorithm such md5 or sha2 rather asymmetric encryption algorithm (such rsa) or key exchange sequence (such dhs). note sip supports md5 looks there new rfc move sha2. if looking confidential sip transmissions sip have support way of tls. sip rfc mandate support of secure transmission channel uses sips prefix sip addresses instead of standard sip , indicates sip messages should sent on tls channel. not while sip rfc mandates support tls channel in practise it's not supported amongst public sip services. asterisk support sip tls.

regex - regular expression in c is not working properly -

i want match " 16kqgn579677 pt " this attempt: ^([a-z0-9]{2}+)([a-z]{4}+)([0-9]{1,6}+)([ ]{0,5}+)([a-z]{1,4}+).*" and code: int main(int argc, char *argv[]){ regex_t str; int reti; char msgbuf[100]; /* need match circuit(16kqgn579677 pt) */ reti=regcomp(&str,"^([a-z0-9]{2}+)([a-z]{4}+)([0-9]{1,6}+)([ ]{0,5}+)([a-z]{1,4}+).*", 0); if( reti ) { fprintf(stderr, "could not compile regex\n"); exit(1); } /* need match circuit(16kqgn579677 pt) */ reti = regexec(&str, "16kqgn579677 pt", 0, null, 0); if( !reti ){ puts("match"); } else if( reti == reg_nomatch ){ puts("no match"); } else { regerror(reti, &str, msgbuf, sizeof(msgbuf)); fprintf(stderr, "regex match failed: %s\n", msgbuf); exit(1); } regfree(&regex); retur

oracle11g - JDBC and Oracle 11g connection reset on ubuntu -

i having strange issue connection jdbc oracle 11g. started happening monday without settings changes either me or team aware of. reading in stackoverflow , oracle forums (see links @ bottom) i've learned there has been issue generation of random bytes on linux 64bit machines. led try several things, unfortunately didn't work. here summary of information i'm aware of. the weird thing is can connect on terminal using sqlplus, not using jdbc. thank ideas or help, amit my setup: os: ubuntu 12.04 java: both 7 , 6_45 (issue same) jdbc: downloaded oracle official site (see further description down) connection behind cisco vpn jdbc-manifests: odbc7.jar: manifest-version: 1.0 ant-version: apache ant 1.7.1 created-by: 20.12-b01 (sun microsystems inc.) implementation-vendor: oracle corporation implementation-title: jdbc implementation-version: 12.1.0.1.0 repository-id: javavm_12.1.0.1.0_linux.x64_130403 specification-vendor: sun microsystems inc. specification

javascript - Remembering data loaded via ajax 'load more' when using the back button -

just looking @ creating feature remember data has been loaded via ajax load more button when user leaves page , returns via button. the way thinking is: when user loads more data, parameter added url e.g ?more=1 when page loaded, checks more parameter , runs query depending on that my query returns 16 new results, 'value of more x 16' , use last parameter in limit claus. this shouldn't affect new data being loaded specifiy url in ajax. is correct way around this? or simpler way? craig when page loaded, checks more parameter , runs query depending on if runs query depending on parameter aren't caching results. if want remember data speed page loading should, after query, calculate html corresponding additional data , save in file. then, if same parameter present in url (and if files exist), can include preformatted data cache files.

stdmap - C++ std::map std::bitset segfault -

i have code: static void xmlcall hackhandler(void *data, const xml_char *name, const xml_char **attr) { setpointers* sets = static_cast<setpointers*>(data); if (strcmp(name, "instruction") == 0 || strcmp(name, "load") == 0 || strcmp(name, "modify") == 0||strcmp(name, "store") == 0) { long address(0); long page(0); int offset(0); long size(0); int i(0); (i = 0; attr[i]; += 2) { if (strcmp(attr[i], "address") == 0) { address = strtol(attr[i+1], null, 16); page = address >> 12; offset = address & 0xfff; continue; } if (strcmp(attr[i], "size") == 0) { size = strtol(attr[i + 1], null, 16); } } map<long, bitset<4096> >::iterator itlocal; itlocal = sets->lcount->find(page); if (itlocal == sets->lcount->end()) { sets->lcount->insert(pair<

Writing AVERAGEIF Statement in Excel over different columns with different criteria -

i'm new excel if statements , having trouble believe called nested if function. i've looked @ other if questions on here , couldn't figure out. i have 2 columns have numbers in , rest text.i need create if statement tell me average based on different combinations of text , numbers. have thousands of rows filter through , don't want them manually if function exists automate in excel. b=iphone c=5s d=verizon e=64 f=normal h=380 i have written if statement finds me average of prices on iphones =averageif(b1:h3792,"=iphone",h1:h3792) i make statement allows me enter more 1 criteria. mean more have "iphone" criteria, have "5s", "verizon", "64" , "normal". 1) ranges b1:h3792 , h1:h3792 should have same dimmention. change b1:h3792 b1:b3792 2) more criterias can use averageifs : =averageifs(h1:h3792,b1:b3792,"iphone",c1:c3792,"5s",d1:d3792,"verizon&qu

java - HttpResponse can return list in android through RESTFUL web service? -

i new android.i using restful web services.i have 1 field category in mysql database.now need value database , put autocompletetextview.but can values database.and know how set value autocompletetextview.but don't know how can list httpresponse. httpresponse can return list? you shouldn't returning httpresponse rest service. return javax.ws.rs.core.response instead. can insert data entity response this: // method annotation here public response somegetmethod() { // build listfromdatabase here return response.ok(listfromdatabase).build(); }

c# - Object gets stuck when trying to bounce off screen edges, am I doing this wrong? -

public class asteroidmovement : monobehaviour { public vector2 speed; public vector2 direction; private vector2 movement; private vector3 topscreenbound; private vector3 bottomscreenbound; // use initialization void start() { topscreenbound = camera.main.viewporttoworldpoint(new vector3(0f, 1f, 0f)); bottomscreenbound = camera.main.viewporttoworldpoint(new vector3(0f, 0f, 0f)); } // update called once per frame void update() { if (gameobject.transform.position.y >= topscreenbound.y) { direction.y *= -1; } if (gameobject.transform.position.y <= bottomscreenbound.y) { direction.y *= -1; } movement = new vector2(speed.x * direction.x, speed.y * direction.y); } void fixedupdate() { rigidbody2d.velocity = movement; } } i trying have asteroids in game bounce off edge of screen , have got working decently, after few bounces, asteroid/object gets "stuck" in wall , glitches out playing area. am going wrong?

c# - Class defined Datatable, how to leave row [0] unchanged? -

i add rows table configs this, form want datarow row2 = dataaccess.instance.configs.newrow(); row2["nome"] = "abrirficheiro"; row2["valor"] = convert.tostring(variables.abrirficheiro); dataaccess.instance.configs.rows.add(row2); but wanna keep row @ index 0 (the first one) untouched, idea how it's done? edit: i've been working around past hour, still unsucessful the table class code this public sealed class dataaccess { static readonly dataaccess instance = new dataaccess(); //**adicionar tabelas aqui public datatable configs { get; private set; } // explicit static constructor tell c# compiler // not mark type beforefieldinit static dataaccess() { } dataaccess() { this.configs = new datatable("configs"); tabelasset.tables.add("configs"); configs.columns.add("nome"); configs.colum

IOS layout issue -

if i'm right, in ios, don't have layout in android. i'm new ios. suppose have 2 label, 1 on top of other. possible make label goes down. went through widgets in ios. i've not seen linear layout i suggest first go through getting started guide ios. in case need set size of uilabel dynamically can using below code: cgsize maximumlabelsize = cgsizemake(296,9999); cgsize expectedlabelsize = [yourstring sizewithfont:yourlabel.font constrainedtosize:maximumlabelsize linebreakmode:yourlabel.linebreakmode]; //adjust label the new height. cgrect newframe = yourlabel.frame; newframe.size.height = expectedlabelsize.height; yourlabel.frame = newframe;

Display Excel Spreadsheet in WinForms, C# -

i have been struggling last few hours trying excel spreadsheet/workbook displayed on windows form using visual studio 2012, c#. can retrieve data workbook , display on form, need functionality of excel in application, including stuff filtering , conditional formatting , formulas , etc. i have read quite lot, , understand it, there no controls in visual studio embed these (office) files due licencing, makes sense. have found solution though, display file in webcontrol (i sure able work this), when try load excel file in web control, prompts user either open or save file, , when 'open file' chosen, file opened using microsoft excel. as understand it, happens because contenttype (mime type, excel contenttype ) of file needs set in browser (i need more research on not yet familiar concept, ). the resources using: logic save contents excel file: epplus i working following project, among others: winforms excel example the latter want achieve, keeps on asking save or

Pointer to Python classes and methods -

i have function pointer dictionary points different class methods. best method of doing it? class a(): command_map = { "call func1 of object1": ("1", func1) "call func1 of object2": ("2", func1) } def __init__(self, object1, object2): self.o1 = object1 self.o2 = object2 def call(self, cmd): t = self.command_map[cmd] target = t[0] func = t[1] if target == "1": resp = self.o1.func() elif target == "2": resp = self.o2.func() else: self._logger.warn("unknown target %r\n" % target) in case eclipse highlights func variable saying unused. how proceed? want call funca() of objecta or funcb() of objectb dependent on input values. is there way self.o1 put "command-map"? change command_map hold function names instead of actual 'pointers'. command_map = {

calabash-android giving "No keystores found." when run under Jenkins -

i have simple test android project can test fine using ".\gradlew calabashdebug" in dos shell logged in myself. however, when run project under jenkins on continuous integration server fails "no keystores found." error (see stack trace below). 07:54:04.462 [debug] [org.gradle.process.internal.defaultexechandle] changing state to: starting 07:54:04.464 [debug] [org.gradle.process.internal.defaultexechandle] waiting until process started: command 'cmd'. 07:54:04.507 [info] [org.gradle.process.internal.processparentinginitializer] attempt initialize behaving parent process finished. 07:54:04.513 [debug] [org.gradle.process.internal.defaultexechandle] changing state to: started 07:54:04.513 [debug] [org.gradle.process.internal.exechandlerunner] waiting until streams handled... 07:54:04.514 [info] [org.gradle.process.internal.defaultexechandle] started process 'command 'cmd'' 07:54:05.111 [quiet] [system.out] no test server found combinatio

Use specific TypeScript compiler version in Visual Studio -

i wonder if there's way set specific typescript compiler version project in visual studio. configure project use version 1.0, if new versions released. i know it not possible before , wonder if things changes after typescript matured 1.0 version. i noticed visual studio creates <typescripttoolsversion>0.9</typescripttoolsversion> property in project file, couldn't find documentation it. if try compile project <typescripttoolsversion>0.9</typescripttoolsversion> using typescript version 1.0 you'll following error: your project file uses different version of typescript compiler , tools installed on machine. no compiler found @ c:\program files (x86)\microsoft sdks\typescript\0.9\tsc.exe. may able fix problem changing element in project file. so it's preventing compiling newer version. not put compiler 0.9 compatibility mode. but if have typescript 0.9 installed, compile against version. yes, can force specific versi

Is there a reason to import the string module in Python? -

i beginner in programming , python first language. using python shell right now, don't understand why need import string module. i know importing string imports functions, when tried using functions string.split , string.join , work without import, assume means python builtins. is there works once import string module wouldn't work otherwise? generally don't need import string module class in builtins. however, there several constants in string module not built in, can usefull.

scheme - Building accumulator for lazy lists in Racket -

i defined simple lazy list of integers zero: (define integers-from (lambda (n) (cons n (lambda () (integers-from (+ 1 n)))))) (define lz (integers-from 0)) i coded accumaltor gets lazy list parameter (define lz-lst-accumulate (lambda (op initial lz) (if (null? lz) initial (cons (op (head lz) initial) (lambda () (lz-lst-accumulate op (op initial (head lz)) (tail lz))))))) does accumaltor answer format of lazy lists? here simple test of accumulator: (define acc (lz-lst-accumulate * 1 lz)) (take acc 4) => '(1 2 6 24) take helper function creates list first n elements of lazy list: (define head car) (define tail (lambda (lz-lst) ((cdr lz-lst)) )) (define take (lambda (lz-lst n) (if (= n 0) (list) (cons (car lz-lst) (take (tail lz-lst) (sub1 n)))) )) in lz-lst-accumulate calculate once (op (head lz) initial) , (op initial (head lz)) . inconsistent; both

python - Find number of zeros before non-zero in a numpy array -

i have numpy array a . return number of zeros before non-zero in a in efficient way in loop. if a = np.array([0,1,2]) np.nonzero(a)[0][0] returns 1. if a = np.array([0,0,0]) doesn't work (i answer 3 in case). , if big , first non-zero near beginning seems inefficient. here's iterative cython version, may best bet if serious bottleneck # saved file count_leading_zeros.pyx import numpy np cimport numpy np cimport cython dtype = np.int ctypedef np.int_t dtype_t @cython.boundscheck(false) def count_leading_zeros(np.ndarray[dtype_t, ndim=1] a): cdef int elements = a.size cdef int = 0 cdef int count = 0 while < elements: if a[i] == 0: count += 1 else: return count += 1 return count this similar @mtrw's answer indexing @ native speeds. cython bit sketchy there may further improvements made. a quick test of extremely favourable case ipython few different methods in [1]: import nump

css - Theron-Lite Theme - How to widen page width -

so i'm using wordpress develop website. theme using 'theron-lite'. have created child theme custom style.css the pages great, want them wider. don't need make entire length of screen; maybe 5%. i can't figure out how this. closest i've come modify page width adding code style.css: / page width / content .single_wrap{width:105%!important;} by changing {width:100%!important;} {width:105%!important;}, changes page desired width. however! it's not centered. change extends page on right-hand side instead of left , right equally. here's example: http://paradigmcurve.com/?page_id=65 is there way extend page on both sides, equally? or issue lie in margins? hopefully there savvy developers out there can me out. consideration! you have .center class width fixed of 1000px, how change width of ?

actionscript 3 - What is the fastest way to check if a user is connected to the internet in AS3? -

i need check if user connected internet. what's fastest way in flash as3? do http of reliable , fast website, google.com. see as3 http example.

Error Installing Entity Framework 6.0.1 From Nuget (This operation would create an incorrectly structured document.) -

in asp.net mvc 5 need use entity framework. have tried installing latest entity framework through nuget package, getting following error below. have pasted complete nuget stack error. have tried several things un-installing/installing ef, adding ef references manually,etc. none have worked far , have lost 2 days. i have tried links similar problem here in site , has not helped , hence starting new thread hoping me here! need here...i stuck. error stack: install-package entityframework installing 'entityframework 6.1.0'. downloading entityframework microsoft, license agreement available @ http://go.microsoft.com/fwlink/?linkid=320539. check package additional dependencies, may come own license agreement(s). use of package , dependencies constitutes acceptance of license agreements. if not accept license agreement(s), delete relevant components device. installed 'entityframework 6.1.0'. adding 'entityframework 6.1.0' epp. added 'entityframework 6.1.0&

php - Remove quotes from json_encoded ints prior to 5.3.3 -

when using json_encode, annoyingly automatically coverts int keys strings. example, if have array: $a = array(); $a[12] = 15; echo json_encode($a); {"12":15} //notice quotes around 12 after searching so, solution use json_encode($array,json_numeric_check) however, available in php > 5.3.3. production server i'm stuck using 5.3.2. surely there work around? so problem here mixing approach data structure , json_encode() trying make best guess how interpret array, since in json, there not such concept of non-zero based, numerically indexed array. if example, had zero-based numeric array continuous number sequence, json_encode() encode a numerically-indexed array of format: [value1, value2, ...] since don't have zero-based array, data structure being interpreted object structure , given string key (the available key type object in json) of format: {"key", value} so seems need make mind trying represent in array. need numeri

Listen for track ended event in Spotify iOS SDK -

i'm integrating spotify ios sdk app. how can listen track ending events on sptaudiostreamingcontroller or spttrackplayer ? i'm cool playing, pausing, authenticating, etc. need grab track-ended event. i can see spttrackplayerdelegate has methods, appropriately, trackplayer:didendplaybackoftrackatindex:ofprovider , but how can use these? there examples of usage? thanks time! these classes follow standard cocoa delegate pattern. first, set delegate on track player: self.trackplayer.delegate = self; then implement delegate method in whatever self is: -(void)trackplayer:(spttrackplayer *)player didendplaybackoftrackatindex:(nsinteger)index ofprovider:(id<spttrackprovider>)provider { // track playback ended. } your delegate method called track player when appropriate.

How to scroll without clicking window to focus in vim? -

Image
i have file navigate window (b) , edit window (a). want scan window-b scrolling, while i'm editing file in window-a . so set mouse=a , , have focus cursor in window-b . wish not focus it, how to? i don't believe there's way want. if had window-c, how know window scroll !? just use :h window-move-cursor :h scrolling window in focus, or if you're more comfortable mouse, use instead.

javascript - Find a TD closest to a Parent Div of a submit button -

i'm trying key attribute of <td> tag below html code. <td class="xedit editable editable-click editable-open" id="3" key="details" data-original-title="" title="">javascript library </td> <div class="popover fade top in editable-container editable-popup" style="top: 289px; left: 534px; display: block;"> <div class="arrow"></div> <div class="popover-content"> <div> <div class="editableform-loading" style="display: none;"></div> <form class="form-inline editableform" style=""> <div class="control-group form-group"> <div> <div class="editable-input" style="position: relative;"> <input type="text" class="form-control input-sm" style="padding-right: 24px;">