Missing routes.php File in New Laravel Project

I downloaded Composer, installed Laravel, and started my first Laravel project to begin learning Laravel using the lessons on laracast (great lessons). Lesson two covers routes. My new project does not have a routes.php file.
I deleted composer and started again. Same thing. Tried two different computers. Same thing. I was using NetBeans so I tried using PHP Storm. Same thing. I tried making my own routes.php file but it doesn't seem to work right because I know nothing about Laravel at this point. I tried creating and saving the project in htdocs, and then PHPStorm project folder, again - no routes.php file.
Composer is saved here- C:\Users\myName\AppData\Roaming\Composer\vendor\bin. I used composer global require "laravel/installer" in command prompt to install laravel. Any ideas?
---Answer----
1.
I downloaded Composer, installed Laravel, and started my first Laravel project to begin learning Laravel using the lessons on laracast (great lessons). Lesson two covers routes. My new project does not have a routes.php file.
I deleted composer and started again. Same thing. Tried two different computers. Same thing. I was using NetBeans so I tried using PHP Storm. Same thing. I tried making my own routes.php file but it doesn't seem to work right because I know nothing about Laravel at this point. I tried creating and saving the project in htdocs, and then PHPStorm project folder, again - no routes.php file.
Composer is saved here- C:\Users\myName\AppData\Roaming\Composer\vendor\bin. I used composer global require "laravel/installer" in command prompt to install laravel. Any ideas?
2.
If you want to install laravel you should install it by composer command like this:
composer create-project --prefer-dist laravel/laravel your-project-name
laravel documentation: laravel installation
and if your composer is not installed perfectly you should go to composer installation and install your composer from here.
and routes.php file is located under app\Http\routes.php.
enter image description here


Localise App display name that have append suffix

I have a issue with getting app display name to include the appending suffix when adding localisation to InfoStrings.plist.
I have add different scheme and User-Defined attribute. So in my info.plist, i have App Name $(BUNDLE_DISPLAY_NAME_SUFFIX) in my CFBundleDisplayName. It will append a -S to my app name when running on development scheme and normal app name on release scheme that i created. Everything is working well.
However, when I try to translate the app name, it does not work anymore. So in my infoPlist.strings, I tried the following:
"CFBundleDisplayName" = "App Name ";
"CFBundleDisplayName" = "App Name $(BUNDLE_DISPLAY_NAME_SUFFIX)";
Both does not append the -S anymore when I run on development scheme. Does anyone know how I could still do that? Like maybe how to get the $(Bundle_DISPLAY_NAME_SUFFIX) to be read in the infoPlist.strings.
More specifically, how do I include a preprocessor in InfoPlist.strings?
-----Answer-----
Follow following steps as mentioned in attached screenshots.
enter image description here
enter image description here
enter image description here
enter image description here

Couchbase Admin Console Settings Notification

On my local instance of Couchbase (4.1.0) a notification icon has appeared on the settings tab inside of Admin Console. When clicking on the Settings tab and navigating to the sub tabs there doesn't appear to be any new information and the icon remains. What is the icon notification used to 
indicate/ additionally how do I get rid of the notification
Notification icon top right of fhe scree,  
 -----Answer-----
This is just a notification to upgrade couchbase to 4.5. Not sure why it never appeared before since 4.5 has been out for a while 

How do I subtract two date columns and two time columns in sql

I have 4 columns that are
Startdate, 
enddate, 
starttime, 
endtime.  
I need to get subtractions from the enddate and endtime - startdate and starttime. I will need that answer from the four columns in sql.
so far I have this I found but dont think this will work right.
SELECT DATEDIFF (day, enddate, startdate) as NumberOfDays  
DATEDIFF(hour,endtime,starttime) AS NumberOfHours 
DATEDIFF(minute,endtime,starttime) AS NumberOfMinutes 
from table;
Thanks for your help
----Answer----
1.
Assuming you have data like this, you can add the StartDate to the StartTime to get the StartDateTime, same for the EndDateTime
StartDate                StartTime                EndDate                  EndTime              
-----------------------  -----------------------  -----------------------  -----------------------
2014-05-01 00:00:00.000  1900-01-01 10:53:28.290  2014-05-07 00:00:00.000  1900-01-01 11:55:28.290
Once you've done that you can get the Days, Hours and Minutes like this:
select 
DATEDIFF(minute, StartDate + StartTime, EndDate + EndTime) / (24*60) 'Days',
(DATEDIFF(minute, StartDate + StartTime, EndDate + EndTime) / 60) % 24 'Hours',
DATEDIFF(minute, StartDate + StartTime, EndDate + EndTime) % 60 'Minutess'
  from YourTable
