Posts

Showing posts from April, 2012

How to change the Java webapp 'WEB-INF path' convention under tomcat or jetty -

under java webapp, i want set /web-inf/lib d:/somepath/lib and /web-inf/classes e:/somepath/classes and web.xml f:/somepath/config.xml how config these under tomcat or jetty change convention? the specification (java™ servlet specification version 2.3) mentions standard folders: the web application classloader must load classes web-inf/classes directory first, , library jars in web-inf/lib directory. with tomcat or jetty cannot "out-of-box" provided functionality: tomcat : webappx — class loader created each web application deployed in single tomcat instance. unpacked classes , resources in /web-inf/classes directory of web application, plus classes , resources in jar files under /web-inf/lib directory of web application, made visible web application, not other ones. jetty : the normal configuration each web context (web application or war file) given it's own classloader, has system ...

How to check if a spinners item changed by user in android? -

i filtering using spinners. have 2 spinners, 1st list of states, 2nd list of colleges. when program runs, select state in 1st spinner, program filters colleges in state in 2nd spinner. when change state in 1st spinner, not filter it. wanted know how can select state , filter accordingly. spinner 1 contain; select state [ny,nj] spinner 2 contain; select college [nyu, nyit, njit] i wanna able select ny first , see nyu , nyit . wanna select nj , see nyit. please give me guideline. use database store values. have 1 table states , 1 table colleges. in colleges table have column storing state load spinner states table , set onclik listener. when user clicks on state, search load spinner colleges table column state = selected state. below modifide class http://www.androidhive.info/2012/06/android-populating-spinner-data-from-sqlite-database/ i suggest going through tutorial. import java.util.arraylist; import java.util.list; import android.content.contentva...

playframework 2.0 - Error when save Vietnamese font in playframework2 + java + Mysql Workbrench -

i use play2.0.4 + java + mysql workbench on ubuntu :) when add em xin cảm ơn // = thank this error appeared : [persistenceexception: error executing dml bindlog[] error[incorrect string value: '\xe1\xba\xa3m \xc6...' column 'description' @ row 1]] and mark error user.save() public static void create (users user){ user.save(); // mark line } and if changed password, display : em xin c?m ?n i try config databse collation utf8_unicode_ci , utf8_general_ci or latin_general_ci didn't work. any ideal or in case ? oh ~.~ change database utf8-defaultcollation , worked :) hope other language :)

actionscript 3 - Tween Multiple object turn by turn in tweenlite -

have 5*5 movie clips . want tween them slighter delay , turn turn. best way achieve ? think creating multiple tween may cause performance right? confused achieve in more optimised way. appreciated. usually i'd this: for (var i:int = 0; < 5; i++) { tweenlite.to(object, duration, {delay: duration * i}); } it create tweens @ once, won't effect performance since active tweens noticeable. i did on 200 objects , had no lag @ all. you might want pool tweenlite object on mobile platforms, again - won't see difference 800+ objects.

iterator - Improper use of foreach in java? -

i'm trying remove item of type subclass arraylist using foreach, , removing right when finds it. the code: for (superclass item : list) { if (item instanceof subclass) { list.remove(item); } } i don't know how iterator works in case, i'm asking is: safe? or should throw out of bounds exception ? any appreciated! you cant remove items list while using foreach statement. concurrentmodificationexception you need use iterator.remove() method for(iterator<superclass> = list.iterator(); i.hasnext(); ) { superclass s = i.next(); if(s instanceof subclass) { i.remove(); } }

php - Hybridauth in yii won't redirect to google -

i've been trying make hybridauth work in yii hybridauth extension . problem when want sign using google, redirects me http://mywebsite.com/site/login . i'm using htaccess remove "index.php" path, , have index.html default (because i'm testing yii , don't want show yet) looks this: directoryindex index.html index.php rewriteengine on # if directory or file exists, use directly rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d # otherwise forward index.php rewriterule . index.php hybridauth extension configured in config/main.php in modules section way: 'hybridauth' => array( 'baseurl' => 'http://'. $_server['server_name'] . '/hybridauth', 'withyiiuser' => false, // set true if using yii-user "providers" => array ( "google" => array ( "enabled" => true, "key...

javascript - changing Images src with jquery -

i'm using code changing image src not working. if i'm write variables text values fox example: track = '212'; artist = 'azealea banks'; it's changing last images src when i'm getting variables values neighbor span it's not working @ all. my jquery code: $(function () { $(".plimg").attr("src", function (index) { var title = $(this).next('span.titletrack').text(); alert(title); var array = title.split(' - '); var track = array[0]; var artist = array[1]; var output; $.ajax({ url: "http://ws.audioscrobbler.com/2.0/?method=track.search", data: { track: track, artist: artist, api_key: "ca86a16ce762065a423e20381ccfcdf0", format: "json", lang: "en", limit: 1 }, asy...

