Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from 2017-10-23T10:43:17Z
Updated: 42 min 18 sec ago

react-native-router-flux drawer changing scenes

Sat, 07/08/2017 - 18:13

I'm trying to use react-native-flux with tabbar and navbar, but the scene change works strange. The first time I press each option in the drawer it works, not the second. Also if I return to the 'Main' scene, the 'drawerImage' doesn't apply and renders the default one.

Any help will be appreciated!

This is my router file

import React, { Component } from 'react'; import { Text } from 'react-native'; import { Router, Scene } from 'react-native-router-flux'; import SplashPage from './SplashPage'; import Start from './Start'; import Drawer from './Drawer'; import ClientNoLogged from './ClientNoLogged'; import NoLogged from './NoLogged'; import Login from './Login'; import SignUp from './SignUp'; import Forgot from './Forgot'; import Pending from './Pending'; import Answered from './Answered'; import OtherRequests from './OtherRequests'; import Reviews from './Reviews'; import Profile from './Profile'; import STYLES from '../core/Styles'; class TabIcon extends React.Component { render(){ return ( <Text style={{color: this.props.selected ? 'white' :'#ff514f'}}>{this.props.title}</Text> ); } } export default class App extends Component { render() { return ( <Router> <Scene key="root"> <Scene key="SplashPage" panHandlers={null} component={SplashPage} initial={true} hideNavBar={true} /> <Scene key="Start" panHandlers={null} component={Start} hideNavBar={true} /> <Scene key="ClientNoLogged" panHandlers={null} component={ClientNoLogged} hideNavBar={false} backButtonImage={require('../img/back.png')} navigationBarStyle={[STYLES.navBar]} navigationBarTitleImage={require('../img/logoSplash.png')} navigationBarTitleImageStyle={[STYLES.navBarLogo]} /> <Scene key="NoLogged" panHandlers={null} component={NoLogged} hideNavBar={true} /> <Scene key="Login" panHandlers={null} component={Login} hideNavBar={true} /> <Scene key="Forgot" panHandlers={null} component={Forgot} hideNavBar={true} /> <Scene key="Signup" panHandlers={null} component={SignUp} hideNavBar={true} /> <Scene key="Drawer" component={Drawer} open={false}> <Scene key="Main" tabs={true} tabBarSelectedItemStyle={STYLES.tabSelected} tabBarStyle={STYLES.tabBar}> <Scene key="tab1" initial={true} title="Pending" icon={TabIcon}> <Scene key="tab1_1" component={Pending} panHandlers={null} drawerImage={require('../img/burger.png')} navigationBarStyle={[STYLES.navBar]} navigationBarTitleImage={require('../img/logo.png')} navigationBarTitleImageStyle={[STYLES.navBarLogo]}> </Scene> </Scene> <Scene key="tab2" title="Answered" icon={TabIcon}> <Scene key="tab2_1" component={Answered} panHandlers={null} drawerImage={require('../img/burger.png')} navigationBarStyle={[STYLES.navBar]} navigationBarTitleImage={require('../img/logo.png')} navigationBarTitleImageStyle={[STYLES.navBarLogo]}> </Scene> </Scene> </Scene> <Scene key="OtherRequests" drawerImage={require('../img/burger.png')} navigationBarStyle={[STYLES.navBar]} navigationBarTitleImage={require('../img/logo.png')} navigationBarTitleImageStyle={[STYLES.navBarLogo]}> <Scene key="OtherRequestsBody" component={OtherRequests} panHandlers={null}> </Scene> </Scene> <Scene key="Reviews" drawerImage={require('../img/burger.png')} navigationBarStyle={[STYLES.navBar]} navigationBarTitleImage={require('../img/logo.png')} navigationBarTitleImageStyle={[STYLES.navBarLogo]}> <Scene key="ReviewsBody" component={Reviews} panHandlers={null}> </Scene> </Scene> <Scene key="Profile" drawerImage={require('../img/burger.png')} navigationBarStyle={[STYLES.navBar]} navigationBarTitleImage={require('../img/logo.png')} navigationBarTitleImageStyle={[STYLES.navBarLogo]}> <Scene key="ProfileBody" component={Profile} panHandlers={null}> </Scene> </Scene> </Scene> </Scene> </Router> ) }


Not able to access protected variables

Sat, 07/08/2017 - 18:05

I have created a simple test project to use a class as a custom List type and have a couple of questions regarding the use of different syntax when declaring variables.

I have a class called CustomerInfo which defines all the variables required to be stored for the customer information which will be added to a list as seen below:

protected string Firstname { get; set; } protected string Surname { get; set; } protected int Age { get { return Age; } set { if(value < 0) { throw new AgeException("Age cannot be a value below 0"); } else { Age = value; } } } protected string Gender { get; set; }

1) Why does the code below not allow me to access the protected variables in the CustomerInfo class even though I am inheriting the class?

