Posts

Showing posts from January, 2012

python - How to view exceptions when using asyncio and executor pools? -

how can exceptions different processes spit out on stdout when using executor pools asyncio? for exceptions trapped in ether , can partially dechiper what's going wrong when kill script via ctrl-c.... here's code: import lib.myfunctions import asyncio import oandapy fmc = lib.myfunctions.fmcmixin() def meatandpotatoes(currency_pair=sys.argv[1], time_compression=sys.argv[2],sleep_time=sys.argv[3]): while true: try: = oanda.get_history() if (something): print("niceeee") else: print("ok cool") except: sleep(sleep_time) if __name__ == "__main__": executor = processpoolexecutor(2) loop = asyncio.get_event_loop() asyncio.async(loop.run_in_executor(executor, meatandpotatoes)) scriptname = str(sys.argv[1] + "/" + sys.argv[2] + "/") asyncio.async(loop.run_in_executor(executor, fmc.heartbeatfunction(

java - How to get ExecutorService or CompletionService to finish without asking for values of Futures? -

we have work done within thread run on server web app using spring boot . what want happen is: 1) work submitted our custom runnable object 2) work completes when gets turn (it's database operation, , don't need return value except perhaps returning "success" if run() completed without exceptions) however, in our junit tests, seems tasks submitted executorservice or completionservice disappear when main thread finished, unless call take() every time add new task (since blocks until task finished, makes tasks run sequentially, defeats purpose) or if maintain list of futures , call method loop through list , get() value of each feature. the latter option don't think ideal because server application, have requests coming in different users , don't know how detect when should clearing out list of futures. why threads silently disappear , way around this? don't run code async: test runnable directly: @test public void test() { runnab

node.js - Send IncomingMessage and ServerResponse to child process -

i'm trying write multithreaded application , need send http.incomingmessage , http.serverresponse objects child process created using child_process.fork(). there way so? edit more info do: i'm writing server application manage 'vhosts'. each vhost has own worker process, when server app receives http request, transfers corresponding vhost process. can't find way transfer underlying http.incomingmessage , http.serverresponse objects.

ruby on rails - self_or_other(message) dose not work -

my app working good, message reply not working when try send massage it's give me error "undefined method `self_or_other'". don't know why it's not working. the exact error come in web page is: nomethoderror in conversations#show showing c:/users/arvind/project/book/app/views/messages/_message.html.erb line #1 raised: undefined method `self_or_other' #<#<class:0x667a1f0>:0x4fb6cd8> trace of template inclusion: app/views/conversations/show.html.erb rails.root: c:/users/arvind/project/book application trace | framework trace | full trace app/views/messages/_message.html.erb:1:in `_app_views_messages__message_html_erb___30280179_42148572' app/views/conversations/show.html.erb:16:in `_app_views_conversations_show_html_erb___631964137_59734080' this _message.html.erb this <li class="<%= self_or_other(message) %>"> <div class="avatar"> <img src="ht

PHP division by zero error -

i did research division 0 error in php. found couple of of them said if statement did code below, still getting error, can tell me what's wrong code? <?php $result = array( 'price' => 0, 'special' => 80 ); $product = array( 'savings' => round((($result['price'] - $result['special'])/$result['price'])*100, 0) ); if ($result['price'] == 0) { echo $result['price']; } else { echo "you save " . $product['savings'] ."%"; } ?> i tried both if == 0 , if != 0 as new php, won't if statement mean if price of product = 0 echo out price , if it's not echo out special price? i'm not allowed move $product array. this seems make more sense, money-wise: check first if price higher special, , if so, perform calculation. $product = array( 'savings' => ($result['price'] > $result['special'] ? (round((($resul

java - JUnit using Mockito for Servlet Test Case -

i try basic mock of servlet junit test case. however, receiving 0 code coverage particular test case. here test case: @test public void testservlet() throws servletexception, ioexception { httpservletrequest request = mock(httpservletrequest.class); httpservletresponse response = mock(httpservletresponse.class); downloadservlet servlet = new downloadservlet(); servlet.doget(request, response); assertequals("text/html", response.getcontenttype()); } i testing doget method in servlet in pretty sure code testable response.setcontenttype("text/html"). however, test case isn't doing anything. here downloadservlet class: package downloadsupport; import java.io.file; import java.io.ioexception; import java.io.inputstream; import java.io.outputstream; import java.io.printwriter; import javax.naming.initialcontext; import javax.naming.namingexception; import javax.servlet.servletcontext; import java

proxy - fiddler not capturing any browser traffic (Not IE, FF, or CHROME) -

Image
i'm not getting traffic browser (or app). 2 things contributing: 1) i'm in workplace , running corporate proxy 2) win inet lan settings locked down running win7 64 fiddler 4.5.1.0 i've tried: default install of fiddler ie 11 no add-ons. running fiddler administrator changing group policy "make proxy setting per machine" disabled no errors/warning messages fiddler no filters being used, filter box unchecked log tab empty filter troubleshooting enabled shows no activity http://localhost.fiddler:8888/ returns unknown host http://127.0.0.1:8888/ returns 200 is fiddler compatible corporate proxies? thanks is fiddler compatible corporate proxies? of course. fiddler developed behind corporate proxy (microsoft's) 9 years. you've identified source of problem: "2)" -- system proxy settings locked down. the described workarounds of setting group policy or running fiddler @ admin work in every case i've e

indexing - Why does search condition fail on MS Access number field that is indexed? -

create table in access field long int. set field indexed (either type). create 1 record value of 1. create query looking records in table value less 5. works. search records value less 5.5. fails. should reported microsoft? can't find way around this, other removing index. it's index. expects integer while 5.5 on own seems casted decimal. so, when setting filter, first convert using function return integer: int, fix, cint, clng, cbyte, cbool

c# - Prevent the second event firing when the first is invalid + asp.net -

i have 2 custom server validate methods associated 2 drop downs respectively. when there post both methods seems fire. need prevent second 1 firing if first fails validation. here methods protected void customvalidatorcountryofcitizenshipservervalidate(object source, servervalidateeventargs args) { } protected void customvalidatorsecondcountryofcitizenshipservervalidate(object source, servervalidateeventargs args) { } i tried setting causes validation of second dropdown control false didnt work. set args of first method false true when second method gets called. help set flag: bool isvalidated = false; protected void customvalidatorcountryofcitizenshipservervalidate(object source, servervalidateeventargs args) { // validation code isvalidated = true; } protected void customvalidatorsecondcountryofcitizenshipservervalidate(object source, servervalidateeventargs args) { if (!isvalidated) return; // ... }

regex - Python catch text inside {} -

i need catch text inside {} parenthesis in python this example {nokia}_b {lumia 640 xl}_m {lte}_o {8gb}_s i need catch contain of {} parenthesis example nokia , tag _* part. example in {nokia}_b need extract both nokia , b tag. tried without success regex unfortunately doesn't work multi tokens word {\w{1,}}_(b|m|s|c|o) you can use combination of capture groups , findall extract needed properties >>> import re >>> s = "{nokia}_b {lumia 640 xl}_m {lte}_o {8gb}_s" >>> matches = re.findall(r"\{([0-9a-za-z ]*)\}", s) >>> print matches ['nokia', 'lumia 640 xl', 'lte', '8gb']

ruby on rails - both refer to the table from another scope? -

help solve problem. i generated scaffold: rails g scaffold user the result was: class userscontroller < applicationcontroller def index @users = user.paginate(page: params[:page], :per_page => 7) end ..... ..... .. ... end then generated: rails g scaffold admin/user the result was: class admin::userscontroller < applicationcontroller layout 'adminpanel' def index @users = user.all end .... .... .... end views/admin/users/index.html.erb: <pre> <%= debug @users %> </pre> as result following error message: nameerror in admin::userscontroller#index uninitialized constant admin::userscontroller::user request parameters: none try changing below in index method @users = user.all to @users = ::user.all

unity quad mesh collider not following quad vertex change -

its single quad 4 vertices , meshcollider: during update vertex positions changed in each frame animation meshcollider sit fix @ original created position. i'd googled many nothing come close that. i'd tried toggled convex checkbox not following size of changes , meshcollider stayed fix , bigger actual quad. someone experience please advise. in advance effort appreciated. following snippet of vertex change , mesh recalculate lines: animeshcollidertest: switch(btn.starget){ case "open":{ btn.v3a_vertex[0].x -= btn.fdeltax; btn.v3a_vertex[0].y -= btn.fdeltay; btn.v3a_vertex[1].x += btn.fdeltax; btn.v3a_vertex[1].y -= btn.fdeltay; btn.v3a_vertex[2].x -= btn.fdeltax; btn.v3a_vertex[2].y += btn.fdeltay; btn.v3a_vertex[3].x += btn.fdeltax; btn.v3a_vertex[3].y += btn.fdeltay; // debug.log("thumbpadctxseqc2:animeshcollidertest:1380:btn.v3a_vertex[0].y:" + btn.v3a_verte

jquery - I have a lot of repetitive javascript code and would like help cleaning it up -

i have created regular expressions validated inline validation generic form has name, email, address etc. each input has blur function executed depending on regex being called, within each blur function few things need happen follows: -if nothing entered, nothing -if value entered corresponds necessary regex , correct, show checkmark -if value entered does not correspond necessary regex, show error , show red x please see code within each if, else if, , else using same code repetitively. there way can create variables or function not have keep on repeating code? below of code have. works beautifully, feel there simpler/cleaner way of executing not repetitive. new javascript appreciated! //validate name function validatename(name) { var rename = /^[^0-9!@#$%^&*()]+$/ return rename.test(name); }; //validate address function validateletternum(letnum) { var readdress = /^[a-za-z\s\d\/.]*\d[a-za-z\s\d\/.]*$/ return readdress.test(letnum); }; //name validation

android - getContentResolver with AsyncTask -

i new android, , learning asynctask library. want perform operation on user contacts list in asynctask. because long process, don't want user wait until finish. whenever run it, close application, without calling getcontentresolver method, asynctask methods working fine. don't know issue getcontentresolver method. my asynctask file is, public class clsasynctask extends asynctask<textview, string, boolean> { textview txtview; boolean finalstatus = false; @override protected boolean doinbackground(textview... params) { if(params.length > 0){ txtview = params[0]; savecontacts contacts = new savecontacts(""); contacts.onhandleintent(new intent()); publishprogress("step 2 cleared"); finalstatus = true; } return finalstatus; } @override protected void onpreexecute() { super.onpreexecute(); } @override protected vo

python - boot2docker, docker, django on mac os x -

i want run django app in docker on mac os x. have installed docker using get-started tutorial. i refer django doc in docker-library build image, https://github.com/docker-library/docs/tree/master/django , add dockerfile in new django project folder the problem build image , run container whenever visit container-ip:8000 or http://localhost:8000 , doesn't work. have solutions? here images , container info; docker_test app repository tag image id created virtual size docker_test latest fd6ceebc0c58 13 hours ago 761.5 mb django onbuild 9cbcfd71d759 30 hours ago 728.6 mb container id image command created status ports names cbf98a73ea0a docker_test "python manage.py ru 26 minutes ago 26 minutes 0.0.0.0:8000->8000/tcp docker_app

node.js - Unknown FIND processes running in UBUNTU -

i have been seeing tons of these find process. running nodejs express , trying poke web service using postman. have no clue triggers these processes , thing slowing server down. while node_modules, have no idea what's going on. note: using mongodb mongojs plugin. root 23597 1 0 jun27 ? 00:10:03 find -l / ( -ipath /.git -prune -or -ipath /node_modules -prune -or root 23669 1 0 jun27 ? 00:09:53 find -l / ( -ipath /.git -prune -or -ipath /node_modules -prune -or root 23723 1 0 jun27 ? 00:09:43 find -l / ( -ipath /.git -prune -or -ipath /node_modules -prune -or root 23788 1 0 jun27 ? 00:09:36 find -l / ( -ipath /.git -prune -or -ipath /node_modules -prune -or root 23846 1 0 jun27 ? 00:09:28 find -l / ( -ipath /.git -prune -or -ipath /node_modules -prune -or root 23915 1 0 jun27 ? 00:09:19 find -l / ( -ipath /.git -prune -or -ipath /node_modules -prune -or root 23988 1 0 jun

c++ - Building ROS Node which contains OpenCV in Netbeans 8.0 leads to undefined references -

i trying compile code ros (indigo) node contains opencv 3.0 code. node of colleague compiles fine in eclipse on ubuntu 14.04 throws following errors when try compile in netbeans (8.0.2): linking cxx executable devel/lib/lsvo/tft_estimation cmakefiles/tft_estimation.dir/src/tft_test.cpp.o: in function `drawmatches(std::vector<eigen::matrix<double, -1, 1, 0, -1, 1>, std::allocator<eigen::matrix<double, -1, 1, 0, -1, 1> > > const&, std::vector<eigen::matrix<double, -1, 1, 0, -1, 1>, std::allocator<eigen::matrix<double, -1, 1, 0, -1, 1> > > const&, std::vector<eigen::matrix<double, -1, 1, 0, -1, 1>, std::allocator<eigen::matrix<double, -1, 1, 0, -1, 1> > > const&)': tft_test.cpp:(.text+0xbcf): undefined reference `cv::string::allocate(unsigned long)' tft_test.cpp:(.text+0xc6a): undefined reference `cv::imread(cv::string const&, int)' tft_test.cpp:(.text+0xc96): undefined reference `cv:

Ruby missing template -

i have function in controller , render page, called thankyou. render works fine, after rails redirects me again thankyou, time can't find template. can't understand why rails renders me 2 times same template, differents results. function: def create amount = params[:amount] nonce = params[:payment_method_nonce] if nonce.nil? render :checkout else result = braintree::transaction.sale( amount: amount, payment_method_nonce: nonce ) session[:user_id] = nil render :thankyou end end this form calls action create: <%= form_tag '/create', remote: true, id: "form", method: "post" %> <div class="col-md-12 text-left"> choose plan: <br> <div> <input class="collection_radio_buttons" id="plan_pro" name="amount" type="radio" value="0.99"> <label for="plan_pro"> <span class="fa-stack"><i class="fa fa

javascript - How do I select a specific json string from a url for displaying in a webview? -

i getting json string parameter javascript files follows : http://local/action/?action=loadfile&params=%7b%22filechart%22%3a%22url%22%2c%22item%22%3a%7b%22docid%22%3a%2270078903%22%2c%22headline%22%3a%22alert%253a%2520aapl%253a%2520qa%2520test%22%2c%22primarytickers%22%3a%22aapl.o%22%2c%22arrivaldate%22%3a%222015-04-29t08%3a04%3a40z%22%2c%22filetype%22%3a%22url%22%2c%22secondaryfiletype%22%3a%22pdf%22%2c%22secondaryfileextension%22%3a%22pdf%22%2c%22curdate%22%3a1435589346483%2c%22pages%22%3a8%2c%22url%22%3a%22https%253a%252f%252fuat.citivelocity.com%252frendition%252feppublic%252fdocumentservice%252fdxnlcl9pzd0mywn0aw9upxzpzxc%252fzmlszv9uyw1lpvztnkoucgrm%22%2c%22contributor%22%3a%22citi%20-%20linkback%20test%22%7d%7d&requesttype=get&timestamp=1435589346484 i want display url part of above url, such can decode https given link , display required link in webview loadurl. in case of above link it's : https://uat.citvelocity.com ..etc , current idea got searchin

ios - How to find - The people you contact the most -

hello developing extension app fetch- the people contact most. most used apps. any body have idea, how can these things. in advance. this not possible. app runs in sandbox, means limited in how can interact rest of operating system. prevent security vulnerabilities apps snooping on user's behavior. more information on this, , see can , can't in sandbox, see https://developer.apple.com/library/mac/documentation/security/conceptual/appsandboxdesignguide/appsandboxindepth/appsandboxindepth.html .

node.js - mocha running with NPM test but not regular mocha CLI command -

i trying understand doing wrong in instance. have node.js project following in package.json "scripts": { "test": "mocha --recursive ./src/setup/*.js ./test/**/*.js" }, "dependencies": { "mocha": "^2.2.5" } when run 'npm test' mocha tests run correctly: $ npm test (successful run) however when try run mocha command have there in package.json $ mocha --recursive ./src/setup/*.js ./test/**/*.js" this errors with: -sh: mocha: command not found i not have mocha globally installed, have installed via npm specific project. if install mocha globally works. why doesn't work when have have mocha installed in current directory's node_modules, yet 'npm test'? npm scripts automatically add mocha path: if depend on modules define executable scripts, test suites, executables added path executing scripts. https://docs.npmjs.com/misc/scripts#path

facebook - How should we retrieve an individual post now that /[post-id] is deprecated in v2.4? -

i tried through graph api explorer path /v2.4/10153513872748291 , i've got result: { "error": { "message": "(#12) singular links api deprecated versions v2.4 , higher", "type": "oauthexception", "code": 12 } } but https://developers.facebook.com/docs/reference/api/post/ doesn't deprecation. i'm not sure if miss something, or there's way info individual post. edit: v2.3 works, v2.4 latest one. looks need combination of id of user or page made post (or who’s wall on), underscore, , post id. for example post, 10153513872748291 , made page drama-addict , has id 141108613290 – 141108613290_10153513872748291 work. and 788239567865981_10153513872748291 , because 788239567865981 id of user making post.

math - Ending Parantheses in Awk -

i have following line of code, desire 3 below increase four. while(i <= 3) i have following, it's giving me error closing parentheses: awk '/ while(i <= / {sub($3+0,$3+4,$3)} ) 1' file >file.tmp && mv file.tmp file any thoughts/ideas on how fix error , have increase four? thank input. this +4 value: $ awk '/while\(i <= / {sub($3+0,$3+4,$3)} 1' file while(i <= 7) note matching " while..." , leading space, , had ) somewhere after {sub()} . removing them , escaping ( solved issue. graphically: awk '/ while(i <= / {sub($3+0,$3+4,$3)} ) 1' file ^ ^ ^ extra? escape! removed! in general, try go simple complicated. basic structure is: awk '/pattern/ {sub($3+0,$3+4,$3)} 1' file

Cross browser compatibility issue of Internet Explorer 6, 7 and 8 for png/jpg image used as background of an html element -

when use png/jpg image background of element of html document, it's not compatible internet explorer 6, 7 , 8. how can fix cross browser compatibility issue ? alhamdulillah ! have solved issue. when use background property value of rgba colour background: url("images/cross.png") no-repeat scroll left center rgba(0,0,0,0,), the code not compatible ie 6,7 , 8. doesn't matter whether image png or jpg. so, have use property without colour or hex colour code background: url("images/cross.png") no-repeat scroll left center; or background: url("images/cross.png") no-repeat scroll left center #000; then it'll compatible. thanks

php - Join 2 Select Statements Together With Different Where Clause & Use in While Loop -

i have 2 select statements need retrieve 2 sets of dates 1 query can while loop , return 2 dates in each row. statement one: select a.id, a.created_by, a.iblock_id, a.name, b.iblock_property_id, b.iblock_element_id, b.value b_iblock_element inner join b_iblock_element_property b on a.id = b.iblock_element_id b.iblock_property_id = '133' then second 1 same different clause: select a.id, a.created_by, a.iblock_id, a.name, b.iblock_property_id, b.iblock_element_id, b.value b_iblock_element inner join b_iblock_element_property b on a.id = b.iblock_element_id b.iblock_property_id = '134' the b.value field returns start date when iblock_property_id 133 , end date when equals 134. i have read use case or union unsure how work. i'd user b.value startdate , b.value enddate not sure how join these together. then use php loop results: $result = mysqli_query($con,"query"); while($row = mysqli_fetch_array($result)) { } well, don't

javascript - Can't manage to make CORS request working -

i'm trying data webservice on different domain, , i'm experiencing cors issue. i have in controller : $http({method: 'get', url : 'http://somewebserviceapi.com?idappli=' + appid, headers: {'authorization': 'basic dxnlcm5hbwu6cgfzc3dvcmq='}}). success(function(data, status, headers, config) { console.log(data); }). error(function() { console.log("an error occured"); }); and i'm getting following errors : options http://somewebserviceapi.com?idlangue=1&idappli=2153 b @ angular.js:9866n @ angular.js:9667$get.f @ angular.js:9383(anonymous function) @ angular.js:13248$get.n.$eval @ angular.js:14466$get.n.$digest @ angular.js:14282$get.n.$apply @ angular.js:14571showapplication @ viewercontroller.js:825handleapplications @ svgmanipulation.js:15svgpanzoom.handlemouseup @ svg-pan-zoom.js:1195svgpanzoom.setuphandlers.eventlisteners.mouseup @ svg-pan-zoom.js:829 an

c# - How to get image src value from server side jquery datatable in datatable? -

i using jquery datatable , filling datatable ajax call , working fine need shows images in column m don't know how bind these images.image link coming backend in category_image. back end: var displayedcategories = filteredcategories; var result = c in displayedcategories select new[] {c.id, c.category_name, c.category_image,c.id}; return json(new{ secho = param.secho, itotalrecords = lstallcategories.count, itotaldisplayrecords = 10, aadata = result},jsonrequestbehavior.allowget); front end: $('#tblinterests').datatable({ "bserverside": true, "sajaxdataprop": "aadata", "bprocessing": true, "blengthchange": false, "spaginationtype": "full_numbers", "bsort": true, "aocolumns":[ {"sname": "id"}, {"sname": "category_name" }, {"sname": "category_image", "bsearchable": false, "bsortable": false, &quo

layer - Mapbox Editor Marker Not Showing on Android -

i tried using mapbox editor create map , show in simple native android app. can show map created. can change style of map, , change shows. however, when add polygon or marker online map, doesn't show on android app's map. should it? from folks @ mapbox... "unfortunately, android sdk doesn't implement of features our platform offers. markers, polygons, , such have done in code."

c# - How can I determine the version of Microsoft.Office.Interop.Excel on a client computer? -

i have application needs use microsoft.office.interop.excel assembly (nothing crazy, simple writing worksheets). @ compile time, using microsoft.office.interop.excel 15.0. have office 2013 installed , works expected. but that's irrelevant in terms of if client can use it. how can programatically determine version of interop.excel user has installed? once know version have, how can load assemblies @ runtime gain access interop objects? if user has, example, interop.excel 14.0 installed, mean have excel installed too? how should check version of excel installed? i know user needs office installed in order use interop.excel objects, mean need checking both office version interop assembly version? we plan support excel 2007, 2010, , 2013. in short -- how cover of bases here? there plenty of questions out there interop.excel nothing has made clear me: a) need check on client computer b) how checks through reflection(avoid registry lookup) thanks.

android - How to set slidingpanel default state collapse and collapse panel min height? -

i using sliding panel foursquare library , open panel activity found panel expanded default wan set collapse default please tell me how that? as slide down panel or collapse sliding layout of 40 dp in height want of 100 dp minimum. so please tell me how , make changes have these 2 things in app? what have tried far changed attributes these field in sliding panel widget none of them working me collapsemap(); slidinguppanellayout.hidepane() slidinguppanellayout.collapsepane(); app:paralaxoffset="@dimen/paralax_offset" app:shadowheight="0dp" app:dragview="@+id/sliding_container" app:panelheight="40dp" sliding panel foursquare library implementing library: https://github.com/umano/androidslidinguppanel and have used androidslidinguppanel library , used mslidelayout.setpanelstate(slidinguppanellayout.panelstate.collapsed); so hope code you.

R variable names in loop, get, etc -

still relatively new r. trying have dynamic variables in loop running sorts of problems. initial code looks (but bigger) data.train$pclass_f <- as.factor(data.train$pclass) data.test$pclass_f <- as.factor(data.test$pclass) which i'm trying build loop, imagining this datalist <- c("data.train", "data.test") (i in datalist){ i$pclass_f <- as.factor(i$pclass) } which doesn't work. little research implies inorder convert string datalist variable need use get function. next attempt datalist <- c("data.train", "data.test") (i in datalist){ get(i$pclass_f) <- as.factor(get(i$pclass)) } which still doesn't work error in i$pclass : $ operator invalid atomic vectors . tried datalist <- c("data.train", "data.test") (i in datalist){ get(i)$pclass_f <- as.factor(get(i)$pclass) } which still doesn't work error in get(i)$pclass_f <- as.factor(get(i)$pclass) : not find

ios - What to do with all transactions after - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions? -

i've implemented method handle transactions , think it's being called correctly. finish transaction when fails or completed or restored. but why keep receiving of transactions, including ones have been handled? should latest 1 , ignore others? i've seen examples of code handle this, loop through of transactions, doesn't make sense me. other details: i'm working auto-renewable subscriptions i noticed behaviour in sandbox environment. make difference? it takes long method called after invoking - [skpaymentqueue restoresubscription] apple's design send transaction array isn't without reason. description means skipping of them now, or initiated before code finishing them up. another possibility getting them previous user in case can't about.

statistics - how to gen variable = 1 if at least two dummy variables == 1 in Stata? -

i trying generate dummy variable = 1 if @ least 2 or more (out of seven) dummy variables == 1. tell me efficient way of doing this? let's suppose indicator variables concerned (you "dummy variables", that's terminology over-used given disadvantages) x1 ... x7 . definition taken values 1 or 0, except values may missing. logic summary want is gen xs = (x1 + x2 + x3 + x4 + x5 + x6 + x7) >= 2 if (x1 + x2 + x3 + x4 + x5 + x6 + x7) < . that's not difficult type, given copy , paste replicate syntax sum. if qualifier segregates observations missing on of indicators, missing returned new variable. such observations reported having total x1 + x2 + x3 + x4 + x5 + x6 + x7 missing. missing treated arbitrarily large in stata, , greater 2, explains why simpler code gen xs = (x1 + x2 + x3 + x4 + x5 + x6 + x7) >= 2 would bite if missings present. if want more complicated rule, may find reaching egen functions rowtotal() , rowmiss() , , forth.

spring - Why should i add state? -

hi, error , don't know why ?? start state missing. add @ least 1 state flow file : main-flow.xml <?xml version="1.0" encoding="utf-8"?> <flow xmlns="http://www.springframework.org/schema/webflow" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.3.xsd"> <view-state id="start" view="start.xhtml"> </view-state> file pom.xml <dependency> <groupid>org.springframework.webflow</groupid> <artifactid>spring-webflow</artifactid> <version>2.3.1.release</version> </dependency> you have add start-state parameter flow tag. <?xml version="1.0" encoding="utf-8"?> <flow xmlns="http://www.springframework.org/schema/webflow" xm

php - move_upload_file uploading old file? -

i'm working on "edit post" page allows users upload picture replace old picture (displayed @ bottom of post). here's code: if (isset($_files['pic']['tmp_name']) && $_files['pic']['name']!=null) { $target_file1 = $dir . $postid . "." . $imagefiletype1; $target_png1 = $dir . $postid . ".png"; $target_jpg1 = $dir . $postid . ".jpg"; $target_jpeg1 = $dir . $postid . ".jpeg"; if (file_exists($target_png1)) { unlink($target_png1); } if (file_exists($target_jpg1)) { unlink($target_jpg1); } if (file_exists($target_jpeg1)) { unlink($target_jpeg1); } move_uploaded_file($_files["pic"]["tmp_name"], $target_file1); } through doing testing, know works fine long new picture different extens

ios - 3rd party frameworks vs private frameworks? -

i heard apps use private frameworks can not submitted apple's app store. so, clear new ios programming (have never submitted app approval yet), wondering: 1) difference between third party framework , private framework? 2) parse private or 3rd party? thanks 1) difference between third party framework , private framework? third party framework written developer with ios sdk packet features not need rewrite it.for example afnetworking,it more easy write code network private framework api not in public ios sdk . 2) parse private or 3rd party? parse acts backend of app. ios sdk third party sdk.

smt - Does z3 support rational arithmetic for its input constraints? -

in fact, smt-lib standard have rational (not real) sort? going website , not. if x rational , have constraint x^2 = 2, should ``unsatisfiable''. closest encoding constraint following: ;;(set-logic qf_nra) ;; intentionally commented out (declare-const x real) (assert (= (* x x) 2.0)) (check-sat) (get-model) for z3 returns solution, there solution (irrational) in reals. understand z3 has own rational library, uses, instance, when solving qf_lra constraints using adaptation of simplex algorithm. on related note, there smt solver supports rationals @ input level? i'm sure it's possible define rational sort using 2 integers suggested nikolaj -- interested see that. might easier use real sort, , time want rational, assert it's equal ratio of 2 ints. example: (set-option :pp.decimal true) (declare-const x real) (declare-const p int) (declare-const q int) (assert (> q 0)) (assert (= x (/ p q))) (assert (= x 0.5)) (check-sat) (get-value (x

java - Basic Spring Web MVC Application using annotation -

my basic spring mvc web application doesn't work. created simple spring web maven project , deleted unnecessary code simplify it. then, added controller implementation , annotated in book have read recently. deployed sample application book , app have created. sample app works - mine not. when try acces url ...localhost.../app-name/start/basic/show tomcat server shows 404 error. there's code: basiccontroller in spring.app package @controller @requestmapping("/basic") public class basiccontroller{ @requestmapping("/show") public modelandview handlerequest(httpservletrequest arg0, httpservletresponse arg1) throws exception { map < string, string > modeldata = new hashmap < string, string >(); modeldata.put("message", "hello world!"); return new modelandview("showmessage", modeldata); } } app/src/main/webapp/web-inf/mvc-config.xml file: <?xml version=&qu

java - AudioTrack in MODE_STREAM has no sound -

Image
i've been stuck on problem days. i'm @ stage i'm trying working example build from, can't reach point. my question based on this example . i've included source (and solution) own code, , can see buffer being written to, no sound comes device. i'm struggling identify how debug further. package com.example.audio; import com.example.r; import java.io.ioexception; import java.io.inputstream; import android.content.context; import android.media.audioformat; import android.media.audiomanager; import android.media.audiotrack; import android.util.log; public class synth { private static final string tag = synth.class.getsimplename(); private audiotrack audiotrack; private context context; public synth(context context) { this.context = context; int minbuffersize = audiotrack.getminbuffersize(22050, audioformat.channel_out_mono, audioformat.encoding_pcm_16bit); audiotrack = new audiotrack(audiomanager.stream_music, 22050,

objective c - How to properly check iOS version controlling (from iOS 7.0) -

we developing project lot of functionality , module (call, chat, update feed , on). it's deployment target 7.0 latest. project has been developing since 2013. there lot of bugs , old code. project completed , ready release in app store. but finding difficulties while testing qa. ios changes many things according it's version. struggling check these changes in different versions. for example ios 8.3 facebook sharing have implemented own sdk. old slcomposeviewcontroller no more good. have take care of ios 8.3. i wondering if somehow can list of these ios versions apple make changes, easier check project installing ios version in iphone. think type of information find in developer site. if kind of information helpful us. thanks lot in advance. i asked similar question couple years ago (not saying duplicate!), , got - "read documentation carefully". unfortunately still remains true now, can tools out. for external libraries, recommend using eithe

javascript - JSON data type with inline datepicker (calendar) -

i'm developing web application while/for learning web development has calendar widget/portlet/sidebar thingy. used in-lined bootstraps datepicker.you can click on date , posts "date_event" == "date_clicked" (i'm using php mvc structure , mysql). on front. i got stuck trying dates on calendar highlighted if post exists day of month. used ajax , json post dates corresponding selected month, triggered datepicker.changemonth. nice json object (or it?) php function sent browser: calendar.php (controller) function events_per_month($time) { $date = explode("-", $time); $month = $date[0]; $year = $date[1]; $start = mktime(0, 0, 0, $month, 1, $year); $end = mktime(23, 59, 0, $month, date('t', $start), $year); $start1 = date('y-m-d h:i:s', $start); $end1 = date('y-m-d h:i:s', $end); echo json_encode($this->post_m->get_calendar($start1, $end1)); } post_m.php (model) function get_c