Jquery-TableDnd + Form.submit() -

i´m using isocra´s tablednd jquery plugin. works fine far. want submit form in ondrop function like $("#mytable").tablednd({ ondrop: function(table, row) { var input = document.createelement('input'); input.name ='order'; input.value = $.tablednd.serialize(); input.type= 'hidden'; $("#myformular").append(input); $("#myformular").submit() } }); but form isn´t submit. has idea problem? the id of form correct.

objective c - NSdata to writeImageDataToSavedPhotosAlbum bytes not exactly same? -

i trying save nsdata using writeimagedatatosavedphotosalbum . my nsdata size ' 49894 ' , saved using writeimagedatatosavedphotosalbum . if read saved image raw data bytes using alassetslibrary, getting image size ' 52161 '. i expecting both same. can guide me going wrong ? below link not providing proper solution. saving image using writeimagedatatosavedphotosalbum modifies actual image data you can not , should not rely on size, firstly because don't know private implementation , secondly because image data supplied metadata (and if don't supply metadata number of default values applied). you can check metadata contains resulting asset , see how differs metadata supplied. if need save same bytes, , / or aren't saving valid image files should not use photo library. instead should save data disk in app sandbox, either in documents or library directory.

java - Wants to get Check boxes with labels -

in code, i'm adding data database. want set cell renderer label. if run code got check box. try { list<group> listgrchild = grmgmtmodel.performlist(); (final group group : listgrchild) { table.getcolumnmodel().getcolumn(0) .setcellrenderer(new tablecellrenderer() { // method gives component whome // cell must // rendered public component gettablecellrenderercomponent( jtable table, object value, boolean isselected, boolean isfocused, int row, int col) { boolean marked = new boolean(string .valueof(value)); jcheckbox renderercomponent = new jcheckbox(); if (marked) { renderercomponent....

show text in select box in jquery -

i have select box , according selected value want show value in next selected box. code like: $('#category').change(function(){ var cat_val = $('#category option:selected').text(); if(cat_val == 'online'){ $('#workshop-row').hide(); $('#bu_id').val(22); }else{ $('#workshop-row').show(); } }); by doing $('#bu_id').val(22); can value. need set text not val() $('#bu_id option:selected').text("online"); that means if select online first select box in 2nd select box, value text online selected. please guide me. in advance. this select option has text value cat_val $("#bu_id option:contains(" + cat_val + ")").attr('selected', 'selected');

java - Text to speech not working while using that one in listitem click and myactivity is in Tabactivity -