We have work in minutes the whole time in order to prevent problems with partial days crossing midnight and partial hours crossing an hour mark.
2.
EDIT - Now that I realize that the question is for SQL Server 2000, this proposed answer may not work.
The SQL Server 2000 documentation can be found at https://www.microsoft.com/en-us/download/details.aspx?id=18819. Once installed, look for tsqlref.chm in your installed path, and in that help file you can find information specific to DATEDIFF.

Based on the wording of the original question, I'm assuming that the start/end time columns are of type TIME, meaning there is no date portion. With that in mind, the following would answer your question.
However, note that depending on your data, you will lose precision in regards to the seconds and milliseconds.
More about DATEDIFF: https://msdn.microsoft.com/en-us/library/ms189794.aspx

DECLARE @mytable AS TABLE 
    (
        startdate DATETIME,
        enddate DATETIME,
        starttime TIME,
        endtime TIME
    )


INSERT INTO @mytable (startdate, enddate, starttime, endtime)
VALUES      (GETDATE() - 376, GETDATE(), '00:00:00', '23:59')

SELECT      *
FROM        @mytable

SELECT      DATEDIFF(HOUR, startdate, enddate) AS [NumHours],
            DATEDIFF(MINUTE, starttime, endtime) AS [NumMinutes]
FROM        @mytable
This would yield output similar to:
enter image description here


What does this code in Swift do?

I'm following a raywenderlich.com tutorial on using the Google Maps iOS SDK. I came across this piece of code which is halfway down this link here: https://www.raywenderlich.com/109888/google-maps-ios-sdk-tutorial.
I am familiar with Swift but I do not get what the piece of code after geocoder.reverseGeocodeCoordinate(coordinate) does; specifically, how can you just place the curly brackets right after the method call and what does it accomplish? I am asking this in terms of Swift syntax.
func reverseGeocodeCoordinate(coordinate: CLLocationCoordinate2D) {

  // 1
  let geocoder = GMSGeocoder()

  // 2
  geocoder.reverseGeocodeCoordinate(coordinate) { response, error in
    if let address = response?.firstResult() {

      // 3
      let lines = address.lines as! [String]
      self.addressLabel.text = lines.joinWithSeparator("\n")

      // 4
      UIView.animateWithDuration(0.25) {
        self.view.layoutIfNeeded()
      }
    }
  }
}
-----Answer-----------
1.
This is called a "trailing closure" or "trailing closure syntax". It's described in Apple's docs here:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Closures.html#//apple_ref/doc/uid/TP40014097-CH11-ID102
In summary, if the last parameter of a method or function is a closure, you can provide it immediately after the closing ) of the function call and the previous arguments. Example:
func sendMessage(text:String, withCallback:(Bool)->()) {
    // Implementation
}

let message = "hello"
sendMessage(message) { 
    let result = $0 ? "Suceeded" : "Failed"
    print(result)
}
If a function take only one parameter and that parameter is a closure, then you don't need to use () at all and can just pass the closure immediately after the function name. For example see how this filter method is called:
let boolArray = [true, true, false, true, false]
let filtered = boolArray.filter { $0 == false }  // Only the falses
2. 
It is called a trailing closure. A trailing closure is a closure expression that is written outside of the parentheses of the function call.
The only requirement here is that the closure must be function's final argument.
Given the following function, these two calls are identical:
func someAPICall(url: String, completion: (Bool -> Void)) {
  // make some HTTP request
  completion(result.isSuccess)
}

someAPICall("http://httpbin.org/get") { success in
  print("Success", success)
}

someAPICall("http://httpbin.org/get", completion: { success in
  print("Success", success)
})
 
 

What is the difference between PowerMock, EasyMock and Mockito frameworks ?

I am very new to mocking framework, and my work needs mocking framework to finish unit testing. When I try to use mock methods, variables of a class using junit which one of the above frameworks should I prefer? 

------Answer--------

