Posts

Showing posts from July 2, 2018

Optimizing mysqli query for calculating Median using GROUP BY & ORDER BY

Optimizing mysqli query for calculating Median using GROUP BY & ORDER BY Please see below for a sample portion of my MySQL table: table name: eb_tickets I want to output the response like so, calculating the median value with distinct values ASC: Currently I am achieving this with the following query: Unfortunately this query is taking around 1 second per record, and I am querying thousands of records with the possibility of 20 different values for the ticket_type column. I am asking for help in seeing if it is possible to optimize my current query in attempt to make the query perform faster. Thank you for your help! 1 Answer 1 Could you try like this ? SELECT counter.ticket_type,AVG(time_first_response) AS median FROM ( SELECT IF(@type = type, @ctr := @ctr + 1, @ctr := 1) AS rownum, @type := ticket_type AS ticket_type, time_first_response FROM eb_tickets ORDER BY

Ionic serve VS ionic serve -c

Image
Ionic serve VS ionic serve -c I'm new in Ionic and using Ionic 3.9.2 I got several terminal commands to serve my ionic-app but, I'm not getting any difference between these two commands. ionic serve and ionic serve -c 2 Answers 2 This is basically short form of ionic serve --consolelogs for printing the log of you app in ionic CLI.(see the image) ionic serve --consolelogs There is second command to debug the app which is ionic serve --verbose ionic serve --verbose Hope this helps you to find out the difference. ionic serve -c ionic serve -c or ionic serve --consolelogs will Print app console logs to your Ionic CLI. Hope this helps By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Go to top page button after scrolling down

Go to top page button after scrolling down I created a method that go to the top of the page every time I click on it. The problem is, I want this button to be shown only if you already scrolled down and not just as default. How can I define it? Here is my code: show/hide the button - doesn't work: scrollFunction() { if (document.body.scrollTop > 5 || document.documentElement.scrollTop >5) { document.getElementById("myBtn").style.display = "block"; } else { document.getElementById("myBtn").style.display = "none"; } } scrolling to top - works: topFunction() { document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; } Thank you. where on your code are you calling the scrollFunction() ?? – Teobis Jun 29 at 0:09

Trying to print every combination of bits , given a variable

Trying to print every combination of bits , given a variable Lets say combinationlength =4. My logic is create the array {0,0,0,0} add 1 to the last element until first element gets the value 1 .Until then if with the addition of 1 the array[3] ends up in a 2 result then make it 0 and then traverse the array(reversed) given a counter variable and every first non 1 element make it 0 while making all elements before the value that first non 1 equal to 0 .This is for 8 repetitions.How close am i?Can someone help me finish this? combinationlength array {0,0,0,0} 1 1 1 array[3] 2 0 counter variable 1 0 1 0 Also this doesnt run for some reason.Nothing gets printed and ends after 2 seconds. I just noticed i am skipping a step but anyways. I want in every iteration to have an array like the sequence.And not added printf("0"); and shortcuts like that. void print(int combinationlength){ int i,j,count; int a=combinationlength-1; int c=combinationlength-1;

When connection to facebook is slowed down the site loads slowly

When connection to facebook is slowed down the site loads slowly We have a public website. It contains the Facebook Pixel script. However, in our region sometimes the speed to the Facebook drops down dramatically whereas the rest of the Internet works fine. When it happens the main page loads very slowly. This is the script located in the head of the page: As far as I know this script should load asynchronously but it seems that is doesn't, because the page cannot render completely until the facebook pixel finishes its work. I even set the pagespeed EnableFilters defer_javascript in the pagespeed module of my nginx but it doesn't help. pagespeed EnableFilters defer_javascript What can I do? What am I doing wrong? Try adding <script async> in your tag. P.S only works on external scripts using src . – Alex Jun 29 at 11:02

RecyclerView: Inconsistency detected. Invalid item position. Cause -Removing item using timer

RecyclerView: Inconsistency detected. Invalid item position. Cause -Removing item using timer Before moving ahead i search about this bug on google and i found the so many answer which are available but my scenario is different than their situation. java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 2(offset:2).state:3 I am using recyclerview to display the poll questions and every question has a timer, Item will removed from the list when timer runs out. Exception is occurring when the timer runs out but in only some rare scenario when less time (for ex 100ms) is remaining. so in that case may be recyclerview is inflating item and at that same time, timer rans out and recyclerview try to remove that item. Bug is when timer removing item i am getting the exception. So I solved it after removing the elements from data set when 1 or less seconds is remaining for that poll. So it will not add item in list and that will run the timer. If you want to produce

How to solve Fatal error: Unexpectedly found nil while unwrapping an Optional value in swift 4 [duplicate]

How to solve Fatal error: Unexpectedly found nil while unwrapping an Optional value in swift 4 [duplicate] This question already has an answer here: I am new to a swift, please someone help/advise me. And I am sending the request to a server and using completionBlock. When login button clicks the success completionBlock is calling and here i am getting struck. This is my request typealias CompletionBlock = ( _ response : Any , _ error : Error) -> Void func login(userName: String, password: String, completionBlock: @escaping CompletionBlock ) -> Void { let parameter = ["gs_username":userName, "gs_password":password] as [String : AnyObject] let url = "user-login" let fullUrl = baseUrl?.appendingPathComponent(url) if ((userName != nil) && (password != nil)) { Alamofire.request(fullUrl!, method: .post, parameters: parameter, headers: nil) .validate() .responseJSON { response in

Possible Unhandled Promise Rejection (id: 0): ReferenceError: user is not defined ReferenceError: user is not defined

Possible Unhandled Promise Rejection (id: 0): ReferenceError: user is not defined ReferenceError: user is not defined I have stored data user with AsyncStorage when i want to get it, it renders null in alert and the above error in the console,i don't know why. I can not see why it returns null with user but token all is well profile.js : import React, {Component} from 'react'; import { StyleSheet, Text, View, Image, TouchableOpacity,AsyncStorage} from 'react-native'; import { Container, Content, Header,Right, Left, Body} from 'native- base'; import Feather from 'react-native-vector-icons/Feather'; export default class Profile extends Component { constructor (props){ super(props); this.state = { user: null } } componentDidMount(){ this.fetchData(); } fetchData = async() =>{ let username = await AsyncStorage.getItem('user') this.setState({ user: username })

Can not extend SpringBootServletInitializer while using Apache-Camel Spring starter

Can not extend SpringBootServletInitializer while using Apache-Camel Spring starter I am trying to create a deployable *.war from a Spring Boot application by following their documentation. I am having problem while extending SpringBootServletInitializer. It's giving me a compile time error saying The type org.springframework.web.WebApplicationInitializer cannot be resolved. It is indirectly referenced from required .class files . But in the Maven dependency directory I can clearly see SpringBootServletInitializer.class exists in spring-boot-1.5.10.RELEASE jar. It was downloaded as part of the camel-spring-boot-starter dependency. The type org.springframework.web.WebApplicationInitializer cannot be resolved. It is indirectly referenced from required .class files SpringBootServletInitializer.class spring-boot-1.5.10.RELEASE camel-spring-boot-starter My Main class @SpringBootApplication @EnableAutoConfiguration public class SpringCamelApplication extends SpringBootServletInitiali

ORB SLAM2 build error with eigen3

ORB SLAM2 build error with eigen3 I am trying to build ORBSLAM2 but i always get some errors. I don't know the reason. I am pasting command line output. How can I solve the errors? has someone done this before? ORBSLAM2 orbslam@essafius-Latitude-E6430:~$ cd ORB_SLAM2 orbslam@essafius-Latitude-E6430:~/ORB_SLAM2$ chmod +x build.sh orbslam@essafius-Latitude-E6430:~/ORB_SLAM2$ ./build.sh Configuring and building Thirdparty/DBoW2 ... mkdir: cannot create directory ‘build’: File exists -- Configuring done -- Generating done -- Build files have been written to: /home/orbslam/ORB_SLAM2/Thirdparty/DBoW2/build [100%] Built target DBoW2 Configuring and building Thirdparty/g2o ... mkdir: cannot create directory ‘build’: File exists -- BUILD TYPE:Release -- Compiling on Unix -- Configuring done -- Generating done -- Build files have been written to: /home/orbslam/ORB_SLAM2/Thirdparty/g2o/build [100%] Built target g2o Uncompress vocabulary ... Configuring and building ORB_SLAM2 ... mkdir: canno

request using HTTP Outh 2 authentication with PHP curl not work?

request using HTTP Outh 2 authentication with PHP curl not work? I have set up a http request using PHP CURL with following code. PHP CURL <?php $para='{ "payment_method": "bacs", "payment_method_title": "Direct Bank Transfer", "set_paid": true, "billing": { "first_name": "John", "last_name": "Doe", "address_1": "969 Market", "address_2": "", "city": "San Francisco", "state": "CA", "postcode": "94103", "country": "US", "email": "john.doe@example.com", "phone": "(555) 555-5555" }, "shipping": { "first_name": "John", "last_name": "Doe", "address_1": "969 Market", "address_2"

private MyDbContext _appContext => (MyDBContext)_context;?

private MyDbContext _appContext => (MyDBContext)_context;? Please can some explain what does this code means ? private MyDbContext _appContext => (MyDBContext)_context; Thanks alot you declare a private property _appContext which returns _context as MyDBContext – Pierre 4 mins ago _appContext _context as MyDBContext By calling _appContext.Anything() you actually call ((MyDBContext)_context).Anything() – Pierre 2 mins ago _appContext.Anything() ((MyDBContext)_context).Anything() 1 Answer 1 Basically its an Expression-bodied member introduced in C# 6 Expression body definitions l