Posts

Showing posts from May, 2014

multithreading - Using AsyncTask to update UI in Android -

i'm trying use asynctask read 1000 lines sqlite. i'm using progressdialog show progress. working fine , when method onpostexecute() dismiss dialog , try update entire lines on main thread. dialog disappears ui takes lot update. during doinbackground() method, i'm filling tablelayout , return onpostexecute(). how can show progressdialog until main thread totally filled? private class filltable extends asynctask<void, integer, tablelayout>{ private file file; private progressdialog pleasewaitdialog; private context ctx; private int colcount; private int lincount; private scrollview scroolview; private sqlitedatabase db; private cursor cursor; public filltable(context context, string newquery){ ctx = context; scroolview = (scrollview)serviceactivity.this.findviewbyid(r.id.sv_service_vertical); file = new file(environment.getexternalstoragedirectory().getab

java - Auto Slideshow in JavaFX Pagination -

i've been using javafx lately, beginner, , have been impressed. @ moment i'm stuck trying set pagination slideshow automatically move slideshow forward every 5 seconds (and first slide continue when last slide reached). can 1 steer me in right direction here? @fxml public void slideshow(actionevent event) { // todo auto-generated method stub string[] photos = { "housestark.jpg", "housefrey.jpg", "housebar.jpg", "housebolton.jpg", "housegreyjoy.jpg", "houseaaryn.jpg", "houselannis.jpg", "housemart.jpg", "housereed.jpg", "housetully.jpg", "housetyrel.jpg", }; pagination p = new pagination(photos.length); p.setpagefactory((integer pageindex) -> { return new imageview(getclass().getresource(photos[pageindex]) .toexternalform()); }); stage stage = new stage(); stage.setscene

shell - How to display /proc/meminfo into Megabytes -

i want thank helping me related issue. know if cat /proc/meminfo display in kb how can display in mb ? want use cat or awk please. this convert kb lines mb : awk '$3=="kb"{$2=$2/1024;$3="mb"} 1' /proc/meminfo | column -t this version converts gigabytes: awk '$3=="kb"{$2=$2/1024**2;$3="gb";} 1' /proc/meminfo | column -t for completeness, convert mb or gb appropriate: awk '$3=="kb"{if ($2>1024**2){$2=$2/1024**2;$3="gb";} else if ($2>1024){$2=$2/1024;$3="mb";}} 1' /proc/meminfo | column -t

node.js - How can I run an npm script for an AWS Elastic Beanstalk Deployment? -

my package.json has: "scripts": { "start": "node_modules/.bin/coffee server.coffee", "test": "node_env=test node test/runner.js", "coverage": "node_env=test coverage=1 node test/runner.js -r html-cov test/ > ./test/coverage.html", "testw": "fswatch -o test src | xargs -n1 -i{} sh -c 'coffeelint src server.coffee ; npm test'", "db:drop": "node scripts/drop-tables.js", "encryptconfig": "node_modules/.bin/coffee config/encrypt.coffee", "decryptconfig": "node_modules/.bin/coffee config/decrypt.coffee", "postinstall": "npm run decryptconfig" }, when deploy elastic beanstalk, i'd run postinstall , apparently doesn't that. okay, no problem. i created file called .ebextensions/00.decrypt.config has: commands: 00-add-home-variable: command: sed -i 's

plot - Mathematica - Create a custom plotter from regularly used code -

i've been searching web past hours trying find way implement routine/function in mathematica plotting. i've written code needs 2 dimensional field, say: dx/dt = x-x^2 dy/dt = y-y^2. what here on solve fix points , numerically integrate few trajectories , plot them together... now question can somehow compose code function in matlab? i've been researching concepts of module, , block seems impossible me return plot. so clarification want able write function takes argument field, , returns plot of field me ( customised trajectories fix points etc.. customplotfield[dxdt,dydt] := ............ since lot of stuff plotting, code pretty large copy pasting chunks of code plots i'm doing regularly feels bit annoying. thanks in advance! as far can tell, on right track looking @ modules: https://reference.wolfram.com/language/tutorial/modulesandlocalvariables.html to return plot evaluate last expression in body of module. or use explit return. ht

How much of the iOS filesystem is accessible without root access or a jailbreak? -

i wondering how far sandboxed user can dig filesystem on ios operating system, sandbox escape exploit, of course. aware capable of accessing documents folder of specific sandboxed app , possibly other folders or files within app. question here capabilities sandbox exploit have exactly? how of filesystem can viewed, edited, and/or written said exploit?

select - Selecting rows or columns with data.table R? -

imagine have data.table, example: library(data.table) rrr <-data.table(1:15,runif(15),rgeom(15,0.5),rbinom(15,2,0.5)) v1 v2 v3 v4 1: 1 0.33577273 0 0 2: 2 0.66739739 2 1 3: 3 0.07501655 0 0 4: 4 0.43195663 2 1 5: 5 0.39525841 3 2 6: 6 0.15189738 1 1 7: 7 0.02637279 0 1 8: 8 0.44165623 0 1 9: 9 0.98710570 2 0 10: 10 0.62402805 1 0 11: 11 0.84829465 3 2 12: 12 0.02170976 0 1 13: 13 0.74608925 0 2 14: 14 0.29102296 2 0 15: 15 0.83820646 1 1 how can data.table it, rows contain "0" @ column? (or value) if had single column use: rrr[v4==0,] v1 v2 v3 v4 1: 1 0.33577273 0 0 2: 3 0.07501655 0 0 3: 9 0.98710570 2 0 4: 10 0.62402805 1 0 5: 14 0.29102296 2 0 but if want columns @ once because have many? this doesn't need. rrr[,sapply(rrr,function(xx)(xx==0)), with=true] v1 v2 v3 v4 [1,] false false true true [2,] false false false false [3,] false fa

php include template failed on ubuntu+apache+php -

Image
if ran template locally, template code can expand properly <html> <head> <? include $template ?> </head> <body> <div id="chart_div"></div> </body> </html> however if ran apache+php, failed expand. i checked error.log under /var/log/apache2 cannot find error message related template/php file. on local pc (osx), php version 5.5.20 on apache, php version is: $ dpkg -s php5 package: php5 status: install ok installed priority: optional section: php installed-size: 29 maintainer: ubuntu developers <ubuntu-devel-discuss@lists.ubuntu.com> architecture: version: 5.5.9+dfsg-1ubuntu4.5 depends: libapache2-mod-php5 (>= 5.5.9+dfsg-1ubuntu4.5) | libapache2-mod-php5filter (>= 5.5.9+dfsg-1ubuntu4.5) | php5-cgi (>= 5.5.9+dfsg-1ubuntu4.5) | php5-fpm (>= 5.5.9+dfsg-1ubuntu4.5), php5-common (>= 5.5.9+dfsg-1ubuntu4.5) where should start investigate problem? i have 0 exposure php before.

wildfly - CDI typesafe resolution is not working in weld 2.2.6 when the the bean type parameter is a type variable -

the following code snipset works "weld-core-1.1.5.as71.final.jar" (the 1 used jboss 7.1.1), doesn't work "weld-core-impl-2.2.6.final.jar" (the 1 used wildfly 8.2). public class client<t> { public interface spi<t> { t getsomething(); } @inject private spi<t> spi; // weld-001408: unsatisfied dependencies type spi<object> } public class spiimpl implements client.spi<integer> { @override public integer getsomething() { return 5; } } why? cdi 1.2 specification: a parameterized bean type considered assignable parameterized required type if have identical raw type , each parameter: the required type parameter , bean type parameter actual types identical raw type, and, if type parameterized, bean type parameter assignable required type parameter according these rules, or the required type parameter wildcard, bean type parameter actual type , actual type assignab

javascript - Retrieving an element nested within another element using id -

i have following code parses html markup dom object. var html_str = '<div id="body-wrapper">\ <div id="container-1">\ <p>this first container - line 1</p>\ <p>this first container - line 2</p>\ <p><img src="assets/img/pull_1.jpg"></p>\ </div>\ <div id="container-2">\ <p>this second container - line 1</p>\ <p>this second container - line 2</p>\ <p>this second container - line 3</p>\ <p><img src="assets/img/pull_2.jpg"></p>\ </div>\ <div id="container-3">\ <p>test</p>\ <p><img src="assets/img/pull_3.jpg"></p>\ </div>\ </div>'; var elem_obj = document.createelement("div&qu

sockets - Python TCP Relay/Proxy Server locking up -

i have simple python proxy server i've setup. purpose take tcp stream (video) , forward tcp stream several clients (currently testing 1 start). works great until try forward (o.send(data)) data , receive/send couple packets, freeze , minute or 2 later receive/send few more packets , freeze again. if take incoming data , load variable doesn't slow down @ all. , if both load incoming data data variable send random block of data client instead of received data doesn't freeze. feel maybe there race condition or .recv() shouldn't block don't know deadlock coming from. data flled recv, should able send right? , rinse/repeat indefinitely. can check cpu utilization top -bn1 , python script doesn't appear using cpu @ all. the deadlock happens between .recv() , .send(). if put in debug print it'll print "data received!" ..... pause ... "data sent!" "data received!".... import socket # listen gstreamer tcp stream

c# - Is there any way that Client responses Server in SignalR? -

my server side code: var _identity = connectedusers.firstordefault(aa => aa.serverid == serverid); var rsp = clients.client(_identity.connectionid).rcvsendtouser(message); my client side code: _hub = connection.createhubproxy("testhub"); connection.start().wait(); _hub.on("rcvsendtouser", x => console.writeline(x)); when client receives message , possible client response string value server side? if possible, how modify code on both? one way add new method in server side hub , call client. add method hub in server: public void acknowledgeserver(string ack) { // stuff. } and modify client code little bit: _hub.on("rcvsendtouser", x => { console.writeline(x); // call server method string value. _hub.invoke("acknowledgeserver", "your string server") });

C# Add WPF button to Windows Form -

i found background of wpf button can transparent, window form button can't. have tried many methods found doesn't work. however, possible make wpf button in windows form? it possible use wpf-elements in windows-forms-applications. add reference windowsformsintegration.dll in project, enables use elementhost. can create wpfcontrollibrary containing transparent button , use in elementhost in form.

php - Download url content using file-get-contents -

i trying content client's website , upload website after processing. i trying use file_get_contents obtain content in php environment. if use: file_get_contents("http://www.maideden.com/index.php?route=product/product&path=59&product_id=96") i able content. however, if use variable store address like $url = "http://www.maideden.com/index.php?route=product/product&path=59&product_id=96" and use file_get_contents($url); did not return anything. can me on this? prefer use file_get_contents($url)

ios - Xcode 6.3 Storyboard Autolayout Constraints -

Image
this storyboard: this ipad simulator: for constraints go bottom right , click on button has triangle 2 extruding bars (it sort of looks star wars fighter triangle cockpit). scroll down section says view in view controller click on clear constraints. go same button time click add missing constraints. why happening? how can fix it? adding missing constraints doesn't mean "add constraint think better in project". xcode adds constraints keep in place, may (or may not) want. to paint control in place without ambiguity need @ least 4 constraint, 2 on each axe (two x, 2 y). recommend clear constraints, , start control control, adding constraints. some tips: you can set constraints, move control, ask xcode refresh constraints new position update constraints option. update frames option opposite: given set of constraints, repaints control in right position. use assistant editor split xcode view, can select preview , have while designing s

javascript - Calculating price from selected options in jquery -

my html code : <select class="form-control b3 pricing" name="b3"> <option data-price="0" data-cheap="0">0</option> <option data-price="20" data-cheap="30">1</option> <option data-price="40" data-cheap="60">2</option> <option data-price="60" data-cheap="90">3</option> <option data-price="80" data-cheap="120">4</option> <option data-price="100" data-cheap="150">5</option> </select> my jquery code : $(document).ready(function () { var cheap=false; $('.day1').on('change', function (e) { var optionselected = $("option:selected", this); var valueselected = optionselected.val(); if(valueselected=="saturday") { cheap=true;

java - Which page to make isThreadSafe=false in jsp -

i working database project developed using jsp,servlet. erp project having more 20 users. boss told me use multi-theading in project. please tell me how make decision of pages should muti-threaded , should not. java multi-threading in jsp not valid argument such because @jbnizet said, web container handles multithreading you. what can though use multi-threading in cases have code can run asynchronously. lets assume have scenario : obj1 = obj2.getvalfromdb(obj3.getsessionid(obj4.getid())); in this, multi-threading cannot used because tasks have executed sequentially in order result. single thread need... but in example below... val = getvalfromdb()+getvalfromsrc1()+getvalfromsrc2(); the sub-results can calculated in separate threads. so, have make evaluation of code , use multi-threading appropriately. as isthreadsafe directive in jsps, thing can disable multi-threading (which opposite looking for). specification says: the use of singlethreadmodel i

java - Jsoup - seprate all url while download text of a page -

how can use in jsoup remove link while downloading webpage. i use following code give me text of webpage public static void url(string urltosearch) throws ioexception { url = urltosearch; document doc = jsoup.connect(url).get(); string textonly = jsoup.parse(doc.tostring()).text(); output ob = new output(); ob.write(textonly); } but there way through can separate link while downloading text of page how can use in jsoup remove link while downloading webpage you can select a elements href attribute , remove document object representing dom structure of page. so code can document doc = jsoup.connect(url).get(); doc.select("a[href]").remove();//remove found `<a href...>` elements dom string textonly = doc.text();//generate text dom without links

php - Regex to remove links surrounding images -

i have page of images wrapped links. want remove links surrounding images, keep image tags in tact. eg. have: <a href="something.html" alt="blah"><img src="image1.jpg" alt="image 1"></a> and want: <img src="image1.jpg" alt="image 1"> i tried code found in research, leaves stray </a> tag. $content = preg_replace( array('{<a(.*?)(wp-att|wp-content\/uploads)[^>]*><img}', '{ wp-image-[0-9]*" ></a>}'), array('<img','" />'), $content ); i have no idea when comes regular expressions can please fix code? :-) by provided regex seems using wordpress , want remove hyperlinks content. if using wordpress can use hook remove hyper links on images content. add_filter( 'the_content', 'attachment_image_link_remove_filter' ); function attachment_image_link

android - ORMLite get single database column -

i'm trying use sql command ormlite: select address receive with code: list<receivers> receiver_address = receiverdao.querybuilder().selectcolumns("address").query(); but object returned is: 1 = {receivers@830028192208} address = {string@830028192264} "my new address" city = null email = null telephone = null mobile = null name_family = null national_code = null postal_code = null receiver_name = null id = 2 i need address field in query without iterator such as: list<string> list = new arraylist<string>(); for( receivers lst:receiver_address) list.add(lst.getaddress()); how action? you can use rawrowmapper here: list<string> addresses = receiverdao.queryraw("select address receive", new rawrowmapper<string>() { @override public string maprow(string[] columnnames, string[] resultcolumns) throws sqlexception { return resultcolumns[0]; } }).getre

Regex to extract first part of string in Apache Pig -

i need extract post code district input data below ab55 4 dd7 6ll dd5 2hi my code a = load 'data' postcode:chararray; b = foreach { code_district = regex_extract(postcode,'<some exp>',1); generate code_district; }; dump b; output should like ab55 dd7 dd5 what should regular expression extract first part of string? can try below regex? option1: a = load 'input' postcode:chararray; code_district = foreach generate regex_extract(postcode,'(\\w+).*',1); dump code_district; option2: a = load 'input' postcode:chararray; code_district = foreach generate regex_extract(postcode,'([a-za-z0-9]+).*',1); dump code_district; output: (ab55) (dd7) (dd5)

php - How to get Submit Button Values in Controller/Action Yii2 -

i'm new in yii2 framework. want submit button name/value in controller/action. following code: form: <?php $form = activeform::begin(); ?> <?= $form->field($model, 'admin_document_key_id')->dropdownlist(arrayhelper::map(admindocumentkey::find()->all(), 'id', 'key_name'), ['prompt' => 'select']) ?> <?= $form->field($model, 'key_value')->textinput(['maxlength' => 255]) ?> <div class="form-group"> <?php if (yii::$app->controller->action->id == "create"): ?> <?= html::submitbutton('create & add new', ['class' => 'btn btn-primary']) ?> <?php endif; ?> <?= html::submitbutton($model->isnewrecord ? 'create' : 'update', ['class' => $model->isnewrecord ? 'btn btn-success' : 'btn btn-primary', 'value'=>'cr

environment variables - Working in separate prefix in Linux -

i'm downloading on open source linux tool , trying build it. the build guide says need work in separate prefix avoid corrupting system. have created my_prefix dir , written setup-env file in it, follows : setup-env project=~/my_prefix export path=$project/install/bin:$path export ld_library_path=$project/install/lib:$path export pkg_config_path=$project/install/lib/pkgconfig:$pkg_config_path export ac_local_flags="-i $project/install/share/aclocal $aclocal_flag" after source setup-env now whenever install new tool using, sudo apt-get install, should go new install dir, getting updated in /usr/bin only. any idea reason?

ios - Catch push notification text on lock screen -

how can push notification text when app not run or in lock screen? i did try: func application(application: uiapplication, didreceiveremotenotification userinfo: [nsobject : anyobject], fetchcompletionhandler completionhandler: (uibackgroundfetchresult) -> void) { println(userinfo) // or println("something") } but doesn't print me anything. wrong function??? didreceiveremotenotification function called condition. while app running , app in foreground.(alert not showing) if app in background , click notification on home screen if app not run in device didreceiveremotenotification function not called, in case user click notification in home screen, identify app launched notification or not in didfinishlaunchingwithoptions uilocalnotification *localnotif =[launchoptions objectforkey: uiapplicationlaunchoptionsremotenotificationkey]; you userinfo data in localnotif.userinfo try in swift func application(application: uiapp

java - AndroidStudio can't find CSV file. Tried Absolute File Path & Relative File Path -

i've created simple android app displays text user. now i'm attempting implement csvreader retrieve text csv file. after hours of trying different things. i implemented open source csvreader (at least it's not giving me compile errors anymore). now when run app, crashes , "file not found" exception. either i'm not placing csv file in correct location, i'm not referencing correct file path, or both. i've tried using absolute file path (ex. starting c:/users/tim/androidstudioprojects/... ). i've tried using relative path starting assets folder (ex. "assets/social_posts.csv" ) , nothing i've tried has worked. i've tried looking similar questions on stack overflow, , i've tried several variations of file paths , nothing has worked far. think should try next? here link project on github. the code pointing csv file under app > src > main > java > com > example > tim > inspiredques

r - Error - replacement has [x] rows, data has [y] -

i have numeric column ("value") in dataframe ("df"), , generate new column ("valuebin") based on "value." have following conditional code define df$valuebin: df$valuebin[which(df$value<=250)] <- "<=250" df$valuebin[which(df$value>250 & df$value<=500)] <- "250-500" df$valuebin[which(df$value>500 & df$value<=1000)] <- "500-1,000" df$valuebin[which(df$value>1000 & df$value<=2000)] <- "1,000 - 2,000" df$valuebin[which(df$value>2000)] <- ">2,000" i'm getting following error: "error in $<-.data.frame ( *tmp* , "valuebin", value = c(na, na, na, : replacement has 6530 rows, data has 6532" every element of df$value should fit 1 of which() statements. there no missing values in df$value . although if run first conditional statement (<=250), exact same error, "...replacement has 6530 rows...&qu

MySql BigQuery with IN(1,3,8...N) optimization -

we have mysql database large table(30000000 rows) banner are. have query such as: select * banner banner.id in (1,3,8...n); the problem number in in large result in slow query. i want separate number groups query, e.g. 1000 each group is method? or other optimization?

python - Why only 1024 bytes are read in socketserver example -

i reading through documentation examples python socketserver @ https://docs.python.org/2/library/socketserver.html why size specified 1024 in line self.request.recv(1024) inside handle method. happens if data sent client more 1024 bytes ? better have loop read 1024 bytes until socket empty ? have copied example here : import socketserver class mytcphandler(socketserver.baserequesthandler): """ requesthandler class our server. instantiated once per connection server, , must override handle() method implement communication client. """ def handle(self): # self.request tcp socket connected client self.data = self.request.recv(1024).strip() # why 1024 bytes ? print "{} wrote:".format(self.client_address[0]) print self.data # send same data, upper-cased self.request.sendall(self.data.upper()) if __name__ == "__main__": host, port = "localhost&

android - Hide button while EditText is empty (Design Principles) -

what im wondering is, should hide "continue" button while edittext empty? there principle not recommending that? alternative solution popping error dialog warning user enter text. thanks. it better use text validator, user click continue, popup appear near text , show going wrong field. it may similar this: edittextvalidator

c++ -fpermissive error while implement callback in c++ -

class caller{ private: callbackinterface &m_cb; public: caller(callbackinterface& cb):m_cb(cb){}; doesn't give -fpermissive error whereas following gives. why so? class caller{ private: callbackinterface &m_cb; public: caller(callbackinterface& cb){ m_cb=cb; }; a reference variable should initialized when declaring. member variable constructed in constructor, should in initialization list . if trying initialize member reference variable inside constructor, assignment variable should have been defined. so code has issues in 2 fold reference variable not initialized when defined reference variable assigned once has been defined inside constructor.

hadoop - log file parsing in hcatalog regex or serde -

i pretty new hadoop. i trying load log file hcatalog. following format of log file. time: 2014-10-28 06:32:34z userid: arun groupid: admin page: welcome.aspx message: login successful time: 2014-10-28 06:32:34z userid: arun groupid: admin page: main.aspx message: menu load .. .. do need write serde parse or can achieved via regex? i belive load external log files hive tables wherein hive metastore managed hcatalog service. if so, first analyze source log records fixed delimiter hive parse records required n number of columns, tab (\t) char help. the next option achieving column parsing source log records using hive regexserde class relevant regular expression. if regex parsing not feasible other option create custom hive serde class parse source log file records . of custom serde class, hive able fit delimited cells relevant columns of hive external table. please refer, http://docs.aws.amazon.com/gettingstarted/latest/emr/getting-started-emr-load-data.ht

mysql - How to order SQL results with year and date? -

i have written postgresql query retrieves month,year , corresponding count. query looks like: select (case when extract(month app_pgm_req_dt) = 01 'january' when extract(month app_pgm_req_dt) = 02 'february' when extract(month app_pgm_req_dt) = 03 'march' when extract(month app_pgm_req_dt) = 04 'april' when extract(month app_pgm_req_dt) = 05 'may' when extract(month app_pgm_req_dt) = 06 'june' when extract(month app_pgm_req_dt) = 07 'july' when extract(month app_pgm_req_dt) = 08 'augst' when extract(month app_pgm_req_dt) = 09 'september' when extract(month app_pgm_req_dt) = 10 'october' when extract(month app_pgm_req_dt) = 11 'november' when extract(month app_pgm_req_dt) = 12 'december' end) month ,extract(year app_pgm_req_dt) year,count(*) app_pgm_choice group month,year order year as results ordered month , year, ordering month in alphabetical order , want ordered in actual month

python - Django with multiple subdomains - sometimes renders incorrect template -

bizarre: i have 2 domains: www.domain.com app.domain.com both individual settings.py, urls.py, , wsgi.py files (set this: http://michal.karzynski.pl/blog/2010/10/19/run-multiple-websites-one-django-project/ ) sometimes--maybe 30% of time--everything works fine. when visit www.domain.com, have pages such /login, /contact, /join. it's standard django site. app.domain.com single page app, urls file looks this: from django.conf.urls import include, url .app_views import index urlpatterns = [ url(r'^.*$', index, name='app'), ] so, time user visits app.domain.com or app.domain.com/foo or app.domain.com/anything, want render index function. now, sometimes, i'll visit app.domain.com, , www.domain.com template rendered. not that, i'll have urls such app.domain.com/login or app.domain.com/contact weird! even stranger, if go www.domain.com, app.domain.com index template rendered! if refresh page few times, correct page, seems random ,

find 'name' not the value of variable that holds maximum value matlab -

assume have 30 variables, looking way find value hold biggest value. need 'name' of it, not value of it. example: i1=10 i2=12 i3=14 i4=90 i5=5 i6=90 how can code function return 'i4' , 'i5'. not return 90. one way first find maximum comparing each variable can find out name of variable. but, not efficient if have lot of variables. has idea? in advance. it's better use cell arrays sort of thing, anyway this: names = who('-regexp', 'i[0-9]+'); values = cellfun(@eval, names); maxvalue = max(values); maxnames = names(values == maxvalue)

ruby on rails - How to stub HTTP POST request in rspec? -

i have controller contains method , conditional statements. following sample of controller. class <controllername> < applicationcontroller def method if params["c"] http = net::http.new(uri.host, uri.port) req = net::http::post.new("api_url_here") response = http.request(req) array = json.parse(response.body) url = params["s"] ..... elsif params["e"] ..... else ..... end end end i wrote rspec above controller it "should something" array ="some array values" :method, {"c" => "value c", "s" => "value s"} expect(response).to have_http_status(200) end i know above rspec method wrong. when case runs value array , response obtained post call inside method , response httpbadrequest expected. what want is to stub values array , response in spec case(these values needed later operations) , spec case not call http::po

asp.net - Is there any way to clear cache from server farm? -

i have implemented outputcache in application , works fine, since have specified location server, , applications runs in server farm (2 servers) , when clear cache, clears 1 server @ 1 time. have thought specifying server location (hardcode), cache stored @ 1 place , can cleared when have to. so, there way hardcode server name location attribute in outputcache? or webconfig file? declaration in webconfig <system.web> <caching> <outputcachesettings> <outputcacheprofiles> <add name="cache10minutes" duration="300" location="server" varybyparam="none"/> </outputcacheprofiles> </outputcachesettings> </caching> definition in related page (page header) <%@ outputcache cacheprofile="cache10minutes" duration="300" location="server" varybyparam="none"%> to clear cache on button click httpruntime.un

constraints - Odoo restrict delete of record that is still referenced (m2m) -

i have field: range_application_ids = fields.many2many('insurance.commission.rule.range.application', 'application_rule_range_rel', 'rule_range_id', 'application_id', 'applications', ondelete='restrict', required=true) i need restricts delete of models ( insurance.commission.rule.range.application ) records if referenced through many2many relation. if go models records list , delete of it, odoo won't throw warning , lets me it. when got models record has relation insurance.commission.rule.range.application through many2many field, see removed (and field required). setting ondelete='restrict' did not anything. is there way restrict such deletes odoo standard functionality or need implement such checking myself? now implemented such constraint myself, if know how using standard methods, please post answer. here code (it goes in insurance.commission.rule.range.application model (or class in other words):

perl script to print square of numbers side by side? -

i want print numbers 1 10 , print square of side side. script wrote for (1..10) { print $_,"\n" } this printing 1 through 10 want know how square , print side side. have tried using exponential operator don't know how implement , print side side. as understand question correct, should solve problem for (1..10) { print $_." ".($_*$_),"\n" }

algorithm - All permutations of n numbers in depth first manner -

how can generate permutations (order matters) replacements , order matters set of n numbers, contain m elements in each combination? i don't want use more memory, generate combination, want use it. first, note if order matters , replacements allowed, have n options choose each element ( m of those) - , amount of choices have remains constant. this means have n*n*...*n = n^m possible combinations. to generate them, can use recursion: python code: (if don't know python, read pseudo code, it's pretty clear). def generateall(numbers, m, currentpermutation=[]): if m == 0: dosomething(currentpermutation) return x in numbers: currentpermutation.append(x) generateall(numbers, m-1, currentpermutation) currentpermutation.pop() for example, if define def dosomething(l): print str(l) and run generateall([1,2,3], 4) output print combinations repalcements, order matters, of size 4 [1,2,3]: [1, 1,

outlook - Change in MS .cfg script -

i have found article on howto-outlook website (by robert sparnaaij) instructions how show sender's e-mail address column in outlook's message view. same thing, showing recipient e-mail address in own column. can advise how edit robert's viewsenderaddress.cfg file (downloaded http://www.howto-outlook.com/howto/viewsenderaddress.htm ) work recipient, rather sender, address? in advance. nb - cfg file stands: designerruntimeguid={0006f020-0000-0000-c000-000000000046} clsid={00020d31-0000-0000-c000-000000000046} displayname=sender's email address category=standard subcategory=form comment=this form used expose sender's email address in view. largeicon=ipml.ico smallicon=ipms.ico version=1.0 versionmajor=1 versionminor=0 locale=enu hidden=1 owner=www.howto-outlook.com composeinfolder=1 [platforms] platform2=ntx86 platform9=win95 [platform.ntx86] cpu=ix86 osversion=winnt3.5 [platform.win95] cpu=ix86 osversion=win95 [properties] property01=senderemailaddress

asynchronous - OnItemClick listener selects multiple rows in async filled list android -

i have list filled contacts. load contacts in list async class. in list class have setonitemclicklistener implemented. in setonitemclicklistener place selected contact in array can sent text them. working dream. but there small problem. when selecting contact in list there multiple contacts selected this: -normal contact- -selected contact- -normal contact- -normal contact- -normal contact- -normal contact- -selected contact- i load contacts code: @override protected void onpostexecute(arraylist<list_item_person> contacts) { // todo auto-generated method stub super.onpostexecute(contacts); pd.cancel(); personlistadapter adapter = new personlistadapter(getactivity().getapplicationcontext(), r.layout.list_item_person, contacts); list.setadapter(adapter); } this async class and onclick this: list.setonitemclicklistener(new adapterview.onitemclicklistener() { @override p

javascript - Wow + jquery + animate div shows on load and then appear again -

i using jquery + wow + animate appearing div animations on page. working except page not loading smoothly. divs should appear smoothly first appear on page load, hide , after appear animation. please check www.pester.rs , see problem, have tried nothing works. it loading order issue - first, browser downloads document , display it. later when loads entire javascript hides content provide nice animation. think it's affected internet connection speed. solution 1 : hide content css load hidden cons: if javascript crashes, content stay hidden solution 2 : place code @ end of body, before other scripts loaded (before other script tag) var wows = document.getelementsbyclassname('wow') (i = 0; < wows.length; i++){ wows[i].style.visibility ='hidden'; } it executed right after page loading before jquery , should fast enough. solution 3 : use inserted css file head of document suggested there http://robertnyman.com/2008/05/13/how-to-hide-and-sh

azure sql database - Is there a way to rewrite EXCEPT statements into NOT IN statements in SQL? -

i'm few weeks learning sql, , finished problem on homework assignment using in , not in. managed correct answer, however, used except clause, aren't allowed use yet. can tell, except , not in similar statements in sql, can't understand difference is. here's general format of query: select * table x in ( select x /* ... subquery*/ except select x /* ... other subquery*/ ) is there way rewrite general query without using except statement? how except , not in differ each other in general? edit: this other post seems have information, seems focus on exists , not in, have different purposes don't they? this might understand difference between except , not in except operator returns distinct rows left hand side table not exist in right hand side table. on other hand, "not in" return rows left hand side table not present in right hand side table not remove duplicate rows result.

Why are the types different in Java variable declarations? -

this question has answer here: arraylist or list declaration in java 10 answers what purpose of specifying different types on left , right side in java variable declarations? for example, code standard: list<string> l = new arraylist<>(); why don't: arraylist<string> l = new arraylist<>(); or object l = new arraylist<>(); // silly example shows 2 extremes this list<string> l = new arraylist<>(); allows instantiate types of list , arraylist or linkedlist of string . can use methods of list arraylist<string> l = new arraylist<>(); can instantiate arraylist of string . object l = new arraylist<>(); cannot use list methods.

c# - WCF and IIS performance spawning thousands of tasks using Task Parallel library -

my scenario: a user login triggers wcf-server kicks off 20 async-tasks . each separate task (named job in code) calling external soap-services. 1 000 simultaneous users logging in, means 20 000 async tasks. must call services in batches (due external limitations), fetch paged data - allowed in parallel. every 1 of 20 tasks spawns 10 tasks of own, mean 400 tasks per individual login - 400 000 tasks 1 000 simultaneous logins. my 2 questions: how impact our iis , server performance? understand tasks queued , run in parallell if possible - there limits on recommended number of tasks? am using right approach in creating these tasks? running async (except waitall )? see code below: create tasks each service called foreach (var job in jobs) { task.factory.startnew(() => job.fetch()); } the job-class called above: public async void fetch() { var batchlist = await fetchbatches(); //saves list database mergeandsavebatchlist(batchlist); } private async

c# - In WPF is it possible to define a ControlTemplate for a UserControl inside the UserControl itself (without getting warnings/errors in VS)? -

i have usercontrol want show different control templates in parts of window. want keep these templates inside usercontrol (for better maintaining). here is: <usercontrol x:class="pruebasdewpf.myusercontrol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:pruebasdewpf" mc:ignorable="d" d:designheight="300" d:designwidth="300"> <usercontrol.resources> <controltemplate x:key="usercontroltemplate1" targettype="local:myusercontrol"> <grid> <rectangle fill="red"></rectangle> </grid> </controltemp

android - Null pointer exception: unable to parse the Json data. (null object reference) -

iam trying data url. have read lot of post regarding same question nothing works. please me out slove issue... ill post code below jsonparser.class import android.util.log; public class jsonparser { final string tag = "jsonparser.java"; static inputstream = null; static jsonobject jobj = null; static string json = ""; public jsonobject getjsonfromurl(string url) { // make http request try { defaulthttpclient httpclient = new defaulthttpclient(); //httppost httppost = new httppost(url); httpget httpget = new httpget(url); httpresponse httpresponse = httpclient.execute(httpget); httpentity httpentity = httpresponse.getentity(); string json = entityutils.tostring(httpresponse.getentity()); = httpentity.getcontent(); } catch (unsupportedencodingexception e) { e.printstacktrace(); } catch (clientpro

regex - How to extract only person A's statements in a conversation between two persons A and B -

i have record of conversations between 2 arbitrary persons , b. c1 <- "person a: blabla...something person b: blabla else person a: ok blabla" c2 <- "person a: again blabla person b: blabla else person a: blabla" the data frame looks this: df <- data.frame(id = rbind(123, 345), conversation = rbind(c1, c2)) df id conversation c1 123 person a: blabla...something person b: blabla else person a: ok blabla c2 345 person a: again blabla person b: blabla else person a: blabla now extract part of person , put in data frame. result should be: id person_a 1 123 blabla...something ok blabla 2 345 again blabla blabla i'm big fan of solving sort of problem in way gives access data (that includes person b's discourse well). love tidyr 's extract sort of column splitting. used use do.call(rbind, strsplit())) approach love how clean e