Differences

  • No record/replay modes - no need for them. There only 2 things you can do with Mockito mocks - verify or stub. Stubbing goes before execution and verification afterwards.
  • All mocks are nice (even somehow nicer, because collection-returning methods return empty collections instead of nulls). Even though mocks are nice, you can verify them as strictly as you want and detect any unwanted interaction.
  • Explicit language for better readability: verify() and when() VS the mixture of expect(mock.foo()) and mock.foo() (plain method call without expect). I'm sure some of you will find this argument subjective :)
  • Simplified stubbing model - stubbed methods replay all the time with stubbed value no matter how many times they are called. Works exactly like EasyMock's andStubReturn(), andStubThrow(). Also, you can stub with different return values for different arguments (like in EasyMock).
  • Verification of stubbed methods is optional because usually it's more important to test if the stubbed value is used correctly rather than where's it come from.
  • Verification is explicit - verification errors point at line of code showing what interaction failed.
  • Verification in order is flexible and doesn't require to verify every single interaction.
  • Custom argument matchers use hamcrest matchers, so you can use your existing hamcrest matchers. (EasyMock can also integrate with Hamcrest though it is not a part of EasyMock but Hamcrest. See the documentation of Hamcrest).
PowerMock is an extension of other Mocking frameworks like Mockito or EasyMock that comes with more powerful capabilities. It means that you can combine Mockito/EasyMock and PowerMock into the same unit test.
I personally use Mockito for unit testing big part of my code and PowerMock only in code that needs its extra features as testing static methods.

 

this.setState is undefined

I keep seeing answers that say to use => or .bind(this) but neither of those solutions worked.
import React, { Component } from 'react';
import { View, Text, TextInput, StyleSheet } from 'react-native';

export default class MyWeatherApp extends Component {
  constructor(props) {
  super(props);

  this.state = {};
}

getInitialState() {
  return {
    zip: '',
    forecast: null,
  };
}

_handleTextChange(event) {
  var zip = event.nativeEvent.text;
  this.setState({zip: zip});
}
----Answers------------
1.
When you extend React.Component with ES2015 class syntax you need to bind your action handlers to a context of your class.
Try this: onChange={e => _handleTextChange(e)}
Generally, it's better not to use arrow functions or bind methods inside render as it generates a new copy of the function on any render call. Move function declaration to the class constructor.
I personally prefer to use arrow functions as class properties in this case
class MyClass extends React.Component {

  handleClick = () => {
    // your logic
  };

