Posts

Showing posts from 2011

javascript - Rails:In-place editing in edit form with submit button -

i want create edit form such display current user information text not in text filed , when user click on text turn text field , user can edit information . changes reflect in data base when user click on submit button. not in place editing , not default edit form mixture of behaviour of both features. my form looks following .it not complete form these of fields of form. <%= form_for @contact, :html => { :multipart => true, :class => "contact_form"} |f| %> <% if @contact.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@contact.errors.count, "error") %> prohibited contact being saved:</h2> <ul> <% @contact.errors.full_messages.each |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :f_name, "first name...

Rails incompatible character encodings: UTF-8 and ASCII-8BIT -

in rails app,i send post request: require 'net/http' url="http://192.168.0.84:809/services/sdservice.asmx/userregister" net::http.post_form(uri(url),{:memtyp=>'cu',:memid=>'100867',:dob=>'1989-01-01'}).body but got error: incompatible character encodings: utf-8 , ascii-8bit i found response data include utf-8 character 中文 ,and got error. so should do? you can send data in json format if want can following: require 'rest_client' require "net/http" require "uri" require 'json' restclient.post 'localhost:3001/users',{:memtyp=>'cu',:memid=>'100867',:dob=>'1989-01-01'}.to_json , :content_type => :json, :accept => :json plese change localhost url actual url want hit.

c# - WebClient download string is different than WebBrowser View source -

Image
i create c# 4.0 application download webpage content using web client. webclient function public static string getdoctext(string url) { string html = string.empty; try { using (configurablewebclient client = new configurablewebclient()) { /* set timeout webclient */ client.timeout = 600000; /* build url */ uri innuri = null; if (!url.startswith("http://")) url = "http://" + url; uri.trycreate(url, urikind.relativeorabsolute, out innuri); try { client.headers.add("user-agent", "mozilla/4.0 (compatible; msie 7.0; windows nt 6.1; trident/5.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr " + "3.0.30729; media center pc 6.0; .net4.0c; .net4.0e; infopath.2; asktbfxtv5/5.15.4.23821; bri/2)"); ...

java - Discard Webservice call if no response in specified time -

how stop invoked webservice client program(java) if there no response server within specific time. if there no response server within specified time, need prepare error message , send message ui. try { applicationprocessrs = service.processapplication(applicationprocessrq); } catch ( applicationprocessfaultmsg e ) { log.error( e.getmessage(), e ); } thanks, ramakrishna k if want set timeouts specific services, once you've created proxy need cast bindingprovider (which know already), request context , set properties. online jax-ws documentation wrong, these correct property names myinterface myinterface = new myinterfaceservice().getmyinterfacesoap(); map<string, object> requestcontext = ((bindingprovider)myinterface).getrequestcontext(); requestcontext.put(bindingproviderproperties.request_timeout, 3000); // timeout in millis requestcontext.put(bindingproviderproperties.connect_timeout, 1000); // timeout in millis myinterface.callmyremot...

Prestashop Backend home page "access denied" error how to fix -

i'm using prestashop™ 1.5.6.2 version. first i'm working local server. , moved site client sever. site working fine , back-end working fine. admin dashboard showing access problem (check image). http://i.stack.imgur.com/ki2en.png it seems not logged super admin profile, should check it. if 1 created site, try @ database value in "access" table, search tab id trying see.

How to hide properties file from compiled android apk -

i have security issue related properties file. have project when compiled , tested working perfectly. but when view contents of extracted apk file, see few properties files lying in there. for me security problem. ideas how might able hide/remove properties files compiled apk.

java - associating two ArrayList in JSP -

i trying associating 2 arraylist , print.. <c:when test="${postitem.posttype.equals('text')}"> <h5>id="${postitem.postid}"</h5> <pre> ${postitem.postdata} </pre> <span>datetime="${postitem.posttime}</span> <c:foreach items="${postitem.comment}" var="comment"> <span>comment="${comment}" </span> </c:foreach> <c:foreach items="${postitem.commenttime}" var="comment_time"> <span>comment_time="${comment_time}" </span> </c:foreach> </c:when> i want print "comment" "comment time" values of 2 different arraylists code printing whole first arraylist , second one. any hint???! you have use vars...

design - Models as Scala case classes interacting with DAO? -

i starting design involving scala case classes models, , wondering design decision. let's imagine have 2 models, user model , order model. order model references user model foreign key. case class user(id: userid, [other fields...], password: string) case class order(id: orderid, [other fields...], userid: userid) then, given design, have orders dao method findbyuser method. my question is: design have orders method in user calls dao method, , making system more oo, or better keep layers isolated , not include method? thanks! if understand correctly, you're asking active record pattern. pattern, has pros , cons, can find more online. here of them: http://www.mehdi-khalili.com/orm-anti-patterns-part-1-active-record https://softwareengineering.stackexchange.com/questions/70291/what-are-the-drawbacks-to-the-activerecord-pattern active record design pattern? in play2 project, firstly used pattern, because of ebean support. however, since neede...