class Program : CustomerInfo { static void Main(string[] args) { CustomerInfo custInfo = new CustomerInfo(); custInfo.Firstname = "Richard"; //not working custInfo.Surname = "Smith"; //not working List<CustomerInfo> custList = new List<CustomerInfo>(); custList.Add(custInfo); } }

2) When looking at Windows Forms applications they already contain an inheritence of Form in the code of any Form you create. If you have to inherit a class to access the protected variables & methods it has, how can you access the variables if each form already has an inheritance that you cannot remove?


PHP Regex to match url contains url fragment

Sat, 07/08/2017 - 18:03

I have one url fragment: page/login and i need to know if another url fragment contains them.

These, will match:

/admin/page/login/ /admin/page/login admin/page/login /admin/page/login?id=10 /admin/page/login/id/10 /admin/page/login/?id=10 /admin/page/login/user?id=10 /admin/page/login/user/?id=10 page/login page/login/ page/login/id/10 /page/login/id/10

And these not:

/admin/firstpage/login admin/page/loginOk /admin/page/loginOk/id/10 mypage/login/id/10 /mypage/login/id/10 mypage/login

I tried: page\/login[\/\s\?], \/?page\/login[\/\s\?] without any result

Unable to find htdocs on xammp?

Sat, 07/08/2017 - 17:59

I have intalled xampp for mac os sierra.I have one icon in application for xammp.I am able to run the server & it's services.But i am not able to find the htdocs folder.

I have not found it under \Library\Webserver

Why do we need a Scanner Object for taking input in java

Sat, 07/08/2017 - 17:56

In Java

To print output we simply use System.out stream while to take input, we have to pass in Constructor of a Scanner object and then use that object only. Why is it so ? Why is there no direct method like or Something ?

ps: I'm a newbie

Angular JS : Failed to instantiate module test due to:

Sat, 07/08/2017 - 17:50

I'm running some Javascript inside a HTML file. And I'm trying to use some Angular JS with the function ng-repeat. Each time I run it, I get this error in the console :

angular.js:38 Uncaught Error: [$injector:modulerr]

And when I click on the link within the error message in the console, I get this:

Failed to instantiate module test due to: Error: [$injector:nomod]$injector/nomod?p0=test at at at b ( at at at q ( at g ( at eb ( at c ( at Sc (

Here is my Javascript inside my HTML file:

//Get User ID and Trip ID in URL function GetURLParameter(sParam) { var sPageURL =; var sURLVariables = sPageURL.split('&'); for (var i = 0; i < sURLVariables.length; i++) { var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == sParam) { return sParameterName[1]; } } } var userid = GetURLParameter('userid'); var tripid = GetURLParameter('tripid'); </script> <script> //Get photos URL inside a particular Trip ID from a User ID var database = firebase.database(); database.ref(`photos/${userid}/trips/${tripid}`).once('value') // will return you all the photo objects inside the `tripId` .then(photosSnap => { var photosObj = photosSnap.val(); var photosUrl = Object.keys(photosObj).map(key => photosObj[key].photourl); // then you can return the array or use it here; var app = angular.module('test', []); app.controller('MainCtrl', function($scope) { $scope.urls = photosUrl; }); console.log(photosUrl); // will be an array of all the photourls }).catch(err => alert(err));

And finally my HTML which uses ng-repeat:

<div class="spot" ng-app="test" ng-controller="MainCtrl"> <ul> <li ng-repeat="url in urls">{{url}}</li> </ul> </div>

I'm using a controller with scope to loop inside my HTML with an array. So first I don't know where my error message comes from, and second I'm not sure i'm using the controller and ng-repeat properly.


PS: I included in the head tag of my HTML file this link :

<script src=""></script>

Why is this html photo gallery not centering?

Sat, 07/08/2017 - 17:43

I'm trying to put a photo library on my webpage but it just won't center properly and it's driving me nuts. Any suggestions? I've tried putting so many different things for centering in the code but nothing works :/


<div style="display: inline-block; position: relative; text-align: center; width: 100%" > <h3 align="center" class="highlight">Photo Library</h3> <div align="center" class="" style="max-height:450px;max-width:800px;margin: 30px 30px 30px 30px; text-align: center"> <img class="mySlides" src="images/slideshow/1.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/2.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/3.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/4.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/5.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/6.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/7.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/8.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/9.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/10.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/11.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/12.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/13.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/14.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/15.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/16.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/17.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/18.png" style="width:auto"> <img class="mySlides" src="images/slideshow/19.png" style="width:auto"> <img class="mySlides" src="images/slideshow/20.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/21.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/22.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/23.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/24.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/25.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/26.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/27.jpg" style="width:auto"> <img class="mySlides" src="images/slideshow/28.jpg" style="width:auto"> </div>


<script> var myIndex = 0; carousel(); function carousel() { var i; var x = document.getElementsByClassName("mySlides"); for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } myIndex++; if (myIndex > x.length) {myIndex = 1} x[myIndex-1].style.display = "block"; setTimeout(carousel, 5000); } </script>


.mySlides { display:none; width: 200px; height: 400px; align-self: center; text-align: center; align-content: center; }

JSF backing bean method not invoked [duplicate]

Sat, 07/08/2017 - 17:29

This question already has an answer here:

Here is my bean responsible for adding data from the selectOnemenu JSF.

public void add() { // ... } public Map<String, String> getFloorP() { return floorP; } public Map<String, String> getBedr() { return bedr; } public Map<String, String> getHouseType() { return houseType; } public Map<String, String> getItems() { return items; }

Now, this is my JSF XHTML code:

<h:form > <div class="col-md-6"> <div class="panel panel-default"> <div class="panel-heading"> <p> <label>MOVING FROM</label> </p> </div> <div class="panel-body"> <div class="form-group"> <label>Phone Number</label> <h:inputText value="#{ctrl.pnumber}" class="form-control req-input" pt:placeholder="Full Name" /> </div> <div class="form-group"> <label class="">Address</label> <h:inputText value="#{ctrl.address}" class="form-control req-input" pt:placeholder="Full Name" /> </div> <div class="form-group"> <label class="">State</label> <h:selectOneMenu value="#{}" class="form-control select" title="From State" required="true"> <f:selectItem itemValue="#{null}" itemLabel="-- select state --" /> <f:selectItems value="#{ctrl.items}" /> </h:selectOneMenu> </div> <div class="form-group"> <label>Type of Apartment</label> <h:selectOneMenu value="#{}" class="form-control select" title="From Type" required="true"> <f:selectItem itemValue="#{null}" itemLabel="-- select apartment --" /> <f:selectItems value="#{ctrl.houseType}" /> </h:selectOneMenu> </div> <div class="form-group"> <label>How many Bedrooms?</label> <h:selectOneMenu value="#{}" class="form-control select" title="From Beds" required="true"> <f:selectItem itemValue="#{null}" itemLabel="-- select bedrooms --" /> <f:selectItems value="#{ctrl.bedr}" /> </h:selectOneMenu> </div> <div class="form-group"> <label>On what floor is this apartment?</label> <h:selectOneMenu value="#{ctrl.floor}" class="form-control select" title="From Floors" required="true"> <f:selectItem itemValue="#{null}" itemLabel="-- select apartment floor --" /> <f:selectItems value="#{ctrl.floorP}" /> </h:selectOneMenu> </div> </div> </div> </div> <h:commandButton value="Add" actionListener="#{ctrl.add()}"/> </h:form>

I have tried to run it, but the add() method is not invoked, I don't know what's wrong with the code.

Wrong redirection Uri with Google OAuth2

Sat, 07/08/2017 - 17:16

I have been working in a web Symfony app that uses a google oauth2. Well, to use it I had to create a Client and a Secret id for development environtment.

The redirection uri is:

and it is working properly. When I finish and put on a EC2 instance, I created a new Client an Secret id for a production environment and set them properly on parameters, and the uri is:

The problem is google is redirecting to the dev one uri, not the new one.

I tried: php bin/console cache:warmup --env=prod clearing the browser cache

Anybody know why this behaviour?


Where to place tsconfig.json in Symfony Encore to define TypeScript config?

Sat, 07/08/2017 - 17:15

Symfony Encore now supports using TypeScript by default (Add support to enableTypescriptLoader), and it works great. However, I would like to configure my TypeScript configuration using a tsconfig.json file.

I tried figuring out where to place this, but I got lost in the rabbithole and didn't figure out where I should place the file for ts-loader to pick it up. Or if there is a configuration that enables this.

Android app with java ee backend

Sat, 07/08/2017 - 17:15

i'm asking if i can work with java ee and spring like a backend to developp an android application, also I wonder if I can execute an android app on iphone or it must be ios app to work on iphone thanks :)

Flex-grow having no effect on flex-items [on hold]

Sat, 07/08/2017 - 16:53

Edited for clarity: I've assigned a div to be a flex container, and thus the direct children (two div containers inside it) should be flex-items. I should be able to assign a flex-grow value to these items to manipulate how much space they take up in a row. My goal is for the image to take up approximately 1/5 of the space, while the text takes up about 4/5. However, it appears that my assigned flex-grow values are having no effect, as my image stubbornly stays the same size and the text resizes around it.

Edited typo: There was a stray 'pre' tag in my code here as I was trying to paste it in. That 'pre' tag is not in MY code, and I've deleted it from here.

Edited image: Before I had a link to an image that visitors could not see, as it is hosted on my machine. I've updated the image src to include an image hosted online of approximately the same dimensions, so that visitors could (hopefully) see and reproduce the problem via Run Code Snippet.

Edited pargraph: Added more text to accentuate the problem.

I do have a max-width set on the container, but turning that off doesn't appear to allow the flex to work either, so I don't think it's conflicting.

Here is my code:

.home-div { display: flex; max-width: 900px; margin: auto; } div.portrait { flex-grow: 1; } div.welcome-text { flex-grow: 3; } .rj { max-height: 500px; } <div class="home-div lg-pad"> <div class="portrait"> <img src="" class="rj sm-pad"> </div> <div class="welcome-text sm-pad"> <h1>Rebecca Jensen</h1> <h3>UX/UI Designer</h3> <p>Keytar art party food truck tofu salvia pork belly. Meditation whatever kogi, messenger bag vexillologist DIY master cleanse artisan selfies tbh. Tofu pork belly PBR&B gentrify ugh, green juice irony truffaut. Beard tattooed pug cold-pressed farm-to-table hammock jean shorts salvia ramps tote bag. Man braid bespoke gastropub put a bird on it four dollar toast try-hard flannel taiyaki. Lo-fi copper mug 8-bit locavore. Drinking vinegar authentic selvage 90's man bun, fingerstache poutine wolf jean shorts lomo mixtape DIY normcore knausgaard leggings. Artisan flexitarian aesthetic art party neutra drinking vinegar palo santo. Cornhole irony copper mug sriracha fashion axe. Pug single-origin coffee chicharrones raw denim paleo. </p> <p><a href="contact.html" title="Contact me">Contact me!</a></p> </div> </div>

It seems that the image is the source of the problem, but I don't know what about it is causing the problem.

Sudden memory expansion between 2 inits. Can go log chronilogical functions called?

Sat, 07/08/2017 - 16:48

I have a routing package that inits multiple others. When I log all the inits I get the following order of output:

Initializing Config.. Initializing Countries.. Initializing Languages.. Initializing Globals.. Initializing Translations.. Initializing Tokenpool.. Initializing Mail.. Initializing Routing..

If I halt-loop at the end of tokenpool the memory is 7MB. At the beginning of mail it's suddenly 24MB.

Besides pprof memory tracing, is there a runtime-style tactic to get a big trace, until some runtime.StopTrace() kind-of-thing gets called, that will show all functions that have been called?

Stuck with evenly resizing an image animation

Sat, 07/08/2017 - 16:15

I'm trying to recreate this effect:

I tired everything, I got it to resize but can't get that effect where image is fixed and its being resized from all sides.

Here is my code:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <style> body { padding: 0; margin: 0; } </style> <body> <div id="menu" style="float: left; width: 200px; height: 1000px; background: black; display: inline-block;"> </div> <div id="img-01" style="z-index: 100; width: 100%; position: absolute;"> <img src="" id="photograph" style="width: 100%; height: 100%;"> </div> <script src="" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> <script> $(document).ready(function () { $("#img-01").click(function () { $("#img-01").animate({ height: '400px', width: '400px', left: '300px' }, 1500); }); }); </script> <script> $(document).ready(function() { $('#photograph').hide(); $('#photograph').each(function(i) { if (this.complete) { $(this).fadeIn(); } else { $(this).load(function() { $(this).fadeIn(); }); } }); }); </script> </body> </html>

Not sure what to do. Thanks.

Twig table get id outside for loop

Sat, 07/08/2017 - 15:01

I'm trying to access to the user id outside my for loop in twig


{% set userid = '' %} <table class="display dataTable" id="manageusertable" cellspacing="0" width="100%"> <thead> <tr> <th>Image</th> <th>Login</th> <th>Nom / Prenom</th> <th>Email</th> <th>Activé</th> <th>Actions</th> </tr> </thead> <tfoot> </tfoot> <tbody> {% for user in users %} {% set userid = %} <tr class="getid"> <td>{{ user.UserImage }}</td> <td>{{ user.username }}</td> <td>{{ user.UserLastname }} / {{ user.UserFirstName }} </td> <td>{{ }}</td> {% if user.enabled == 1 %} <td><i class="fa fa-check" aria-hidden="true"></i></td> {% else %} <td><i class="fa fa-times" aria-hidden="true"></i></td> {% endif %} <td> <i class="fa fa-search" aria-hidden="true"></i> <button type="button" class="btn btn-add btn-sm" data- toggle="modal" data-target="#update"><i class="fa fa- pencil"></i></button> <button type="button" class="deleteuser btn btn-danger btn-sm" data-toggle="modal" data-target="#deleteuser"><i class="fa fa-trash-o"></i> </button> </td> </tr> {% endfor %} </tbody> </table>

Modal div when button data-model=#delete is clicked (outside loop)

<div class="modal fade" id="deleteuser" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header modal-header-primary"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3><i class="fa fa-user m-r-5"></i> Delete User</h3> </div> <div class="modal-body"> <div class="row"> <div class="col-md-12"> <form class="form-horizontal"> <fieldset> <div class="col-md-12 form-group user-form-group"> <label class="control-label">Delete User</label> <div class="pull-right"> <button type="button" class="btn btn-danger btn-sm">NO</button> <button " class="btn btn-add btn-sm"><a style="color:#fff;" href="{{ path('lemon_user_deleteuser', {'id': userid}) }}">YES</a></button> </div> </div> </fieldset> </form> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-danger pull-left" data-dismiss="modal">Close</button> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div>

The line <button " class="btn btn-add btn-sm"><a style="color:#fff;" href="{{ path('lemon_user_deleteuser', {'id': userid}) }}">YES</a></button>

always returns the last id (15 if i have 15users in my DB) no matter on which line the button is clicked

i know how to do this with jquery/ajax and from scratch php but since im new to symfony/twig im kinda lost

Generate PDF file from HTML code

Sat, 07/08/2017 - 15:00

I would like to generate a PDF file from a HTML code which contains the stylesheet rules, using PHP.

I am trying to do it using the MPDF library, but when is generated it doesn't look like the HTML page. Most of the elements are not situated in the right position and is like some css rules were not applied.

Does anyone know how can I make it look fine, please?

Changing background of qt widget with css

Sat, 07/08/2017 - 12:56

i am new in Qt and want to change background color and set animation to background of widget(in Qt so its not duplicated question ) but when i go to change style sheet and paste css code in it i faced with non changed background any help lets assume this html code witch has css :

div { width: 100px; height: 100px; position: relative; background-color: red; animation-name: example; animation-duration: 4s; animation-iteration-count: infinite; }

Localhost Service Discovery For a Custom XEP-0114 Component in Prosody or ejabberd

Sat, 07/08/2017 - 09:52

I have written a silly hello-world XEP-0114 component and got it connected to Prosody and ejabberd. Now I want to use service discovery to announce presence of the service and provide instructions about its usage.

So I seek a way to make it discoverable for anyone with a JID, remote or local, to provide more details about it.

For Prosody I do:

Component "foo.localhost" component_secret = "secret" disco_items = { { "foo.localhost", "FOO BAR" }; }

For ejabberd I do:

modules: mod_disco: extra_domains: - "foo.localhost" - "localhost" server_info: - modules: all name: "abuse-addresses" urls: - "" listen: - port: 8888 module: ejabberd_service access: all shaper_rule: fast ip: "" hosts: "foo.localhost": password: "secret"

Then in Gajim I start service discovery on localhost and get error:

There is no service at the address you entered, or it is not responding. Check the address and try again.

What do I miss?

Angular 4 Refresh section of page only

Sat, 07/08/2017 - 06:29

Hi community I have a Plunker where I have implemented this flow:

Updated Plunker: I solved but header component gets called each time and I have to put my header component in each html is there a better way to do it?

  1. Login
  2. Show list of countries (User info on top)
  3. Click on one of the countries and show details about it (Problem is here)
  4. Go back to list

I need to refresh only the section of the countries list, but in my plunker you can see the whole page is refreshing I want to keep the user info on top (static).

I have little experience. Thanks a lot!

@Component({ selector : 'login', template: ` <input type="text" value="james"> <input type="password" value="123"> <button (click)="logIn()">Login</button> ` }) class LoginComponent { constructor(private route: ActivatedRoute, private router: Router) { } logIn () { //LOGIN LOGIC this.router.navigate(['/base']); } }

Automatically handle alert popups in selenium

Sat, 07/08/2017 - 06:12

can anyone help me how to automatically handle the alert popus in selenium i.e. Whenever an alert comes, then my driver should automatically handle this. How can I write the code?