  render() {
    return (
      <button onClick={this.handleClick}>Click me</button>
    );
  }
}
It's not a part of ES2015 specification but babel stage-0 preset supports this syntax
You can read more about context binding in React in this article
2.
i hope the below code may give you the idea
import React, { Component } from 'react';
import { View, Text, TextInput, StyleSheet } from 'react-native';

export default class MyWeatherApp extends Component {
  constructor(props) {
    super(props);
    this.state = {
      zip: '',
      forecast: null
    };
   }

_handleTextChange(event) {
  var zip = event.nativeEvent.text;
  this.setState({zip: zip});
}

render() {
return (
   <button onChange={e => _handleTextChange(e)}>Click me</button>
  );
 }
}
 

Designing Data structure for Firebase

------Question-------
Warning: My query would be more theoretical (sorry programmers, please bear with me). I am trying to get some idea on how to define the database structure for use in Firebase.
I am exploring the use of Firebase as a backend for a Review app (in Android) I am trying to build.
The app provides product details and review for products of different kinds. So here is an example use case.
  1. The products displayed in the app are of same type (say smartphones). In this use case, defining the database structure is easier. For every phone, I simply need to save the phone specs to Firebase and retrieve them into my app.
Root
 |
 +--Smartphone
     |
     +--Manufacturer Name
     +--Screen Size
     +--Screen Density
     +--Processor
     +--RAM,...
  1. The products displayed in the app are of different type (say smartphones, Car, Book,...). In this use case, defining the database structure becomes complex. I can simply define the data structure like
Root
 |
 +--Product
     |
     +--Manufacturer Name
     +--Screen Size
     +--Screen Density
     +--Processor
     +--RAM
     +--Fuel type (Petrol/Diesel/Electric)
     +--Vehicle Type (Sedan/Hatchback)
     +--Vehicle Price,...
However, the problem with above data structure is, when I am trying to make a product review for a smartphone, the data related to Car will remain blank. Same will be the case for a product review of a Car.
This problem can be solved by using Flattening the data structure. This is where I am confused.
Root
 |
 +--Smartphone
 |   |
 |   +--Manufacturer Name
 |   +--Screen Size
 |   +--Screen Density
 |   +--Processor
 |   +--RAM
 |
 +--Car
     |
     +--Fuel type (Petrol/Diesel/Electric)
     +--Vehicle Type (Sedan/Hatchback)
     +--Vehicle Price,...
However, all product reviews will be displayed in a single activity/fragment. Hence, there will not be different activities/fragments for every product type. Could someone provide me a clear picture of using flattened data structures in my use case?
----Answers----
1.
You can structure your database like this:
products: {
    smartphones: {
        smartphone1: {
            name: "Best Phone",
            ram: "6 GB",
            screen: "5.5 inch"
            reviews: {
                review1: true,
                review2: true
            }
        }
    },
    cars: {
        car1: {
            name: "Lightning"
            reviews: {
                review3: true,
                review4: true,
                review5: true
            }
        }
    }
},
product-review: {
    review1: {
        submittedBy: "Conqueror",
        message: "Best phone at this price",
        timestamp: 1472405901
    },
    review2: {
        submittedBy: "Magic Blaster",
        message: "Pros: RAM, Cons: Everything else."
        timestamp: 1472405901
    },
    review3: {
       submittedBy: "Boss",
       message: "Excellent Car",
       timestamp: 1472405901
    },
    ...
}
Every product(smartphone1, car1 etc..) contains a reviews node, so you can easily load the linked reviews of a particular product.
2.
Here is the flattest database structure that I can think of. For the products node, you can also use the third structure in your question, it will only affect the logic on how to map the item in your app.
products: {
    item1: {
        type: "smartphone",
        manufacturer_name: "some value",
        screen_size: "some value",
        screen_density: "some value",
        processor: "some value",
        ram: "some value"
    },
    item2: {
        type: "car",
        fuel_type: "some value",
        vehicle_type: "some value",
        vehicle_price: "some value"
    }
},
users: {
    user1: {
        name: "some value",
        email: "some value"
    },
    user2: {
        name: "some value",
        email: "some value"
    },
},
products_reviews: {
    item1: {
        user1: ewview1,
        user2: review2
    },
    item2: {
        user2: review3
    }
},
users_reviews: {
    user1: {
        item1: review1
    },
    user2: {
        item1: review2,
        item2: review3
    }
},
reviews: {
    review1: {
        text: "this is my review",
        timestamp: 1472488486000
    },
    review2: {
        text: "this is my review",
        timestamp: 1472488486000
    },
    review3: {
        text: "this is my review",
        timestamp: 1472488486000
    }
}
Now you should be able to retrieve all reviews from each user and also retrieve all reviews for each product.
Comment here if you have questions, hope this helps :)

Is it possible to access (read only) the variables captured by a lambda?

Is it possible to access (read only) the variables captured by a lambda?
This doesn't work:
std::function<double  (const double)> plus (const double a) {
    return [a] (const double b) -> double {
        return a+b;
    };
}

auto plus5 = plus(5);
cout << plus5.a << endl;
----Answers------
1. 
auto plus( double a ) {
  using R = struct {
    double a;
    double operator()(double b)const{return b+a;}
  };
  return R{a};
}
live example.
Please note that a std::function is not a lambda, and lambda is not a std::function. They work with each other, but using one term to refer to the other is the opposite of helpful.
2.
This is not how a lambda should be used.
The interface of a lambda is its function signature. Its captures should be considered an implementation detail and not be visible to the user.
If you want explicit access to the captures, write your own function object and expose the respective data members accordingly:
struct MyPlus {
    double a;
    MyPlus(double x) : a(x) {}
    double operator()(const double b)
    {
        return a+b;
    }
};

auto plus5 = MyPlus(5);
std::cout << plus5.a;
 3.
Well let's relieve Yakk's karma; here's a proof of concept of a C++14 solution which you definitely don't want to let loose in the wild:
auto magic = [a, b](auto &&... args) mutable -> decltype(auto) {
    return makeOverload(

        // Capture access boilerplate
        [&](cap_<0>) -> auto& { return a; },
        [&](cap_<1>) -> auto& { return b; },

        // Actual function
        [&](int p) {
            return "[" + std::to_string(a) + ", " + b + "](" + std::to_string(p) + ")";
        }

    )(std::forward<decltype(args)>(args)...);
};
makeOverload takes any number of functors and blends them into a single one. I borrowed the idea from this blog post, with help from the comment section to make it actually work.
The resulting functor is used to tag-dispatch between the cap<N> tags and the actual parameters of the function. Thus, calling magic(cap<0>) causes it to spit out the corresponding captured variable, that is a. The actual behaviour of the function is, of course, still accessible with a normal call to magic(123).
As a bonus, the outer lambda is mutable, and the capture accessors return by reference: you actually have read-write access to the captured variables!
You can observe and interact with this creature in its natural habitat on Coliru right here.
 