time - MySQL TimeStamp +5 Hours -

i have timestamp column in mysql table. storing timestamps according utc/gmt. wish store in ist format +5 hours utc/gmt. what query that? you can use date_add in select/where statement (up needs)... think that's want. date_add(date_column_name, interval 5 hour)

c# - Dynamics CRM SDK: Execute Multiple Requests for Bulk Update of around 5000 Records -

i have written function update default price list active products on crm 2013 online. //the method takes iorganization service , total number of records created input private void updatemultipleproducts(iorganizationservice service, int batchsize, entitycollection updateproductscollection, guid pricelistguid) { //to execute request have add microsoft.xrm.sdk of latest sdk reference executemultiplerequest req = new executemultiplerequest(); req.requests = new organizationrequestcollection(); req.settings = new executemultiplesettings(); req.settings.continueonerror = true; req.settings.returnresponses = true; try { foreach (var entity in updateproductscollection.entities) { updaterequest updaterequest = new updaterequest { target = entity }; entity.attributes["pricelevelid"] = new entityreference("pricelevel", pricelistguid); req.requests.add(updaterequest); } v...

copy - Batch: Checking if a file is locked does not work -

i wrote following batch following steps: check if file on server opened user make backup of file open file 2>nul ( >>test.xlsx (call )) if %errorlevel% == 1 goto end @echo off rem date, make if file name friendly /f "tokens=1-4 delims=/ " %%i in ('date/t') set d=%%j-%%k-%%l@%%i@ rem time, make if file name friendly /f "tokens=1-9 delims=:. " %%i in ('time/t') set t=%%i_%%j_%%k%%l set xlsx=%d%%t%.xlsx ren test.xlsx %xlsx% xcopy *.xlsx j:\test\backup ren %xlsx% test.xlsx call test.xlsx :end the problem is, line wich tries check if file locked not work on server. can me find mistake in batch? if write 2>nul ( >>test.xlsx (call )) if %errorlevel% == 1 goto end you error. if not expected . 2 instructions in same line without separation. if converted 2>nul ( >>test.xlsx (call )) & if %errorlevel% == 1 goto end then problem delayed expansion. %errorlevel% variable replaced value when ...

indexing - After changing the column width in a table in sql server, do I need to recreate the index? -

i've increased width of column varchar(8) varchar(10). need drop index of column , recreate it? no need drop , recreate index - because it's meta data change only. check below link reference. reference

android - How to upload image to server? -

Image
i have searched many sites know how upload image server.i have seen 1 sample example.but not reading imaging internal memory of phone. have included mainactivity.java file.any suggestions please.. mainactivity.java import java.io.dataoutputstream; import java.io.file; import java.io.fileinputstream; import java.net.httpurlconnection; import java.net.malformedurlexception; import java.net.url; import android.app.activity; import android.app.progressdialog; import android.content.intent; import android.database.cursor; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.net.uri; import android.os.bundle; import android.provider.mediastore; import android.util.log; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.imageview; import android.widget.textview; import android.widget.toast; public class mainactivity extends activity implements onclicklistener{ private textview...

android - I can not pass a string to fragment -

call fragment fragment. need pass string fragment. how it? if (position==1){ fragmenttransaction ft; videolist lf = new videolist(); ft = getfragmentmanager().begintransaction(); ft.replace(r.id.fragmentspanel, lf); ft.addtobackstack(null); ft.commit(); } i want pass string str = "absd"; , second fragment take string str1 = row of first fragment use arguments! public static videolist videolistwithstring(string string) { videolist videolist = new videolist(); bundle arguments = new bundle(); arguments.putstring("teststring","test"); videolist.setarguments(arguments); return videolist; } and in fragments oncreate... bundle arguments = getarguments(); string teststring = arguments.getstring("teststring");

ibm midrange - DB2 AS400 & RPG please explain relationship -

db2 as400 & rpg please explain relationship in simple way since i'm quite confuse after doing research so far understand db2 kind of database as400 system written in rpg programming language. is correct? the as/400 series (consisting of as/400s @ first, , iseries, system , later systems) has db2 dbms. db2 tightly integrated os , compiled languages used on system. db2 relational dbms may accessed , maintained via sql. rpg programming language , commonly used language business programming on as/400 series. there 2 common "flavors" of rpg on as/400s: older rpg iii , newer rpg iv. (there can older rpg ii, it's irrelevant question.) you'll see rpg iii referred rpg/400 or opm rpg, while rpg iv referred ile rpg. opm stands 'original programming model'. ile stands 'integrated language environment'. those 2 terms apply many compiled languages on as/400 series. so, there ile cobol , opm cobol, ile c/c++ , others. implementation o...

