Posts

Showing posts from March, 2014

php - filter_var_array() order of execution and rules -

the following simple bit of code shows working of filter_var_array(), <?php $data = array('age' => 21, 'rating' => 4, 'price' => 9.95, 'thousands' => '100,000.95', 'european' => '100.000,95' ); $instructions = array('age' => filter_validate_int, 'rating' => array('filter' => filter_validate_int, 'options' => array('min_range' => 1, 'max_range' => 4)), 'price' => array('filter' => filter_sanitize_number_float, 'flags' => filter_flag_allow_fraction), 'thousands' => array('filter' => filter_sanitize_number_float, 'flags' => filter_flag_allow_fraction | filter_flag_allow_thousand), 'european' => array('filter' => filter_validate_float, 'options' => array(&#

Why can't I validate Google Analytic tracking code on subdomain -

Image
i have subdomain, http://m.abc.com . on google analytic account, defined property subdomain. tracking code copied , pasted on subdomain files. on google analytics reporting, need demographics info. i've added code generate report: but when click validate code, validation not proceed. page below: i've gone on instructions , did not miss out item. i've turn on enable advertiser features , enable demographics , interest reports. is there else need do? it typically takes @ least 48 hours displayfeatures validate (at least took long me). if after 48 (or 72) hours it's still not validating, can skip step without detriment.

c# - How to add additional validation to Model field? -

i have second thing: <td> @html.labelfor(m => m.number, titlehtmlattrs) </td> <td> <span class="element-value2"> @html.editorfor(m => m.number) @html.validationtooltipfor(m => m.number) </span> </td> and how field looks in model: [display(name = "special number")] [stringlength(20)] public string number { get; set; } which means if wanted change field, can have value empty 20. it's ok, need additional validation. in model have fields: public datetime? timeof { get; set; } public bool hastype { get; set; } new validation should work only if timeof not null , hastype true. new validation should prevent empty values in number. basically, change (from empty 20) (from 1 20). how correctly accomplish this? p.s sorry bad english. for complex validation logic, @ implementing ivalidatableobject in viewmodel , can place conditional validation logic inside validate met

d3.js - How to add space between bars in a grouped bar chart in a nvd3 grouped multibar chart? -

i'm trying add space/padding nvd3 multi bar chart. "groupspacing" not need, since adds space between groups. i'll need space between each bar inside group. found 1 link in github support . can post solution or tweak? i found d3 example of grouped bar chart . in example helpful me. thanks. i have draw d3 group barchart: fiddle you can adjust groupspacing change code on line 56: var groupspacing = 6; technically achieve change width of each rects' width: var barsenter = bars.enter().append('rect') .attr('class', 'stm-d3-bar') .attr('x', function(d,i,j) { return (j * x1.rangeband() ); }) .attr('y', function(d) { return y(d.y); }) .attr('height', function(d) { return height - y(d.y); }) .attr('width', x0.rangeband() / bardata.length - groupspacing ) .attr(&

caching - Spring DomainClassConverter Cache -

i'm using spring-data-jpa, , i'm trying apply spring cache abstraction. findbyemail() method caches well, however, user variable on retrieve() method @ controller spring-data-jpa provide domainclassconverter looks db. in documentation, calles findone() resource, @cacheable trigger won't work. seems implementation class simplejparepository invoke crudrepository instead of userrepository created , put @cacheable annotation. is there way apply @cacheable findone() except custom domainclassconverter class ? usercontroller.class @requestmapping(method = requestmethod.get, value = "/users/{user}") public responseentity retrieve(@pathvariable user user) { logger.info("retrieve: " + user); return new responseentity(user.touserresponse(), httpstatus.ok); } userservice.class public interface userrepository extends jparepository<user, long>, jpaspecificationexecutor<user> { @cacheable("us

Accessing structure's variable in C++? -

struct app { int id; char name[20]; char developer[20]; char type[20]; int date_uploaded [3]; }; . . . void search(app a[2]) { int choice; char t_check[20]; dhome(); cout<<"\n\nselect way want search app" <<"\n(1) search app name" <<"\n(2) search developer name" <<"\n(3) search type" <<"\n(4) return previous menu\n"; cin>>choice; cin.ignore(); switch(choice) { case 1: dhome(); cout<<"\n\nenter app's name: "; search_specific(a,"name"); //similar cases passing developer , type } } void search_specific(app a[2], char choice[10]) { int i, flag=0; char t_check[20], s_type[5]; gets(t_check); for(i=0; i<2; i++) { if(strcmp(t_check, a[i].choice)==0) { flag=1;

Start Activity from BroadcastReceiver only once using locks --Android -

scenario : when 2 alarms set @ same time, of them should shown. my problem: i have broadcastreceiver forwards intent alarmgooffactivity when time. however, need check if alarmgooffactivity running before forwarding intent. 1 of answers saw in so. tried approach.earlier, both alarms fired. now, neither alarm fires now. code mybroadcastreceiver.java if (alarmgooffactivity.running) { blog("alarmactivity running"); } else { blog("alarmactivity not running "); //set variable true new broadcasts not entertained alarmgooffactivity.running = true; intent intent1 = new intent(context, alarmgooffactivity.class); intent1.setflags(intent.flag_activity_new_task); intent1.putextra(dbhelper.column_id, id); string ext = extras.getstring(dbhelper.task_title); if (ext != null) { intent

java - adding users to JList in chatroom GUI -

i'm trying write simple chatroom gui using java, including jlist show online users. first user chooses display name name displayed in jlist. here code: (the problem inside createserver() method sends name argument handler constructor, in order display in jlist!) public class gui{ private jframe frame; private jbutton btnsend, btnconnect; private jtextarea txtchat; private jtextfield fldtext, fldname; private jlist clientlist; private defaultlistmodel listmodel; private jscrollpane sc, scclients; private jpanel jps2all, jps2client, jps2text; private string name; class handler implements actionlistener, mouselistener{ private string name = null; void handler(string name) { this.name = name; } @override public void actionperformed(actionevent e) { chatroom(); } @override public void mouseclicked(mouseevent e) { fldname.settext("&quo

c - bit store order in memory -

x86 machine, os: linux 2.6 rh. here codes: #include "stdio.h" typedef struct ch_t { int c0:1; int c1:1; int c2:1; int c3:1; int c4:1; int c5:1; int c6:1; int c7:1; } ch; typedef union chh_u { char a; ch chat; } chh; int main(void) { chh uu; uu.a = 6; printf("\n%d", uu.chat.c0); printf("\n%d", uu.chat.c1); printf("\n%d", uu.chat.c2); printf("\n%d", uu.chat.c3); printf("\n%d", uu.chat.c4); printf("\n%d", uu.chat.c5); printf("\n%d", uu.chat.c6); printf("\n%d", uu.chat.c7); printf("\n%d\n", uu.a); return 0; } as expected, output should be: 0 0 0 0 0 1 1 0 6 but actual output was: 0 -1 -1 0 0 0 0 0 6 i can't understand why output above. think 6 bit

sql - Creating non clustered Index for multi table joins -

i have written query joining multiple tables , multiple column condition. have large amount of data need create index on these columns. query should use index better performance. let me know how create below scenario ? select a.name, b.sal, c.date1 inner join b on a.id = b.id inner join c on b.id1 = c.id1 a.status1 = '0' , a.totalamt <> 0 , a.flag = 'n' , b.sal > 100 , c.date1 not in('2008-08-08', '2009-09-09') i tying same thing @ozren has written.but verify condition have written . primary key table a=id table b=id1 table c=id1 verify uncessary condition i) when sal>100 totalamt >0 (is so?) ii) a.status1 , a.flag ?(like when flag='n' status always='0' can put such validation while insert , avoid condition. non ci table (status1, totalamt, flag) table b (sal) table c (date1) analyze proc check amonth thee columns use in condition. if example fl

How to use a single JSON object in two controller without seperate call in angularjs? -

i have 2 pages. 1 list , detail page. both page’s data coming single json. have 2 controllers both pages. want use same json in 2 controllers single call. json structure this: [ { "tid": "3388", "name": "adagio bar", "description": "choose enjoy 1 of our italian inspired cocktails while taking in spectacular views or relax. "field_location_category": "aft", "category_tid": "351", "category_name": "entertainment/bars", "deck": "sun deck 16" }, { "tid": "3439", "name": "botticelli dining room", "description": "a sumptuous variety of dining options awaits on every voyage. "field_location_category": "aft", "category_tid": "350", "category_name": "food , dining", "deck"

asp.net mvc - jQuery initiating a extra call to server -

i have asp.net mvc application , on 1 of page; have button sends ajax request load data (data request goes web api have created) in kendo listview control have on page. there 4 kendo list views on page , data getting binded them on click of button. how bind data 1 of 4 kendo list view below: @(html.kendo().listview<carecomplete.data.core.viewmodel.personinfo>() .name("otherlistview").tagname("div") .clienttemplateid("templateperson") .pageable(page => { page.messages(mess => mess.display(constants.showingpersonperpage + " others")); page.pagesizes(appsettings.pagingarray).messages(mes => { mes.itemsperpage(string.format(constants.personperpage, "other persons")); mes.empty(string.format(constan

r - Count number of connenction in data.frame dplyr -

i have data.frame: df <- data.frame(id = rep(1:4, each = 3),x = c("a","b","c","d","e","a","a","c","d","a","c","e")) i want count connections inside each id: output want get: connections |num. of connections - b | 1 b - c | 1 c - d | 1 - c | 3 - e | 2 - d | 2 d - e | 1 c - e | 1 how in dplyr? using dplyr , combn library(dplyr) df %>% group_by(id) %>% mutate(connections=c(combn(as.character(x),2, fun=function(x) paste(sort(x), collapse=" - ")))) %>% group_by(connections) %>% summarise(numconn=n()) # connections numconn #1 - b 1 #2 - c 3 #3 - d 2 #4 - e 2 #5 b - c 1 #6 c - d 1 #7 c - e 1 #8 d - e 1 or same approach da

C# Check Condition With Duplicated ID and Different Name -

i confirm coding correct due run seems doesn't checking on ic_no unique number , different name. point want set if statement if ic_no duplicate , different name out error. if (!ic_no.equals(var_name)) { var_return = false; lfc.writetxtfile(var_logfilepath, var_errorlogfilename + "_" + var_minvalue + "-" + var_maxvalue + ".log", "error - ic_no duplicated different name (policy no: " + policyno + ", actual age: " + actualage + ", ic_no: " + ic_no + ", name: " + name + ", dob: " + var_day + "/" + var_month + "/" + var_year + ")", true, true, false); } looking @ names of variables used in writetxtfile method, can gather you're missing part of if statement... , collection policies. you need keep track of ic_no , names in collection , check if given ic_no there's existing name already, this: if (collectionofpolicies.firstordefault(x => x.ic_no

ruby on rails - Foreign key in active record’s self-referential has_many :through -

i'm using rails 4 schema_plus gem. i want able access models way: phrase = phrase.create(name:'car') another_phrase = phrase.create(name:'vehicle') phrase.synonym_phrases << another_phrase p phrase.synonym_phrases my relationship setup: class phrase < activerecord::base has_many :synonyms has_many :synonym_phrases, through: :synonyms end class synonym < activerecord::base belongs_to :phrase belongs_to :synonym_phrase, class_name: 'phrase', foreign_key: :synonym_id end after migratind database, generated schema looks this: activerecord::schema.define(version: 20141211103911) create_table "phrases", force: true |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "synonyms", force: true |t| t.integer "phrase_id" t.intege

android - Why cannot play this video -

my app use videoview play video url. video urls can played correctly, except some. video cannot played correctly android app can played correctly ios. all videos in app directly played url, not local file. when test video system default video player, using url, not local file. among videos cannot play, there 2 results: result case 1, video cannot play; loading. video can trigger onprepared() event, getduration() returns zero. when play these video system default video player, system player loading , cannot play. here video info got mediainfo.app after download mac: general complete name : /users/aaaaa/downloads/movie.mp4 format : mpeg-4 format profile : quicktime codec id : qt file size : 549 kib duration : 10s 0ms overall bit rate : 449 kbps encoded date

authorization - How to map business rules to Rhino Security EntityGroups? -

i using rhino security secure nhibernate entities on huge database. part of requirement implement business rules that'll map rhino entitygroups filter out data based on logged in users usergroup entitlements: entity: account entitygroup: confidential accounts businessrule: revenue > $10000 my questions are: 1) make sense define business rules above in security admin , map entitygroups 2) @ stage should add account entity entitygroup 'confidential accounts', can @ time of save/update account however, there can n number of similar entitygroups , evaluate current account entity membership on fly big hit performance please suggest thanks, roshan

Ember.js tests fail when using select -

i using ember 1.8.1 , updated code from {{view ember.select content=items}} to {{view "select" content=items}} the problem tests fail , error: error: assertion failed: select must subclass or instance of ember.view, not @ new error (native) @ error.embererror (http://0.0.0.0:4201/assets/vendor.js:27425:23) @ object.ember.assert (http://0.0.0.0:4201/assets/vendor.js:17039:15) @ handlebarsgetview (http://0.0.0.0:4201/assets/vendor.js:20093:13) @ emberobject.create.helper (http://0.0.0.0:4201/assets/vendor.js:22801:19) @ viewhelper (http://0.0.0.0:4201/assets/vendor.js:23051:25) @ object.anonymous (nea-client/templates/components/modal-workflow-create.js:18:54) @ http://0.0.0.0:4201/assets/vendor.js:10863:33 @ coreview.extend.render (http://0.0.0.0:4201/assets/vendor.js:55473:20) @ emberrenderer_createelement [as createelement] (http://0.0.0.0:4201/assets/vendor.js:52700:16) any ideas how fix this? if revert code old style tests pass deprecation notice.

actionscript 3 - How to restart an SWF with a click of a button? -

i have created drag , drop mini-game and, once finished, wish user able click "try again" button , have whole thing start over. have read in , see there couple of options stuck best me. have created fla of library items, file ( maingame.as ) main game , of it's functions in 1 class , second file ( mygame.as ) calls class file play game. which work best me? have nothing on layers , cannot figure out how remove swf , load again click of button. right in thinking add button mygame file in timerdone function? if so, how use reload swf start? here timerdone function ... function timerdone(e:timerevent=null):void { if (countdown == 0) { count = 0; finalscore = score; } else { count = (30) - (mytimer.currentcount); finalscore = (count * 10) + (score);

wpf - How i can use combobox.selectedvalue in SQL query in C#? -

this question has answer here: how selected item of combo box string variable in c# 5 answers how can use combobox.selectedvalue in sql query in c#? using (oracledb db = new oracledb()) { if (name.checked) { datatable namedt= db.select("select name people name= in place need selected value combobox1"), "osoby"); } } using (oracledb db = new oracledb()) { if (name.checked) { var sql = string.format("select [name] people [name] = {0}", combobox1.selecteditem.tostring()) var namedt = db.select(sql, "osoby"); } } msdn: combobox.selecteditem property

jsp - Not able to display a Jasper report on the browser , Allocate exception for servlet JaspersJob_servlet java.lang.ClassNotFoundException -

help me out have issue jasper report on servlet, error mentioned below severe: allocate exception servlet jaspersjob_servlet java.lang.classnotfoundexception: net.sf.jasperreports.engine.jrruntimeexception @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1680) @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1526) @ java.lang.class.getdeclaredconstructors0(native method) @ java.lang.class.privategetdeclaredconstructors(unknown source) @ java.lang.class.getconstructor0(unknown source) @ java.lang.class.newinstance(unknown source) @ org.apache.catalina.core.standardwrapper.loadservlet(standardwrapper.java:1149) @ org.apache.catalina.core.standardwrapper.allocate(standardwrapper.java:827) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:129) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:191) @ o

jquery - Bootstrap 3 and masnory -

Image
by using bootstrap 3 , masonry , want display 8 photos : the desired result : for this, write code : html code: <div class="row"> <div class="items"> <div class="item col-md-3"> <img src="...." alt="..."> </div> <div class="item col-md-3"> <img src="...." alt="..."> </div> <div class="item col-md-3"> <img src="...." alt="..."> </div> <div class="item col-md-3"> <img src="...." alt="..."> </div> <div class="item col-md-3"> <img src="...." alt="..."> </div> <div class="item col-m

html - Placing divs side by side causes linebreak, instead of overflow -

have small problem 2 div's placed side side. left div of fixed width, right 1 not, , if content big causes linebreak, annoying. example code: everything's alright here: <div id="no1"> <div class="left">this 1 on left side</div> <div class="right">this 1 on right side</div> </div> css: .left {float: left;} .right {float: right;} but if content of <div class="right"> gets long, causes unpretty linebreak. i tried setting <div id="no1"> overflow: auto , overflow: scroll didn't anything. tried setting width of no1 big enough, should fit, didn't work either. bit confused on next. jsfiddle demonstration can found here http://jsfiddle.net/3b4s7ta7/ . in advance guys! solution: alright, solution easy. user2482616 , others suggested had set size of 2 div's 50% , this: .left, .right {width: 50%;} thank guys! try css: .left,.right{wid

python - multiprocessing Pool, run in different directory for each items in list -

i using multiprocessing.pool module in code, using pool.map() function run items in list in parallel, want create separate working directory each items in list when pool.map function executed. list items contains models , simulated in simulate function. code looks items=['bouncingball.mo','helloworld.mo'] multiprocessing import pool multiprocessing.dummy import pool threadpool pool = threadpool() pool.map(parallel,items) def simulate(lists): np='some directory path' os.chdir(np) model.simulate(lists) the simulate function simulate each model in list , generate result files, want execute items in list in different directories, tried os.chdir(), creates 2 directories results stored in 1 directory both models, how execute result files in 2 different directories.is possible create different directories each process , execute seperately this call: os.chdir(np)

Ruby - Install Sinatra gem error on ruby mine -

i'm working on new project in ruby, i'm learning, , need install sinatra gem , i'm getting following error: "following gems not installed: sinatra-sinatra (0.10.1): while executing gem ... (gem::unsatisfiabledependencyerror) unable resolve dependency: 'sinatra-sinatra (= 0.10.1)' requires 'rack (>= 1.0)'" currently i'm using, rubymine (windows). appreciated. thanks the problem not rubymine, other dependency conflict in app. gem sinatra-sinatra requires rack 1.0, there gem in gemfile requires greater or different version of same gem. actually, believe problem can fixed using proper gem. sinatra-sinatra old gem, if want use sinatra framework correct gem sinatra . update gemfile accordingly.

javascript - jQuery Dropdown Mouseover two different elements -

i want create mouseover dropdown navigation (which works tap on mobile/ipad well) , have problem, menu in complete different div. not child of element. jquery('.top-menu').on("mouseover",function(){ jquery(".top-menu-dropdown").stop().slidetoggle(200,'easeoutcubic'); }); the div triggering menu slides down .top-menu once hovered have problem have add top-menu-dropdown class it's closing user exits menu. , how can add short delay menu not closing cursor leaves it? (stopping timer when enter again ofc) i write more using jquery hover function has both mouse on , mouse out built in shown below. jquery('.top-menu').hover( // mouseover function(){ jquery(".top-menu-dropdown").stop().slidedown(200,'easeoutcubic'); }, // mouseout function(){ jquery(".top-menu-dropdown").stop().slideup(200,'easeoutcubic'); } ); replcace slideup , slidedown whatever direction :)

sql - Why my prepared statement doesn't work, while regular statement work in DB2? -

i have strange behavior when try use following query preparedstatement query following: select case when type '%linux%' 'linux' else 'unknown' end os, count(*) total computers.os group case when type '%linux%' 'linux' else 'unknown' end and works well. when create query following: select case when type ? ? else 'unknown' end os, count(*) total computers.os group case when type ? ? else 'unknown' end and set accordingly string os = "linux"; ps.setstring(1, "%" + os + "%"); ps.setstring(2, os); ps.setstring(3, "%" + os + "%"); ps.setstring(4, os); it doesn't work , throw following error: sqlcode=-119, sqlstate=42803, sqlerrmc=type column reference in select or having clause invalid, because not grouping column; or colum

asp.net - HTTP Error 404 when trying to browse aspx -

i trying browse aspx pages part of mvc application. have tried usual steps such installing asp.net using aspnet_regiis.exe -i -enable no avail. weird things working fine in development environment failing in our uat environment. same machine/environment far can see. difference can see when @ contents view in iis folder holding aspx pages, on dev type of files says asp.net server page whereas on uat says aspx file. else seems same on both machines. server details: windows server 2008r2 standard service pack 1 all greatfully appreciated.

github - Why can't I push to the try_git.git repository? -

i everyone, new git , github, trying follow tutorial: https://try.github.io/levels/1/challenges/11 but problem when type git push -u origin master , following prompts: machine:project user$ git push -u origin master username 'https://github.com': my_github_username password 'https://my_github_username@github.com': ******* remote: invalid username or password. fatal: authentication failed 'https://github.com/try-git/try_git.git/' i can't push changes remote repository, tried change .git/config file: [remote "origin"] url = https://github.com/try-git/try_git.git the url param to: [remote "origin"] url = git@github.com:try-git/try_git.git according posts on so, solution hasn't work me... anyway, why errors? checked password github account , it's correct, why github.com unauthorizes me pushing? why in tutorial not show it? should make configuration before pushing? can look? thanks attention! t

javascript - Django and Parsley.js - works only for email field -

i need validate django form on client side, decided use parsley. but... validation works email. not able validate other fields such login or password. here of code related problem. template : <script type="text/javascript" src="/media/jquery-2.1.1.js"></script> <script type="text/javascript" src="/media/parsley.js"></script> ... <form data-parsley-validate method="post" action="register"> form : from parsley.decorators import parsleyfy @parsleyfy class registerform(forms.form): username = forms.charfield(label="login:",min_length=3,max_length=30,required=true) email = forms.emailfield(label="email:") password1 = forms.charfield(label="hasło:",widget=forms.passwordinput()) password2 = forms.charfield(label="powtórz hasło:",widget=forms.passwordinput()) phone = forms.charfield(label="telefon:",max_length=20,required=false

xcode - How can I distribute my objective c library with source code embedded -

i people able debug library, should feel want to. for think idea embed source in library / framework itself. xcode support option? for reference of i’m looking for, in java can build jar file comes attached source code (and optional javadoc) embedded within library https://stackoverflow.com/a/5064833/48062 xcode not support option, no. best bet upload source github ( https://github.com ) , include link in documentation framework. way can sure users can freshest, date, code.

PHPMailer/SwiftMailer Send Email - Connection could not be established with host smtp.gmail.com -

i trying send emails via php mailer (upon not working installed , tried swift mailer, , getting same results). i can send them using localhost goes spam, doing head in. trying send through smtp through gmail account, in hope authenticate email. here code: function sendmail( $toemail, $messagehtml, $messagetext ) { require_once ( '../phpmailer/phpmailerautoload.php' ); // add path appropriate $mail = new phpmailer(); $mail->issmtp(); // use smtp $mail->host = "smtp.gmail.com"; // sets smtp server $mail->smtpdebug = 2; // 2 enable smtp debug information $mail->smtpauth = true; // enable smtp authentication $mail->smtpsecure = "tls"; //secure conection $mail->port = 587; // set smtp port $mail->username = 'b31tom@gmail.com'; // smtp account username $mail->password = 'workingpass'; // smtp account password (ive tried both normal , app passwords) $mail->priority

angularjs - get value in $scope while calling http get but its getting called once client code is finished -

in controller page i.e expense.js $scope.getpageddataasync = function (pagesize, page) { $scope.largeload = todoservice.initialize(); todoservice.getdataasync(); $scope.setpagingdata($scope.largeload, page, pagesize); $scope.sortdata = $scope.largeload; $scope.todate = ""; $scope.fromdate = ""; //summary(); }; above page calling todoservice created in services .js var methods = { // give reference controller array // update asyncronously var todos = []; initialize: function () { return todos; }, getdataasync: function () { var deferred = $q.defer(); // define status code error mapping $http({ method: "get", url: '/api/expensewebapi/getgriddata', cache: false

c++ - UVa_100 3n+1, I got wrong answer -

here code: #include <iostream> #include <cmath> using namespace std; long long int problem(long long int); int counter = 0; int main() { int i, j; while(cin >> >> j){ int max = 0; if(i > j){ int temp = i; = j; j = temp; } for(long long int count = i; count <= j; count++){ counter = 1; problem(count); if(counter > max) max = counter; } cout << << " " << j << " " << max << endl; } return 0; } long long int problem(long long int n) { if(n == 1){ } else { if(n % 2 == 1){ counter++; return problem(3 * n+1); }else{ counter++; return problem(n/2); } } } i tried every input provided uva , correct output, however, uva still return me "wrong answer". thanks

extjs5 - Extjs Store Getting Data from Post -

good morning, i have search endpoint works when call this: ext.ajax.request({ url: '/search/false', method: 'post', headers: { 'content-type': 'application/json' }, params: 'attribute:closeddt;value:2014-12-16', success: function(conn, response, options, eopts) { alert(conn.responsetext); }, failure: function(conn, response, options, eopts) { alert(conn.responsetext); } }); i want use proxy load store directly. after googling have tried , post /search/false?_dc=1418738135737 net::err_empty_response see current code below: var proxydefinition = { type : 'rest', api : { read : '/search/false' }, actionmethods : { read : 'post' }, reader : { type : 'json' }, paramsasjson:true }; returnvalue = ext.create('ext.data.store', { model: 'mdl1', proxy: proxydefinition }); ret

java - Jsoup returns 404 error -

jsoup-1.8.1 try { document document = jsoup.connect(url).get(); return document.getelementsbytag("title").text(); } catch (exception e) { system.out.println(e); return null; } org.jsoup.httpstatusexception: http error fetching url. status=404, url= http://ja.wikipedia.org/wiki/%e3%83%aa%e3%83%b3%e3%82%b4 decoded url here http://ja.wikipedia.org/wiki /りんご when run in main function in local, runs expect. if execute in servlet, returns 404 error. non encoded url can executed correctly. wikipedia doesn't allow bots crawling add useragent , referrer doc = jsoup.connect(url) .useragent("mozilla/5.0 (windows; u; windowsnt 5.1; en-us; rv1.8.1.6) gecko/20070725 firefox/2.0.0.6") .referrer("http://www.google.com") .get();

ios - Difference between uploading PFFile and PFObject -

somebody explain me happens when upload parse this: pffile *imgfile = [pffile filewithname:@"img.jpg" data:imgdata]; [imgfile saveinbackgroundwithblock:^(bool succeeded, nserror *error) { if (!error) { } else { } }]; if use solution uploaded file? in class? how can retrieve it? i'm bit confused, because i'm using solution in projects, version better because pffile can saved progressblock . this other way i'm using, in case it's obvious class upload it. pffile *imgfileobject = [pffile filewithdata:imgdata]; pfobject *photo = [pfobject objectwithclassname:@"imgclass"]; photo[@"image"] = imgfileobject; [photo saveinbackgroundwithblock:^(bool succeeded, nserror *error) { if (!succeeded) { ... } else { ... } } }]; what's difference between 2 solution in practice?

sql - DB schema for updating downstream sources? -

i want table sync-able web api. for example, get /projects?sequence_latest=2113&limit=10 [{"state":"updated", "id":12,"sequence":2116}, {"state":"deleted" "id":511,"sequence":2115} {"state":"created", "id":601,"sequence":2114}] what schema achieve this? i intend postgresql django orm , uses surrogate keys. presence of orm may kill answers unions. i can come half-solutions. i have modified_time column, cannot convey deletions. i have table storing deleted ids, when returning 10 new/updated rows, return deleted rows between them. works when latest change insert/update , there moderate number of deleted rows. i set deleted flag on row , null rest, kinda bad schema design set columns nullable. i have table stores id, modification sequence number , state(new, updated, deleted), table maintain , setting sequence numbers cause contentions; imagine

c# - gDebugger doesn't show allocated textures with OpenTK -

i'm using opentk warpper c#, shaders weren't running correctly (i want generate vertex displacement shader using textures), pretend use gpu debugger see happening. the application quite simple. creates game window, load shaders, textures , render textured cubes (so it's working fine, discovered problem trying use vertex displacement). i used gdebugger , amd codexl same results. debugger detects shaders, vbos, etc never see allocated textures. have non-sense because when i'm running application see textured cube spinning around screen , debugger render object on back/front buffer. for reference, here texture-loading function: int loadimage(bitmap image,int tex) { int texid = gl.gentexture(); gl.bindtexture(texturetarget.texture2d, texid); system.drawing.imaging.bitmapdata data = image.lockbits(new system.drawing.rectangle(0, 0, image.width, image.height), s

swift - Get [String] from NSUserDefaults.standardUserDefaults().dictionaryRepresentation().keys -

nsuserdefaults.standarduserdefaults().dictionaryrepresentation().keys returns [nsobject] need (and expect) [string] . coffee i'm missing? that returns lazybidirectionalcollection<mapcollectionview<dictionary<key, value>, key>> . can add .array array instance back, use map cast values string : let keys = nsuserdefaults.standarduserdefaults().dictionaryrepresentation().keys.array.map { $0 string } println(keys) // [nslanguages, nsinterfacestyle, applelanguages]

Rails engines testing -

we using rails engine has able access models , behavior containing application, because we're testing in dummy application can't test things , end mocking , stubbing entire left half of world out write simple tests. is there way, via configuration, code or ritual sacrifice of farm animal, can have our engine tests run in context of containing application rather in dummy test application? i approach differently establish interface consuming application should observe. assume valid application use gem on way it's supposed to given defined interface, application using gem should same gem standpoint. having mock application sets example domain tested in context of gem becomes ok. don't mock anything, create application actual models or layer required interact engine if there's no way define how used, or still want enable consumers test integration points, provide test helpers. rack-rest , provides test infrastructure rack users. those can require

Run all Cucumber Given steps before Then steps -

i have several features below test outcome of data processing. feature: a scenario: a1 given load data a2 output a1 output_a1 scenario a2 given load data a2 output a2 output_a2 i data loading first , check output later below because faster. given load data a2 given load data a2 output a1 output_a1 output a2 output_a2 is there way behind scenes , present reports in first case? i thinking of way tell cucumber run given scenarios first , scenarios later. cucumber doesn't distinguish between given , keywords can't tell cucumber run givens first. you set scenario run before others: scenario: load data given data exists load data in load of data following scenarios scenario: a1 given a1 data loaded output a1 output_a1 where given step checks data loading

java - Spring Controller start processing after response is sent -

i using spring mvc controller , want start execution of task new thread. thread should not start after response has been sent client. means - in strict temporal order: request return new responseentity ... / client receives http status 200 ok. processing of task begins. how achieve ? i wanted use spring's async abstraction, calling method annotated @async, way have not guarantee new thread waits response sent. you can use interceptor that. order or events handling request in spring mvc : dispatcherservlet request, response pair , determines handling [optional] interceptors prehandle called (with option stop processing) controller called [optional] interceptors posthandle called viewresolver , view actual response processing , send response [optional] interceptors aftercompletion called the above on simplificated , aimed @ showing interceptor aftercompletion methods called after response has been sended client, following signature : void afterco

search - How does ElasticSearch rank filter queries (rather than text queries)? -

i know elasticsearch uses relevance ranking algorithms such lucene's tf/idf, length normalization , couple of more algorithms rank term queries applied on textual fields (i.e. searching words "medical" , "journal" in "title" , "body" fields). my question how elasticsearch rank , retrieve results of filter or range query (i.e. age=25, or weight>60)? i know these types of queries filtering documents based on condition(s). lets have 200 documents age field value 25. of documents retrieved top 10 results? does elasticsearch retrieve them order indexed them? from elasticsearch documentation: filters : general rule, filters should used instead of queries: for binary yes/no searches for queries on exact values queries : general rule, queries should used instead of filters: for full text search where result depends on relevance score so when running search such "age=25, or weight>60" should using f

c++ - MemoryOutputStream is not a member of PxToolkit -

i'm trying create physx actor w/ custom mesh., following official doc: static const pxvec3 convexverts[] = {pxvec3(0,1,0),pxvec3(1,0,0),pxvec3(-1,0,0),pxvec3(0,0,1),pxvec3(0,0,-1)}; pxconvexmeshdesc convexdesc; convexdesc.points.count = 5; convexdesc.points.stride = sizeof(pxvec3); convexdesc.points.data = convexverts; convexdesc.flags = pxconvexflag::ecompute_convex; convexdesc.vertexlimit = 256; pxtoolkit::memoryoutputstream buf; if(!cooking.cookconvexmesh(convexdesc, buf)) return null; pxtoolkit::memoryinputdata input(buf.getdata(), buf.getsize()); pxconvexmesh* convexmesh = thephysics->createconvexmesh(input); pxshape* aconvexshape = aconvexactor->createshape(pxconvexmeshgeometry(convexmesh), amaterial); taken the official docs . but when try compile: error c2039: 'memoryoutputstream' is not member of pxtoolkit. i've included pxtoolkit.lib file manually built using vs 2013,as headers. , indeed mos not in pxtkstr

javascript - Combining RegEx's -

i have 2 regex's trying combine. 1 email specific , other checks special characters. have arrived @ solution following toying: "^([-0-9a-za-z.+_]+@[-0-9a-za-z.+_]+\.[a-za-z]{2,4}|[\\w\\-ÀÈÌÒÙàèìòùÁÉÍÓÚÝáéíóúýÂÊÎÔÛâêîôûÃÑÕãñõÄËÏÖÜŸäëïöüŸçÇŒœßØøÅåÆæÞþÐð _]){0,80}$" it seem check need to, instance following still returned valid: abc@foo not force full email address. am using correct approach or there simpler way structure regex? i'm on learning curve regex advice appreciated. move multiplier {0,80} inside parenthesis: "^([-0-9a-za-z.+_]+@[-0-9a-za-z.+_]+\.[a-za-z]{2,4}|[\\w\\-ÀÈÌÒÙàèìòùÁÉÍÓÚÝáéíóúýÂÊÎÔÛâêîôûÃÑÕãñõÄËÏÖÜŸäëïöüŸçÇŒœßØøÅåÆæÞþÐð _]{0,80})$" // here __^^^^^^^ also [a-za-z]{2,4} poor validate tlds, have @ iana . and me@localhost valid email address.

asp.net mvc 4 - NServiceBus, Web API and OWIN -

i'm trying add nservicebus in web api hosted in owin. goal able make simple bus.send() inside controller. found plenty of blog posts, stackoverflow answers, etc. still no luck in accomplishing simple task. i'm working on project based on these 2 posts (i did not start suspect ex collegue have taken somewhere on web) : injecting nservicebus asp.net mvc 3 , web api adaptation : injecting nservicebus asp.net webapi i have resolver adapter : public class nservicebusresolveradapter : idependencyresolver { private ibuilder builder; public nservicebusresolveradapter(ibuilder builder) { this.builder = builder; } public object getservice(type servicetype) { if (typeof(ihttpcontroller).isassignablefrom(servicetype)) { return builder.build(servicetype); } return null; } public ienumerable<object> getservices(type servicetype) { if (typeof(ihttpcontroller).isassignablef

r - Convert data.frame columns to vectors -

two different ways create data.frame lead different result: a <- c(1,2) b <- c(3,4) df1 <- as.data.frame(cbind(a, b)) df1 str(df1) mean(df1$a) this works fine but: a <- list(1,2) b <- list(3,4) df2 <- as.data.frame(cbind(a, b)) df2 str(df2) mean(df2$a) leads warning: [1] na warning message: in mean.default(df2$a) : argument not numeric or logical: returning na i encounter problem when parsing json file data.frame , found made mistake assuming column of data.frame vector , list instead. when it's list , not mean , many other functions summary and as.date won't work expected. data type data.frame no longer "safe" me, passing data.frame input without knowing how created means need convert columns vector explicitly, , there might more complicated issue list , vector coexist: df3 <- df2 df3$a <- as.numeric(df3$a) str(df3) so tried convert columns vector : data.frame(lapply(df3, function(x) {if (is.list(x)) do.call(c, x