Running nasm program on ARM linux

Question

I am trying to teach myself assembly programming with NASM. However I only have a Chromebook with ARM processor. I have xubuntu running on it with crunton. However how can I setup a x86 emulation environment to get myself started? I also want to be able to use insight debugger.
Answers
1.
Try bochs or qemu.
If you're only on a chromebook probably without a lot of RAM, you probably just want to run a very minimal Linux system inside your emulated x86 environment. Not a full xubuntu GUI install inside the emulated x86 environment.
For learning x86, you should start with 32 or 64bit ASM, either for functions you call from C, or as a standalone program. (Either really standalone, where you don't link with the C standard runtime or library, and write your own _start in asm, and make your own system calls, or just write main in asm and end your program with a ret from main.)
bochs has a built-in debugger, but using it would be more appropriate for debugging the kernel, or boot-loader. IDK anything about the Insight debugger, but if it can remote-debug, running an ARM binary of it natively, connected to the target you want to debug, might make sense.
You could write x86 asm that you boot directly (instead of a Linux image), but then you'd only have BIOS calls available, and the CPU would start in 16bit real mode with segmented memory and all that crap that's basically useless to learn except for writing bootloaders.
2.
QEMU has a user mode emulation feature which can be used to run x86 Linux programs on ARM Linux, or any other combination of supported architectures.

Android studio add different size drawable and layout folder

how can i add those folders in my project in android studio
res/drawable-ldpi/
res/drawable-ldpi-v8/
res/drawable-ldpi-v11/
res/drawable-mdpi/
res/drawable-mdpi-v8/
res/drawable-mdpi-v11/
res/drawable-hdpi/
res/drawable-hdpi-v8/
res/drawable-hdpi-v11/
res/drawable-xhdpi/
res/drawable-xhdpi-v8/
res/drawable-xhdpi-v11/
res/drawable-xxhdpi/
res/drawable-xxhdpi-v8/
res/drawable-xxhdpi-v11/
res/layout-land
res/layout-small-port-v4
res/layout-sw600dp-v13
res/layout-w480dp-v13
res/layout-v11
res/layout-port
i just made new project and i cant see any folder of those in my project
this is image of my project folders
enter image description here
------Answers----
1.
you have to create new folder inside res folder
2.
In Android Studio, at the top right where you have your project structure and Android View is selected, choose "Project", and you will be able to see the full hierarchy of your project. From there you can achieve what you are trying to do.
3.
Since these are folders, you can always use Windows Explorer to add them.
In Android Studio, the Project Window is currently in the default Android View. If you want to see the physical directory structure, you need to change it to the Project View by clicking on the drop down menu at the top of the Project Window.
enter image description here
Now you can add folders any where you want similar to how you do in Windows Explorer.







Work around for re-rendering new state in react

      import React, {Component} from 'react';
      import Square from './components/board.js';

      const spaceArr = ()=> {
         const arr =[];
         for (var i=0; i<20; i++){
         arr.push(Math.floor(Math.random()*(400-0)));
         }
         return arr;
      };


      class App extends Component{

        constructor(){
          super();
          this.state={
            spaces: spaceArr(),
            array : new Array(400).fill(false)
          } ;
          var th = this;
          this.state.spaces.map(function(value){  
          th.state.array.splice(value, 1, true)});
            this.click= this.click.bind(this);
          }

          componentDidMount(){
            this.setState({array: this.state.array})
          }

          click(i, live) {  
            this.state.array[i]= !live;
            var array = this.state.array;
            this.setState({array: array}, function(){
             console.log(array[i]) 
          })
          }


         render(){

           var th = this;
          return (
             <div>
               <div className='backboard'>
               <div className='board'>
                 {this.state.array.map(function(live, index){

                   return <Square key={index} living={live} clicker=  
                     {th.click.bind(this, index, live)}/>
                   })

                  }
                </div>
             </div>
           </div>
           )
          }
         }

         export default App;
I am trying to figure out how to re-render the updated state change after setState. the click event is a handler that is passed to a child component. the updated array should re-render an updated rendering of child components.

-----Answers------

1. Try this.
 click(i, live) {  
      var array = this.state.array;
      array[i]=!live
      this.setState({array:array}, function(){
         console.log(this.state.array[i]) 
      })
  }
 2.
You shouldn't mutate this.state directly as mentioned in React docs. Use concat for getting a new array before setting the new state:
click(i, live) {  
  var newArray = this.state.array.concat();
  newArray[i]!=live
  this.setState({array: newArray}, function(){
     console.log(this.state.array[i]);
  })
}

3.

on your return it should be,
return (<Square key={index} living={live} 
  clicker= {th.click.bind(th, index, live)}/>
});
 

