Posts

Showing posts from April, 2015

vector - lvalue required as left operand of assignment error in c++ -

all of fellas, have problem code. try use macro , vector in code. but, there error in code, in macro code. dont know error. code : #include <iostream> #include <vector> #include <string> #include <algorithm> #include <ostream> using namespace std; #define loop(a,b) for((int)(a) = 0; (a) < (int)(b); (a)++) int main(){ vector<string> sentence; sentence.reserve(10); int i=0, c = sentence.size(); sentence.push_back("hello,"); sentence.push_back("how"); sentence.push_back("are"); sentence.push_back("you"); sentence.push_back("?"); loop(i,c){ cout << << endl; } return 0; } i hope of can me solve problem. regards. it bad idea use such kind of macros in c++. problem expression ( int )( ) is rvalue (some temporary object) , may not assign value like ( int )( ) = 0; either remove entirely casting or @ least use c

javascript - how to filter input value in AngularJS -

i'm trying implement filtering on input element. want make filtering input type="text" field. instance, if model contain more available characters want change input value. i've created jsfiddle have directive generate html template dynamically , contains input field. var app = angular.module('app', []) .controller('ctrlr', function($scope){ $scope.mymodel = "test"; $scope.availablecharacters = 5; $scope.$watch('mymodel', function(newvalue, oldvalue){ if(!newvalue){ return; } if(newvalue.length > 5){ $scope.cutstring(); } }); $scope.cutstring = function(){ var length = $scope.mymodel.length; var string = $scope.mymodel.slice(0, $scope.availablecharacters); var countstars = length - string.length; $scope.mymodel = $scope.createstars(string, countstars); } $scope.createstars = function(string, count

java - Why am I losing type information? -

i have found interesting happen maps, rawtypes , generics. following code: static { map map = new hashmap (); set <map.entry> set = map.entryset (); (map.entry entry : set) {} // fine (map.entry entry : map.entryset()) {} // compilation error } i getting compilation error type incompatibility, namely: "object cannot cast entry". ideone convenience why iterator on entryset() losing type information if there's no variable storing again? the rawtypes shouldn't affect type map.entry object. or mistaken? your example makes have type information never had. have written: map map = new hashmap (); set <map.entry> set = map.entryset(); (map.entry entry : set) {} // fine (map.entry entry : map.entryset()) {} // compilation error but map.entryset() returning set , not set <map.entry> . you've performed unchecked assignment "adds" type information. in second loop, don't

list - Python : verifying user's input? -

my variable useranswerlist[] takes user's input, , need verify if user has input other a , b , c , d . here's code below, , wondering how should validate user's input between range of ( a b c d ) , if not print error message? answerlist = ["a","c","a","a","d","b","c","a","c","b","a","d","c","a","d","c","b","b","d","a"] useranswerlist = [] correct = 0 incorrect = 0 def main(): in range(20): = + 1 answer = input("please enter answer question %d:" %i) useranswerlist.append(answer) numcorrect = [i in useranswerlist if in answerlist] if len(numcorrect) > 15: print("congratulations have passed exam!") elif len(numcorrect) < 15: print("failed....please try again") correct = l

jquery - Select and wrap specific parent elements with siblings until next specific parent element -

there lot of similar questions on s.o none cover specific task, looking use jquery select p tags grandparent element of span class 'hdr', want wrap p tag , of it's siblings until next p tag parent of 'hdr' class, on , forth. the problem have 2nd , 3rd wrappers , it's containing content end getting nested inside of previous set of wrappers instead of each wrapper being printed 1 after another. my initial markup: <div class="main"> <p><strong><span class="hdr">heading #1</span></strong></p> <p>some paragraph text</p> <p>some paragraph text</p> <p>some paragraph text</p> <p>some paragraph text</p> <p><strong><span class="hdr">heading #2</span></strong></p> <p>some paragraph text</p> <p>some paragraph text</p> <p><strong><span

java - Output every minute for ten minutes -

i trying print out android app every minute ten minutes. preferably access phone's clock have code start automatically @ specific time. however, not sure how part. here have far. so here main code want add code below in along answer provided below: package com.example.james.texttospeech; import android.os.bundle; import android.app.activity; import android.view.view.onclicklistener; import android.widget.button; import android.view.view; import android.widget.edittext; import android.speech.tts.texttospeech; import android.speech.tts.texttospeech.oninitlistener; import android.content.intent; import java.util.locale; import android.widget.toast; public class mainactivity extends activity implements onclicklistener, oninitlistener { //tts object private texttospeech mytts; //status check code private int my_data_check_code = 0; //create activity public void oncreate(bundle savedinstancestate) {

Unable to make a MySQL connection through Perl when called in a PHP script -

i'm creating connection mysql database within perl script, called php script. here 2 scripts: perl: #!/usr/bin/perl # script name = mycode.pl use dbi; $data_source = q/dbi:mysql:name:localhost/; $user = q/myname/; $pwd = q/pword/; print "before...\n"; # connect! $dbhandle= dbi->connect($data_source,$user,$pwd) or die "can't connect $data_source: $dbi::errstr \n"; print "...after \n"; php: <?php // script name = test.php $myresult=shell_exec("perl /path/mycode.pl"); echo $myresult; ?> when executed on command line, test.php prints "before..." , "...after" , db connection indeed established within perl code. however, when test.php executed (chrome) browser, prints "before..." , no connection made. , no error message displayed. why there success on command line not web server? yes, php shell_exec() function doesn't capture stderr. to debug code, can add 2&g

android - Roboblender annotation processing not working -

i try make roboblender work roboguice compile time processing doesn't seem anything, annotationdatabaseimpl class not generated. (project builds without error.) i created sample project, please see below. miss? (i know gradle task , second metadata needed multi module project, didn't work without them either). build.gradle: project.tasks.withtype(javacompile) { task -> options.compilerargs << "-aguiceannotationdatabasepackagename=gk.com.roboguice_compile" } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.0.0' compile 'org.roboguice:roboguice:3.+' provided 'org.roboguice:roboblender:3.+' } manifest: <meta-data android:name="roboguice.modules" android:value="gk.com.roboguice_compile.roboguicebindings" /> <meta-data android:name="roboguice.annotations.packages&q

swing - Java GridBagLayout Aligning buttons -

Image
i have problem gridbaglayout; i've 5 buttons , want have them in way: i've tried different approaches no 1 works in correct way. for example: import java.awt.gridbagconstraints; import java.awt.gridbaglayout; import javax.swing.box; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.swingutilities; import javax.swing.uimanager; import javax.swing.unsupportedlookandfeelexception; public class testgridbaglayout { protected void initui() { jframe frame = new jframe("test"); frame.setdefaultcloseoperation(jframe.exit_on_close); jpanel southpanel = new jpanel(new gridbaglayout()); gridbagconstraints gbc = new gridbagconstraints(); gbc.gridwidth = 2; gbc.gridy = 0; jbutton enterroom = new jbutton("enter room"); jbutton exitroom = new jbutton("exit room"); jbutton login = new jbutton("login"); jbutto

ffi - true - false response of query from prolog in C# -

i using swi- prolog c# front end. want to display whether the query executed or not in mmessagebox. need answer in 'true' or 'false' comes in prolog console. here code: static void main(string[] args) { environment.setenvironmentvariable("swi_home_dir", @"c:\program files\swipl"); environment.setenvironmentvariable("path", @"c:\program files\swipl"); environment.setenvironmentvariable("path", @"c:\program files\swipl\bin"); string p1 = @"c:\program files\swipl\try9.pl"; string[] p = { "-q", "-f", p1 }; plengine.initialize(p); try { plquery q = new plquery("get(sam,age(26))."); // here need responce of prolog engine of above query whether true or false . console.readline(); } catch (plexception ex) { console.writeline("exception handeled" + ex.message); } } let me

c++ - How can pointers container can have the ownership of pointers if pointers are already deleted? -

in code tried make template class p_array store pointer object shown below. template class stores pointers , deletes them if not deleted after usage. should null check. although problem addressed in other questions. don't understand how check if pointer null or not. in destructor ~p_array() checking null pointers not effective. i tried similar using std::shared_ptr explain idea. p_array destructor: ~p_array() { unsigned int = 0; while(i < total) { if (t_array[i]) //not effective { std::cout << "deleting " << t_array[i] << "\n" ; delete (t_array[i]); //ownership of pointer } i++; } } main.cpp : #include <iostream> #include <memory> #include "p_array.h" class obj { public: ~obj () { std::cout << "deleting obj...\n" ;} }; int main() { p_array<obj> ap; obj * op[10]; (int = 0; &l

python - trouble with setting a SNMP attribute using pythone and netsnmp library -

i trying use netsnmp library snmpset attribute error robm@pc2303vm:~/code/python/snmp$ ./tester2.py file "./tester2.py", line 5 ipaddr=netsnmp.varbind('.1.3.6.1.2.1.69.1.3.1.0',172.168.100.2,'ipaddress') ^ syntaxerror: invalid syntax now command line snmpset -v2c -c private 10.1.1.8 .1.3.6.1.2.1.69.1.3.1.0 172.168.100.2 works fine , quoting "172.168.100.2" gives different error typeerror: expected string or unicode object, nonetype found #!/usr/bin/python import netsnmp ipaddr=netsnmp.varbind('.1.3.6.1.2.1.69.1.3.1.0',172.168.100.2,'ipaddress') netsnmp.snmpset(ipaddr, version=2, desthost="10.1.1.8", community="private") filename=netsnmp.varbind('.1.3.6.1.2.1.69.1.3.2.0', './robertme/q2q_rel_7_2_2_2015_04_07_t1935.bin','string') netsnmp.snmpset(filename, version=2, desthost='10.1.1.8', community='

android - phonegap app with Smart Card integration -

i have phonegap/cordova app want secure precise biometric's smart card tactivo reader. new smart card integration, , precise biometrics not seem have informative documentation. have found need create own plugin phonegap in order use card reader. my question is: there plugin created this, or can post example of plugin code need? so far have code in plugin.xml file: <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-device" version="1.0.0-dev"> <name>smartcard</name> <description>cordova smartcard plugin</description> <license>apache 2.0</license> <keywords>cordova,smartcard</keywords> <repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git</repo> <issue>https://issues

merge - Merging two columns into one in R -

i have following data frame, , trying merge 2 columns one, while replacing na 's numeric values. id b 1 3 na 2 na 2 3 na 4 4 1 na the result want is: id new 1 3 2 2 3 4 4 1 thanks in advance! you can do: with(d,ifelse(is.na(a),b,a)) where d data frame.

How can I get POST variable form HTTP header with java? -

socket client = ss.accept(); bufferedreader in = new bufferedreader(new inputstreamreader(client.getinputstream())); printwriter out = new printwriter(client.getoutputstream()); out.print("http/1.1 200 \r\n"); out.print("content-type: text/html\r\n"); out.print("\r\n"); out.print("<form method='post' action=''>first name: <input type='text' name='firstname' value='mickey'><br><input type='submit' value='submit'></form>" + "\r\n"); string line; while ((line = in.readline()) != null){ if(line.length() == 0) { break; } system.out.println(line); } system.out.println("lõpp"); out.close(); in.cl

scipy - Avoiding hard coding a lot of coupled ODEs in python -

first of, i'm sorry if title not entirely fitting, had hard time finding appropriate 1 (which might have effect searching efficiency asked questions :/ ). the problem following. while comparably easy solve coupled ode's in python scipy, still have write down ode in form explicitly. example coupled ode of form d/dt(c_0)=a(c_0)+b(c_1) , d/dt(c_1)=c(c_0) i set sth like: import numpy np scipy.integrate import ode a=1 b=2 c=3 val=[] def dc_dt(t, c): return [a*c[0]+b*c[1], c*c[0]] c0, t0 = [1.0,0.0], 0 r = ode(dc_dt).set_integrator('zvode', method='bdf',with_jacobian=false) r.set_initial_value(c0, t0) t1 = 0.001 dt = 0.000005 while r.successful() , r.t < t1: r.integrate(r.t+dt) val.append(r.y) however, have coupled ode's of rough form d/dt(c_{m,n})=a(c_{m,n})+b(c_{m+1,n-1})+k(c_{m-1,n+1}) with c_{0,0}=1 , have include orders m^2+n^2-mn smaller max value. small max, did, using dictionary use notation 2 indices , map on 1d

windows - Win Task Scheduler: Start A Task Based on Other Multiple Task Successes -

based on this work i want extend custom xpath given below following case: have tasks. a, b, c, , d. a, b, , c set run @ 7am. action fails, , when does, task restarts application until succeeds. when a, b, , c done, want d trigger. xpath use to make d trigger ? query article: <querylist> <query id="0" path="microsoft-windows-taskscheduler/operational"> <select path="microsoft-windows-taskscheduler/operational">*[eventdata [@name='tasksuccessevent'][data[@name='taskname']='\ping']]</select> </query> </querylist> after posting in various places online, of popular belief windows task manager can not handle such request. personally, using etl system. after looking @ microsoft build session data factory, believe may right tool me. other enterprise task tools exist different applications have functionality.

vbscript update excel spreadsheet -

i've looked on many sites, including questions came when entered title, , can't seem program work. activates spreadsheet, no data prints. option explicit dim objexcel, objworkbook dim strtin, strname, strfname, strlname, strstate, strempid, strrecdate, strcomment set objexcel = createobject("excel.application") set objworkbook = objexcel.workbooks.open("c:\users\lpeder6\desktop\important info\data tracking.xlsx") copydata set objexcel = nothing set objworkbook = nothing '---------------copydata - copies required data----------------- sub copydata() strtin = "2-123456789-00005" strname = "smith john " strstate = "mn" strempid = "s987654321" strrecdate = "04/02/2015" strcomment = "this in comment." strlname = trim(left(strname, 10)) strfname = trim(right(strname, 15)) strname = strlname & " " & strfname objexcel.visib

javascript - angular-rails-templates Failed to load template -

i'm trying angular load template: var app = angular.module("myapp", ['templates']) and html: <div ng-app="myapp"> <div ng-include="'blah.html'"></div> </div> but 404 failed load resource because, rails tells me, no route matches [get] "/blah.html" . understand because of asset pipeline in rails. blah.html in /app/assets/javascripts/templates/blah.html , using angular-rails-templates gem try solve problem. application.js has: //= require angular-rails-templates //= require_tree ./templates but i'm not having luck. the html generated suggests angular-rails-templates loading (it has script /assets/angular-rails-templates....js ) rails failing find blah.html versions: rails 4.2.1 angular-rails-templates 0.1.4 angularjs 1.3.15 this turned out sprockets incompatibility (see here , here ) the short version is: add gem 'sprockets', '2.12.

ms access - Why won't my "WHERE" statements work in sql? -

i have ms access database 40 similar tables. couple listed below simplicity. want grab 3 cells of data row if date in row yesterday. data comes other employee's homebrew spreadsheets refuse give up. can't change column names or them on same workbook template. i've tried variations on code below can't dates work right. if drop statement returns everything. need whittled down. in advance! select [customer name],[$ amount], [quote completed] 1081 [quote completed] = date()-1 union select [customer name],[$ amount], [quote completed] 1145 [quote completed] = date()-1 union select [customer name],[$ amount], [quote completed] 1149 [quote completed] = date()-1 union select [customer name],[$ amount], [quote completed] 1228 [quote completed] = date()-1 union select [customer name],[$ amount], [quote completed] 1353 [quote completed] = date()-1 ; do need condition on each section of union? or want whole results filtered? select * ( select [customer na

android - How to get the package name of an external app which calls my app -

my app com.test.sample invoked external app com.testexternal.outsideapp. external app uses intent invoke mainactivity of com.test.sample calling startactivityforresult. looking way programmatically obtain package name of external app. tried several ways string parentpackagename = this.getparent().getpackagename(); //this fails since parent returning null. string packagename = this.getintent().getpackage(); //this returns package name of current application not want. is there other way package name of caller app? you can if application started activity#startactivityforresult using activity#getcallingactivity() .

sql server - Why can't I connect to my mssql database using PHP? -

i've done research trying php code hosted on iis connect mssql database. can't seem figure out issue. has come across before? <?php $servername = 'aegis-pc\sqlexpress'; $connectioninfo=array('database'=>'tttb_db'); $con = sqlsrv_connect($servername, $connectioninfo); if($con){ echo 'connection established<br />'; } else { echo 'connection failed<br />'; die(print_r(sqlsrv_errors(), true)); } ?> update, have new error: connection failed array ( [0] => array ( [0] => 28000 [sqlstate] => 28000 [1] => 18456 [code] => 18456 [2] => [microsoft][odbc driver 11 sql server][sql server]login failed user 'nt authority\iusr'. [message] => [microsoft][odbc driver 11 sql server][sql server]login failed user 'nt authority\iusr'. ) [1] => array ( [0] => 42000 [sqlstate] => 42000 [1] => 4060 [code] => 4060 [2] => [microsoft][odbc driver 11 sql server][

javascript - How to calculate totals based on current state of divs -

what have house plan had javascript overlaid divs. i want create function calculates figures based on whether these div ids displayed or not , return answer. here jsfiddle https://jsfiddle.net/offtkdqk/ function calculate_total(ppa, cpa, cpo, gar) { var tot_price = 279500; var = document.getelementbyid(ppa); if (a.style.display == 'block') var ppa_tot = 1000; var b = document.getelementbyid(cpa); if (b.style.display == 'block') var cpa_tot = 5000; var c = document.getelementbyid(cpo); if (c.style.display == 'block') var cpo_tot = 6000; var d = document.getelementbyid(gar); if (d.style.display == 'block') var gar_tot = 9000; var estimate = tot_price + ppa_tot + cpa_tot + cpo_tot + gar_tot; return estimate(); } and html: <div id="main-bg" class="main-img"> <img src="images/house.jpg" width="100%"> </div> <div id="main-ppa" cl

amazon web services - What IAM policy do I need to sign an browser-based POST policy document? -

my goal make browser upload form s3 bucket. i'm following instructions here: http://docs.aws.amazon.com/amazons3/latest/dev/httppostexamples.html in it, 1 needs create policy document , sign using secret access key. if follow instructions exactly, using administrator-level account (e.g. access things), works. i prefer have user account specific function , sign document using user's credentials. way, can deprecate key (or entire user) whenever wish. however, not listed in instructions (nor can figure out google/experimentation) precisely what authority user needs in iam in order sign document . i've tried being wide policy below (i renamed bucket name my-bucket), sufficient user log s3's web interface , manage bucket entirely there. however, using upload form still yields access denied. please note desired behavior allow user only upload files specific folder in specific bucket. not delete, get, etc. { "statement":[ { "effec

r - Color Cells in Rstudio -

i have dataframe i've imported csv. in free text section following included caused cell in rstudio highlight red: <p><font style="background-color: #ff0000">sp#12. notified 7/9. ending 7/29.</font></p> <p>boa bin 7-24-2014</p> <p>this amendment alt252143. adding habitable basement square footage unit 1. </p> <p><font style="background-color: #ff0000">paid nominal fee only</font></p> i know "background-color: #ff0000"bit causing can't find how reproduce this. ideas? class of vector character. i'm using preview version of rstudio, not sure if make difference.

javascript - jQuery get numeric input from all browsers -

i want user press on number key while focus on input item, , browser should go foo.com/[number] this code using: function isnumberkey(evt){ var charcode = (evt.which) ? evt.which : event.keycode; if (charcode != 46 && charcode > 31 && (charcode < 48 || charcode > 57)) return false; return true; } $(document).ready(function(){ $('.my_input').keypress(function(event){ if(isnumberkey(event)){ window.location='foo.com/'+(event.keycode-48); } }); }); it works on google chrome, firefox users getting errors. want implement mobile version user can input number, , press "enter" key of mobile device. how can ensure work on browsers support javascript? thanks help! here's code corrected don't think you're after. note charcode returned numpad different of number-key row. function isnumberkey(evt){ var charcode = (evt.which) ? evt.which : ev

winforms - How can I validate only the controls inside a panel? -

i have form 2 panels each have [save] button. how can validate of controls inside each panel separately? i hoping panel class have validate() method doesn't. it's not containercontrol doesn't have validatechildren method. what's best way accomplish this? if set form's autovalidate mode enableallowfocuschange , , presuming have validating events hooked each of controls inside panel, this: private void tb_validating(object sender, canceleventargs e) { textbox tb = sender textbox; if (tb != null) { if (tb.text == string.empty) { errorprovider1.seterror(tb, "textbox cannot empty"); e.cancel = true; } else errorprovider1.seterror(tb, ""); } } then on click handler save button, can this: private void savebutton_click(object sender, eventargs e) { foreach (control c in panel1.controls) c.focus(); // if want s

javascript - Hide keystrokes from window-wide listeners -

i'm making extension chrome used on youtube. extension adds overlay on top of video text input. however, typing extension triggers youtube's various keystroke listeners (e.g. space -> pause ). event.stoppropagation() nothing, neither return false @ end of angular event callback. my current (successfully prototyped not yet implemented) solution wrap input in iframe, pass messages parent window: iframe.contentwindow.document.queryselector("#wrapped-input").addeventlistener("input", function(){ result.innerhtml = this.value; }); i feel solution bit of hack, , i'm hoping find more elegant. aside, using angularjs app, if there angular-specific workarounds, i'd love know too. thoughts? edit current solution: <iframe id="wrapper-frame"></iframe> ... link: { var input = '<input id="inner-input" />'; var wrap = $window.document.queryselector('#wrapper-iframe').contentwindo

git - Deploying Perl Docker Container to Elastic Beanstalk -

i building docker container pulls perl/mojolicious repo bitbucket having problems. have dockerfile this: # docker-version 0.3.4 perl:latest maintainer name myname@name.com # update aptitude new repo run apt-get update # install software run apt-get install -y git # make ssh dir run mkdir /root/.ssh/ # copy on private key, , set permissions add repo-key /root/.ssh/id_rsa # create known_hosts run touch /root/.ssh/known_hosts # add bitbuckets key run ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts run curl -l http://cpanmin.us | perl - app::cpanminus run cpanm mojolicious run cachebuster=b953b35 git clone -b branch git@bitbucket.org:org/project.git expose 8080 workdir project cmd hypnotoad script/project and, locally, upon docker build -t name/project . builds fine , says "successfully built." i zipped repo-key file , fed elastic beanstalk, clicked upload , deploy (i deployed 2048 game sample, , tried replicate it). this comes dockerrun.aw

php - replace www with any word and it resolves to the website instead of giving a 404 error -

i have website when type in word in subdomain part of url resolves domain. instance monkey.mysite.com resolves same www.mysite.com or mysite.com would. no matter page on still resolve url. wordpress site , has ssl certificate. infected virus. can explain me cause this? here rewrite rule in .htaccess file: rewritecond %{http_host} ^mysite\.com$ [or] rewritecond %{http_host} ^www\.mysite\.com$ rewriterule ^/?$ "http\:\/\/mysite\.com" [r=301,l] there not subdomain associated site. this issue not related rewrite rules in apache rather dns settings. if subdomain.mysite.com not have dns record, proper response in browser "server not found" (since ip not resolved) rather http 404 error (i.e. page not found). anyway, can check response given dns server on mac/linux with, dig subdomain.mysite.com which should return not found if subdomain indeed not exist. alternatively, there tools online .

conditionalPanel javascript condtions in shiny: is there R %in% operator in javascript? -

i trying build shiny application using conditionalpanel function shiny package. condition should written in javascript able use condition follows (written in r) "tp53" %in% unlist(input$modelvariables) the documenatation states: condition - javascript expression evaluated repeatedly determine whether panel should displayed. i'm not familiar javascript @ all. i've tried input.modelvariables == 'tp53' doesn't work when input.modelvariables has length bigger 1. my sidebarpanel fragment conditionalpanel below checkboxgroupinput("modelvariables", label = h3("which variables view?"), choices = list( "cohort", "stage", "therapy",

c - How to get number of arrays in a multidimensional array -

i have multidimensional array consisting of several sub arrays. possible count number of sub-arrays in array? if array declared on stack, can number of elements using sizeof() function: #include <stdio.h> #include <stdlib.h> int main() { int a[3][4]; fprintf(stdout, "size of in bytes: %zu\n", sizeof(a)); fprintf(stdout, "size of a[0][0] in bytes: %zu\n", sizeof(a[0][0])); fprintf(stdout, "number of elements in a: %zu\n", sizeof(a)/sizeof(a[0][0])); int b[3][4][5]; fprintf(stdout, "size of b in bytes: %zu\n", sizeof(b)); fprintf(stdout, "size of b[0][0][0] in bytes: %zu\n", sizeof(b[0][0][0])); fprintf(stdout, "number of elements in b: %zu\n", sizeof(b)/sizeof(b[0][0][0])); return exit_success; } to compile: $ gcc -wall stack_array_test.c -o stack_array_test results: $ ./stack_array_test size of in bytes: 48 size of a[0][0] in bytes: 4 number of elemen

Is Java 8 Stream a safe return type? -

are java 8 streams safe return types public methods, in impossible mutate underlying object given stream it? for example, if have list , return list.stream(); return value in way used mutate original list? judging api, don't think it's possible confirm. yes, safe so. streams not/should not modify underlying data structure. a few excerpts java.util.stream.stream : a sequence of elements […]. collections , streams, while bearing superficial similarities, have different goals. collections concerned efficient management of, , access to, elements. contrast, streams not provide means directly access or manipulate elements […]. to preserve correct behavior, [behavioral parameters stream operations …] must non-interfering (they not modify stream source). and package java.util.stream description : streams differ collections in several ways: no storage. a stream not data structure stores elements ; instead, conveys elements source

android - Could not find class com.joanzapata.pdfview.PDFView -

i want open pdf in android using pdfview. https://github.com/joanzapata/android-pdfview this layout code: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <com.joanzapata.pdfview.pdfview android:id="@+id/infoinstalacion_fragment5_pdfview" android:layout_width="match_parent" android:layout_height="match_parent"/> </linearlayout> and java code. want open pdf in fragment.: @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // todo auto-generated method stub view view = inflater.inflate(r.layout.infoinstalacion_fragment5, container, false); pdfview pdfview= (pdfview) view.findviewbyid(r.id.infoinstala

Print Email Address on home page using SESSION after successful login PHP -

i trying use session store email address , print on home page after successful login. here have tried keep getting undefined variable error $email. know email address getting stored because appears in "inspect element--> resources --> localhost" here code far. appreciate or advice on how correct going wrong. <?php session_start(); if (isset($_session['email'])) { $email=$_session['email']; } echo "welcome homepage: ".$email; ?> you getting undefined variable error because $email set if session variable exists. fix: if (isset($_session['email'])) { $email = $_session['email']; } else { $email = '<unknown>' } possible cause: misconception how session works / sequence of request , response events.

unity3d - How can I get sensor data into Unity while using Google Cardboard? -

i have basic google cardboard unity application loaded , working great. i want utilize few sensors on phone aren't available in unity. example, want access step_detector sensor. i created own unityplayeractivity, , without cardboard, seems work well. problem have no idea how use custom unityplayeractivity cardboard. from can tell, cardboard demo uses "unitycardboardactivity" class main activity. took @ unitycardboardactivity.jar , looks unitycardboardactivity class inherits cardboardactivity, not unityactivity. so guess unitycardboardactivity manually starting default unityplayeractivity somewhere in code, can't change start own custom unityplayeractivity in way can tell. is there way sensor data without using unityplayeractivity? i tried making activity extend unitycardboardactivity instead, reason don't have access "getsystemservice" method when that, can't access sensors.

Intern functional test: mock datetime -

i'm new intern test. know can mock datetime intern functional testing (example: test run 3 days ahead of today). lolex ( https://github.com/sinonjs/lolex ) used sinon.js mock date. it replaces date own implementation ( https://github.com/sinonjs/lolex/blob/master/lolex.js#l477-l479 ).

c++ - Swapping two elements in a template type list. Seeking most efficient algorithm -

swap<t, position1, position2, pack>::type , pack consists of elements of type t, return pack elements in position1 , position2 swapped. solution below not efficient. there should way accomplish cleanly, without visiting element twice . can think of it? // replaceelement replaces element of pack specified position (0 being first position) specified value. template <typename t, std::size_t, std::size_t, t, typename, typename> struct replaceelementhelper; template <typename t, std::size_t position, std::size_t currentposition, t newvalue, template <t...> class z, t first, t... rest, t... accumulated> struct replaceelementhelper<t, position, currentposition, newvalue, z<first, rest...>, z<accumulated...>> : replaceelementhelper<t, position, currentposition + 1, newvalue, z<rest...>, z<accumulated..., first>> {}; template <typename t, std::size_t position, t newvalue, template <t...> class z, t first, t... r

c# - Bindings not working for views first time MvvmLight -

i have been using approach mvvm navigation create datatempalte viewmodel view inside. main window setup this <window x:class="vaultprez.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ignore="http://www.ignore.com" xmlns:v="clr-namespace:vaultprez.views" xmlns:vm="clr-namespace:vaultprez.viewmodel" mc:ignorable="d ignore" height="720" width="1280" title="mvvm light application" datacontext="{binding main, source={staticresource locator}}"> <window.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictiona

lc3 - Why am I getting extra characters? -

program description i used .blkw allocate 20 locations each character user inputs , now, want display string user typed @ first prompt. (this pig latin translator, hence second prompt; right want see if can print out user input) the problem the problem when run it, characters @ end. for example: english word: apple pig-latin word: apple english word: @ pig-latin word: atple english word: set pig-latin word: setle my program .orig x3000 start st r1,saver1 st r2,saver2 st r3,saver3 ld r5,enter repeat lea r0,prompt ; loading starting address of prompt puts ; displays prompt on screen lea r4,englword ; sets aside memory locations typed characters input getc ; user has typed, read char r0 add r6,r5,r0 ; adds negative value of ascii enter key code input character brz pigprompt ; if sum of ascii codes step before 0, means user pressed enter go pigprompt out ; write char in r0 console str

java - Android: EditText in CustomView not behaving as expected when touched -

i have customview contains linearlayout holds edittext & custom view element. however, when run app , touch edittext not behave expected (doesn't appear receive focus & soft keyboard doesn't open). i've tried setting duplicateparentstate="true" on both edittext & linearlayout. attached ontoucheventlistener edittext calls simple toast & toast did show up. here's code customview. form_field.xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="horizontal" android:layout_marginbottom="15dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/grey_rounded_borders"> <edittext android:id="@+id/edit_text"