angularjs - How to filter an object array with multiple parameters? -

i'm having array employees containing data of employees. example of 1 employee in list: accountactive: false companynr: 0 email: "aart.versendaal@technomanage.nl" id: 100 photourl: "http://technet/employeephoto/anonymous.jpg" staffnr: 0 tla: "fis" username: "firstname surname" workplace: "999" with following code show search results. (only show name , photo) <div class="result" ng-repeat="employee in data | limitto:showlimit"> <div class="result_wrapper"> <div class="result_name">{{employee.username}}</div> <div class="result_image"> <img ng-src="{{employee.photourl}}"/> </div> </div> </div> with login_controller var employees; //list of employees $scope.data = []; //the filtered employees $scope.showlimit = 5; //the filter made (no input = no results) $scope...

php - Sending post data along with file_get_contents() -

this question has answer here: how post data in php using file_get_contents? 3 answers i read question stackoverflow: how post data in php using file_get_contents? covers pretty in order explain how use file_get_contents() function in php to practice, created these 2 php files : 1.php <?php $postdata = http_build_query( array( 'name' => 'example', 'roll' => '123321' ) ); $opts = array('http' => array( 'method' => 'post', 'header' => 'content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents('http://localhost/2.php', false, $context); echo $result; ?> and code for 2.php <?php $name = $_pos...

asp.net - ADOMD.net Impersonate Windows User ID -

i trying connect ssas cube uses windows authentication my web application stored on seperate server sql analysis instance (lets says serverwebapp ) , ssas cube on servercube olapcon = new adomdconnection("provider=msolap.4; roles=administrator; integrated security=sspi; persist security info=true; effectiveusername=<domain\username>; " _ & " initial catalog=<dbname>; data source=<servercube>; ") as ssas uses windows authentication have tried impersonate windows login specifing effectiveusername however, doesn't seem work getting follow error: either user, domain\serverwebapp, not have access <dbname> database, or database not exist. as can see using web apps login id not windows id how impersonate windows id in ssas adomd connection string? this tripped me when used effectiveusername. msdn : to use [the effectiveusername] property, caller must have administrative permissions in analysis services. ...

python 2.7 - Fetching top n records in pandas pivot , based on multiple criteria and plotting them with matplotlib -

usecase : extending pivot functionality of pandas. fetch top n records & plot them against own "click %"(s) vs. no of records of name import pandas pd import numpy np df1 = pd.dataframe({'name':['a', 'a', 'b', 'b','c','a'], 'click':[1,1,0,1,1,0]}) click name 0 1 1 1 2 0 b 3 1 b 4 1 c 5 0 [6 rows x 2 columns] #fraction of records present & clicks fraction of it's own records present f=df1.pivot_table(rows='name', aggfunc=[len, np.sum]) f['len']['click']/sum(f['len']['click']) , f['sum']['click']/sum(f['sum']['click']) (name 0.500000 b 0.333333 c 0.166667 name: click, dtype: float64, name 0.50 b 0.25 c 0.25 name: click, dtype: float64) but able plot them need store top n records in object supported matplotlib. tried storing ...

automation - How to run a script in OSX first thing every morning AND directly after login / unlock? -

i've researched thing quite time haven't found solution, time ask wisdom of crowd... here's i'm trying achieve: on workdays, first thing greets me when log in (with macbook coming standby mode , not booting up), want start script shut down windows , open daily planning list. if have not opened mac few days, should not execute multiple times. script doesn't matter here, couldn't find reliable solution execution hook anywhere. i've dabbled automator , read through tasks already: programmatically run @ startup on mac os x? running script upon login mac but see somehow related login items, seem aren't executed when coming standby. i'm open solution, preferably commandline or baked in (launchd etc.), app. thanks in advance, dom i have thought have bunch of answers now. concept of "workday" needs bit of definition. if talking m-f, or whatever, consider running script every day, determines day of week , nothing on non...

java - Libgdx Quiz Storage -

this question exact duplicate of: libgdx quiz- using sqlite database? 1 answer i'm creating quiz in libgdx , trying find best solution storing questions , answers since don't support sqlite. i've never coded in json before trying out pretty hard. tried out shared preferences worked few questions unsure on 500 questions. i tried xml storage worked out too. my question app have 500 questions/answers best choice here? server :d imagine setting server based quiz. change questions directly in database without forcing users download new version each time? but in all, above said. if works, what's stopping you?

php - Get last post in each category -

i've got 4 tables: 1. forums (id,forum_id,name,group_id) - there categories , sub-categories 2. topics (id,forum_id,user_id,name,dt,deleted[default - 0]) 3. posts (id,topic_id,text,edit_dt,user_id,deleted) 4. users (id,name) what best way main categories last posts? or maybe add in forums table new fields - last_post_id , last_post_name , last_post_dt , , @ delete, add new topic/reply update these fields? at first, identify " last post " should add timestamp (datetime) posts table. also, in question, define categories (i presume it's topics) , example of data, paired example of desired output.

internet explorer 8 - Drawing arc in excanvas IE8 to 2Pi does not draw arc -

i'm drawing discs may or may not complete. i've found if i'm drawing value goes way 2pi, tends not drawn. seems somewhere simplifying 0. for example (with arcs offset slightly): ctx.arc(x, y, radius, startangle + math.pi/2, resangle+math.pi/2); when circle should complete, end of circle not drawn. have check condition, add 0.1 in order circle appear. any ideas why? what steps reproduce problem? try draw circle clockwise, won't draw delta between start point , end point small. a fix located @ following url: excanvas-arcfix.js which following: change line 689 : if (xstart == xend && !aclockwise) { to if ((abs(xstart - xend) < 10e-8) && !aclockwise) { references ctx.arc() 2*pi angle won't draw anything

CSS - Move menu to top on hover -

i have menu needed move item top on hover, doesn't work. here do. .menu li{ display: inline-block; } .menu li a{ display: block; line-height: 20px; padding: 0 20px; border-bottom: 5px solid #000000; } .menu li a:hover{ margin-top: -5px; border-bottom-width: 10px; } <li class="active"> <a href="#">home</a> </li> <li> <a href="#">about</a> </li> <li> <a href="#">contact</a> </li> http://jsfiddle.net/26mlv/ one possible solution: .menu li{ display: inline; } .menu li a{ display:block; float:left; line-height: 20px; padding: 0 20px; border-bottom: 5px solid #000000; margin:0; background-color:#cecece; } .menu li a:hover{ ...

sql - Any keyword to skip the current row in DB2 trigger -

i have write trigger insert data db if doesn't exists. wrote till inserting records. doing signaling if data exists failing entire batch of records. questions: there keyword skip/ignore/discard current row? trigger below. want remove signal , keep else discard/ignore/skip current row insertion. example : continue keyword in java . create or replace trigger tri_books_edit no cascade before insert on books referencing new n each row when ((select count(*) books book_name = n.book_name , author = n.author) > 0) signal sqlstate '75000' set message_text = 'duplicate row same name , author' you don't need use trigger this. add unique index on 2 fields: create unique index books_name_author on books(book_name, author); much simpler solution preventing duplicates.

css - href assetic doesn't work -

i'm trying link stylesheet html template, doesn't seem work. i use symfony2 , assetic. in demo bundle, css linked line: <link rel="stylesheet" href="{{ asset('bundles/acmedemo/css/demo.css') }}" /> so, in mainbundle, wrote lines <head> <style> {% block stylesheets %} <link href="{{ asset('bundles/acmemain/css/demo.css') }}" rel="stylesheet" /> {% endblock %} </style> </head> and put demo.css file in folder acme\mainbundle\resources\public\css, then executed php app/console assets:install in situation, web page doesn't have css style, without formattation. if write css directly in template, works. if link it, doesn't work. how can solve this? my css file line: h1{color:blue;text-align:center;} thank you. you have execute command copy stylesheets (found in public folder) in web folder becau...

php - Creating custom input form for a node using Ajax -

Image
attached example screenshot of form i'm using php , ajax in drupal 7. by default, form display 10 fields. form uses ajax enable users add potentially infinite number of input fields initial 10 in groups of 5. need upon retrieval, repopulate fields saved, same functionality available, should user wish edit. i have on previous attempt used $form_state in entries_form_add_five add number of input boxes , returned using ajax call couldn't work when loading data edit. how can rebuild form new $node-->entries_form['term'] array has been increased 5? <?php function entries_form_form_entries_node_form_alter(&$form, &$form_state, $form_id) { //trimmed $node = $form['#node']; $form["section"]["term"]["#tree"] = true; $items = $node->entries_form['term']; foreach($items $key => $item) { $form["section"]["term"][$key] = array( '#type' => 'textfield', ...

ruby on rails - How to update thousands of records -

i have update age column based on value in date of birth column. there thousands of records update. how do using rails? is right way it? user.update_all(:age => some_method); def some_method age = date.today.year - dob.year end yes, update_all right method no, can't this. some_method called once set database call (i assume you're persisting database). you'll error because dob won't recognised in scope of user class. you'll need translate date logic sql functions. something (for mysql): user.update_all("age = year(now()) - year(dob) - (date_format(now(), '%m%d') < date_format(dob, '%m%d'))") (nb. date_format stuff right age people who's birthdays later in year current date - see this question more details)

point out a date in time series plot in matlab -

i have time series of daily prices, plotted , have days highlight little circle on curve of price on these days. example, time series spans 1-jun-2000 1-oct-2000 , have days 5-jun-2000, 6-jun-2000, 10-aug-2000,.. prices show on plot. problem series of days point out on different vector , not find them in series of days. think should @ first find indexes of these particular dates in complete series of dates , use index point out corresponding prices highlight on curve. help? thank in advance john never mind, have got it: [tf, index] = ismember(date, tofinddate) % position in series plot(date(index),p(index),'ro') % highlight desired point

list - Sort dictionaries based on timestamp in python -

here list , [{u'lang': u'en', u'createdat': 1326158349, u'canonicalurl': u'https://foursquare.com/item/4f0b920de4b0c4aaa8bc78ec', u'text': u'one of great restaurant in new haven , excellent food , service', u'user': {u'lastname': u's.', u'gender': u'male', u'id': u'19483764', u'firstname': u'ram', u'photo': {u'prefix': u'https://irs0.4sqi.net/img/user/', u'suffix': u'/blank_boy.png'}}, u'todo': {u'count': 0}, u'id': u'4f0b920de4b0c4aaa8bc78ec', u'logview': true, u'likes': {u'count': 2, u'groups': [{u'count': 2, u'items': [], u'type': u'others'}], u'summary': u'2 likes'}}, {u'lang': u'en', u'createdat': 1305643797, u'canonicalurl': u'https://foursquare.com/item/4dd28b152...

join - Python : Generate a string of bits. -

i trying generate random string of bits using following code. bitstring = [] in range(0, 8): x = str(random.randint(0, 1)) bitstring.append(x) ''.join(bitstring) however instead of giving me this: 10011110 i looks this: ['1','0','0','1','1','1','1','0'] can point me in direction of i'm doing wrong? thanks! bitlist = [] in range(0, 8): x = str(random.randint(0, 1)) bitlist.append(x) bitstring = ''.join(bitlist) more pythonic this: >>> random import choice >>> ''.join(choice(['0', '1']) _ in xrange(10)) '0011010100'

java - org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '910000' is defined -

i have businesskeys.properties file keeps codes 910000=terminalalivecommand etc. application sends message pos device , receives message pos device. in xml defined bean terminalalivecommand : <bean id="terminalalivecommand" class="sinaps.domain.terminalalivecommand" scope="prototype"> <property name="sinapsdao" ref="sinapsdao" /> </bean> org.springframework.beans.factory.nosuchbeandefinitionexception: no bean named '910000' defined @ org.springframework.beans.factory.support.defaultlistablebeanfactory.getbeandefinition(defaultlistablebeanfactory.java:527) @ org.springframework.beans.factory.support.abstractbeanfactory.getmergedlocalbeandefinition(abstractbeanfactory.java:1068) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:274) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(...

Google analytics API list out eventLabels -

im trying learn google analytics + oauth2. the documentation confusing, figured i'd go ask help. i want list out event labels ordered visits. $results = $analytics->data_ga->get($analytics_id, $from, $today, 'ga:visits', array( 'dimensions' => 'ga:source', 'sort' => '-ga:visits', 'filters' => 'ga:medium==organic', 'max-results' => '100')); foreach($results $key => $value) { echo $results['totalsforallresults']['ga:visits']; echo "<br />"; } i can list out visits far:/ advice appreciated! here's sample query explorer report should there. replace variables in code above rows in textboxes: http://ga-dev-tools.appspot.com/explorer/?dimensions=ga%253aeventlabel&metrics=ga%253avisits%252cga%253atotalevents%252cga%253auniqueevents&filters=ga%253amedium%253d%253dorganic&start-...

regex - Why do I need to add DOTALL to python regular expression to match new line in raw string -

why 1 need add dotall flag python regular expression match characters including new line character in raw string. ask because raw string supposed ignore escape of special characters such new line character. docs: the solution use python’s raw string notation regular expression patterns; backslashes not handled in special way in string literal prefixed 'r'. r"\n" two-character string containing '\' , 'n', while "\n" one-character string containing newline. this situation: string = '\nsubject sentence is: appropriate support families of children diagnosed hearing impairment\ncausal verb : may have\npredicate sentence is: direct impact on success of hearing detection , intervention programs in reducing negative effects of permanent hearing loss' re.search(r"subject sentence is:(.*)causal verb :(.*)predicate sentence is:(.*)", string ,re.dotall) results in match , , when remove dotall flag, no match. yo...

java - Javascript result to Prepared Statement -

i have jsp page populates dropdown list dynamically database, have dropdown list set "onchange" event call javascript obtain selected value. how can use javascript result placed in clause of sql prepared statment? the prepared statement have set in javabean. you can make form dropdown , send response jsp servlet or controller. there dropdown value request.getparameter("name") . now have dropdown value in servlet, here can set value in class.

c - structure within structure declared in a file not able to access inner structure -

i have created file msgbuf.h follows: //msgbuf.h typedef struct msgbuf1 { long mtype; m1 *m; } message_buf; typedef struct msgclient { int msglen; int msgtype; char cp[100]; }m1; and program check.c. below prog giving error there no m1. why so? mistake doing? think contents of file "msgbuf.h" should copied in prog check.c , program should run fine. please let me know this. //check.c #include<stdio.h> #include<string.h> #include<stdlib.h> #include"msgbuf.h" int main() { message_buf *sbuf; sbuf=malloc(sizeof(sbuf)); sbuf->m=malloc(sizeof(m1)); sbuf->m->msglen=10; printf("\n%d",sbuf->m->msglen); printf("\n %d",sizeof(sbuf->m)); return 0; } thanks :) simple, declare m1 before message_buf ; . typedef struct msgclient { int msglen; int msgtype; char cp[100]; }m1; typedef struct msgbuf1 { long mtype; m1 *m; ...

angularjs: multiple values in a ng-switch-when -

i have following ngswitch: <p ng-switch="status"> <span ng-switch-when="wrong|incorrect"> wrong </span> <span ng-switch-default> correct </span> </p> as can see, have text wrong 2 options wrong , correct . have tried (as can see) use pipe | , doesn't work. suggestions ? for angular >=v1.5.10, you can adding ng-switch-when-separator="|" ng-when node. see example in documentation. <span ng-switch-when="wrong|incorrect" ng-switch-when-separator="|"> see discussion here https://github.com/angular/angular.js/issues/3410 note, based on experience doesn't work numbers...yet?

java - Using compareTo in ArrayLists -

i need using compareto in arraylists. guide given paragraph: addorder(arraylist words, string newword) – method adds newword in proper alphabetical order. hint can use: x.compareto(y) if x.compareto(y) < 0, x comes before y) addorder should return updated arraylist of strings. but though researched alot still struggling understand how apply arraylists. code want use compareto method: import java.util.arraylist; import java.util.arraylist; import java.util.list; class stringlist { public static void main(string [] args) { arraylist< string> list = new arraylist< string>(); list.add("goldsmiths"); list.add("college"); list.add("london"); list.add("manchester"); list.add("london"); list.add("york"); system.out.println("these words:"); system.out.println(list); system.out.println("t...

javascript - How to check if HTML element is/is not hidden? -

this question has answer here: how check if element hidden in jquery? 48 answers i have 2 elements(setproject , sethdc). when clicked, show other table elements. want make 1 group of table elements appear @ same time. example when user clicked on "setproject", "sethdc" element must hidden. , same otherwise. there way can if statment? or there simpler way it? <script> $(document).ready(function(){ $("#setproject ").click(function(){ $("#test1").fadetoggle("fast"); $("#projecttable1").fadetoggle("fast"); $("#projecttable2").fadetoggle("fast"); $("#projecttable3").fadetoggle("fast"); }); }); $(document).ready(function(){ $("#sethdc").click(function(){ $("#hdctable1").fadetoggle("fast"); $(...

wpf - Datagrid Custom Combobox not Updating -

Image
i'm having issue wpf datagrid's datagridtemplatecolumn , updating items display on combobox based off of user's interaction. since program database bound, doesn't make sense load items database @ once, instead uses entity framework pull user requests @ given moment. to facilitate view that's compact, next/previous buttons on combobox template, search functionality, issue i'm running is: when templated comboboxes in datagrid, next/previous not function. outside of datagrid function properly. i've tried using knowledge combobox present , manually pulled visual tree doing search combobox name, pulled binding itemssource , told update. nothing happens. here image of mean below: the display update once select new cell; however, since capture when it's enter edit mode , update list contain item selected (for binding purposes, comboboxes don't have selected item that's not in item set.) as can imagine, rather big issue. it's diffic...

asp.net - MVC 5 Change the home page -

i have mvc5 app running locally expected ,when run it automatically open home page ,i have additional folder in view can navigate them specify path(e.g. http://12.0.0.1:80/list/index ) want change when run main project ( http://12.0.0.1:80 ) automatically open page http://12.0.0.1:80/list/index ,how should ? go routeconfig.cs file in app_start folder of project , change default route constraints controller="list" instead of controller="home" .

php - Codeigniter chrone not working -

i have added following code in codeigniter page call function test_cron in scheduler controller setting crone.but return html of default_controller $application_folder = 'application'; $_server['path_info'] = '/scheduler/test_cron'; $_get = '/scheduler/test_cron'; // required installations $_server['request_uri'] = '/scheduler/test_cron'; please me it seems want run codeigniter function cronjob. correct way is: pahto_codeigniter/index.php scheduler test_cron codeingiter documention refference: http://ellislab.com/codeigniter/user-guide/general/cli.html

javascript - Pass google maps coordinates to marker -

i looking pass set of coordinates received 2 textfields(displaylat , displaylong) , create marker passed in coordinates marker location. code far: <html> <head> <script> function initialize() { var markersarray = []; //array hold map markers function clearoverlays() { //function clear markers arrays, deleting them map (var = 0; < markersarray.length; i++ ) { markersarray[i].setmap(null); } markersarray.length = 0; } var mapprop = { //the actual map in page center:new google.maps.latlng(51.8978719,-8.471087399999988), //center of map zoom:12, //zoom level maptypeid:google.maps.maptypeid.roadmap //kind of map }; var map=new google.maps.map(document.getelementbyid("googlemap") //element id ,mapprop); google.maps.event.addlistener(map, 'rightclick', function(event) { //what happens when map right clicked...

java - What is the proper implementation for test cases which accept similar type of input parameter,same implementation code but different output -

which 1 advisable use out of 2 ? when there "same implementation" testcode "different output" because "slight difference in input" i.e input1 , input2 has minor difference. "suppose input1 empty list , input2 parameterized list" let have dummy code 2 possibilities of test classes : both behaviour achieved same test method i.e : public class dataprovider{ private static setup(){ } public static object[][] data_all_behaviour(){ setup(); return new object[][]{ {"dataforbehavior1",input1,output1}, {"dataforbehavior2",input2,output2}}; } } } @runwith(junitparamsrunner.class) public class testclass{ @parameters(class=dataprovider.class) public void test_all_behaviour(string message,input inp, output out){ //execute input , verify output , display message } } here each behaviour ,there separate test method. @runwi...

Java tomcat6 OOM, massive amount of com.mysql.jdbc.StatementImpl instances -

i've got java web application runs fine 2 days. after hangs oom heap space errors. a thread dump gives following information heap: heap par new generation total 38336k, used 38181k [0x00000000d5a00000, 0x00000000d8390000, 0x00000000d8390000) eden space 34112k, 100% used [0x00000000d5a00000, 0x00000000d7b50000, 0x00000000d7b50000) space 4224k, 96% used [0x00000000d7b50000, 0x00000000d7f49628, 0x00000000d7f70000) space 4224k, 0% used [0x00000000d7f70000, 0x00000000d7f70000, 0x00000000d8390000) concurrent mark-sweep generation total 481728k, used 481727k [0x00000000d8390000, 0x00000000f5a00000, 0x00000000f5a00000) concurrent-mark-sweep perm gen total 38172k, used 22900k [0x00000000f5a00000, 0x00000000f7f47000, 0x0000000100000000) i made heapdump read visualvm. shows me there massive amount (1.2 million) of statementimpl instances take lot of memory. some information application: 16 sql connections 32 insert statements per second about 200 proc...

ODBC-JDBC Bridge Windows-1251 (Cyrillic) character encoding -

i've got dbase file window 1251 encoding. i've made odbc datasource file , access jdbc-odbc bridge java following code: printstream ps = new printstream(system.out, true, "utf-8"); system.out.println("test: Русский язык"); class.forname("sun.jdbc.odbc.jdbcodbcdriver"); properties properties = new properties(); properties.put("charset", "windows-1251"); connection conn = drivermanager.getconnection( "jdbc:odbc:test_ds",properties); statement statement = conn.createstatement(); string sql = "select * table"; resultset resultset = statement.executequery(sql); while (resultset.next()) { system.out.println(resultset.getstring("desc")); } character encoding ok test println (2nd line), encoding data dbase incorrect. i'm able open dbf file libreoffice same encoding correct. is there chance set encoding correctly? is possible set connection encoding in connection strin...

php - View SQL queries -

i on wamp configuration. there way within wamp or package allow me see sql queries fired php mysql server. i familiar overriding db adapters in java see fired sql requests. there similar in php or there way view fired sql mysql functions itself? click wamp tray icon, , click 'my.ini' in mysql menu. then, add following in [mysqld] section: general-log=1 general-log-file = "c:\wamp\logs\mysql_general.log" finally, restart services , queries should logged. enables mysql's general query log.

c# - Force WCF XML Serializer to include empty strings -

i have following property in struct being returned wcf service: [xmlattribute] public string batchid; in cases value of batchid empty string, serialization excludes property resulting xml if never included in object begin with. how can force serializer include property, if empty string? edit: using base xml serializer , not datacontract serializer emitdefaultvalues not option. try use datamemberattribute emitdefaultvalue = true : [xmlattribute, datamember(emitdefaultvalue=true)] public string batchid_sched; the emitdefaultvalue cannot used xml serializer. i think way implement ixmlserializable interface , manually serialize/deserialize fields/properties of class: public class test:ixmlserializable { public string prop; public void writexml (xmlwriter writer) { writer.writeattributestring("prop", prop ?? ""); } public void readxml (xmlreader reader) { if(reader.hasattributes) { ...

wordpress - .htaccess - redirect if page not found -

i've spent lot of time searching solution this. i've tried various scenarious, no avail... i have migrated blog wordpress drupal. of links ok, there few aren't. i redirect blog pages not found blog root. ex. old (broken) link - www.mydomain.com/blog/my-old-article should redirect new link - www.mydomain/blog but if www.mydomain.com/blog/my-old-article exists, should displayed. is possible using .htaccess? i think should done in drupal itself. because apache webserver not know database entries of blog articles.

php array_iunique case insensitive no latin values -

hello have string might include duplicate strings-words example "Το το" far have this: function array_iunique($array) { return array_intersect_key($array,array_unique(array_map('mb_strtolower',$array))); } array_iunique when test string in english "to to" works great , outputs array 1 value, when try greek string mentioned above doesn't. missing here ? expected result return 1 word , i'm interested in greek only. for might have same issue solves issue: function array_iunique($array) { return array_intersect_key( $array, array_unique( array_map( function($text) { return mb_strtolower($text, 'utf-8'); }, $array ) ) ); } ref

Autocomplete like Outlook using typeahead and Angularjs -

Image
i want create textbox utlise typeahead autocomplete of ui-angular, want autocomlementation works every time type key ";"for example: when type "anny" in textbox contact email address containing "anny" appears, select 1 want , when type key ";" can again use autocomlementation.(like outlook)... have created textbox works email address <div class="form-group" ng-class="{'has-error':newrequest.beneficiaryid.$invalid}"> <label for="inputemail3" class="col-lg-2 control-label"> email:</label> <div class="col-sm-10"> <input type="text" name="beneficiaryid" ng-model="ticket.beneficiaryid" placeholder="email" typeahead="address address.email address in form.autocomplete($viewvalue) | filter:$viewvalue" typeahead-loading=" loadinglocations...

oauth 2.0 - OAUTH2(OPENID Connect) + MVC 5. refresh token issue -

i'm looking useful suggestion regards obtaining refresh_token using owin libs. i follow article http://www.asp.net/mvc/tutorials/mvc-5/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on all stuff works sweet. no way, @ least don't know way, retrieve refresh_token i've tried add "access_offline" initial request, nothing useful. wrong. why need it? - i'm trying chain functionality of google glass + mvc5 + owin . p.s. appreciate link working sample built using google.api.auth. thanks. take in following blogpost: http://peleyal.blogspot.com/2014/01/aspnet-mvc-with-google-openid-and-oauth.html and, can find working sample code in https://github.com/peleyal/peleyal/tree/master/google.apis.sample.mvc .

How to handle JSON encoding -

i believe valid json not contain encoding information (as opposed xml, instance). correct ? have "standard" encoding (e.g. utf-8 ) ? how supposed handle json encoding ? from json rfc , section 3: 3. encoding json text shall encoded in unicode. default encoding utf-8. since first 2 characters of json text ascii characters [rfc0020], possible determine whether octet stream utf-8, utf-16 (be or le), or utf-32 (be or le) looking @ pattern of nulls in first 4 octets. 00 00 00 xx utf-32be 00 xx 00 xx utf-16be xx 00 00 00 utf-32le xx 00 xx 00 utf-16le xx xx xx xx utf-8

java - PipedInputStream, PipedOutputStream and Process -

i'm learning java pipedinputstream/pipeoutputstream . i'd read stdin (the ' source ' class below) , redirect process ( here 'grep a'), output of grep redirected system.out. to consumme stdout , stderr after grep, created class copyto redirect inputstream outputstream. import java.io.*; class test { private static class source implements runnable { private pipedoutputstream pipedoutputstream=new pipedoutputstream(); private inputstream in; source(inputstream in) throws ioexception { this.in=in; } @override public void run() { try { int c; while((c=this.in.read())!=-1) { pipedoutputstream.write(c); } pipedoutputstream.flush(); ...