Resolving Promises Asynchronously in angularjs

My code:
$q(function (resolve) {
    var imageUploadResults = [];
    fileUploadService.uploadImage($scope.filesUpload, "/api/mailbox/uploadAttachFile", function (result) {
        console.log(result);
        imageUploadResults.push(result.LocalFilePath);
    });
    $scope.mail.Files = imageUploadResults;
    resolve($scope.mail);
}).then(function (mail) {
    console.log(mail);
    apiService.post("/api/mailbox/sendMail", mail, sendMailSucceed, sendMailFailed);
});
Expect:
I want to add value to mail.Files finish,then call apiService.post()
Actual:
But it execute apiService.post() with mail.Files value is [].
When apiService.post() execute finish mail.Files return value.length > 0.

------Answers-----

1.
Without knowing exactly which library you are actually using, it seems clear to me that fileUploadService.uploadImage() is asynchronous.
The function that you give as an argument is a callback and there is no guarantee that it would be executed "on time". In your case the path is added to imageUploadResults after the moment where you set $scope.mail.Files.
you should set $scope.mail.Files and call resolve in your callback function.
$q(function (resolve) {
    var imageUploadResults = [];
    fileUploadService.uploadImage($scope.filesUpload, "/api/mailbox/uploadAttachFile", function (result) {
        console.log(result);
        imageUploadResults.push(result.LocalFilePath);
        $scope.mail.Files = imageUploadResults;
        resolve($scope.mail);
    });
}).then(function (mail) {
    console.log(mail);
    apiService.post("/api/mailbox/sendMail", mail, sendMailSucceed, sendMailFailed);
});
2.
When you assigned $scope.mail.Files = imageUploadResults; and resolved resolve($scope.mail); there are no guarantee that fileUploadService.uploadImage finished request and saved imageUploadResults.push(result.LocalFilePath);
Possible solution is to add resolve($scope.mail); right after imageUploadResults.push(result.LocalFilePath); in function passed to fileUploadService.uploadImage
 

Resize problem in scroll area


Hello everyone, here is my code:
myplot *p = new myplot(gao.structpayloadgraph, 
                       gao1.structpayloadgraph, 
                       gao.structcol-2, "payload");

ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->scrollArea->setWidgetResizable(false);
p->resize(ui->scrollArea->size().width(), ui->scrollArea->size().height());

ui->scrollArea->setWidget(p);

-----Question-----

I want p to take up the full available space of the 
scrollbar area and fit itself. However, the appearance looks 'squeezed' 
even though I called the resize function. What should I do to achieve 
the desired effect? 

-----Answers-----

1.
You have to treat the scroll area content widget as a normal QWidget. If you want automatic resize and you must use layouts in Qt. Try the following :
QVBoxLayout layout = new QVBoxLayout( ui->scrollAreaContent);
layout->setMargin(0);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
ui->scrollAreaContent->setLayout( layout);
layout->addWidget(p);
NOTE: ui->scrollAreaContent is a guess, but I think you are using ui files and default content widget is named like that ...
2.
Go to the top right of the QT creator designer screen (Object, Class), right click on the QScrollArea row and select the "Lay Out" menu item, choose a layout (eg vertical or horizontal layout), make sure that your QWidget has a minimum or above size policy. Your scroll widget should now resize with the layout. 



Angular2 Filter issue

Here's how I am using the filter:
  <ion-item *ngFor="let contact of contacts | isMember">
           <ion-label>{{contact.name}}</ion-label>

           {{contact.phoneNumber}}-{{contact.isMember}}
       </ion-item>
Filter definition below:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'isMember'})
export class IsMemberPipe implements PipeTransform {
    transform(value: any): any {

        if (value.isMember === true) {
            return value;
        }
        return undefined;

    }
}
-----

