Posts

Showing posts from June, 2010

php - How can I bind quantity (input of type number) and item (input of type checkbox) in HTML? -

i have list of dynamically generated items (in php) , have let user chose quantity each item, how can bind (and distinguish) each input of type number corresponding item? each item has code attribute "value" , give names (attribute "name") "numitems_".$itemcode input tags of i'm not sure clean solution. there several ways of doing this. i set name of inputs array: echo '<input type="number" name="numitems['.$itemcode.']" />'; then can check this: foreach($_post['numitems'] $code => $number){ echo 'value of '.$code.' is: '.$number; }

Android Volley Synchronize Server SQLite -

i new android development, started sqlite. working on location app should retrieve locations mongo server, , populate local sqlite db. listview, search queries etc.. should use local db data. i using volley library networking. questions: 1- after getting volley response, how populate sqlite? 2- how send updated location data server device? (i dont need update server device info.) 3- how ensure sqlite gets updated, not overwriten server everytime? i have seen examples using asynctask, syncadapter etc... @ point in project cannot change code volley. my volley code below (currently parses json object): private void getresource() { requestqueue rq = volley.newrequestqueue(this); jsonarrayrequest jobjr = new jsonarrayrequest(url_all_points, new response.listener<jsonarray>() { @override public void onresponse(jsonarray response) { parsejson(response); } }, new response.errorlistener() { ...

machine learning - spell checker uses language model -

i spell checker use language model. i know there lot of spell checkers such hunspell , see doesn't relate context, token-based spell checker. for example, i lick eating banana so here @ token-based level no misspellings @ all, words correct, there no meaning in sentence. "smart" spell checker recognize "lick" correctly written word, may author meant "like" , there meaning in sentence. i have bunch of correctly written sentences in specific domain, want train "smart" spell checker recognize misspelling , learn language model, such recognize thought "lick" written correctly, author meant "like". i don't see hunspell has such feature, can suggest other spell checker, so. see "the design of proofreading software service" raphael mudge. describes both data sources (wikipedia, blogs etc) , algorithm (basically comparing probabilities) of approach. source of system, after deadline , availab...

javascript - localStorage value turns back into zero -

i made kind game using html, css, js, ajax , php. however, in order save user's best score, used localstorage (for first time). for reason, though best score being displayed in "best score" box while user still playing (as wanted), it's being removed when refresh page, , turns 0 again (which defined default value). can please point @ problem me? here specific part of code: $(".pi_tab .best_result #score").html(localstorage.record); $("#pi_input").keyup(function() { // on pressing digit var num = parseint($("#counter").html()); // convert counter's value integer if (!isnan(num)) // if it's legal number { if (num + 1 > localstorage.record) // if it's score new record { localstorage.record = num + 1; // update record $(".pi_tab .best_result #score").html(localstorage.record); // show record "best score" } } }); try us...

java - How does iterator work with constructor -

hi i'm new java , encountered following problem in homework. i'm required write class adds new object list when void method called. hint, structure of iterator method given, core structure of code looks this: public class objectlist implements iterable<obj> { private arraylist<obj> objectlist; attribute_a a; attribute_b b; attribute_c c; public objectlist(attribute_a a, attribute_b b, attribute_c c){ objectlist = new arraylist<obj>; this.a = a; this.b = b; this.c = c; } public void extendlist(attribute_a a, attribute_b b, attribute_c c){ objectlist.add(new obj(a,b,c)); } public iterator<obj> iterator(){ return objectlist.iterator(); } @override public string tostring(){ newstr = ""; for(i = 0;i<objectlist.size();i++) { //assuming obj has method tostring() //it prints out details of each object, join 1 string newstr += objectlist....

Facebook Unity SDK Feed Dialog - iOS callbacks always "cancelled" -

using latest facebook sdk unity, whenever make request using fb.feed api, , user has official facebook app installed on ios, callback returns "cancelled:true". if uninstall official facebook app ios device, callback returns post id expected. any here appreciated. adam

text - Image Description on Hover Image Link -

i have page 9 images. each image links page project. want project name , faded color appear when 1 hovers on image. cannot figure out if can hover definition of link style, or if need use javascript. not know if need multiple divs overlapped-- expecially because want fade color cover entire image, text left-indented. below find divs of top row of images place holders. <div id="wrapper"> <div id="images"> <div id="thumbnails_row1"> <div id="houses_01"><div class="site_nav_left">project title</div class="site_nav_left"></div> <div id="houses_02"><div class="site_nav_right">project title</div class="site_nav_right"></div> <div id="houses_03"><div class="site_nav_right">project title</div class="site_nav_right"></div> </div> </div> </div> click demo...

Plotting a graph row by row from a table using matlab (Instead of column) -

Image
i have data set looks below , want plot them graph. have seen couple of examples online graphs , plotting column column , data source different matrix file. what trying achieve plot multiple graphs on same figure using data set below. final product trying achieve image below. can kind enough guide or point me in right direction ? c1990 stands carbon emission yr 1990. so far able plot following changes data source, rearranging , performing transpose operation. here starting point. data = rand(5, 20); // random data 5 countries countries = {'afghanistan', 'argentina', 'australia', 'austria', 'belgium'}; // cell array containing names of countries h = zeros(size(countries)); hold on h = plot(data', 'marker', '.', 'linewidth', 1.0, 'markersize', 16); legend(h, countries) output: this answers question how plot multiple graphs (by row). polish plot have play different properties of gr...

c# - Connect working Binding to a List<string> -

i binding property of object capturenameslist . variable need bind list<string> . it doesn't work when bind straight list<string> . created wrapper class strings, stringwrapper , , works when use list<stringwrapper> _test4 backing variable. however, need somehow link _test1. attempt shown commented out, doesn't seem work. how bind list<string> ? xaml: <itemscontrol itemssource="{binding capturenameslist}"> <itemscontrol.itemtemplate> <datatemplate> <textbox text="{binding path=value, mode=twoway, updatesourcetrigger=propertychanged}"/> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> c#: public list<stringwrapper> capturenameslist { { return _test4; } set { _test4 = value; } //get { return stringwrapper.castlist(_test1); } //set { _test1 = stringwrapper.castbacklist(value); } ...

c# - Error casting SqlDataReader DataItem to DataRowView on RowBound event of GridView -

i have gridview assign datasource , bind this: protected void search(object sender, eventargs e) { using(sqlconnection con = new sqlconnection(constring)) using(sqlcommand com = new sqlcommand("xxx", con)) { com.commandtype = commandtype.storedprocedure; // parameter declarations here con.open(); sqldatareader rdr = com.executereader(); gvresults.datasource = rdr; gvresults.databind(); } } there onrowbound method looks this: protected void gvresults_onrowbound(object sender, gridviewroweventargs e) { gridviewrow row = e.row; if (row.rowtype != datacontrolrowtype.datarow) return; datarowview rowdata = (datarowview)row.dataitem; // fancy stuff happen here } when line attempts cast row's dataitem datarowview reached error thrown reads: unable cast object of type 'system.data.common.datarecordinternal' type 'system.data.datarowview' i understand i...

What does the leading semicolon in a javascript file mean? -

Image
this question has answer here: what leading semicolon in javascript libraries do? 5 answers i have file jquery.flex.js starts with what beginning mean? the purpose of semicolon avoid error if file concatenated one. for example suppose have 2 files : (function(){ ... })() it's ok long it's in 2 separate files it's error if concatenate them done reduce number of requests. happens have (a)()(b)() and engine trying call result of (a)() argument b . adding semicolon delimit statements fix problem.

java - Indexing an Enum type field with hibernate-search -

i having problems searching using hibernate search when index want use of enum type. here example of application looks like: @entity @indexed public class myentity{ @id @field public long id; @field(bridge=@fieldbridge(impl=enumbridge.class)) public flavour flavour; } with public enum flavour { vanilla, chocolate, strawberry, pistacchio; } then try find instances using type of query. querybuilder qb = [~] ; query q = qb.keyword().onfield("flavour").matching(flavour.vanilla).createquery(); when test results comes empty. tried see content of indexes using luke , not seem find "flavour". re-index after committing changes. everyother type of indexing works , querying works on enum fields. i have tried combination of norms , analyze , index , store , ... of @field annotation (i using hibernate-search 4.5.x hibernate 4.3.1). what doing wrong? settings should looking at? welcome. the entity seems store flavour using o...

linq to sql - Get Distnct items from a group of 2 tables -

tableowner: id: (primary key) name tableitems: id (primary key) name: description: reportingowner: [ foreign key owner table) mappeditems: id: (primary key) itemid: (foreignkey tableitems) ownerid:(foreign key owner) i have 3 tables , want fetch list of items in tableitems not in mappeditems specific owner. how can write linqtosql query it? maybe this: var owner="owner"; var result= ( item in db.tableitems !( mapped in db.mappeditems join owner in db.tableowner on mapped.ownerid equals owner.id owner.name==owner select mapped.itemid ).contains(item.id) select item ).tolist(); where db linq data context

vb.net - Get combobox selected from another form dynamically -

Image
i have combobox in form1 , datagridview in form2. want combobox selected value datagridview in second form use code below in form2 , works: private sub datagridview1_celldoubleclick(byval sender object, byval e system.windows.forms.datagridviewcelleventargs) handles datagridview1.celldoubleclick form1.cbo_fournisseur.text = datagridview1.rows(e.rowindex).cells(0).value.tostring me.close() end sub but want name of form passed dynamically avoid using , ifelse clause enumerate forms have in project use form2 private sub datagridview1_celldoubleclick(byval sender object, byval e system.windows.forms.datagridviewcelleventargs) handles datagridview1.celldoubleclick if formbon2.name = "frm_bn_reception_cuir" frm_bn_reception_cuir.cbo_fournisseur.text = datagridview1.rows(e.rowindex).cells(0).value.tostring elseif formbon2.name = "frm_reception_acc_provisoire" frm_reception_acc_provisoire.cbo_...

sql server - SQL - complicated link table, no simple solution -

i working on project has relatively complicated data structure, , bit stumped following situation: the db has various tables represent glazing unit* components (glass pane, coating, blind) , each 1 of these components has spectra. (* glazing unit - think double/triple glazing glass unit) have 1 spectra table per component table, , there simple fk relationship, follows: tbl_glasspane 1 -- many tbl_glasspane_spectra ------------- ------------- + id + glasspane_id glasspanename + wavelength typeid etc. value where glasspaneid primary key in glasspane, , glasspaneid/wavelength composite primary key in tbl_spectra. this works fine, need 1 tbl_xxx_spectra each component table. the solution have 1 spectra table each of component tables reference, therein lies problem - how arbitrary number of component tables reference 1 spectra table? my initial solution was: tbl_spectra tbl_spectraindex ...

django-cms picture plugin - bulk upload -

what best way make possible upload many pictures @ once cms page? or alternatively, how can change admin template/view make work? there nice way achieve it? (i'm working withe default picture plugin) picture plugin not support multiple uploads. why don't use gallery plugin? can add many images @ once.

python - slicing the pandas data frame with month range -

i working on dataset has years data on pandas data frame. sample given below. data indexed on date column date 2013-12-07 6555 10171 2013-06-17 3754 11140 2013-10-02 5278 6986 2014-01-26 4493 10432 2013-11-17 6739 9001 2014-02-28 3708 11540 2013-04-16 262 6616 2013-08-29 5247 7062 2013-09-18 4401 7032 2013-06-13 2739 7386 2014-03-04 5247 11140 2013-07-22 5047 8647 2013-04-04 277 6447 2013-08-09 5508 7155 2013-11-13 5632 9201 i a sample of 3 months , 6 months data frame. please advice on how best achieve it. thanks if want extract 3/6 month chunk of data data frame why not truncate? assuming dataframe called "df": # 3 month chunk df3 = df.truncate(df.index[0],df.index[0]+3) # 6 month chunk df6 = df.truncate(df.index[0],df.index[0]+6) there ambiguity in question, wonder if mean 3/6 month resampling. if so, quite easy. df3 = df.resample('3m',how='mean',axis=0) df6 = df.resam...

ios - CCScaleTo causes CCSprite to move, apart from scaling it -

i pretty new cocos2d , trying implement scaling sprite , down. using cceaseinout perform task. code snippet looks follows: barrel setanchorpoint:ccp(0.5,0.5)]; id scaleupaction = [cceaseinout actionwithaction:[ccscaleto actionwithduration:.35 scalex:1.5 scaley:1.5] rate:1.0]; id scaledownaction = [cceaseinout actionwithaction:[ccscaleto actionwithduration:.35 scalex:1.0 scaley:1.0] rate:1.0]; ccsequence *scaleseq = [ccsequence actions:scaleupaction, scaledownaction, nil]; [barrel runaction:scaleseq]; barrel of type ccnode . i have tried set anchorpoint (0.5,0.5) considering scaling might happening around centre. but, doesn't seem help. i have seen similar question: ccsprite moved when using ccscaleto or ccscaleby . unfortunately, there no answer in link solves problem. it great if point me in right direction. note: might useful mention barrel object being used box2d object. problem arising there? cheers! note: have following in code: nsobject* bodyuserda...

java - Parsing InputStream into Json object and getting a value -

the response json: { "filename": "vcops-6.0.0-mpforaws-1.1-1695068.pak", "links": [ { "rel": "pak_information", "href": "https://<ip>:443/casa/upgrade/cluster/pak/mpforaws-600/information" }, { "rel": "pak_file_information", "href": "https://<ip>:443/casa/upgrade/slice/pak/mpforaws-600/file_information" }, { "rel": "pak_cluster_status", "href": "https://<ip>:443/casa/upgrade/cluster/pak/mpforaws-600/status" } ], "pak_id": "mpforaws-600" } i using 1 helper of framework have. framework returns response "inputstream". want "pak_id" "inputstream". tried inputstreamobj.tostring() not work me. the method using is: private string ge...

javascript - Cannot get JSON data from URL -

apologies asking looks asked question cannot seem able data following url: http://www.strava.com/stream/segments/860503 i have tried following: $(document).ready(function() { $.ajax({ url: "http://www.strava.com/stream/segments/860503&callback=?", datatype: "json", success: function(data) { $(document.body).append(data.latlng); } }); }); and: $(document).ready(function() { $.getjson("http://www.strava.com/stream/segments/860503&callback=?", function(data) { $(document.body).append(data.latlng); }); )}; but not having luck. have fiddled around 'json' , 'jsonp', adding '&callback=?' url other things suggested on so, no avail. any appreciated. that particular url not support jsonp. neither provide support cross origin resource sharing (cors) via access-control-allow-origin response header, therefore impossible directly call via aj...

javascript - ExpressionEngine 2.8.1: in channel form date field gives error -

i have grid in channel form uses datefield. gives following javascript error in console: uncaught typeerror: cannot read property ‘date_format’ of undefined or in firefox: ee.date undefined now datepicker field disabled, , no javascript after gets executed. ee version: 2.8.1 greets rick it sounds affected this bug contains following solution: open system/expressionengine/fieldtypes/date/ft.date.php , @ lines 168-172: $date_js_globals = array( 'date_format' => ee()->localize->datepicker_format(), 'time_format' => ee()->session->userdata('time_format', ee()->config->item('time_format')), 'include_seconds' => ee()->session->userdata('include_seconds', ee()->config->item('include_seconds')) ); replace lines these: $date_js_globals = array( 'date_format' => ee()->localize->datepicker_format(), 'time_format...

cloudera - hive service is not starting getting error Failed initialising database? -

i have installed cloudera 4.6 on 4 node while starting services getting error in hive logs due issues skipped first run command , hive db not created failed initialising database. fatal: password authentication failed user "hive" org.datanucleus.exceptions.nucleusdatastoreexception: fatal: password authentication failed user "hive" @ org.datanucleus.store.rdbms.connectionfactoryimpl$managedconnectionimpl.getconnection(connectionfactoryimpl.java:494) @ org.datanucleus.store.rdbms.rdbmsstoremanager.<init>(rdbmsstoremanager.java:304) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:39) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:27) @ java.lang.reflect.constructor.newinstance(constructor.java:513) @ org.datanucleus.plugin.nonmanagedpluginregistry.createexecuta...

Multiple Enum Classes in One Java File 2 -

i learned enums , bit confused. want declare enums in 1 file found question , can see did multiple enum classes in 1 java file only not work public class derstring{ public enum fertigkeit { ueber = "Überreden"; heiml = "heimlichkeit"; suche = "suchen"; } public enum terrain { leicht = "leicht"; mittel = "mittelschwer"; unpass = "unpassierbar"; } } for each inner ennum class eclipse gives me error "insert 'enumbody complete classbodydeclaration. i'm doing wrong here? you have incorrect syntax. try this: public class derstring{ public enum fertigkeit { ueber("Überreden"), heiml("heimlichkeit"), suche("suchen"); private string name; private fertigkeit(string name){ this.name=name; } public string getname() { return name; ...

c# - An XML document contains error (0,0) -

i have xml document: <?xml version="1.0" encoding="utf-8" ?> <menu> <mainmenu> <meal>example1</meal> <meal>example1</meal> <meal>example1</meal> <meal>example1</meal> <meal>example1</meal> <meal>example1</meal> </mainmenu> </menu> and whant deserialize list in class mainmenu : [serializable()] public class mainmenu { [system.xml.serialization.xmlelementattribute("meal")] private list<string> meal; public mainmenu() { meal = new list<string>(); } } by method: private void menudeserializer() { mainmenu mainmenu = null; string path = "menuxml.xml"; xmlserializer serializer = new xmlserializer(typeof(mainmenu)); streamreader reader = new streamreader(path); reader.readtoend(); mainmenu = (mainmenu)seriali...

android - END CALL through a Button -

i trying end call through button. end of call works fine on few phones. how make work in phones? on few phone calls don't cut @ all? here have tried: onclick on end call following called: telephonymanager telephony = (telephonymanager)this.getsystemservice(context.telephony_service); try { // java reflection gain access telephonymanager's // itelephony getter class c = class.forname(telephony.getclass().getname()); method m = c.getdeclaredmethod("getitelephony"); m.setaccessible(true); com.android.internal.telephony.itelephony telephonyservice = (itelephony) m.invoke(telephony); telephonyservice.endcall(); finish(); timeswapbuff += timeinmilliseconds; customhandler.removecallbacks(updatetimerthread); } catch (exception e) { e.printstacktrace(); log.e("error", "fatal error: not connect telephony subsystem"); lo...

javascript - call a php variable in createmarker function -

i'm parsing php xml file , i'm trying put marker in every $item . error i'm getting : 'uncaught syntaxerror: unexpected string' in these lines function createmarker( '<?php echo $item['temp']; ?>',latlng,cold ) { var marker = createmarker( '<?php echo $item['temp']; ?>',latlng,cold ); here code function initialize() { var mapoptions = { zoom: 6, center: new google.maps.latlng( 38.822590,24.653320 ) }; var map = new google.maps.map(document.getelementbyid('map-canvas'),mapoptions); <?php foreach ( $item_array $item ) : ?> var latlng = new google.maps.latlng(parsefloat(<?php echo $item['glat']; ?>), parsefloat(<?php echo $item['glon']; ?>)); if ( '<?php echo $item["temp"] ?>' >= "18 °c" ) { al...

django - Form instantiation mechanism -

i have problem django form instantiation. sum up, here's code. in view, have generate context related many objects. def my_view(request): myobjects = objectfrommodels.objects.filter(some_attribute = '1234') item in myobjects: form_related = associatedform(item_pk = item.pk) my_context[item] = form_related class associatedform(forms.form): # attributes def __init__(self,item_pk,*args,**kwargs) super(associatedform,*args,**kwargs) if item_pk : obj = objectfrommodels.objects.get(pk=item_pk) self.someattribute = obj.calling_function() # returns list here's trouble, in view, after iteration, items, value of my_context[item.name] overriden value of last element of iteration in order debug, printed results : def my_view(request): myobjects = objectfrommodels.objects.filter(some_attribute = '1234') item in myobjects: form_related = associatedform(item_pk =...

How users can fill up form after login with facebook in drupal 7? -

i developing drupal website. when user clicks on signup link, has option of login facebook or twitter, after user logged in, 1 form should come in popup fill other details address, phone number etc. how achieve that? to achieve functionality create form , set after login in drupal 7. you can create form either using webform (setup rules using [webform rules]) or cck module. use rules module redirection after login. the following link might helpful, if want achieve writing hook. https://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_login/7

php - my document has no title - my url is displayed as title -

Image
it such have not shown title , keywords , description, but if print php code away works fine if add php'en not work in manner. i have 3 posts in database. here click im site; <?php $sql = " select fms_forum.id, fms_forum.title, fms_forum.url, fms_bruger.fornavn, fms_bruger.efternavn, fms_bruger.profilbillede fms_forum inner join fms_bruger on fms_forum.brugerid=fms_bruger.id "; if ($stmt = $this->mysqli->prepare($sql)) { $stmt->execute(); $stmt->bind_result($id, $title, $url, $fornavn, $efternavn, $profilbillede); while ($stmt->fetch()) { ?> <tr class="postbox"> <td><a href="/forum/<?php echo $id;?>/<?php echo $url;?>/"><?php echo $title;?></a></td> </tr> <?php } $stmt->close(); } ?> .htaccess rewriterule ^forum/([0-9]+)/([^/.]*)/?$ /forum-s.php?id=$1&url=$2 [l] it title on site; if ($stmt = $this-...

php - MySQL replication issues with recording client history -

i have 2 lamp servers, master , slave. the master's web root gets mirrored onto slave using rsync, , databases replicated onto slave using mysql replication. the master in on our office lan. use capture data , generate reports. slave clients access use our website. all client activity needs saved database. obvious problem if slave allowed write database, goes out of sync master. if slave becomes unavailable, client traffic redirected temporarily use master (dns failover) do have ideas recording client activity database without breaking master/slave sync. so far best can come not replicate database containing client usage history. risky not replicate tables how .... switching roles, old master slave , old slave becomes master. therefore, shouldnt run sync-problems mentioned. as "ps", use alternate database that. tables need sync-ed in 1 database, non-synced in other db.

LiqtoTwitter Authorization Automation -

is ever possible authorize twitter app on desktop without user input (of 7 digit number)? trying develop realtime tweet fetching application between list of friends/followers "suspects" communicating together. authorization code needs reset after 15 mins issue, unless if manually present handle re authorization after couple of mins serious challenging. there solution question. joe mayo or one, pls here. thanks there 2 different issues @ work here: authorization , 15 minute rate limit windows. authorization, receive oauthtoken , accesstoken, accessible via iauthorizer.credentials after user authorizes. these tokens never expire. so, save them when user first authorizes , load them iauthorizer.credentials , won't need perform authorization again. here's more detailed description: linqtotwitter - grab saved credentials since mentioned "reset after 15 mins", assume you're referring rate limits, set in 15 minute windows. here's recen...

perl - Sorting an XML element's children by node name -

hi new perl , xml trying sort xml file nodes. using libxml here example of xml file <root> <st_5>val5</st_5> <st_1>val1</st_1> <st_6>val6</st_6> <st_8>val8</st_8> <st_4>val4</st_4> <st_0>val0</st_0> </root> here code have far. of code here got form questions posted here on stackoverflow #!/usr/bin/perl use warnings; use strict; use xml::libxml; @newnodes = qw(); $parser = xml::libxml->new(); $xmldoc = $parser->parse_file('test2_new.xml'); my($book) = $xmldoc->findnodes ('/root/.'); $book->appendtextchild('st_2', 'stss'); $xmldoc->tofile ("test2_new.xml",2); $node ($xmldoc->findnodes('/root/*[text()]')) { @nodes = $node->nodename(); push (@newnodes,@nodes); } @x = sort { substr($a, 3) <=> substr($b, 3) } @newnodes; print "soted list \n @x \n","\n...

xml - Wicket doesn't encode correctly pair of two characters -

Image
coulnd't find better question sorry , sorry bad english. so i'm using wicket read messages xml file. "ż" , "ó" polish letter. xml: <?xml version="1.0" encoding="utf-8"?> <properties> <entry key="wrongencode">inżynierów</entry> </properties> html: <?xml version="1.0" encoding="utf-8" ?> <html ...> <wicket:extend> <div class="someclassforwrongencode"><h3><wicket:message key="wrongencode"></wicket:message></h3></div> </wicket:extend> </html> css: .someclassforwrongencode{ position:relative; left:40px; width: auto; display: inline-block; height: 15px; } with i'm getting one: but if change in xml file <entry key="wrongencode">iżynierów</entry> i this: so seems encoding polish letters correctly ("ż" , "ó"...

python - numdisplay ds9 crashes on Debian linux -

i started use python astronomer , have been using package numdisplay display , manipulate images on sao ds9. computer lab of university has updated linux version debian 7.1. running python 2.7.3 python 0.13.1 , numdisplay v.1.5.6, pyds9 v.1.7 , pyfits v2.3.1. i using display procedure given in http://stsdas.stsci.edu/perry/pydatatut.pdf . once loaded fits image , opened ds9 interface, try display image on ds9 ds9 crashes. hereafter steps use in interactive mode: in [2]: import pyfits pf in [3]: import numdisplay nd in [4]: import ds9 in [5]: ds9.ds9() out[5]: ds9.ds9 @ 0xa3e870c in [6]: im = pf.getdata('m52b.fit') in [7]: nd.display(im) and following error message: error traceback (most recent call last) <ipython-input-7-6988a1e88909> in <module>() ----> 1 nd.display(im) /usr/local/lib/python2.7/dist-packages/numdisplay/__init__.pyc in display(self, pix, name, ...

OAuth2, creating local accounts using Facebook and Google -

i'm trying implement oauth2-based registration/login project i'm working on. a thought struck me; if user decides login site first time using facebook , second time using google; 1) possible connect 2 different login methods same account? 2) idea? at first thought use email unique identifier, doubt secure enough. is there way accomplish this, or should create 2 separate accounts two, depending on login method used? why should e-mail unique identifier lack security? problem user having kind of spam mail address @ facebook avoid email notifications. give user cookie , if he's trying authenticate second time google instead of facebook, created account can work around function enabling him connect google subaccount main one, created facebook. needs quite amount of time ;)

c++ - code change for each version update -

i downloaded open source code(sphinx) , modified of *.cpp , *.c files inorder achieve result required. now each version update,need go , modify code again , again... is there possible ways achieve without touching source code directly? can me in regard...? use version control system. example git. create branch changes, , merge each new version of library branch. preserve changes , show possible conflict easily. or if project open source project hosed on git server, crate private fork it.

c# - How to read data from database and put it into model -

i'm building application in store provinces , cities of country. have 2 models: public class province { public int id { get; set; } public string name { get; set; } } public class city { public int id { get; set; } public string name { get; set; } public province province { get; set; } } this way read province data database: public static list<province> readlist() { var list = new list<province>(); using (var connection = new mysqlconnection(_connectionstring)) { using (var cmd = new mysqlcommand("select * province;", connection)) { connection.open(); mysqldatareader reader = cmd.executereader(); while (reader.read()) { list.add(new province() { id = convert.toint32(reader["id"]), name = reader["name"].tostring() }); } re...

Simple XML Framework - Adding XSI Location in JAVA -

issue: no annotation provided adding xsi location root. stackoverflow question detailed same problem in c#. i'm not quite sure how covert on java. need update xml in flat file , thought of using string manipulation add xsi locations hoping there might cleaner approach. reference question: c# stackoverflow same issue sample xml: <?xml version="1.0" encoding="utf-8"?> <ns0:mysample xmlns:ns0="someurl" xsi:schemalocation="someotherurl"> <othertag/> </ns0:mysample> since schemalocation attribute , not namespace can parse using @attribute annotation. @attribute private string schemalocation; do not forget declare namespace of root element: @namespace(prefix="xsi", reference="http://www.w3.org/2001/xmlschema-instance"), this worked fine me.

regex - Python re.finditer match.groups() does not contain all groups from match -

Image
i trying use regex in python find , print matching lines multiline search. text searching through may have below example structure: aaa abc1 abc2 abc3 aaa abc1 abc2 abc3 abc4 abc aaa abc1 aaa from want retrieve abc* s occur @ least once , preceeded aaa . the problem is, despite group catching want: match = <_sre.sre_match object; span=(19, 38), match='aaa\nabc2\nabc3\nabc4\n'> ... can access last match of group: match groups = ('aaa\n', 'abc4\n') below example code use problem. #! python import sys import re import os string = "aaa\nabc1\nabc2\nabc3\naaa\nabc1\nabc2\nabc3\nabc4\nabc\naaa\nabc1\naaa\n" print(string) p_matches = [] p_matches.append( (re.compile('(aaa\n)(abc[0-9]\n){1,}')) ) # matches = re.finditer(p_matches[0],string) match in matches: strout = '' gr_iter=0 print("match = "+str(match)) print("match groups = "+str(match.groups())) group in match.group...

python - Creating variable length fields with scapy -

i'm trying create new layer scapy build kind of specific packets. in layer, i'm adding different fields don't know how add variable length ones. can please show me example of creating variable length field scapy? thank you. see scapy build dissect class foo(packet): name = "foo" fields_desc = [ varlenqfield("len", none, "data"), strlenfield("data", "", "len") ] >>> f = foo(data="a"*129) >>> f.show() ###[ foo ]### len= 0 data= 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'

regex - HTAccess 'Mirror Domain', respecting SSL, respecting co.uk+.com, keeping subdomain and request_uri -

i map multiple domains onto main 1 seo , simplicity purposes. my 3 domains are webdevguru.co.uk t3chguy.co.uk mortie.org i want both of example domains redirected main domain, keeping subdomain , file , query string client accessed. for example: str.webdevguru.co.uk => str.webdevguru.co.uk/ webdevguru.co.uk => www.webdevguru.co.uk/ fusion.t3chguy.co.uk => fusion.webdevguru.co.uk/ mortie.org/foo?bar => www.webdevguru.co.uk/foo?bar https://mortie.org/ => https://www.webdevguru.co.uk/ basically, want traffic redirected main domain, has respect https domain cms gets transferred different url, subfolder containing cms subdirectory files has following code in .htaccess. rewriteengine on rewritecond %{http_host} ^cms\.webdevguru\.co\.uk$ [nc] rewriterule .* https://secure24447.qnop.net/~t3chguy/tools/cms%{request_uri} [r=301,l] this second code works absolutely fine showing further explain example. keep having issues regex keep trying, works in 1 way ...

Vim isn't loading syntax -

i had unrelated problem vim while back, thought deleting vim files help. did not, have new problem. whenever try put syntax on, says: error detected while processing /home/jonah/.vimrc: line 16: e484: can't open file /usr/share/vim/syntax/syntax.vim i've tried reinstalling fully, doesn't fix issue. you still have broken vim installation missing runtime files. file $vimruntime/syntax/syntax.vim needs there. you should never modify / remove system runtime files in /usr/share/vim yourself! use distribution's package manager (you didn't tell linux disto you're using) reinstall vim, , ensure file there.

mysql - Unable to understand LIKE behavior -

considering following 2 tables: series id name screen_name deleted_at 9 series name 9 screen name 9 null 11 series oneb seriesoneb null 15 mad dogs maddogs null tickets id series_id subject deleted_at 8 15 subject 8 null 13 11 subject 13 null 28 9 subject 28 null 34 11 subject 34 null 37 9 subject 37 null 41 9 subject 41 null 48 9 subject 48 null how possible following query: select * `tickets` ( select count( * ) `series` `series`.`deleted_at` null , `tickets`.`series_id` = `series`.`id` , screen_name '%series name%' or name '%series name%' , `series`.`deleted_at` null ) gives me 7 rows , shouldn't 6 ? try add parenthesis or condition below select * `tickets` ( select count( * ) `series` `series`.`deleted_at` null , `tickets`.`series_id` = `series`.`id` ...

image - ismember fails to find a number generated by bwlabel -

Image
following post steve: http://blogs.mathworks.com/steve/2009/02/27/using-ismember-with-the-output-of-regionprops/ i wanted apply on simple case. here logical image have, has 3 objects: this code used : [l_t,n_t] = bwlabel(logical_image); iii = find(l_t == 2); bbb = ismember(l_t,iii); imshow(bbb); but getting in bbb empty matrix. i.e. logical image same size of original consisting entirely of 0 . n_t shows 3 objects found. max value of l_t 3 . how come ismember fails find 2? it doesn't work because iii list of indices (positions in l_t l_t == 2 ), , l_t number 1 3. not same doing in original example: idx = find((100 <= area_values) & (area_values <= 1000)) here, area_values list taken regionprops of area of different regions in labelled image. has same length, n , number of regions (different values) in l . e.g. if there 10 areas in image , areas 1, 3, , 7 have areas in specified range output of idx [1 3 7] . this selects parts of...

java - Spring testing controller does not work -

i have following class : import org.junit.before; import org.junit.test; import org.springframework.beans.factory.annotation.autowired; import org.springframework.test.web.servlet.mockmvc; import org.springframework.test.web.servlet.setup.mockmvcbuilders; import static org.springframework.test.web.servlet.request.mockmvcrequestbuilders.get; import static org.springframework.test.web.servlet.result.mockmvcresultmatchers.*; import server.testing.webtest; public class campaigncontrollertest extends webtest { @autowired campaigncontroller campaigncontroller; private mockmvc mockmvc; @before public void mysetup() throws exception { this.mockmvc = mockmvcbuilders.standalonesetup(campaigncontroller).build(); } @test public void teststatus() throws exception{ mockmvc.perform(get("/01/status")).andexpect((status().isok())); } } and following error : failed tests: teststatus(cz.coffeeexperts.feedback.server.web.c...

Jenkins running parallel scripts -

i new jenkins , need help.. i have 4 shell scripts : test1.sh, test2.sh, test3.sh , test4.sh i want test2.sh run if test1.sh runs , test4.sh run if test3.sh runs successfully. want test1.sh , test3.sh run in parallel. how achieve in jenkins? i using "execute shell script on remote host using ssh" , "conditional steps(multiple)" (just exploring). have set keys communicate remote server. illustration using screen shot or other way helpful. thank you! first, ensure test1.sh , test3.sh return standard success code when succeed (0). simple way, works in command line, not jenkins, use command line: ((test1.sh && test2.sh) &) ; ((test3.sh && test4.sh) &) each pair of parentheses forms subshell, double-amperands mean "if first succeeds run second", , single ampersand mean "run in backgorund". equivalent of 2 backgrounded shells each running 2 scripts, exit if first script doesn't return 0. the j...

node.js - Sailsjs Waterline's Query method calls cast function to undefined attributes -

i'm using waterline (postgresql database) method model.query(). example: (the sql query more complicated :) ) model.query('select * user', function(err, result) { }); and there such error: typeerror: cannot read property 'type' of undefined @ /node_modules/sails-postgresql/lib/query.js:544:33 this code in sails-postgresql module, error occurs: object.keys(values).foreach(function(key) { // lookup schema type var type = self._schema[key].type; if(!type) return; // attempt parse array if(type === 'array') { try { _values[key] = json.parse(values[key]); } catch(e) { return; } } }); so, i've printed values , keys that console.log('self._schema[' + key + '] = ' + self._schema[key]); and found out waterline calls cast function every attruibute of model, there no such attribute used in query. ofcourse causes error. i've made patch: if(!self._schema[key]...

Qlikview : How create a Trigger on the last Date (Year)? -

i'm new on qlikview , i'm little bit stuck... i'm trying build trigger on document qv. have auto-select, when document launch, field [yearq] , last value (so 2014). [yearq] inclued values {2012, 2013, 2014}. i've try =max[[annéeq]] =year(today())=[annéeq] but didn't work. could me pliz ? thx, in advice :) put on open trigger, year based on reload date: =year(today()) and highest value in year field: =max([annéeq]) if want highest year based of date this: =year(max(datefield))

php - Conditionally remove header/footer in Magento -

i have module page can accessed like www.example.com/module/controller/action/id/10 i want in controller's action $page = (int) mage::app()->getrequest()->getparam('id'); if($page == '12') { $this->getlayout()->unsetblock('header'); $this->getlayout()->unsetblock('footer'); } but above method doesn't work, guess i'm passing wrong alias unsetblock method. i know how hide header/footer via layout xml here want hide them in controller. so searching alternative <remove name="header"/> <remove name="footer"/> i found solution own question, sharing because may others. 1. create new layout handle page // namespace/modulename/model/observer.php class namespace_modulename_model_observer extends mage_core_model_abstract { public function addattributesethandle(varien_event_observer $observer) { $page = (int) mage::app()->getrequest()->getpa...

c++ - stoi() CodeBlocks not working -

i using codeblocks , can't make stoi() function work. read other questions regarding issue couldn't solve it. checked c+11, using namespace std , have string header. don't know how can solve problem. error: 'stoi' not declared in scope found answer on same question here : "it seems mingw needs patch: enabling string conversion functions in mingw " from link can download .zip, follow instructions. this patch enables following list of c++11 functions , templates in std namespace: stoi, stol, stoul, stoll, stof, stod, stold, to_string, to_wstring attention, maybe haver errors later versions, after using copy/paste: as conduit said here : "people should note direct replacement of files not guaranteed safe on versions later mingw gcc 4.7 - use pastebin snippets, open files, , comment/add existing files. applied such, still works fine on mingw gcc 4.8.1 afai"

regex - PHP regular expressions and XML -

i have xml database of 17000 records not formed. problem xml attributes not in quotes (""). my script collects 1 record. the problem put attribute values within quotes. so if have string like: $str = "this test id=abc> string"; $str1 = '="'; $str2 = str_replace("=", $str1, $str); my problem to attribute value within quotes ( id="abc"> ). tried using regular expressions, didn't work. <?php $string = "this test id=abc> string"; $replace = preg_replace('/=([\w]+)/i', '="$1"', $string ); echo $replace ; //this test id="abc"> string ?> http://ideone.com/ourhhv