Posts

Showing posts from April, 2012

ember.js - How to get records in JSON format from the model in emberjs? -

i accessing model data using .find method how records in json format model? getting output .find() as: (console log view) class {type: function, store: class, isloaded: true, isupdating: true, tostring: function…} ember1375269653627: "ember313" __ember1375269653627_meta: meta _super: undefined content: function () { isloaded: true isupdating: false set content: function (value) { store: class tostring: function () { return ret; } type: grid.modalmodel __proto: object i new user of community, unable upload image. if you're using ember model, model.tojson(). if trying values model should use getter model.get('name').

c# 4.0 - XMl parsing in c# 4.0 -

i have following xml parsed <config> <parametrictesting>y</parameterictesting> <functionaltesting>y</functionaltesting> <utilities>n</utilities> <commonapi>n</commonapi> <clientdata>n</clientdata> <datasourcetest>y<datasourcetest> <excel> <excelfilepath>myexcel1.xlsx</excelfilepath> </excel> <access> <accessdb> </accessdb> </access> <sql> <sqlconnectionstring> </sqlconnectionstring> </sql> <runnerconsole>n</runnerconsole> <schedular>n</schedular> </config> i using xmlreader read xml since new c# don't know why code breaking after reading second tag i.e parameterictesting. code: string configxml = path.getfullpath("config.xml"); xmlreader xmlreader = xmlreader.create(configxml); while (xmlreader.read()) { if ((xmlreader.nodetype== xmlnodetype.element) && xmlreader.name

g++ 4.7 - CUDA 5.5 RC with g++ 4.7 and 4.8: __int128 build errors -

i'm trying compile code cuda sdk 5.5 rc , g++ 4.7 on macos x 10.8. if understand correctly cuda 5.5 should work g++ 4.7. looking @ /usr/local/cuda/include/host_config.h should work g++ 4.8. concerning g++ 4.8: tried compile following program: // example.cu #include <stdio.h> int main(int argc, char** argv) { printf("hello world!\n"); return 0; } but fails: $ nvcc example.cu -ccbin=g++-4.8 /usr/local/cellar/gcc48/4.8.1/gcc/include/c++/4.8.1/cstdlib(178): error: identifier "__int128" undefined /usr/local/cellar/gcc48/4.8.1/gcc/include/c++/4.8.1/cstdlib(179): error: identifier "__int128" undefined 2 errors detected in compilation of "/tmp/tmpxft_00007af2_00000000-6_example.cpp1.ii". the same program compiles , runs g++ 4.7: $ nvcc example.cu -ccbin=g++-4.7 $ ./a.out hello world! but if include <limits>... // example_limits.cu #include <stdio.h> #include <limits> int main(int argc, char** argv) {

java - javax.mail.AuthenticationFailedException: 535 authentication failed (#5.7.1) -

i making auto send email java project using javamail api. when send mail using smtp.gmail.com host, works. when use own host server mail.sitename.com...it shows exception..my username , password right. please me sort out problem... exception is:- javax.mail.authenticationfailedexception: 535 authentication failed (#5.7.1) @ com.sun.mail.smtp.smtptransport$authenticator.authenticate(smtptransport.java:826) @ com.sun.mail.smtp.smtptransport.authenticate(smtptransport.java:761) @ com.sun.mail.smtp.smtptransport.protocolconnect(smtptransport.java:685) @ javax.mail.service.connect(service.java:317) @ javax.mail.service.connect(service.java:176) @ javax.mail.service.connect(service.java:125) @ javax.mail.transport.send0(transport.java:194) @ javax.mail.transport.send(transport.java:124) @ com.zenga.servlet.mailnotification.sendmail(mailnotification.java:130) @ com.zenga.servlet.mailnotification.dopost(mailnotification.java:45) @ javax.se

Finding out the Python used to install the current package? -

this question has answer here: find full path of python interpreter? 5 answers is there way programmatically find python version used install current package? if have package called mypackage , has in setup.py like: scripts = ["myscript.py"] suppose install package easy_install or pip using particular python version, python 2.x: /usr/local/bin/python2.x setup.py install then in myscript.py , how can find out /usr/local/bin/python2.x used install mypackage myscript.py opposed other python version available on system? i'd know full path , not version info because want use /usr/local/bin/python2.x in script. use sys.executable . a string giving absolute path of executable binary python interpreter, on systems makes sense. if python unable retrieve real path executable, sys.executable empty string or none.

java - How one to many relationship gets persisted in JPA if i have thousands of related entities already in data base and i add new entities in collection -

we have 2 entities entity1 , entity2, entity1 contains set of entity2, have thousands of entities stored in database of entity type entity2 referenced instance of entity1, myentity. now if add more entity2 entities collection , try persist myentity, newly added entities of entity2 persisted. my question how behavior on persist of myentity , whether existing members of relation travel memory , new members added or new members added database without bringing existing members memory if have thousands of referenced entities, might better not map relationship , instead query when needed - allowing use paging or other mechanisms reduce amount of entities read in @ time. depends on type of mapping is, owning relationship needs mapped (the 1 doesn't have mapped by) set foreign key in database. set entity2 side owning side if isn't already. if m:m relation table , doesn't make sense map entity2 side instead - add entity relation table read in same way. new e

java - How tomcat is running my project in Eclipse? -

i know how configure tomcat run dynamic web project created in eclipse. can body please explain me step step process tomcat run web project? i see detail clarification regarding in following links; where eclipse deploy web applications using wtp? http://oreilly.com/pub/a/java/archive/tomcat.html?page=1 http://www.mulesoft.com/tomcat-deploy

ios - I'd like to have a UITabBarController, with no UITabBar -

i'm building akin uisplitview on ipad. "master" panel have buttons, instead of list. the detail panel have @ 7 different screens (corresponding buttons in master pane). so, i'd build uitabbarcontroller in interfacebuilder (for no other reason it's easy view). each button press in "master" view tell tab-bar controller show different panel. can done, or approach silly? suppose create container view, , swap view-controllers in , out. using uitabbarcontroller in ib makes obvious (visually) these views connected. thanks advice. i did same thing, unable hide tab bar in clean , legal way. so, decided change approach: use uitabbar in storyboard "placeholder" connections , fill viewcontrollers array of splitcontroller, when loading splitcontroller, load programmatically uitabbarcontroller storyboard, copy content of viewcontrollers array and, finally, dismiss uitabbarcontroller. with approach have manage transition between vc

android - Is file transfer possible with asmack? -

i implementing chat application ,for using 1. openfire server 2. asmack-jse-buddycloud-2010.12.11.jar i able text chat. trying file transfer . have tried documents code, nothing worked me. some developers writing asmack , smack bug. so, has implemented file transfer code using asmack . if it's not asmack issue please give me suggestion. thanks in advance.

python - Flask-Admin extending templates -

i'm trying extend template 'master.html' template of flask-admin this: {% extends 'admin/master.html' %} {% block body %} hello!!! {% endblock %} and error: file "/usr/local/cellar/python/2.7.3/lib/python2.7/site-packages/jinja2-2.6-py2.7.egg/jinja2/environment.py", line 894, in render return self.environment.handle_exception(exc_info, true) file "/users/slowpoke/projects/python/spider/spider/templates/form.html", line 1, in top-level template code {% extends 'admin/master.html' %} file "/usr/local/cellar/python/2.7.3/lib/python2.7/site-packages/flask_admin-1.0.6-py2.7.egg/flask_admin/templates/admin/master.html", line 1, in top-level template code {% extends admin_base_template %} file "/usr/local/cellar/python/2.7.3/lib/python2.7/site-packages/flask-0.9-py2.7.egg/flask/templating.py", line 57, in get_source return loader.get_source(environment, local_name) file "/usr/local/cellar/python/2.7.3/lib/p

javascript - move npapi plugin object in webpage from one div to another, why plugin destroy and recreate?[chrome, FireFox] -

i got 1 plugin , embeded webpage page, plugin used play media files(.mp3,mp4,m3u8, etc).my webpage looks like: <div id='div1'>plugin</div> <div id='div2'><div id='div2sub'></div></div> plugin created <object id='plugin' type='xxxx' width='xxxx' height='xxxx'></object> the problem is: when move plugin div1 div2sub like: var x = document.getelementbyid('plugin'); var y = document.getelementbyid('div2sub'); y.appenchild(x); then find result ie: plugin still playing media file, video, audio output,it works fine(activex plugin) chrome , firefox: no video, audio output,plugin not play media file anymore.(npapi plugin) i found reason is: ie, plugin moved,not destroy recreate, chrome , firefox,the plugin destroy recreated, have 1 function register callback event on pluin, chrome console shows plugin never received callback event, media file can't

SFTP a file created on SQL Server with a Stored Procedure to a UNIX Server -

i'm trying create sql server stored procedure generate xml file. once file generated, has sftp file unix server. i've never done sftp stuff before here i'm seeking help. please take @ below stored procedure i've written , me out. use [mydb] go set ansi_nulls on go set quoted_identifier on go create proc [dbo].[generatexml] select fileid, systemid, filename dbo.file xml raw('file'), elements, root('file') declare @cmd varchar(255) set @cmd = 'osql -e /q “exec generatexmlproc” /o usadevenv01:/home/xml/file.xml' exec xp_cmdshell @cmd go i facing similar problem , solved using ssis , free tool called winscp. first shuold know that: by default, sql server integration services (ssis) not support access sftp sites. 1 way of getting done using third party software, there's free tool called winscp provides command line utility communicate sftp sites. has scripted command line , executed ssis. then... the first s

Oracle: one query to output different where condition result -

i've got following query output plots 3 rows , 3 columns. each "owner" want extract on same line "pdf" in common , "pdf" doesn't exist on second table. do know other elegant , faster way show in same query output result of different conditions? with temp (select t.owner, (select flh_punto_erogazione dual exists (select 1 netatemp.backlog_nobill_storico p p.flh_punto_erogazione = t.flh_punto_erogazione)) "pdf in comune", (select flh_punto_erogazione dual not exists (select 1 netatemp.backlog_nobill_storico p p.flh_punto_erogazione = t.flh_punto_erogazione)) "pdf non in comune" netatemp.tmp_backlo

VB6 Split String with < > Characters -

i trying split this when source webpage , contains value multiple times, don't think split because of "<" character, way around this? sourcesplit = split(source, "<span class='btext' id='btext'>") i tried using chr(60) instead, didn't either, ideas? thanks help i guess html uses double quotes attribute values, not single. need escape double quotes: sourcesplit = split(source, "<span class=""btext"" id=""btext"">")

matlab - How to organize a list of tags with IDs and subtag-relations into a nested structure? -

i have given 1xn-fields struct array nested n structs 3 fields: id : unique numerical identifier name : unique alphanumeric name parent_id : parental relation id the parental relation given parent_id , refers id under current id nesting, making current tag subtag. parent_id can blank, meaning current id @ root level , not nested under other id. example: tags = field1: [1x1 struct] field2: [1x1 struct] tags.field1 = id: 1 name: 'tag1' parent_id: [] tags.field2 = id: 2 name: 'tag2' parent_id: 1 with struct tags above, field2 nested in field1 in tree diagram. leads me problem: how can reorganize data in given format efficiently generate text based tree diagrams , provide data further processing? one approach tried reorganization whole bunch of nested structs, this: tags_sorted = field1: [1x1 struct] tags_sorted.id_1 = id: 1 name: 'tag1' parent_id: [

facebook graph api - Error : (#1) An error occured while creating the share on php sdk -

i have php/javascript api on website posting messages on user wall depending on actions on website. use on 1 side javascript api logging user app , php sdk on other side posting on user wall link. the thing when launch php graph api method, facebook respond me given error : error : array(1) { 'error' => array(3) { 'message' => string(46) "(#1) error occured while creating share" 'type' => string(14) "oauthexception" 'code' => int(1) } } the php call : $facebook->api( '/me/feed/', 'post' ,$data ); and data $data array message , link but if exact same code in javascript( using fb.api('/me/feed' ) method), message posted on wall. is there have missed ?

spring - @Autowired on a constructor of a Scala class -

i have simple question, how use spring @autowired on constructor of scala class? class messagembeanexporter(messagedirectory: messagedirectory) extends mbeanexporter smartlifecycle { ..... } i haven't tried it, according this , this link , 2.8+ do: class messagembeanexporter @autowired() (messagedirectory: messagedirectory) extends mbeanexporter smartlifecycle { ..... }

asp.net - Multi Project Template folder structure incorrect -

so trying build multi project template , when set folder structure coming out incorrectly (not how microsoft when creating projects) , it's messing things packages folder , references folder. this current structure: solution folder -solution file -folder (solution name) --packages --references --project1 folder --project2 folder i wanting have same structure .net automatically: solution folder -solution file -references folder -packages folder -project1 folder -project2 folder here vstemplate: <vstemplate version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" type="projectgroup"> <templatedata> <name>asp solution template</name> <description>this solution template asp applications</description> <icon>__templateicon.ico</icon> <projecttype>csharp</projecttype> </templatedata> <templatecontent buildonload="true&quo

What are the valid characters in PHP variable, method, class, etc names? -

what valid characters can use in php names variables, constants, functions, methods, classes, ...? the manual has some mentions of regular expression [a-za-z_\x7f-\xff][a-za-z0-9_\x7f-\xff]* . when restriction apply , when not? the [a-za-z_\x7f-\xff][a-za-z0-9_\x7f-\xff]* regex applies when name used directly in special syntactical element. examples: $varname // <-- varname needs satisfy regex $foo->propertyname // <-- propertyname needs satisfy regex class classname {} // <-- classname needs satisfy regex // , can't reserved keyword note regex applied byte-per-byte, without consideration encoding. that's why allows many weird unicode names . but regex restricts only these "direct" uses of names. through various dynamic features php provides it's possible use virtually arbitrary names. in general should make no assumptions characters names in php can contain. parts arbitrary strings. doing th

blackberry - Number of Events in EventList -

i need find number of events stored in eventlist events extracted calendar. there no size() method found. below code eventlist eventlist = (eventlist)pim.getinstance().openpimlist( pim.event_list, pim.read_write); enumeration eventslist = eventlist.items(eventlist.starting, startdateevent, enddateevent, false); how can find number of events in eventslist enumeration? unfortunately, if want number of events between start , end dates, you'll need count them. enumeration doesn't provide interface getting number of elements. eventlist eventlist = (eventlist)pim.getinstance().openpimlist( pim.event_list, pim.read_write); enumeration eventslist = eventlist.items(eventlist.starting, startdateevent, enddateevent, false); int numevents = 0; while (eventslist.hasmoreelements()) { eventslist.nextelement(); numevents++; } system.out.println("there " + numevents + " events in list"); if still want iterate on list a

java - Reuse code for looping through multidimensional-array -

let's have multi-dimensional array member of class , lot of methods, loop through every element of array , operate on it. code might this: public class baz { private foo[][] fooarray = new foo[100][100]; public baz() { (int = 0; < fooarray.length; i++) { (int j = 0; j < fooarray[i].length; j++) { // initialize fooarray } } } public void method1() { (int = 0; < fooarray.length; i++) { (int j = 0; j < fooarray[i].length; j++) { // fooarray[i][j] } } } public void method2() { (int = 0; < fooarray.length; i++) { (int j = 0; j < fooarray[i].length; j++) { // else fooarray[i][j] } } } // , on } now, since code loop same, operation within loop changes, there way code looping somehow refactored seperate method? nice able do doinloop(functiontoexecute()); wh

python - why is converting a long 2D list to numpy array so slow? -

i have long list of xy coordinates, , convert numpy array. >>> import numpy np >>> xy = np.random.rand(1000000, 2).tolist() the obvious way be: >>> = np.array(xy) # slow... however, above code unreasonably slow. interestingly, transpose long list first, convert numpy array, , transpose faster (20x on laptop). >>> def longlist2array(longlist): ... wide = [[row[c] row in longlist] c in range(len(longlist[0]))] ... return np.array(wide).t >>> = longlist2array(xy) # 20x faster! is bug of numpy? edit: this list of points (with xy coordinates) generated on-the-fly, instead of preallocating array , enlarging when necessary, or maintaining 2 1d lists x , y, think current representation natural. why looping through 2nd index faster 1st index, given iterating through python list in both directions? edit 2: based on @tiago's answer , this question , found following code twice fast original version: >>> i

How to run a python script continuosly once started on an online server without user interaction? -

few days wrote python script retrieves running train information website , sends sms user specified number. checks train website, every 10 minutes in loop, change in running status of train, if change found updated information sent user via sms. now runs great pc kept on always, wanted upload script somewhere online runs continously once started , sends smses when user offline. facilitate live updates of train while 1 on move. i have checked answers posted here: https://stackoverflow.com/questions/904977/somewhere-to-store-python-scripts-run-them-online of them online interpreters , pythonanywhere have done work had allowed connection http servers. i have published on github at: https://github.com/naivealgorist/rtsly have @ google appengine https://appengine.google.com/ or amazon aws http://aws.amazon.com/ . both platforms host long running services. appengine easy setup, has limitations. amazon require own system management , more difficult started with, allows an

python - Pandas: df.groupby(x, y).apply() across multiple columns parameter error -

basic problem: i have several 'past' , 'present' variables i'd perform simple percent change ' row-wise ' on. example: ((exports_now - exports_past)/exports_past)) . these 2 questions accomplish when try similar method error function deltas gets unknown parameter axis . how apply function 2 columns of pandas dataframe pandas: how use apply function multiple columns data example : exports_ past exports_ imports_ past imports_ ect.(6 other pairs) .23 .45 .43 .22 1.23 .13 .21 .47 .32 .23 0 0 .41 .42 .93 .23 .66 .43 .22 .21 0 .12 .47 .21 1.23 following answer in first question, my solution use function this: def deltas(row): '

c - Why does my text not print? -

why printf() not called in case? can use && in case or what? { int zz1,zz2; zz1 = 8; zz2= zz1 / 2; if ( (zz1==! 0 ) && (zz2 ==! 1 ) ){ printf("!!!!!!!!!!"); } } i think write (zz1 != 0 ) && (zz2 != 1 ) . actually (zz1 == !0 ) && (zz2 == !1 ) valid syntax in case produces unwanted result because writing: zz1 equals (not)0 , zz2 equals (not)1 that zz1 equals 1 , zz2 equals 0 that false , printf not called

Breeze projection query from already-loaded entity -

if use breeze load partial entity: var query = entityquery.from('material') .select('id, materialname, materialtype, materialsubtype') .orderby(orderby.material); return manager.executequery(query) .then(querysucceeded) .fail(queryfailed); function querysucceeded(data) { var list = partialmapper.mapdtostoentities( manager, data.results, entitynames.material, 'id'); if (materialsobservable) { materialsobservable(list); } log('retrieved materials remote data source', data, true); } ...and want have different partial query same entity (maybe few other fields example) i'm assuming need separate query fields weren't retrieved in first query? ok, if want use same fields retrieved in first query (id, materialname, materialtype, materialsubtype) want call fields different names in

Jquery Image gallery with Next/Previous buttons doesn't work correctly -

i'm trying create slide gallery of images. doesn't need run automatically. want have previous , next button user can navigate manually. my problem code doesn't work. next button, jumps second image , never goes remaining image when try clicking again. previous button when clicked, should show last image or previous 1 doesn't. please me out. see code here your problem not removing previous class before add current item. once you've hit next, have 2 items previous , finds first one. $('.next').click(function(event){ event.preventdefault(); $('.previous').removeclass('previous'); $('.current').removeclass('current').addclass('previous'); $('.previous').hide("slide",{direction: 'left'}, 500); var previousid = parseint($('.previous').attr('id')); $('#'+(previousid+1)).show("slide", {direction: 'right'}, 500).a

javascript - EXTJS4 Window Event -

i've been asked re-write file using extjs4 framework. legacy file written in extjs2. have found point in view file can start after reading sencha's documentation, following examples , tutorials pretty stumped on how started. essentially want achieve @ moment having window panel appear when div clicked. this following code event start; <td class="width200 align_left" style="width:213px !important"> <div style="float:right"><a style="text-decoration: none;" href="#" title="<?= t('select product')?>" id="showproductwindowb" onclick="selectfreegift=false;showproductwindowb(); return false;"><img style="vertical-align:middle" src="/www/icons/modify.gif" alt="<?= t('select product')?>"/></a></div> </td> the window doesn't need contain right either, need make 1 appears. there can

ef code first - Two foreign keys to same primary table -

i have 2 classes: customer , association. a customer can have association many customers. each association of defined type (family, friend, etc) i.e customer friend of customer b. customer related customer c. type of association defined enum associationtype. in order create in ef i've defined following classes public class customer { public string firstname {get; set;} public string lastname {get; set;} public virtual icollection<association> associations { get; set; } } public class association { public int customerid { get; set; } public virtual customer customer { get; set; } public int associatedcustomerid { get; set; } public virtual customer associatedcustomer { get; set; } public associationtype associationtype { get; set; } } i've removed data annotations unable compile. error: "model compatibility cannot checked because database not contain model metadata". does have ideas? it happens

uinavigationcontroller - Hamburger button is not displaying in Confluence 5.1.1 instance. How do I get it to display? -

Image
the hamburger button not displaying in our confluence 5.1.1 dev instance. know how display? note: running refinedwiki original theme global site theme—but specific space hamburger button needs display not using refinedwiki original theme / using confluence default theme. thanks ideas. john you need have confluence linked other applications. this, you'll have navigate t administration console. go edit -> administration -> site administration. log in administrator credentials, , scroll way down bottom of left-hand menu. there should link, under administration heading, says "application links." if click can add application links. the hamburger button won't display until have @ least 1 application linked confluence.

ios - Make GMSCircle respond to tap? -

i using google maps api ios , want make when tap on gmscircle pops little thing coded elsewhere. have set circle "tappable" cannot find need set or make listen tap. use? cllocationcoordinate2d circlecenter = cllocationcoordinate2dmake(10,10); gmscircle *circ = [gmscircle circlewithposition:circlecenter radius:10]; circ.tappable = true; [circ setfillcolor:[uicolor colorwithred:1 green:0 blue:0 alpha:.5]]; circ.map = mapview_; you need use delegate method didtapoverlay : - (void) mapview: (gmsmapview *) mapview didtapoverlay: (gmsoverlay *) overlay here parameter overlay indicates overlay tapped. need check if equals circ. edit : adding details on how check circle within didtapoverlay when gmscircle added map, corresponding gmspolygon created. if circle set tappable, on tapping it, overlay passed didtapoverlay method related polygon , not circle . direct comparison between overlay , circle not possible.

-bash: cordova: command not found; or -bash: phonegap: command not found -

i not going ask question, answer one, have found advice online far , have figured out myself. it's share, right? so on command line, did this: sudo npm install -g cordova sudo npm install -g phonegap which worked fine, when ran either of these lines: my-macbook-pro:~ username$ cordova my-macbook-pro:~ username$ phonegap i got these messages: -bash: cordova: command not found -bash: phonegap: command not found why? turned out permissions on /usr/local/lib directory set "everyone: no access". changed "everyone: read only" , tried again. my-macbook-pro:~ username$ cordova my-macbook-pro:~ username$ phonegap this time worked! test turned "everyone: no access" see if problem. time got different messages: -bash: /usr/local/bin/cordova: permission denied -bash: /usr/local/bin/phonegap: permission denied the outcome same though, not call either cordova or phonegap through command line (i'm including these last 2 denial messages

mysql - SQL group by DATENAME -

i'm trying count of rows each day of week between date. so far have: select datename(weekday,date) theday tablename year(date) = '2013' , (month(date) >= 5 , month(date) <= 7) this gives me this: wednesday wednesday wednesday wednesday wednesday thursday thursday friday friday friday friday saturday saturday but i'd like wednesday and in next column 5 and on. know group by, i'm not great sql. select datename(weekday,date) theday,count(*) numberofdays tablename year(date) = '2013' , (month(date) >= 5 , month(date) <= 7) group datename(weekday,date)

mysql - Greek chars in PHP -

i cannot receive data mysql server when run php query that: $mysqli->query("utf8_general_ci"); // have tried "utf8" - didn't work $query = "select * graf onoma 'ΓΕ%' "; $mysqli->query("set character set 'utf8_general_ci'"); $result = mysqli_query($mysqli,$query); if ($result !=0) { while ($row = mysqli_fetch_assoc($result)) { echo $row['onoma']; } } echo mysqli_error($mysqli); //gives no error echo mysqli_sqlstate($mysqli); //gives 00000 means statement correct can that? thank in advance, try use following set php content-type: header('content-type: text/html; charset=utf-8');

javascript - How to change active class while click to another link in bootstrap use jquery? -

i have html sidebar, , use bootstrap . <ul class="nav nav-list"> <li class="active"><a href="/">link 1</a></li> <li><a href="/link2">link 2</a></li> <li><a href="/link3">link 3</a></li> </ul> i want thing: when click link such link 3, page content change link 3's content, , link 3 have class active , , remove active clss in link 1. i think can implemented in jquery , , have searched many question in so, such as: how keep active link in nav list (twitter bootstrap)? bootstrap css active navigation i use script: $(document).ready(function () { $('.nav li').click(function(e) { $('.nav li').removeclass('active'); var $this = $(this); if (!$this.hasclass('active')) { $this.addclass('active'); } //e.preventdefault(); });

java - ImageAdapter onClick goes wrong -

i'm trying set onclick listener on imageview in adapter of gridview. however, weird thing happens: content of onclick function affects other views in gridview. there reason don't click listener on gridview, need solution via imageadapter. logcat called once click, reason, other imageviews affected function. here's relevant code: public view getview(final int position, view convertview, viewgroup parent) { final viewholder holder; if(convertview == null) { holder = new viewholder(); convertview = minflater.inflate(r.layout.row_multiphoto_item, null); holder.tickimageview = (imageview) convertview.findviewbyid(r.id.tickimageview); holder.imageview = (imageview) convertview.findviewbyid(r.id.imageview1); holder.imageviewlayout = (linearlayout)convertview.findviewbyid(r.id.imageviewlayout); convertview.settag(holder); } else{ holder = (viewholder) convertview.getta

jquery - Select element by class name issue -

i have question regarding jquery selector. i have element class following <td class='test color-picker'>cell</td> i tried select $('.test color-picker') doesn't seem able select when there space between them. can't change class name because effects many other things. there anyways can go around it? much! $('.test.color-picker') this match element both classes. class='test color-picker' 2 distinct class names, test , color-picker . your code trying find <color-picker> element contained within element class of test .

java - Error: Main method not found -

error: main method not found in class essence.game, please define main method as: public static void main(string[] args) the code: package essence; import static org.lwjgl.opengl.gl11.*; import java.util.list; import java.util.arraylist; import java.util.random; import org.lwjgl.input.*; import org.lwjgl.opengl.*; import org.lwjgl.*; public class game{ list<box> shapes = new arraylist<box>(16); public game(){ try { display.setdisplaymode(new displaymode(800,600)); display.settitle("essence"); display.create(); } catch (lwjglexception e){ e.printstacktrace(); } shapes.add(new box(15, 15)); shapes.add(new box(100, 150)); glmatrixmode(gl_projection); glloadidentity(); glortho(0, 800, 600, 0, 1, -1); glmatrixmode(gl_modelview); while(!display.iscloserequested()){ glclear(gl_color_buffer_bit);

python - rotating collection of spheres with respect to the z-axis -

Image
i have coordinates (x,y,z) of center of spheres stored in numpy array. want able rotate spheres respect z-axis getting weird results. code rotation seems moving , right. maybe intended result rotation, don't think is. here code: theta = math.pi/6 ct = math.cos(theta) st = math.sin(theta) z = np.array([[ct, -st, 0], [st, ct, 0], [0, 0, 1]]) self.atoms = np.array([[90,100, 1], [140,100, 1]]) self.atoms = self.atoms.dot(z) here image looked before rotation: and here looks after: you have translate entire system center of rotation center of system. the equations used rotation use work if rotating around origin. for translation can multiply matrix having direction of translation last row. anyway, entire transformation p' = inv(t) * r * t * p (where p each point of figure , p' in final result, see example) inverse of translation matrix negate sign of translation components. edit (worked out example -- might have transpose -- switch rows columns

javascript - Reusable select's behaviour in angular while charging its options via ajax -

i know maybe general question know how make reusable select (or input) when wating options (by ajax request) shows 'charging ...' message selected option. so example in of views can use directive called 'ajax-charged' , every select directive have behaviour. the html imagine while charging: <select ng-options="opt in options" ajax-charged> <option>charging ... </option> </select> the charged html: <select ng-options="opt in options" ajax-charged> <option>opt1</option> <option>opt2</option> <option>etc</option> </select> i thought in changing options array 'charging ...' item, how reusable? other approach welcomed! your directive need know array it's watching. can pass directive, , have the directive watch array. i created fiddle showing in action: http://jsfiddle.net/tmvfn/1/ html: </select> <select ng-model="

ios - When does an NSURLRequest time out? -

the nsurlrequest class ( ios docs , os x docs ) in cocoa has timeoutinterval property. docs state if during connection attempt request remains idle longer timeout interval, request considered have timed out. what 'idle' mean, here? best can tell, means in practice if set 30 second timeoutinterval , call method sends nsurlrequest , if body of http response hasn't returned 30 seconds after sending request, request times out. what's going on? a few things can think of might trigger idleness timer reset: receiving http headers, or receiving part of body. (if either) matters in reality? no bytes received 30 seconds normal definition. should able write simple http server (there sample projects over) , run on private port, connect prove yourself. to simulate timing out in server, add "40" or constant byte promising client, client wait forever 40 bytes bytes @ end aren't ever coming.

html - How to change options of a select using JavaScript -

i have html page in have 2 select s. <select id="field" name="field" onchange="checkvalidoption();"> <option /> <option value="plugin id">plugin id</option> <option value="name">name</option> </select> <select id="operator" name="operator" onchange="checkvalidoption();"> <option /> <option value="equals">equals</option> <option value="contains">contains</option> <option value="not contains">not contains</option> <option value="regex">regex</option> </select> what i'd happen checkvalidoption() make if "plugin id" selected in field option equals (and it's selected) , otherwise other options available. idea on how approach this? i tried changing innerhtml of operator select in js: document.getelement

c# - sqlite index on strings columns -

i have query. it's taking 1100 ms don't think should. select * pageinfo url = @url or url @url2 the url /sub/id , /sub2/id/thing . have index on pageinfo(url) . body of page ~10k , sample got me 1120ms 2 rows (<20k). feels wrong takes long. should able both pages on network in less time. what can speed things up? have index, i'm not sure else can do. using like prevent use of index. compare sqlite> explain query plan select * pageinfo url = @url or url @url2; 0|0|0|scan table pageinfo (~500000 rows) sqlite> to sqlite> explain query plan select * pageinfo url = @url or url between @url2 , @url3; 0|0|0|search table pageinfo using index pi (url=?) (~10 rows) 0|0|0|search table pageinfo using index pi (url>? , url<?) (~31250 rows) sqlite> you should use between , construct arguments query @url2 , @url3 such /sub2/1234/thing?page=0 and /sub2/1234/thing?page=99999999

java - Should the constructor of a private inner class be declared public or private? -

is there actual difference between this public class outerclass { private class innerclass { public innerclass() {} } } and this? public class outerclass { private class innerclass { private innerclass() {} } } accessing private members class more complicated because jvm doesn't allow this. result compiler injects accessor methods makes slower or stack trace more complicated. for these reason leave package local. btw constructor of abstract class doesn't need public either. may protected or package local private static class { private a() { throw new error(); } } public static void main(string... ignored) { new a(); } prints stack trace element. exception in thread "main" java.lang.error @ main$a.<init>(main.java:8) @ main$a.<init>(main.java:6) @ main.main(main.java:12) make constructor package local , second 1 disappears.

sql - Count Number of Distinct Columns in a Row with tSQL -

i doing task work , unfortunately tables designed horribly , can't far modifying structure (one of our major programs here has been based off these outdated tables years). being said, need find way use sql server (tsql) count number of distinct columns in given row. example: i have table columns name , fielda , fieldb , fieldc , fieldd , etc want return table each of rows, returning name , number of distinct columns fielda - fieldd visually: jim - 1 - 3 - 4 - 6 john - 1 - 1 - 1 - 2 jane 2 - 2 - 3 - 3 would return jim - 4 john - 2 jane - 2 one way unpivoting data , subsequently grouping again. gives ability use count(distinct) : select name, count(distinct val) t unpivot (val col in (fielda, fieldb, fieldc, fieldd)) unpvt group name; however, efficient way keep processing on single row -- no join s or group by s or union s. assuming none of values null , following works 4 columns: select name, 4 - ((case when fielda in (fieldb, fiel

android - Best practice for getting View dimensions, possibly before they are drawn to screen -

i've seen ton of different questions , answers problems people having retrieving height , width of views, particularly this thread. the following mentioned methods retrieve view dimensions: onwindowfocuschanged() in activity subclassing type of view you're using , overridding either onsizechanged(), onlayout(), or onmeasure() using viewtreeobserver , addongloballayoutlistener() each of them seem work in cases, while in other cases people doesn't work correctly. since there isn't setondimensionsknown(ondimensionsknown odk) or similar method view class, of these methods (or possibly 1 not mentioned) give me dimensions view have, regardless if it's drawn yet, has wrap_content or fill_parent parameters, or has explicit height , width set in px, dp, or similar? edit: perhaps specific example helpful, i'm trying make popupwindow wrap it's contents, , offset in -x direction value of it's width. problem contents width, , popupwindows width, not

java - good way to seperate List<Integer> into 5 lists of chunks around the 5 minimums -

Image
ok guys, time creative. have list of integers, , want preserve integers in 5 green boxes below. thought finding 5 minimums, , going left , right each 1 until next integer distance far. may difficult last boxes have scattered values maintain. so cliff notes, have list of integers want make 5 lists of integers from, each 1 of 5 lists holding values of 1 of green boxes. i sorry if question seems dumb, wanting see if other people had better ways of going 1 mentioned above. edit: perhaps levenberg-marquardt algorithm help? if understand math books xd. swear math explanations never written in english, if shows me use, , how to, , understand it. can go read out of book again , confused on again! that possible solution: let call list of integer p[n]. define new list of point, call max[n], calculated way: if ((max[n] < p[n]) || (n == 0)) max[n] = p[n]; else max[n] = max[n-1]; in way, max[n] list green line above graph: first solution: identify points i

mysql - SQL checking duplicates in one column and deleting another -

i need delete around 300,000 duplicates in database. want check card_id column duplicates, check duplicate timestamps. delete 1 copy , keep one. example: | card_id | time | | 1234 | 5:30 | | 1234 | 5:45 | | 1234 | 5:30 | | 1234 | 5:45 | so remaining data be: | card_id | time | | 1234 | 5:30 | | 1234 | 5:45 | i have tried several different delete statements, , merging new table no luck. update: got working! alright after many failures got work db2. delete from( select card_id, time, row_number() on (partition card_id, time) rn card_table) rn > 1 rn increments when there duplicates card_id , time. duplicated, or second rn, deleted. i suggest take approach: create temporary table tokeep select distinct card_id, time t; truncate table t; insert t(card_id, time) select * tokeep; that is, store data want. truncate table, , regenerate it. truncating table, keep triggers , permissions , other