Question

Goal is to only display rows that have isMember flag set to true.
------

Answers

Just ensure your pipe doesn't explode when null is passed in as value
if (value && value.isMember === true) {

How get ownership property of (Method: TRttiMethod) in TVirtualInterface TVirtualInterfaceInvokeEvent?

how i get ownership property of Method: TRttiMethod in OnInvoke method of TVirtualInterface class?
I have this interface:
IPerson = interface(IInvokable)
   ['{45CE428C-F880-4D61-A2C1-0F3CB47130B5}']
   procedure SetName(const Value: string);
   function GetName(): string;

   [TEntityField('Field Name Here')]
   property Name: string read GetName write SetName;
end;
and this class:
type
   TVirtualEntity<T: IInvokable> = class(TVirtualInterface)
   public
      constructor Create(); reintroduce; overload;
   end;

constructor TVirtualEntity<T>.Create;
begin
   inherited Create(TypeInfo(T));
   Self.OnInvoke :=
      procedure(Method: TRttiMethod; const Args: TArray<TValue>; out Result: TValue)
      var
         attributes: TArray<TCustomAttribute>;
         attributesManager: TAttributesManager;
         entityFieldAttribute: TEntityField;
      begin
         attributesManager := TAttributesManager.Create(Method.GetAttributes);
         try                
            if attributesManager.HasAttribute<TEntityField>() then
            begin
               Result := attributesManager.GetAttribute<TEntityField>.FieldName;
            end;

         finally
            attributesManager.Free;
         end;
      end;
end;
I'd like to get TRttiProperty of Method: TRttiMethod, but how? if i change the interface to:
IPerson = interface(IInvokable)
   ['{45CE428C-F880-4D61-A2C1-0F3CB47130B5}']
   procedure SetName(const Value: string);
   [TEntityField('Field Name Here')]
   function GetName(): string;

   property Name: string read GetName write SetName;
end;
the code works, but i'd like to user interfaces like this:
IPerson = interface(IInvokable)
   ['{45CE428C-F880-4D61-A2C1-0F3CB47130B5}']
   procedure SetName(const Value: string);
   function GetName(): string;

   [TEntityField('Field Name Here')]
   property Name: string read GetName write SetName;
end;
------
Answers
Unfortunately, you can't. There is no RTTI generated for interface 
properties so there's nothing for your custom attribute to be attached 
to. Your decoration of the interface property has no effect, even if 
there's no warning. 

GroupBy after orderBy for complicated query in Laravel

Here is my code for fetching messaging and grouping them for each chat
$query = DB::table('chats');

    $otherUserId= $request->input('loadId');
    if($otherUserId==0){
        $query->join('users as u1', 'u1.id', '=', 'chats.user1_id');
        $query->join('users as u2', 'u2.id', '=', 'chats.user2_id');
        $query->join('messages', 'messages.chat_id', '=', 'chats.id');
        $query->where('chats.user1_id', '=', '{$userId}');
        $query->orWhere('chats.user2_id', '=', '{$userId}');
        $query->select('messages.chat_id', 'messages.from_id', 'u1.id as    user1_id', 'u2.id as user2_id', 'messages.created_at', 'messages.body', 'messages.read', 'u1.name as user1_name', 'u2.name as user2_name', 'u1.picture_url as user1_pic', 'u2.picture_url as user2_pic');

        $query->orderBy('messages.created_at ', 'DESC');
        $query->groupBy('chat_id');
        $messages = $query->paginate(4);
-------
 Question:
When I run the query the result is not as expected OrderBy comes after group by. I've tried a lot but could't find and solution. I tried this solution also but couldn't make it work. Order By before Group By using Eloquent (Laravel)
Please help me I've lost a lot of time trying to sort it out. Thanks in advance for helping me.
--------
Answers 
 1.
One line before the paginate add the following code
dd($query->toSql());
This will return the query string in order to debug the mysql query. If you still can't find out what is happening paste it here to help you.
2.
That's because it's not legal syntax to place the GROUP BY clause after an ORDER BY - note the formal definition in the docs. http://dev.mysql.com/doc/refman/5.7/en/select.html
It's not clear what you're actually trying to accomplish by this - SQL doesn't have particularly good support for ordered data inside an aggregate.
----
The end.
Good luck to you!!!

Popular Posts

Powered by Blogger.