Posts

Showing posts from April, 2015

C++ multiple definition first defined here -

i'm typing out example program absolute c++ , keeps giving me error: /tmp/ccjfp4dm.o: in function `hashtablesavitch::hashtable::hashtable()': hashtableimp.cpp:(.text+0x0): multiple definition of `hashtablesavitch::hashtable::hashtable()' /tmp/cchuzlfl.o:hashtable.cpp:(.text+0x0): first defined here /tmp/ccjfp4dm.o: in function `hashtablesavitch::hashtable::hashtable()': hashtableimp.cpp:(.text+0x0): multiple definition of `hashtablesavitch::hashtable::hashtable()' /tmp/cchuzlfl.o:hashtable.cpp:(.text+0x0): first defined here /tmp/ccjfp4dm.o: in function `hashtablesavitch::hashtable::~hashtable()': hashtableimp.cpp:(.text+0x16): multiple definition of `hashtablesavitch::hashtable::~hashtable()' /tmp/cchuzlfl.o:hashtable.cpp:(.text+0x16): first defined here /tmp/ccjfp4dm.o: in function `hashtablesavitch::hashtable::~hashtable()': hashtableimp.cpp:(.text+0x16): multiple definition of `hashtablesavitch::hashtable::~hashtable()' /tmp/cchuzlfl.o:hash...

excel vba - VBA Proxy auto-configuration for http requests -

i need build client web api in vba , needs work behind proxy (with authentication). i've been looking @ winhttp.winhttprequest , msxml2.xmlhttp/serverxmlhttp classes. turns out that: xmlhttp automatically detects proxy settings provided through proxy.pac file (good) winhttprequest doesn't (bad) however, on other hand: xmlhttp automatically follows redirects, , there's no way of disabling behaviour (bad) winhttprequest doesn't (good) since i'd able have cake , eat it, there way automatic proxy configuration component such winhttprequest doesn't follow redirects blindly? the vba-web project might pastry eating problem. https://github.com/vba-tools/vba-web i guess wish go like: dim client new webclient client .baseurl = "https://www.google.com" .proxyusername = <user> .proxypassword = <password> .enableautoproxy = true end dim request new webrequest request .method = webmethod.httpget ...

c++ - Copy constructor invoked 2 times, not 3 as expected? -

here 1 program taken textbook featuring copy constructors: #include <stdio.h> #include <conio.h> #include <iostream> using namespace std; class point { private: int x,y; public: point(int ox =0, int oy =0) { cout << " make object" << << endl; cout << " using default constructor \n"; x = ox, y = oy; } point(const point &p) { cout << " make object" << << endl; cout << " using copy constructor \n"; x = p.x, y = p.y; } void move(int dx, int dy); void display(); }; point fct(point a); int main() { point a(5,2); a.display(); point b = fct (a); b.display(); getch(); return 0; } void point::move(int dx, int dy) { x += dx, y += dy; } void point::display() { cout << "coordinates :...

PHP script timing out -

i have script able run overnight collect data. goes through loop sleeps 2.5 minutes, after 18 iterations stops. believe these lines supposed keep terminating: ini_set('max_execution_time', 0); ignore_user_abort(true); set_time_limit(0); i have tried running script in firefox , internet explorer.

javascript - Location of the parse attribute on Ampersand.js model or collection -

on current project, using ampersand.js models , rest-collections. when wire api running trouble. api returns object this... { type: ..., multi: ..., data: <good stuff> } in order load data model or collection understanding need use parse. after going on docs seems should place parse in model. in practice though, when run fetch against collection, not load data models unless parse property on collection. however, when run getorfetch not load data unless parse property on model. nothing works if put parse in both model , collection. it doesn't make sense should have move it. need know suppose live, , need work. here model , collection: var case = model.extend({ ajaxconfig: function () { return { headers: { 'x-auth-token': 'testing' } }; }, parse: function (response) { return response.data; }, props: { id: 'string', orgid: ...

Android - URI Scheme - Stop from opening multiple instances of application -

i'm using custom uri scheme redirect user website application, when launching app, opens new instance instead of restoring open one. i have tried both using launchmode="singletask" or "singleinstance" don't seem affect it. <!-- splash. --> <activity android:launchmode="singletask" android:name=".activities.splash" android:label="@string/app_name" android:screenorientation="portrait" android:windowsoftinputmode="statehidden" > <intent-filter> <data android:scheme="customscheme" /> <action android:name="android.intent.action.view"/> <category android:name="android.intent.category.browsable" /> <category android:name="android.intent.category.default"/> </intent-filter> <intent-filter> ...

how to detect merged cells in c# using MS interop excel -

i want detect merged cells either in row/entire sheet(preferable).here code microsoft.office.interop.excel.application xl = new microsoft.office.interop.excel.application(); microsoft.office.interop.excel.workbook workbook = xl.workbooks.open(source); //microsoft.office.interop.excel.worksheet ws = (microsoft.office.interop.excel.worksheet)workbook.sheets[sheetnumber]; microsoft.office.interop.excel.worksheet ws = (microsoft.office.interop.excel.worksheet)workbook.worksheets[objinmemory._sheetname]; xl.screenupdating = false; ws.columns.clearformats(); ws.rows.clearformats(); int colcount = ws.usedrange.columns.count; int rowcount = ws.usedrange.rows.count; int strtrow = ws.usedrange.rows[1].row; int strtcol = ws.usedrange.columns[1].column; microsoft.office.interop.excel.range objrange = null; neither piece of code if (ws.cells.mergecells) { } nor piece of code(only row1) for (int j = strtcol; j < strtcol + colcount; j++) { objrange = ws.cells[strtrow, j]...

android - Retrieve data from a class in Parse.com -

i have class in parse.com, xyz, , has columns email, password, phone, age. have email , password combination , want check whether there such combination in class? how do this? i have class donate, , have been given email(e) , password(pw). here goes code: `parsequery<parseobject> query = parsequery.getquery("donate"); query.whereequalto("email", e); query.whereequalto("password", pw); query.findinbackground(new findcallback<parseobject>() { @override public void done(list<parseobject> list, parseexception e) { if (e == null) { toast.maketext(getapplicationcontext(), "success!!!", toast.length_long).show(); } else { toast.maketext(getapplicationcontext(), "something went wrong!!!...

javascript - AJAX and PHP/SQL Uncertainty over the location of a error -

i trying update element in array, , information, whatever reason, doesn't seem getting through. here javascript sends data: var xmlhttp = new xmlhttprequest(); if (window.xmlhttprequest) { // code ie7+, firefox, chrome, opera, safari xmlhttp = new xmlhttprequest(); } else { // code ie6, ie5 xmlhttp = new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { // nothing } } xmlhttp.open("get","updategame.php?q=" + str + "&e=" + recordtext,true); xmlhttp.send(); where recordtext declared elsewhere. and php recieves q , e : <?php $q = intval($_get['q']); $e = strval($_get['e']); $servername = "localhost"; $username = "*****"; $password = "*****"; $dbname = "*****"; // create connection $conn = new mysqli($servername, $username, $password,...

android - ADB Connect Error: Empty Host Name -

i used able connect android phone via adb fine. now, however, whenever try, "empty host name." i've researched question , advice can find "change net.hostname property on phone" (e.g. thread ). however, know it's not phone's fault because other computers can connect fine. it's computer can't anymore. (i'm using windows 8). i've tried shutting down, turning off wifi (and turning on), doing adb disconnect, kill-server, start-server, etc. none of works. haven't installed updates causing problem. thoughts?

microcontroller - Does chip select disables whole SPI slave or just the SPI lines of that Slave? -

i have doubt on spi slaves. when pull chip select line, disables whole slave ( functionality ) or communication module of slave. taking ex: if have spi adc. when pull slave , disable adc conversion process or spi lines of adc disabled conversion still in going on? i may wrong, research did while looking spi bus on avr mcu's, spi hardware in chip works independently of avr core. say, whether or not there data being transferred on spi bus, chip functionality shouldn't directly affected. i don't know electronics you're using, assume toggling chip-select has no effect on core function of peripherals. when in doubt, reference datasheet of slave device. may have useful insights on particular spi hardware. i hope helps.

Why javascript array element can't be accessed with dot notation? -

why it's not possible access array element dot notation? var arr = ['apple', 'mango', 'pineapple', 'orange', {name: 'banana', color: 'yellow'}]; console.log( arr[0] ); // "apple" console.log( arr.0 ); // "apple" console.log( arr.3 ); // "orange" console.log( arr[4].name ); // "banana" console.log( arr.4.color ); // "color" in other words, why language designers have chosen forbid identifiers starting number? because identifiers not allowed start numbers, , y in x.y identifier. why y in x.y identifier? no idea. ask language designers on appropriate mailing list or in ama session. i'd guess makes both language specification , interpretation wildly easier.

Did I miss anything with this $http.jsonp in angularjs? -

i know question has been asked several times, i'm not understanding if missed or it's server thing. need show code checking please: (function(){ var app = angular.module('c4s', ['ionic', 'starter.controllers', 'starter.services']); app.controller('curiousctrl', function($http, $scope){ $scope.stories = []; $http.jsonp('http://curious4science.com/?json=1&callback=json_callback') .success(function(response) { angular.foreach(response.data.children, function(child){ console.log(response); $scope.stories.push(child.data); }); }); }); app.run(function($ionicplatform) { $ionicplatform.ready(function() { if (window.cordova && window.cordova.plugins && window.cordova.plugins.keyboard) { cordova.plugins.keyboard.hidekeyboardaccessorybar(true); } if (window.statusbar) { // org.apache.cordova.statusbar req...

Regex PHP: get specific content from another website -

i'm writing php script fetch specific codes other site. all done , fetching div has class , showing on page. $title = '#\<div class="detailbox"\>(.+?)\<\/div\>#s'; preg_match($title, $page, $titles); echo $titles[0]; but when try fetch table shows nothing the content on other site this: <tr> <th scope="row">開催時間</th> <td>10:30~17:00</td> </tr> and i'm using code fetch it: $date = '#\<tr\><th scope="row"\>開催時間<\/th\><td\>(.+?)\<\/td\><\/tr\>#s'; preg_match($date, $page, $dates); echo $dates[0]; i have tried $date = '#\<th scope="row"\>開催時間<\/th\>#s'; , works not if add <td> in it. what i'm doing wrong? you need turn on unicode modifier u , match inbetween line breaks. $date = '#<tr>\s*<th scope="row">開催時間</th>\s*<td>(.+?)</td>...

java - Android calling two functions in a webservices -

in android application need call 2 functions in web service. need display both values in 1 page. when did 1 function working fine.. when tried second not working.. giving code below. class progresstask extends asynctask<string, string, string> { @override protected void onpreexecute() { super.onpreexecute(); pdialog = new progressdialog(r_details.this); pdialog.setmessage("verifying details... please wait..."); pdialog.setindeterminate(false); pdialog.setcancelable(true); pdialog.show(); } @suppresswarnings("deprecation") @override protected string doinbackground(string... args) { url = "https://xxx.xxxx.com/appservice/d_service.asmx/mdetails?"; url2 = "https://xxx.xxxx.com/appservice/d_service.asmx/mgodetails?"; sharedpreferences plnumber = getsharedpreferences(prefs_name, 0...

VirtualBox or Genymotion Emulator blocks program protocols through host's port proxy -

something blocks program protocols (for example, ftp) when connect through port proxy server (server_ip:port) started on genymotion android emulator. telnet connects server_ip:port successfully, browser or other programs, can't. direct connection, not through port proxy, works perfectly. i switched off firewalls , antiviruses ann anythig can block network data. scenario: 1) on emulator - start ftp server of es explorer (or other listening server) 2) on host's browser locate - ftp_:_//_emulator_ip_:_emulator_port 3) , operate emulator files on ftp. then make: 4) on host command line - netsh interface portproxy add v4tov4 emulator_port emulator_ip emulator_port 5) on host - telnet host_ip emulator_port or telnet 127.0.0.1 emulator_port 6) , telnet connected 7) on host's browser or other ftp-programms - ftp_:_//_host_ip_:_emulator_port_ or ftp_:_// 127.0.0.1 :_emulator_port or ftp_:_//_host_name_:_emulator_port 8) , cannot access ftp service ...

spring security - SpringBoot SpringSecurity ACL @PostFilter -

i using ... springbootversion = '1.2.4.release' springversion = '4.1.6.release' springsecurityversion = '4.0.0.m2' @configuration @enableglobalmethodsecurity(prepostenabled = true) @enablewebmvcsecurity @profile(elmprofile.has_authentication) public class securityxxx extends websecurityconfigureradapter { } application.java has appropriate @componentscan logging.level.org.springframework.security=trace problem: there strange behaviour ... there may post filter annotations defined on service interface , in logs shows detected annotation on service impl class instead !?. althought there many such methods on service interface 1 method detected yes service has @service annotation shown below : @validated public interface siteservice { @postfilter("haspermission(filterobject, 'read')") @notnull list<site> getsiteswithbins(); @postfilter("haspermission(filterobject, 'read')") @no...

numpy - Multiple regression with OLS in python -

i have code multiple ols-regression newey-west procedure. import pandas pd import numpy np import statsmodels.api sm df = pd.dataframe({'a':[1,3,5,7,4,5,6,4,7,8,9], 'b':[3,5,6,2,4,6,7,8,7,8,9]}) results = sm.ols(df.a, sm.add_constant(df.b)).fit() new = results.get_robustcov_results(cov_type='hac',maxlags=1) print new.summary() it works, how should change code, if have more variables like.... df = pd.dataframe({'a':[1,3,5,7,4,5,6,4,7,8,9], 'b':[3,5,6,2,4,6,7,8,7,8,9], 'c':[3,5,6,2,4,8,7,8,9,9,9], 'd':[3,5,6,2,5,8,8,9,8,10,9]}) ... , wanted analyse influence on variable a, analysis of variable b in original code? how should code-line results = sm.ols(df.a, sm.add_constant(df.b)).fit() looks like? thanks!! you can supply multiple variables this: results = sm.ols(df.a, sm.add_constant(df[list('bcd')])).fit()

python - Scrapy get all children / ignore <br>? -

i have piece of html , want extract text in 1 element scrapy. <td class="infooffre">rue de trazegnies 41<br>6031&nbsp; monceau sur sambre<br>belgique</td> when use xpath('.//td//text()').extract() 3 elements instead you want xpath string() function: >>> import scrapy >>> selector = scrapy.selector(text="""<td class="infooffre">rue de trazegnies 41<br>6031&nbsp; ... monceau sur sambre<br>belgique</td>""") >>> selector.xpath('.//td//text()').extract() [u'rue de trazegnies 41', u'6031\xa0\n monceau sur sambre', u'belgique'] >>> selector.xpath('string(.//td)').extract() [u'rue de trazegnies 416031\xa0\n monceau sur sambrebelgique'] >>> or can join() each text node: >>> " ".join(selector.xpath('.//td//text()').ext...

requirements - Type Error in Alloy specification -

in requirements engineering (2007) article, "requirement progression in problem frames", there worked example on traffic lights problem have transcribed alloy editor. unfortunately, following error when testing code. starting solver... a type error has occurred: must set or relation. instead, has following possible type(s): {primitiveboolean} the error triggered following predicate: pred lightunitbreadcrumb [] { t: time | ngobserve [t] <=> odd [ngpulse [t]] , sgobserve [t] <=> odd [sgpulse [t]] } referencing ngpulse predicate below: sig ngp, sgp, nrp, srp in time {} pred ngpulse [t: time] {t in ngp} pred sgpulse [t: time] {t in sgp} pred nrpulse [t: time] {t in nrp} pred srpulse [t: time] {t in srp} exactly. explain on page 137 of book why boolean not type in alloy.

performance testing - jmeter Root CA certificate alert repeatedly -

i trying record script jmeter test script recorder. added rootca certificate browser following steps ( http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf ) still when start record again giving me alert install root ca certificate, suggestions please help. thanks. if alert you're talking popup in jmeter pops when start recording there's nothing can it, jmeter doesn't know browser certificate install. note it's information popup, if did advises can ignore it

Excel VBA - Populate a column on one sheet with values from another sheet based on 3 criteria (complicated IF AND related VBA with wildcards) -

i new @ excel vba , despite efforts cannot seem find similar example online use solution issue. i creating table of data related inventory of automobiles. workbook have set has 2 tabs. first labeled "feeder", , contains table of hardcoded inputs (automobile values). second labeled "sheet1" , contains raw data inventory. sheet 1 requires automobile values in column "i". goal set workbook column labeled "values" within "sheet1", autopopulated click of button value inputs feeder sheet. tricky part (for me) values based on 1) automobile type (i.e. sedan/ pickup/ etc.), 2) color (different colors have different values), , 3) manufacture year. approaching @ first if , statement, thought creating macro more efficient route take. i have working list, many more automobile types go (400+ total). if @ thsi stage can [hopefully] figure out rest. your appreciated. screen shots here: feeder table , sheet1 inventory list my code: sub v...

angularjs - ng-repeat not working with set data structure -

i'm trying use ng-repeat field set in javascript https://developer.mozilla.org/es/docs/web/javascript/reference/global_objects/set . tried use values(), keys(), entries() method set ng-repat not working, know way, hack work? resumed code: function campaign () { this.site = { type : '', domains : new set() }; } controller: .controller('campaignstep1ctrl', ['$scope', 'languages', 'geolocationservice', function ($scope, languages, geolocationservice) { var vm = this; vm.campaign = $scope.campaign; } html: <tr class="ui-widget-content ui-datatable-empty-message" ng-repeat="domain in vm.campaign.site.domains"> <td colspan="2">{{domain}}</td> </tr> note: if use console.log() , print domains attribute, prints, think problem ng-repeat. this not best solution can make work this: view: <p ng-repeat="value in getsetasarr(...

hadoop - Download large volumes from S3 to Local Machine? - s3distcp -

currently using distcp slow, taking 4:16 minutes copy 1 hour's worth of logs, while custom function wrote me takes 16 seconds. given amazon provides s3distcp examples involving logs, thought give go , test performance. i know possible distcp possible use s3distcp on local machine copy large volumes of data (potentially 100gb+) onto hfs cluster on local machine without use of emr? amazon , subsequent tutorials , articles reference s3distcp abilities step in emr..

Standard method for HTTP partial upload, resume upload -

i'm developing http client/server framework, , looking correct way handle partial uploads (the same downloads using method range header). but, http put not intended resumed. , patch method, know, doesn't accept range header. is there way handle in http standard (not using extension headers or etc)? thanks in advance. i think there no standard partial uploads: content-range inside requests not explicitly forbidden in rfc2616 (http), wording refers response header gets used in response of range-request while use patch method update existing resource (e.g. add more bytes) not same partial upload, because time incomplete resource available if @ protocols of dropbox, google drive etc roll own protocol transfer single files in multiple chunks. need resumeable uploads a way address incomplete upload. normal urls address complete, not partial resource , know of no standard partial resources. a way find out current state of upload, maybe checksums of part...

ember.js - Class/model level property on ember-data -

how can create class level attribute or constant on ember-data? in addition, how call then? thanks! app.color = ds.model.extend({ color: ds.attr() }); app.color.reopenclass({ foo:4 }); alert(app.color.foo); http://emberjs.jsbin.com/lucemocoso/edit?html,css,js,output

jquery - scrollTop() if/else switchClass() animation for shrinking nav bar -

i use jquery ui method switchclass() because want have control on animation duration. 1 thing confused identifying classes in switchclass() methods. use '.' before 1 class not other? below code. is, it's not working. there more elegant solution this? $(document).ready(function(){ $(window).on("scroll touchmove", function () { var x = $(document).scrolltop(); if( x > 0 ) { $('.header').switchclass('header', '.header.tiny', 500); $('.logo').switchclass('logo', '.logo.tiny', 500); } else { $('.logo.tiny').switchclass('tiny', '.logo', 500); $('.header.tiny').switchclass('tiny', '.header', 500); }; }); }); https://jqueryui.com/switchclass/ you dont need '.' see: $(document).ready(function(){ $(window).on("scroll touchmove", function () { var x = $...

regex - Regular Expression to match word in the middle but at the end? (php is crashing :( -

i want find lines between label , return no line indent. example: mylabel: bla if(no) return else foo return if use last return other word. e.g. send works. $r1 = '^(\w[\w\d_]*:\s*\n((?!\nreturn).)*)(\n[^\s][^n]*\n)((((?!\nreturn).)*)\nsend)'; ; working regex but $r2 doesn't work. perl crashes. $r2 = '^(\w[\w\d_]*:\s*\n((?!\nreturn).)*)(\n[^\s][^n]*\n)((((?!\nreturn).)*)\nreturn)'; ; dont working regex here example in php testing $str = '^(\w[\w\d_]*:\s*\n((?!\nreturn).)*)(\n[^\s][^n]*\n)((((?!\nreturn).)*)\nreturn)'; $actual = preg_replace('/^'.$str.'/smi', "$1" . $indentstr . "$2$3", $actual); if not work use loop throw source code line. use prettyfy autohotkey source code tool: https://github.com/sl5net/sl5_ahk_refactor_engine your pattern complicated , uses "famous" trick: ((?!\nreturn).)* slow , doesn't prevent lot of backtracking if subpatterns after fail. you can wri...

javascript - Disable Jasmine's fdescribe() and fit() based on environment -

fdescribe() , fit() great reducing noise when you're working on subset of tests. forget change them describe() / it() before merging branch master. (it's okay have them in separate branch while working on code - i.e. pre-commit check wouldn't work me.) my ci environment codeship. there solution problem fail tests in codeship if came across focused methods? using no-focused-tests okay. idea how enable rule error in codeship , disable locally? using no-focused-tests okay. idea how enable rule error in codeship , disable locally? you use combination of environment variables , redefining fdescribe/fit global functions: npm --save cross-env package.json: "scripts": { "test": "jasmine", "test-safe": "cross-env focused_tests=off jasmine" }, disablefocusedtestsifnecessary.js (included after jasmine defines globals): if (process.env.focused_tests === "off") { console.log("focu...

java - Spring bean initializing dependencies with new keyword? -

i have legacy code class spring bean defined , initialized through xml. singleton field member class dependency. there setter method it, assuming supposed set via spring, although didn't find xml defining it. there get() method dependency, has null check , if null manually creates outside of spring so class test{ dependency d; setd(dependency d){this.d=d;} getd(){ if(this.d==null){ this.d = new dependency(); }return this.d } } i trying understand why spring bean initializing dependency outside of spring , implications if any, bad/old design? or not understanding how spring works. i it's bad design, author wanted provide fall-back case when d not injected in spring. idea attempt make d lazy dependency. should explore what's inside d. generally can use @required mark members should injected. or use simple , nice constructor injection. if you're concerned lazy injection, that's how spring works default. ...

MySQL: Finding id's in separate tables with identical groups of records -

i have 2 different tables of records having same sub groups of information, both having different id values. below example have table of actors movies , plays . i query these 2 tables such pair of movie_id , play_id values have same actors (i.e. have first_name = given_name , last_name = family_name each record same id ). what appropriate query accomplish this? table: movie_actors | movie_id | first_name | last_name | |----------+------------+-----------| | 1 | mary | johnson | | 1 | john | smith | | 2 | tom | anderson | table: play_actors | play_id | given_name | family_name | |----------+------------+-------------| | 23 | mary | johnson | | 23 | john | smith | | 31 | marc | anthony | desired output: | movie_id | play_id | |----------+---------| | 1 | 23 | use group_concat in subqueries actors single column. join subqueries based on this. select m...

android - Adding view/layouts in already inflated hierarchy in runtime? -

i wonder if bad practice add view view hierarchy in runtime inflated view. lets consider example. have following activity class hierarchy base activity - base activity include basic configuration lifecycle methods , without inflating layout(setcontentview). singleframgentactivity has setcontenview method in oncreate method. layout activity looks following c <?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <framelayout android:id="@+id/fragment_container" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </frame...

javascript - Mongoose find() call inside for loop using a latch -

i've been on hours , can't seem find answer. problem have call mongodb inside loop. i'm using latch waits call end before advancing again. here's code: var latch = true; (var i=0; i<array.length; i++) { while(latch == false){} table1.find({}, function(err, result){ ... code ... latch = true; }); latch = false; } the problem doesn't run callback table1.find(), gets blocked on while. can me this? the loop never proceed past while loop (as you've created infinite loop). there several ways handle async code within loops in node, including counter variables outside function, , tail-recursion. can see examples here: http://metaduck.com/01-asynchronous-iteration-patterns.html i big fan of https://github.com/caolan/async provides async.each applies iterator each element in parallel. suit purpose.

android - Function doing different things when being called the same way -

hello i'm having issue seems line of code ignored or giving different result every time. private void getcard() { switch (temp4) { case 1: system.out.println("ace"); valuetobestored = 11; break; case 2: system.out.println("ten"); valuetobestored = 10; break; case 3: system.out.println("two"); valuetobestored = 2; break; case 4: system.out.println("three"); valuetobestored = 3; break; case 5: system.out.println("four"); valuetobestored = 4; break; case 6: system.out.println("five"); valuetobestored = 5; break; case 7: system.out.println("six"); valuetobestored = 6; break; case 8: ...

javascript - What does this variable contain: var message = {}; -

this question has answer here: what curly braces in javascript mean? 10 answers does variable hold empty function? var message = {}; thanks! does variable hold empty function? no. doesn't hold empty function. this empty object. equivalent this var message = new object(); the syntax using curly braces called object literal. more formally, an object literal list of 0 or more pairs of property names , associated values of object, enclosed in curly braces ({}). for detailed explanation of object literals, please have here .

http - ServiceStack HEAD request ContentLength not getting set -

i using servicestack (4.0.31) mono , using raw streaming, means dto of form: [fallbackroute("/{path*}")] public class s3request : irequiresrequeststream{ public string path{ get; set; } public stream requeststream { get; set; } } i implement http request types: get, head, post, put, delete. need head respond defined in rfc 2616 says: "the head method identical except server must not return message-body in response. metainformation contained in http headers in response head request should identical information sent in response request." this should simple within servicestack, has proven difficult given understanding far. example, if try following, gives me want (for head request response): response.endrequestwithnocontent(); however not work because zeroes out content-length header field, not consistent rfc (and client). if not make call, when return servicestack iresponse after having set content-length, default xml in output, not consis...

binary tree - How to check if all leaves are positioned to the left side of the BinaryTree -

i've been breaking head on tasks lecturer posted prep exams. problem relative easy solve if weren't "own" take on definition of perfect binary tree. my task this: "check if given binarytree complete (complete = last level needs full and on last level leaves need @ left side of tree. write pointer implementation. below tree complete/perfect tree in definition. b c d e f nearly info on internet on perfect or full trees don't tackle specific requirement of " leaves need on left side". what i've done far write class total number of nodes in given tree , compare expected number based on perfect tree formula ( math.pow(2, depth)-1)) here code: private int numberofnodes =0; public void printlevelorder(){ linkedblockingqueue<binarynode<e>> stack = new linkedblockingqueue<binarynode<e>>(); binarynode<e> node = root; stack.offer(node); while( !stack.isempty()){ ...

Change HTML element's CSS style using java -

i using jsp create web page. need use java classes access data need pull website's json (this cannot change). say have code: <div class="fruit apple"></div> <div class="fruit banana"></div> //"fruit peach", "fruit orange", , on... style.fruit {display: none;} i need change html element using java, not javascript. in jsp file, in <% %> tag. <% var divclassineedtochange = "banana"; //some sort of java code equivalent to: //document.getelementsbyclass(divclassineedtochange).style.display = "block"; %> i cannot find line of java code equivalent above line. i hope you you can parse page using dom or sax parser. for example documentbuilderfactory factory=documentbuilderfactory.newinstance(); documentbuilder builder=factory.newdocumentbuilder(); document doc=builder.parse(new file(filename)); element e = doc.getelemetbyid(divclassineedtochange);

php - Preventing users from getting access to an admin login page -

currently setting admin login page php , how have set up. if user navigates website.com/admin, returns 404 error. way access admin login go website.com/admin?key=random-string. if key in url doesn't match key in database return 404 error. when key matches present admin login. i thought clever prevent getting access admin login screen, not experienced enough know if true. i thought clever prevent getting access admin login screen, not experienced enough know if true. do not try , defeat attacker trying outwit them. assume attackers clever are, , build security on model. make login , session management system provably secure instead. example: employ 2 factor authentication. use https along secure cookies , hsts. rate limit or lock accounts after number of failed logins. make sure not vulnerable session fixation. make sure not vulnerable user enumeration. checkout session management cheat sheet more pointers. also, don't use secrets in url...

makefile - Why doesn't GNU make output the execution of my command? -

i have gnu makefile target (simplified) looks this: determineversion: $(eval gitdescribe := $(shell git describe --dirty)) anothertarget: determineversion do-something $(gitdescribe) when run make anothertarget , works expected (i value of git describe passed do-something expected). however, see no output git describe command. assume because capturing output := operator? how can echo output part of expression? update 2015-07-13 : fixed code. sorry, missed out dependency anothertarget, crucial understanding question. if reformulate makefile such: gitdescribe := $(shell git --describe) determineversion: [tab]@echo "gitdescribe: '${gitdescribe}'" anothertarget: [tab]do-something ${gitdescribe} you'll successful. alternatively, determineversion: [tab]$(eval gitdescribe := $(shell git --describe)) anothertarget: determineversion [tab]do-something ${gitdescribe} might magic you're looking for.

r - Document a shiny application -

is there way generate documentation r shiny application? it becomes hard maintain shiny application without documentation. it seems eco-system of tests/documentation created r package structure. maybe can emulate/extend behavior shiny application? an example : a reactive expression typically r shiny element taht can contain complex data structure. filtered_dat <- reactive({ dx[ name == input$crr & tou == input$tou & plotyear == input$year. & plotmonth == input$season] }) to give more context, here in context of building complete web application using r shiny. business-logic wrapped in separated package(s). for testing ui think complicated ( 1 can use rselenium example) , generating doc roxygen2 comments parsing. should easy have such tool. it great question. how create complex clear web application shiny?i believe organize huge project weakness of shiny architecture. first, shiny creates web in 1 html document. do...

Sorting files with Google Drive API -

is there workaround sort files while uploading them? need specific filter files besides 4 standard ones in google drive. thought inserting dummy modifieddate files not available edited , sorting specific date name specify while uploading files. all files need sorting uploaded access , write metadata script wishes. i've seen feature has been requested haven't found viable answer or feature being implemented i'd appreciate or ideas. thanks.

android - Declare headless Fragment in layout XML? -

it possible declare headless fragment in layout xml? perhaps attribute tells inflater not expect view ? when try this: <fragment android:name="com.example.headlessfragment" android:id="@+id/headless_fragment" /> ...not entirely unexpectedly, crashes this: 07-08 15:41:32.441: e/androidruntime(5943): caused by: java.lang.illegalstateexception: fragment com.example.headlessfragment did not create view. no, can't when declare fragment in tag, saying: "the following fragment added id parent view." following statement, headless fragment added no parent view, not working. can have @ api add new fragment, need tag or container, , xml fragments make sense on second option. beside that, code , file economy, if want have fragment in xml, makes more sense new whateverfragment() layoutinflater.from(context).inflate(...);

Why does the SonarQube analysis fail through eclipse? -

each time launch project analysis in eclipse, following error in eclipse console. although 13:40:35.053 info - analysis successful in eclipse console think there's wrong. sonar version : 5.1.1 sonar eclipse plugin : 3.4.0 what can fix ? thank you. exception in thread "main" org.sonar.runner.impl.runnerexception: unable execute sonar @ org.sonar.runner.impl.batchlauncher$1.delegateexecution(batchlauncher.java:91) @ org.sonar.runner.impl.batchlauncher$1.run(batchlauncher.java:75) @ java.security.accesscontroller.doprivileged(native method) @ org.sonar.runner.impl.batchlauncher.doexecute(batchlauncher.java:69) @ org.sonar.runner.impl.batchlauncher.execute(batchlauncher.java:50) @ org.sonar.runner.impl.batchlaunchermain.execute(batchlaunchermain.java:41) @ org.sonar.runner.impl.batchlaunchermain.main(batchlaunchermain.java:59) caused by: org.picocontainer.injectors.abstractinjector$unsatisfiabledependenciesexception: org.sonar.core.notification.defaultnotificationm...

How to know which row in a table is changed using java and postgresql -

i have following class listens notifications postgresql database. class listener extends thread { private connection conn; private org.postgresql.pgconnection pgconn; listener(connection conn) throws exception { this.setconn(conn); this.pgconn = (org.postgresql.pgconnection) conn; statement stmt = conn.createstatement(); stmt.execute("listen userdata"); stmt.close(); } public connection getconn() { return conn; } public void setconn(connection conn) { this.conn = conn; } public static void main(string[] args) { try { class.forname("org.postgresql.driver"); string url = "jdbc:postgresql://localhost/users"; string user = "admin"; string password = "password"; connection listenercon = drivermanager.getconnection(url, user, password); listener listener = new listener(listenercon); ...