i have dynamic listview ,while clicking list item,that string array has been converted text speech function,i store string array in string , convert text speech. here included code.. public class ttslist extends listactivity implements texttospeech.oninitlistener { private static final int activity_create=0; private static final int activity_edit=1; private ginfydbadapter mdbhelper; private simplecursoradapter dataadapter; listview lv; public button btnadd1; private texttospeech tts; string typed1; public string praystring; public textview txttext; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_tts_list); lv =(listview)findviewbyid(r.id.list); mdbhelper = new ginfydbadapter(this); btnadd1 = (button)findviewbyid(r.id.btnadd); btnadd1.setonclicklistener(new onclicklistener() { ...

matlab - Is it possible to make hist3 plots smoother? -

Image
i use hist3() function plot density of points. creates grid , finds number of points in each grid, creates plot. colors on plot discrete. there option make distribution smooth, i.e. make transition 1 color smoother. cells of grid have different colors, grin yellow , distribution not apparent. i use following code. axis equal; colormap(jet); n = hist3(final',[40,40]); n1 = n'; n1( size(n,1) + 1 ,size(n,2) + 1 ) = 0; xb = linspace(min(final(:,1)),max(final(:,1)),size(n,1)+1); yb = linspace(min(final(:,2)),max(final(:,2)),size(n,1)+1); pcolor(xb,yb,n1); thanks in advance. you may want use gridfit function matlab file exchange . smooth effect comes both interpolation (more points plot) , full use of available color ( colormap jet here). note edgecolor set none so black lines removed. as used here, takes output of hist3 (20x20 matrix) , interpolate (100x100). plot surface using surf . in addition, can uncomment camlight option. final = randn(1000,2)...

html - input textfield with button on the right and not stacked in mobile using bootstrap -

i trying achieve effect time no success. need button of search form on right side of textfield in both desktop , mobile view using bootstrap classes. th button comes on bottom of textfield no matter do. need both textfield + button centered in both desktop , mobile view. <header class="jumbotron masthead mastheadcstm"> <div class="container"> <div class="row-fluid"> <div class="offset3 span6 offset3"> <form> <input type="text" placeholder="engineer etc etc"> <button type="submit" class="btn btn-primary">search!</button> </form> </div> </div> </div> </header> like this demo css .offset3{ text-align:center; }

PHP: [[:<:]] and [[:>:]] anchors -

why doesn't work (neither matches nor not), seems not parse it. <?php echo preg_match("/[[:<:]]name[[:>:]]/","my name max"); ?> it doesn't output neither 0 nor 1 . why? it seems have error reporting turned off. if you'd have enabled following error: warning : preg_match(): compilation failed: unknown posix class name @ offset 3 in ... this means can't have class name consisting of less sign ( [[:<:]] ); give proper name instead.

How to change the type of input tag(date to text) in jquery.? -

can please tell me how change type of input tag(date text) in jquery on button click. actually want task again want change type (text date.) not sure want kind of code, ways here is $('#dataid').attr('type', 'input'); demo here

c# - visual studio can't find unit tests in web project -

i've created bunch of unit tests methods in web project, can't make visual studio find these unit tests. the unit tests located in app_code/tests/testfile (there's multiple test files under folder tests) how make visual studio find these tests ? i tried having seperate unit test project @ first, couldn't reference web project, , therefore not call of methods in .cs files under app_code. refactor solution code testing in 1 assembly example dataaccess.dll referenced web project , test in test project dataaccesstests reference dataaccess.dll project.

html5 - How to get the column index of particular value of td in HTML tables -

hi there, i created html table , need find column index of particular value, don't know how access each value of table. why unable index of column. here table. <table> <tr> <td>01</td> <td>02</td> <td>03</td> </tr> <tr> <td>04</td> <td>05</td> <td>06</td> </tr> <tr> <td>07</td> <td>08</td> <td>09</td> </tr> </table> and want index of value 03. the following working code, first traverse table values in this, compare required value , find index of it.., <html> <head> <script> function cellvalues() { var table = document.getelementbyid('mytable'); (var r = 0, n = table.rows.length; r < n; r++) { (var c = 0, m = table.rows[r].cells.length; c < m; c++...

ruby on rails - Rspec describe method syntax -

i don't find syntax of rspec describe method, find examples. if correctly understand, can pass describe method string, class name (model name, example), , string , class name parameters. difference between these 3 cases of invocation describe ? describe 'string' ... end describe modelname ... end describe 'string', modelname ... end it depends on thing want describe. that description , other developers working code base. $ rspec --format=documentation spec/ or just $ rspec -fd spec/ will out string ... modelname ... string modelname ...

pacemaker can't start my zabbix service when i stop zabbix sevice -

i want use corosync+pacemaker+zabbix achieve high availability.follow config crm(live)configure# show node zabbix1 \ attributes standby="off" timeout="60" node zabbix2 \ attributes standby="off" primitive httpd lsb:httpd \ op monitor interval="10s" primitive vip ocf:heartbeat:ipaddr \ params ip="192.168.56.110" nic="eth0" cidr_netmask="24" \ op monitor interval="10s" primitive zabbix-ha lsb:zabbix_server \ op monitor interval="30s" timeout="20s" \ op start interval="0s" timeout="40s" \ op stop interval="0s" timeout="60s" group webservice vip httpd zabbix-ha property $id="cib-bootstrap-options" \ dc-version="1.1.8-7.el6-394e906" \ cluster-infrastructure="classic openais (with plugin)" \ expected-quorum-votes="2" \ stonith-enabled="false" \ last-lrm-refresh="1377489711" \ no-quorum-po...

django - how to query a many to many relationship? -

i'm trying build e-learning platform i have users (utilisateur) can take several courses ,each course have several modules , module can in several courses a user can student or teacher or admin, student "managed" teacher or several , teacher can managed teacher (if researcher) ,teachers managed admins i'm not familiar many_to_many concept, please correct me this django models : class utilisateur(models.model): user = models.onetoonefield(user) role = models.charfield(choices=roles,blank=false,max_length=50) managed_by = models.manytomanyfield('self', related_name='managers', symmetrical=false, blank=true) course = models.manytomanyfield('course') #can it? (question 2) module = models.manytomanyfield('module', through='utilisateurmodule') class ...

c# - EF4 Linq - Get top items using criteria from related tables -

i have 3 tables need include in linq query in ef4. using dbcontext generator generate poco classes. linq query querying poco objects. hopefully below explains how tables related in underlying database clearly. orderdetails > - 1 books 1 - < bookcategories as can see 1 book can have many categories , 1 book can appear on many orders. i trying top selling books in specific category. so far have managed top selling books overall below cannot seem extend include book category criteria in clause var topsellingbooks = (from p in this.context.orderdetails p.issueid == issueid && p.publicationid != "4tc" group p p.bookid bookgroup select new { bookno = bookgroup.key, bookcount = bookgroup.sum(q => q.quantity) }).orderbydescending(q =...

Loading an individual file on any directory request (Apache) -

i wish load particular .html file on request of any directory w/ apache. for example if request somewebsite.com/thisdirectory web browser index.html load, if request somewebsite.com/anotherdirectory same index.html render. you use url rewriting: rewriteengin on rewriterule ^.*$ /index.html [l]

sorting - Order result items by other attribute than range key -

i've been researching lot couldn't find right answer/example. in dynamodb have table 'user_playlists' hash key 'user_id' , range key 'playlist_id' (one user can have n playlists). for each playlist store information when playlist created in attribute 'created_ts' (i store timestamp of creation time). 'created_ts' defined index. now query 'user_playlists' table retrieve playlists particular user. query done hash , range key. results ordered range key 'playlist_id' hash, order attribute means nothing me. want sort results attribute 'created_ts'. is possible sort indexed attribute query method? existing logic of retrieving data hash , range key should stay. want add needed things ordered items created time. no, cannot sort scan according amazon ( https://forums.aws.amazon.com/thread.jspa?messageid=328982# ). additionally, cannot sort query field, stated in question. anyway, can sort results lo...

python - Get Text for XML-Node including childnodes (or something like this) -

i have pure text out of xml-node , child nodes, or else these strange inner-tags are: example-nodes: <booktitle> <emphasis type="italic">z</emphasis> = 63 - 100 </booktitle> or: <booktitle> mtn <emphasis type="italic">z</emphasis> = 74 - 210 </booktitle> i have get: z = 63 - 100 mtn z = 74 - 210 remember, example! there type of "child-nodes" inside booktitle-node, , need pure text inside booktitle. i tried: tagtext = root.find('.//booktitle').text print tagtext but .text can't deal strange xml-nodes , gives me "nonetype" back regards & thanks! that's not text of booktitle node, it's tail of emphasis node. should like: def parse(el): text = el.text.strip() + ' ' if el.text.strip() else '' child in el.getchildren(): text += '{0} {1}\n'.format(child.text.strip(), child.tail.strip()) return tex...

how can i return an array created in a loop javascript? -

i trying return column values database in array,but returns empty array. function select(query, db) { var result = new array(); db.transaction(function(tx) { tx.executesql(query, [], function(tx, rs) { var len = rs.rows.length; (var = 0; < len; i++) { var row = rs.rows.item(i); result.push({latitude : row['latitude']}); } }); }); return result; } i sure array created after loop returns empty @ last. you using asynchronous functions. so, direct return not work. need use callback. function select(query, db, callback) { var result = new array(); db.transaction(function(tx) { tx.executesql(query, [], function(tx, rs) { var len = rs.rows.length; (var = 0; < len; i++) { var row = rs.rows.item(i); result.push({latitude : row['latitude']}); } callback(result); }); }); } select(function(res...

c# - using Microsoft.Office.Interop Word and Excel -

i using microsoft.office.interop, scanning word , excel files using c#,i taking file input user, saving on local directory scanning interop library. working fine on local publish, when published on server not scanning word or excel files. have ms-office installed on server, same version have on pc. else need do? have copied required dll's in bin directory. how reading word file public static string word_to_text(string source) { word.application newapp = new word.application(); object source = source; object unknown = type.missing; object miss = system.reflection.missing.value; object readonly = true; microsoft.office.interop.word.document docs = newapp.documents.open(ref source, ref miss, ref readonly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss); string totaltext = ""; (int j = 0; j < docs.paragraphs.count; j++) { totaltext += " \r\n " + docs.pa...

osx - Cannot select repository to commit to -

i`m using xamarin studio 4.0.12 build 3 create ios , android apps. but, think since last update, svn doesn't work correctly anymore. if create new project , want add our svn server, can't select our svn repository , i'm not sure commits go (local maybe?). so, how can commit project our svn server? after update, command line tools not installed (appropriate version). so, in xcode, under preferences dropdown menu, in downloads, find command line tools , download , instal it.

c - Misra rule 19.7 : function like macro -

i have warning regarding misra rule 19.7 : function should used in preference function-like macro in below line : #define goffsetof(type, mem) (goffset)((size_t) ((char *)&((type *) 0)->mem - (char *)((type *) 0))) how should solve ? rule 19.7 (advisory): function should used in preference function-like macro. while macros can provide speed advantage on functions, functions provide safer , more robust mechanism. particularly true respect type checking of parameters, , problem of function-like macros potentially evaluating parameters multiple times. the rule advisory, means "should followed": note status of "advisory" not mean these items can ignored, should followed far reasonably practical. formal deviations not necessary advisory rules, may raised if considered appropriate. so have option break rule without making formal deviation. now, in answer question, "how should solve this?", have 2 choices given macro fu...

getting the wrong timezone in java / android -

this question has answer here: is java.util.date using timezone? 5 answers string = 26/8/2013 15:59; i want convert date gmt, after applying below code, eest time rather gmt. dateformat df = new simpledateformat("dd/mm/yyyy h:m"); df.settimezone(timezone.gettimezone("utc")); df.parse(newdate); log.i(tag, df.parse(newdate).tostring()); output : mon aug 26 18:59:00 eest 2013 whats wrong ? your parsing correct, different locale time zone used display when making tostring(). used formatted output demonstrate correct format . here details example: final string time = "26/8/2013 15:59"; timezone timezone = timezone.gettimezone("utc"); final string request_date_format = "dd/mm/yyyy h:m"; dateformat format = new simpledateformat(request_date_format); date localdate = format.parse(time); // localdate.tos...

python - Remove content between <div> and <ahref> Beautiful Soup -

i have piece of code parse webpages. want remove content between, div, ahref, h1. opener = urllib2.build_opener() opener.addheaders = [('user-agent', 'mozilla/5.0')] url = "http://en.wikipedia.org/wiki/viscosity" try: oururl = opener.open(url).read() except exception,err: pass soup = beautifulsoup(oururl) dem = soup.findall('p') in dem: print i.text i want print text without content between h1, ahref mentioned above. edit: comment "i want return text not between <div> , </div> tags.". should strip out blocks parent has div tag: raw = ''' <html> text <div> avoid </div> <p> nested <div> don't me either </div> </p> </html> ''' def check_for_div_parent(mark): mark = mark.parent if 'div' == mark.name: return true if 'html' == mark.name: return false return check_f...

node.js - Retrieving value of count mongodb collection in a variable -

i trying retrieve value of records collection in mongo db here source. exports.procc = function(req, res) { db.collection('search', function(err, collection) { collection.count({'str':'car'},function(err, count) { console.log(count+' records');//prints 2 records c=count; }); }); console.log('records= '+c);//print 0 records res.end(); }; the problem out of callback prints number of register, out of callback prints 0 , don't know how save value in variable. because db.collection , collection.count asynchronous methods, c variable getting set after second console.log statement executed. so want c has occur within collection.count callback.

javascript - Store html into variable on click, erase from the DOM and put it back in on another click -

i'm trying build on/off button video. i'd simple: on first click, deletes video (not stop it) and, on second, puts dom. i've come bit of code, doesn't work way want to: $('#on-off').click(function(e) { e.preventdefault(); if (videocontent !== ""){ var videocontent = $('#video-container').html(); console.log(videocontent); // @ point, console shows variable videocontent contain content of #video-container. $('#video-container').html(""); } else { $('#video-container').html(videocontent); } }); the first click works fine , stores content of #video-container videocontent. second doesn't put content of videocontent in #video-container, however. in fact, erases content of videocontent. i'm sure pretty simple solve, can't figure out. thanks put variable videocontent in global scope: var videocontent = ''; $('#on-o...

html - Pushing a div inside a div to the very bottom that works with IE7 -

i'm running in slight problem not able align , same effect chrome in ie7. trying accomplish push div background bottom of container div. js fiddle : http://jsfiddle.net/mn34r/ code <div class="container"> <img style="padding-top:20px; padding-bottom:20px" src="img/img.png"> <div class="description"><br> <span style="font-weight:bold;font-size:15px;">harry's nose</span><br> <button class="btn btn-small btn-primary" type="button"><i style="color:#fff; </i>read more</button> </div> </div> css: .container{ border:solid 1px #e2e2e2; height:327px; text-align:center; position:relative; } .description{ height:110px; background-color:#f1f1f1; text-align:center; bottom:0; width:100%; position:absolute } any appreciated. thank you. in ie7 top: overwrites bottom...

php - Split Large XML File Into Smaller Files -

i have ecommerce site needs update products via huge xml file downloaded via ftp distributor. the products.xml file approx 21mb in size , pulling data , looping through exhaustive single pass. i need able split original xml file or processed simplexmlelement 1000 products each, load files , process them separately. i'm pulling xml simplexmlelement casting array looks so: [1] => array ( [products_name] => product name [products_description] => product description [products_image] => 1234.jpg [products_price] => 9.99 [products_model] => 1234 [item_brandname] => acme inc. [item_upc] => 01234567890 [item_height] => 0.500 [item_length] => 4.250 [item_diameter] => 3.375 [products_weight] => 0.05 [manufacturers_name] => acme distributors [item_vendor_number] => xxx-1234 [products_quantity] => 100 [date_recieved...

c# - ELMAH Not working, Could not load file or assembly 'System.Data.SQLite' or one of its dependencies? -

i trying elmah error handling working , followed following tutorial , running: https://code.google.com/p/elmah/wiki/mvc the error message following: could not load file or assembly 'system.data.sqlite' or 1 of dependencies. attempt made load program incorrect format.

java - JComponent contains method does not work in the MouseEvent action of JTable -

i have cell in jtable jpanel has located in it. jpanel has 2 labels inside it. want different action when left label clicked, , want make operation when right action clicked. not want use tablecelleditor , makes code complicated. becase cell values has range of type. i write following code selected component mouse event, no success. tried swingutilies.convertmouseevent , did not change anything. problem below code? why jcomponent contains method not check mouse point. contsimtable.addmouselistener(new mouseadapter() { public void mouseclicked(final mouseevent event) { if (swingutilities.isleftmousebutton(event)) { if (event.getclickcount() == 2) { jtable target = (jtable) event.getsource(); int row = contsimtable.getselectedrow(); int column = contsimtable.getselectedcolumn(); /** * convert view colum model.it column index * stored in table model ...

java - How to solve ArrayIndexOutofBoundsException -

i split string, did not consider exception. error comes out. example, if string "2012-10-21,20:00:00,," here codes: string str = "2012-10-21,20:00:00,,"; string a[] = str.split(","); string timestamp = a[0] + "t" + a[1]; string temp = a[2]; system.out.println(timestamp); system.out.println(temp); here error: exception in thread "main" java.lang.arrayindexoutofboundsexception: 2 actually, a[2] null, don't know how deal problem. because in string array, recodes contains value of temp, such "2012-10-21,20:00:00,90,". thank you. split remove empty elements. need use 2 parameter version: str.split(",",-1); see here: java string split removed empty values

creating typescript definitions for YUI 2 -

i want use typescript in our project uses yui 2 trying create definition file it. what should definition using new yahoo.widget.panel('test'); look like? i tried declare module yahoo { export module util { export interface panel { (id: string); } } } but get error ts2095: not find symbol 'yahoo' when running tsc. here go : declare module yahoo{ export module widget{ export class panel{ constructor(element:string); } } } new yahoo.widget.panel('test'); try online.

angularjs - How to send an array of parameter through GET with Restangular -

i have send array of filters through parameters in api : /mylist?filters[nickname]=test&filters[status]=foo now if send object directly : restangular.one('mylist').get({filters: { nickname: 'test', status: 'foo' }}); the query sent ?filters={"nickname":"test","status":"foo"} how send real array ? should thinks alternative ? i found way it, have iterate on filter object create new object [] in name : var query = {}; (var in filters) { query['filters['+i+']'] = filters[i]; } restangular.one('mylist').get(query); produce: &filters%5bnickname%5d=test someone have better solution ?

regex - Find and replace multiple pairs of chars -

i have text file , use sed editor regex find , replace characters in it. say, a->b, g->h, r->d , e->q. like this: sed -i "s/a/b/g" file.html >nul sed -i "s/g/h/g" file.html >nul sed -i "s/r/d/g" file.html >nul sed -i "s/e/q/g" file.html >nul all works fine. want combine single regex line. can i? after googling , reading lot refex, see no way right now. thanks! tr command this: tr < file.html 'agre' 'bhdq' but if you're asking how make commands run go: sed -e "s/a/b/g" -e "s/g/h/g" -e "s/r/d/g" -e "s/e/q/g" file.html or more if commands different: sed -e "s/a/b/g" file.html | sed -e "s/g/h/g" | sed -e "s/r/d/g" | sed -e "s/e/q/g"

understanding Scala behaviour in auxiliary constructors with a function as parameter -

i have been learning scala, has been far, sadly have found behaviour don't understand. hope guys can give me clues, problem emerged when coded class: class point(idim:int,data:array[double],f: array[double] => double) { ... def this(idim: int, obj :objectthatgenerate_arrayofdouble, f: array[double] => double){ this(idim,obj.generatearray(idim),f) } } so when use these constructors in main code need this var p:point = new point (idim,obj,f _) or var p:point = new point (idim,dataarray,f _) but if delete auxiliar constructor need build object this: var p:point = new point (idim, dataarray, f) why in scala when have auxiliary constructor need pass partially implemented function "f _ " , when don't have auxiliary constructor can pass function directly "f "?, or character "_" have meaning in context? as @ghik says, there type inference limitations when use method (or in case constructor) overloading. in general, shou...

c# - Why is a button enabled if the Command binding resolves to null? -

ok, xaml quite simple , uses mvvm bind icommand somecommand { get; } property on view model: <button command="{binding path=somecommand}">something</button> if somecommand returns null , button enabled. (nothing canexecute(object param) method on icommand , because there no instance call method on) and question: why button enabled? how work around? if press "enabled" button, nothing called. ugly button looks enabled. it enabled because that's default state. disabling automatically arbitrary measure gives rise other problems. if want have button without associated command disabled, bind isenabled property somecommand using appropriate converter, e.g.: [valueconversion(typeof(object), typeof(bool))] public class nulltobooleanconverter : ivalueconverter { public object convert(object value, type targettype, object parameter, cultureinfo culture) { return value !== null; } public object convertback(o...

Better way to re-order Django form errors? -

is there better, more "django-istic", way put django form error messages in particular order technique shown below? have form ten fields in it. if user doesn't fill out required field or if enter invalid data, iterate through form's error fields i've put in custom error list displaying red "x" , error message(s) @ top , red "x" next invalid field(s) below: {# template.html #} <form method="post" action="."> {% csrf_token %} {# non-field errors removed clarity #} {# iterate through error messages in custom ordered error list #} {% error_message in ordered_error_list %} <img src='/static/img/red_x.png' alt='error'></img> &nbsp;{{ error_message }}<br> {% endfor %} <br> {% field in form.visible_fields %} <div> {{ field.label_tag }}<br /> {{ field }} {% if field.errors %} <...

c# - Creating a method that queries a database using linq -

i have multiple methods pretty same thing query different tables. i trying use 1 method , pass method parameters instead can skip creating multiple methods , neaten code. this have currently: myentitymodel entity = new myentitymodel(); private void loaddata() { var query = data in entity.table1 select data; mydatagrid.itemssource = query.tolist(); } i want this: myentitymodel entity = new myentitymodel(); private void loaddata(datagrid datagrid, table mytable ) { var query = data in entity.mytable select data; datagrid.itemssource = query.tolist(); } i'm unsure type parameter should pass mytable tried passing system.data.entity.dbset , myentitymodel is possible using linq? you can create generic method returns data dbset instance of provided entity type: myentitymodel entity = new myentitymodel(); private void loaddata<t>(datagrid datagrid) t : class { datagrid.itemssource = entity.s...

Need two slanted lines to form a point and act as a break for the page using CSS/HTML -

as can't upload images due reputation points here goes me trying explain it. i have 2 div's need separated 2 slanted lines coming down towards each other forming point in middle. jsfiddle show mean. i tried solution: http://jsfiddle.net/rz4b8/7/ however don't know how make responsive values set border-left-width property , works specific browser widths. below code; .top-border { width: 100%; position: relative; left: 0; } .top-border-left { border-top-width: 30px; border-right-width: 0; border-bottom-width: 0; border-left-width: 800px; border-color: transparent transparent transparent #ffffff; float: left; } .top-border-left { border-style: solid solid inset solid; width: 0; height: 0; } .top-border-right { border-top-width: 0; border-right-width: 0; border-bottom-width: 30p x; border-left-width: 800px; border-color: transparent transparent #ffffff transparent; float: right; } .top-border-right { border-style: inset solid solid solid; width: 0; height: 0; } ...

sql server - How to write stored procedure with if then -

am new stored procedures, being familiar c#. i need stored procedure this: select * dbo.file_map file_sub_type = @file_sub_type , column_name = @column_name , col_num = @col_num if found, return true. if not found, insert table row error table. can in 1 stored procedure? or need create 3 of them, 1 see if record exists, 1 insert row in error table, , top level called c# code? a stored procedure can't "return true"... if exists (select 1 dbo.file_map ...rest of query...) begin return 1; end else begin insert dbo.errortable ...columns... ...values...; return 0; end

jquery - highlight main menu item when sub item is open -

in web site have menu bar drop down menus of items. when viewing 1 of sub-pages want parent item in menu bar highlighted ( class='active ). here code: <div id="sidebar-left"> <div class="menu"> <ul class="listeohne"> <li class="color1" id='active'><a href="index.php">startseite</a> </li> <li class="color2"><a href="">wer wir sind</a> <ul> <li class="whiteback"> <a href="werwirsind.php">einf&uuml;hrung</a> </li> <li class="whiteback"><a href="statuten.php">statuten</a> </li> <li class="whiteback"><a href="vorstand.php">vorstand </a> ...

R logistic regression area under curve -

i performing logistic regression using page . code below. mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv") mylogit <- glm(admit ~ gre, data = mydata, family = "binomial") summary(mylogit) prob=predict(mylogit,type=c("response")) mydata$prob=prob after running code mydata dataframe has 2 columns - 'admit' , 'prob'. shouldn't 2 columns sufficient roc curve? how can roc curve. secondly, loooking @ mydata, seems model predicting probablity of admit=1 . is correct? how find out particular event model predicting? thanks update: seems below 3 commands useful. provide cut-off have maximum accuracy , roc curve. coords(g, "best") mydata$prediction=ifelse(prob>=0.3126844,1,0) confusionmatrix(mydata$prediction,mydata$admit the roc curve compares rank of prediction , answer. therefore, evaluate roc curve package proc follow: mydata <- read.csv("http://www.ats.ucla.edu/...

c# - Console program, static methods, socket becomes null -

class program { static socket m_sock; static void main(string[] args) { socket m_sock= new socket(addressfamily.internetwork, sockettype.stream, protocoltype.tcp); . . . m_sock.connect(ipendlocalhost); sendrequest("command"); } static void sendrequest(string scommand) { . . **m_sock.send(szcommand, ibytestosend, socketflags.none);** } when comes send method nullreferenceexception. in debug (i added m_sock watch) see when program enters sendrequest method m_sock becomes null. can't understand why happening , problem is. please help. m_sock defined internal main @ class level, don't have define again in main, initialize it, like: static void main(string[] args) { m_sock= new socket(addressfamily.internetwork, sockettype.stream, protocoltype.tcp); notice socket removed. currently main method initializing local m_sock , , why class level m...

clojure - Variadic function with keyword arguments -

i'm newbie clojure , wondering if there way define function can called this: (strange-adder 1 2 3 :strange true) that is, function can receive variable number of ints , keyword argument. i know can define function keyword arguments way: (defn strange-adder [a b c & {:keys [strange]}] (println strange) (+ b c)) but function can receive fixed number of ints. is there way use both styles @ same time? unfortunately, no. the & destructuring operator uses after on argument list not have ability handle 2 diferent sets of variable arity destructuring groups in 1 form. one option break function several arities. though works if can arrange 1 of them variadic (uses & ). more universal , less convenient solution treat entire argument list 1 variadic form, , pick numbers off start of manually. user> (defn strange-adder [& args] (let [nums (take-while number? args) opts (apply hash-map (drop-while number? ar...

In android layout how do I align elements underneath a listview regardless of the listview's height -

i've got listview , want there 2 textviews , 2 buttons underneath (3 of may hidden in code). every single layout tried either results in 4 elements being anchored bottom of screen when listview few lines, or getting pushed off altogether if listview gets big enough. ideas? it sounds you've used android:layout_below="@id/listvieid" , android:layout_alignparentbottom="true" these give results mentioned. sounds want addfooterview(view v) note docs say note: call before calling setadapter. listview can wrap supplied cursor 1 account header , footer views.

ruby - Sinatra unit test - post with JSON body -

i trying build unit test rest api built using sinatra. right want test echo function works right. echo uses post , return exact same payload post. still new ruby, forgive me if don't use proper lingo. here code want test: post '/echo' request.body.read end this unit test trying make: env['rack_env'] = 'test' require './rest_server' require 'test/unit' require 'rack/test' require 'json' class restserver < test::unit::testcase def app sinatra::application end def test_check_methods data = '{"datain": "hello"}' response = post '/echo', json.parse(data) assert.last_response.ok? assert(response.body == data) end end with above code, here error: nomethoderror: undefined method `datain' sinatra::application:class /users/barrywilliams/.rvm/gems/ruby-1.9.3-p448/gems/sinatra-1.3.4/lib/sinatra/base.rb:1285:in `block in compile!' /use...

java - Value of a host variable in the EXECUTE or OPEN statement is out of range error -

i trying insert html content column of table. this code string query= "insert mytable (id,html) values (?,?)"; insert = conn.preparestatement(query); insert.setint(1, id); insert.setstring(2, html); this ddl create table mytab ( id integer not null, primary key (id), html varchar (10000) ); i getting below exception while inserting html field. [8/26/13 4:50:01:344 edt] 00000796 systemout value of host variable in execute or open statement out of range corresponding use.. sqlcode=-302, sqlstate=22001, driver=3.57.110 the size of html content pretty big (it might vary in size cannot give exact size). the reason using varchar is, easy pull in same html content , display on ui rather converting xml , defining xml column in place of varchar column. can please me out resolve issue? how large html ? i'm pretty sure you'll error when trying insert more 10k bytes. also seem recall limit on 32k varchar attributes in db2 perhap...

wordpress access widgets or plugins outside of admin and with php -

is there way access plugins outside of admin panel? meaning rather putting them in sidebar , "activating" in admin panel can't call script include file? think possible how know how activate it? example: <?php include('wordpress/wp-content/plugins/blog-post-calendar-widget/wp-calendar.php'); ?> this links calendar should display posts. not. wordpress working declared correctly not getting calendar way. below file including. question what function call init calendar? here link file including can see php: click here my guess widget function looks takes args , instance wordpress, have populate variables right information wordpress (title etc). looks need call wp_cal_active either before or after widgit function.