text:
Q: Get value of textlength of left characters before decimal point(.) How can I get the textlength of left characters before decimal point(.)?
Sample Run1:
Textbox7.text = 9.48 03/21/2014
Expected Result = 09.48 03/21/2014
Sample Run2:
Textbox7.text = 9.8 03/21/2014
Expected Result = 09.08 03/21/2014
    'If Val(TextBox7.Text.Trim.Split(".")(1).Length = 1) Then
        '    TextBox7.Text = "0" + TextBox7.Text
        'End If

A: I don't know why this showed up in my question list with an accepted answer, but what you have looks much more complex than needed. This seems to work on your test data:
Dim temp() As String = TextBox7.Text.Trim().Split(". ".ToCharArray())
TextBox7.Text = String.Format("{0:D2}.{1:D2} {2:MM/dd/yyyy}", _
          Integer.Parse(temp(0)), Integer.Parse(temp(1)), Date.Parse(temp(2)))

Once I realized that the 9.8 and 9.48 were times (the .8 threw me for a while), I also came very close to getting a version that worked using Date.ParseExact(TextBox7.Text, "h.m M/d/yyyy").ToString("hh.mm MM/dd/yyyy"). However, by the time I get the format provider and format string right, my first suggestion will end up just as easy.


text:
Q: React infinite loop on router route I'm getting an infinite loop whenever the following line of code is being runned
<Route exact path='/' component={App} />
i get an infinite loop, i think its because react doesnt know that im referring to the class name App, how would i let react know that im referring to the class name ?
the following below works without the <Route exact path='/' component={App} />
import React, { Component } from 'react';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import './App.css';
import AddItem from './components/AddItem';
import IndexItem from './components/IndexItem';

class App extends Component {
  render() {
    return(

        <Router>
          <div>
            // <Route exact path='/' component={App} />
            <Route path='/add-item' component={AddItem} />
            <Route path = '/index' component = {IndexItem}/>
          </div>
      </Router>

    )
  }
}

export default App;

A: You are rendering <App /> inside of <App />.
Your react app's index.js is rendering the  component. When the App component renders, the "/" route matches and attempts to render the  component again. Thus, infinite loop.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Amazon S3 upload Image from Rails I'm uploading the image using aws-s3 gem, it uploads perfectly and give me the url. Image is in PNG format but when I hit the public url in my browser, it starts downloading, but I don't want to download it, I want to see the image in browser.
Please tell me if you know which parameter in the following request should be added for this or what change is required to achieve this?
AWS::S3::S3Object.store(base_name,open(local_file),bucket,:content_type => mime_type,:access => :public_read,:authenticated => false)

s3_url = AWS::S3::S3Object.url_for(params[:name],bucket)[/[^?]+/]

A: Check :content_type => mime_type if mime_type is correct.


text:
Q: TypeORM+Postgres: values in nullable columns deleted after server restart? Any idea why columns defined as nullable in TypeORM have their values deleted after every (nodemon) server restart? Is this expected behaviour?

After restart:

The column definition:
      @Column({ nullable: true }) // TypeORM decorator
      @Field(_type => Number, { nullable: true })  // TypeGraphQL decorator
      rating: Rating;  // for reference: type Rating = 0 | 1 | 2 | 3

A: I had a similar problem, with nullable columns. Deleted dist/build folder fixed it!


text:
Q: iOS: iBeacons same UDID different major and minor Scenario: I have 10 venues.  Each venue has a 40 - 60 iBeacons installed.  As the User enters a museum, the apps shows relevant info that's associated with each iBeacon.
Objective: Don't be tied down to one manufacture or use their SDKs to scan/monitor iBeacons.
Proposed Solution:  Have the same UDID# for all the iBeacons.  Assign the same Major value per museum.  Assign unique Minor value per iBeacon to distinguish between the iBeacons.
Question:
Since we are scanning for the same UDIDs and are not configuring the device from our app, we shouldn't need any manufacture specific SDKs.  We should be able to accomplish this by Using Apple's CoreLocation to monitor and range an iBeacon Device?

A: Well it depends on the manufacturer. Most of the time when you buy the beacons they are running the manufacturer's custom firmware and require you to change the configuration to "iBeacon Configuration" (Usually giving you the options to set the UUID, major, and minor fields) through the manufacturer's custom dashboard. So your correct in saying that all you need is CoreLocation framework to monitor/range beacons but you need to make sure the actual hardware is broadcasting as an "iBeacon Configuration".


text:
Q: Fitting two different functions to data I have a problem that I have been struggling with for several days. I have a dataset and I know the left part is from a curve like y = a/x and the left part of y = bx^c, where a, b and c are the variables I need to find.
I have to fit one curve (my case is exactly like the picture below) but this curve consists of two different "regimes". How can I do this to get a smooth transition between the left and right parts? I tried to do it in Origin but to no avail, I am trying to do it with Mathematica but I don't know the language very well. I will be very grateful for any help!
My data: {1., 200}, {2., 300}, {5.,700}, {0.1,100}, {0.04,1000}, {0.5,130}, {0.05,200}, {0.03,1200}

A: The shape of the curve looks like an hyperbola. So, we can try to fit an hyperbola to the data.
But this is probably not the best choice. I agree with the whuber's comment: A better choice of model should be derived from physical considerations.
The numerical data provided in the question apparently doesn't match to the figure. Since it is better to have more points for the example of calculus, I used the figure to generate the data below. Of course this is not very accurate due to the uncertain scanning of the pixels of the graph.
Notations :
The coordinates of the points on the graph are noted $(X_1,Y_1),(X_2,Y_2) ,..., (X_k,Y_k) ,..., (X_n,Y_n)$
Since the scales are logarithmic they correspond to the "experimental" values :
$$(x_1,y_1),(x_2,y_2) ,..., (x_k,y_k) ,...,(x_n,y_n) \quad \text{with}\quad \begin{cases} X_k=\log_{10}(x_k)\\ Y_k=\log_{10}(y_k)\end{cases}$$
Asymptotically we want $\begin{cases}
y=\frac{a}{x}\\
y=bx^c
\end{cases}\quad\implies\quad\begin{cases}
Y=A-X\\
Y=B+cX
\end{cases}$
Equation of the asymptotes : $\big(Y-(A-X)\big)\big(Y-(B+cX)\big)=0$
Equation of the hyperbola : $\big(Y-(A-X)\big)\big(Y-(B+cX)\big)=G$
$G$ is a constant to be optimiezed to fit the hyperbola to the data.
Equation of the hyperbola :
$$Y^2+(1-c)XY-cX^2-(A+B)Y+(Ac-B)X+AB-G=0$$
The optimized coefficients can be computed thanks to linear regression :
$$Y^2+XY= c(X^2+XY)+(A+B)Y+(B-Ac)X-(AB+G)$$
$$V=cU+DY+EX+F \qquad\begin{cases}
V=Y^2+XY\\
U=X^2+XY\\
D=A+B\\
E=B-Ac\\
F=-(AB+G)
\end{cases}$$
The linear regression gives $c, D,E,F\quad$ then $\quad\begin{cases}
A=\frac{D-E}{1+c}\\
B=D-A\\
\end{cases}\quad\text{and}\quad\begin{cases}
a=10^{A}\\
b=10^{B}\end{cases}$

The equation of the fitted curve comes from solving for $Y$ the next equation :
$$Y^2+(1-c)XY-cX^2-(A+B)Y+EX-F=0$$
$$Y=\frac{1}{2}\left((c-1)X+A+B+\sqrt{((c-1)X+A+B)^2+4(cX^2+EX+F}\right)$$


text:
Q: Having trouble with MS Sql Server OPENJSON feature I created a sql test script below for this question.
 IF OBJECT_ID('tempdb..#temp') IS NOT NULL
    DROP TABLE #temp;

CREATE TABLE #temp
(
    Id INT NOT NULL PRIMARY KEY
  , Attributes NVARCHAR(MAX) NULL
);

INSERT INTO #temp (Id, Attributes)
VALUES (1, '[{"Name":"Step","Value":"A"},{"Name":"State","Value":"Active"}]');
INSERT INTO #temp (Id, Attributes)
VALUES (2, '[{"Name":"Step","Value":"B"},{"Name":"State","Value":"Inactive"}]');
INSERT INTO #temp (Id, Attributes)
VALUES (3, '[{"Name":"State","Value":"Active"}]');
INSERT INTO #temp (Id, Attributes)
VALUES (4, '[{"Name":"Step","Value":"D"}]');

SELECT
    t.Id
  , t.Attributes
  , stepname.Value AS [Step]
  , statename.Value AS [State]
FROM #temp t
    CROSS APPLY
    OPENJSON(t.Attributes)
    WITH
    (
        Name NVARCHAR(MAX) '$.Name'
      , Value NVARCHAR(MAX) '$.Value'
    ) AS stepname
    CROSS APPLY
    OPENJSON(t.Attributes)
    WITH
    (
        Name NVARCHAR(MAX) '$.Name'
      , Value NVARCHAR(MAX) '$.Value'
    ) AS statename
WHERE 1 = 1
      --AND (stepname.Name = statename.Name)     -- A
      --AND                                      -- B
      --(                                        -- B
      --    stepname.Name IS NULL                -- B
      --    OR stepname.Name = 'Step'            -- B
      --)                                        -- B
      --AND                                      -- B
      --(                                        -- B
      --    statename.Name IS NULL               -- B
      --    OR statename.Name = 'State'          -- B
      --);                                       -- B

Running this script as is gives the following output:

Id
Attributes
Step
State

1
[{"Name":"Step","Value":"A"},{"Name":"State","Value":"Active"}]
A
A

1
[{"Name":"Step","Value":"A"},{"Name":"State","Value":"Active"}]
A
Active

1
[{"Name":"Step","Value":"A"},{"Name":"State","Value":"Active"}]
Active
A

1
[{"Name":"Step","Value":"A"},{"Name":"State","Value":"Active"}]
Active
Active

2
[{"Name":"Step","Value":"B"},{"Name":"State","Value":"Inactive"}]
B
B

2
[{"Name":"Step","Value":"B"},{"Name":"State","Value":"Inactive"}]
B
Inactive

2
[{"Name":"Step","Value":"B"},{"Name":"State","Value":"Inactive"}]
Inactive
B

2
[{"Name":"Step","Value":"B"},{"Name":"State","Value":"Inactive"}]
Inactive
Inactive

3
[{"Name":"State","Value":"Active"}]
Active
Active

4
[{"Name":"Step","Value":"D"}]
D
D

What I would like to see in the output though is only 4 rows, one per data row.

Id
Attributes
Step
State

1
[{"Name":"Step","Value":"A"},{"Name":"State","Value":"Active"}]
A
Active

2
[{"Name":"Step","Value":"B"},{"Name":"State","Value":"Inactive"}]
B
Inactive

3
[{"Name":"State","Value":"Active"}]

Active

4
[{"Name":"Step","Value":"D"}]
D

I have left some commented code in my example to see the types of things I've tried but all to no avail. Uncommenting the where statement with a '-- A' gets me closer, but not completely. I thought for sure that uncommenting the statements in the where clause with a '-- B' on the end would give me what I want, but it doesn't.  Any ideas on how to do this?
I originally started out with only 1 OPENJSON block but had no success so I thought that perhaps having 2 OPENJSON blocks, one for the Step and one for the State would help, but still not able to get data rows 3 and 4 included since each of those rows is missing one of the 2 JSON values.
Thanks very much for any help!

A: Conditional aggregation could be used:
SELECT
    t.Id
  , t.Attributes
  , [Step] = MAX(CASE WHEN stepname.Name = 'Step' THEN stepname.Value END)
  , [State] = MAX(CASE WHEN statename.Name = 'State' THEN statename.Value END)
FROM #temp t
CROSS APPLY OPENJSON(t.Attributes) WITH (
        Name NVARCHAR(MAX) '$.Name'
      , Value NVARCHAR(MAX) '$.Value'
    ) AS stepname
CROSS APPLY OPENJSON(t.Attributes) WITH (
        Name NVARCHAR(MAX) '$.Name'
      , Value NVARCHAR(MAX) '$.Value'
    ) AS statename
GROUP BY t.Id, t.Attributes
ORDER BY t.Id;

db<>fiddle demo


text:
Q: Recursively prove that two recursively defined sets are the same I am reading MIT's Mathematics for Computer Science, and there is a problem where you're asked to prove that two recursively defined sets are the same. I'm not sure how to go about mutual inclusion with recursively defined sets.
Here is the problem:
A and B are sets of strings of matched brackets.
Define A as the smallest set such that:
Base case: $\lambda$, the empty string, is in the set. Constructor cases: 1. $st$ is in A (meaning $s$ concatenate $t$ is in A). 2. [$s$] is in A
Define B as the smallest set such that: Base case: $\lambda$, the empty string, is in the set. Constructor cases: $[s]t$ is in B.
Prove A and B are the same set:
Here is my attempt:
Clearly $\lambda$ is in both sets.
Now want to show that anything can be constructed by recursive definition of $A$ can be also constructed with recursive definition of $B$. Suppose $s \in A$, I want to show $[s] \in B$ and $st \in B$.
$[s] \in  B$ since we can let $t=\lambda$ in B, and thus $[s] \in B$. Is this right? It seems like I'm supposing $s$ the same in both sets. I am stuck at how to show $st \in B$.

A: I think I got it:
I will prove by structural induction.
Base case: The empty string $\lambda \in A, B$ clearly.
Induction step: Let $x,y \in A$ and $s,t \in B$. Assume that $x$ and $y$ can be constructed by the recursive definition of $B$, and assume that $s$ and $t$ can be constructed using the recursive definition of $A$. We want to show that 1) $xy$ and $[x]$ can be constructed with $[s]t$ for suitable $s$ and $t$, and 2) $[s]t$ can be constructed by $xy$ and $[x]$.
1) Clearly $[x]=[s]\lambda$ for any $s=x$ and $t=\lambda$, so $[x]$ can be constructed with $[s]t$.
Next, $xy=[s']t'y$ where $s', t' \in B$ by the structural induction assumption. Thus take $s=s'$ and $t=t'y$, so $xy$ can be constructed by $[s]t$.
2) [s]t can be constructed by $xy$, by letting $x=[x']$ where $x'=s$ and $y=t$
Thus we have A=B.

A: Note that all strings are made up of $[$ and $]$ only.
For clarity, call the variables $s, t$ on one side and $x, y$ on the other. As you note, you have to prove both sets of rules give the same end results, you are trying to get an intermediate result. No wonder it won't work.


text:
Q: Adding information returned by threads to an array I am relatively new to Objective C and I am trying to read information from a URL then add its info to my Name object then add the name objects to an array. I am able to read the info from the URLs fine and furthermore I am successful in adding their info to an array however I cannot seem to successfully add the names to my nameArray. I declare the array at the top and initialize it in the viewDidLoad function then furthermore the names are meant to be added to the array when I call the methods readURLOne, readURLTwo and readURLThree. However, when I check the array, after calling these methods in viewDidLoad, it is empty. Why might this be?
@interface ViewController () {
    Name *n1;
    Name *n2;
    Name *n3;
    NSMutableArray *nameArray; //this is the array I am having trouble with
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    nameArray = [[NSMutableArray alloc] init];
    NSOperationQueue *queue = [NSOperationQueue new];
    NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(readURLOne)object:nil];
    [queue addOperation:operation];

    operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(readURLTwo)object:nil];
    [queue addOperation:operation];

    operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(readURLThree) object:nil];
    [queue addOperation:operation];
    NSLog(@"NAME ARRAY: %lu", (unsigned long)[nameArray count]); //This is where I am trying to check if they are added to the array, the are not
}

-(void) readURLOne {
    NSURL *dataURL = [NSURL URLWithString:@"http://example.org/data/1.txt"];
    NSArray *tmp = [NSArray arrayWithContentsOfURL:dataURL];
    for (NSString *str in tmp){ //add contents of URL successfully to tmp
        NSLog(@"%@", str);
    }
    n1 = [[Name alloc] init];
    [n1 setFirstName:tmp[0]];
    [n1 setLastName:tmp[1]];
    [n1 setNumber:tmp[2]];
    [nameArray addObject:n1];
 }

-(void) readURLTwo {
    NSURL *dataURL = [NSURL URLWithString:@"http://example.org/data/2.txt"];
    NSArray *tmp = [NSArray arrayWithContentsOfURL:dataURL];
    for (NSString *str in tmp){
        NSLog(@"%@", str);
    }
    n2 = [[Name alloc] init];
    [n2 setFirstName:tmp[0]];
    [n2 setLastName:tmp[1]];
    [n2 setNumber:tmp[2]];
    [nameArray addObject:n2];
}

-(void) readURLThree {
    NSURL *dataURL = [NSURL URLWithString:@"http://example.org/data/3.txt"];
    NSArray *tmp = [NSArray arrayWithContentsOfURL:dataURL];
    for (NSString *str in tmp){
        NSLog(@"%@", str);
    }
    n3 = [[Name alloc] init];
    [n3 setFirstName:tmp[0]];
    [n3 setLastName:tmp[1]];
    [n3 setNumber:tmp[2]];
    [nameArray addObject:n3];
}

-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return nameArray.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellIdentifier = @"Cell";
    CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[CustomCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }

    cell.firstName.text = [[nameArray objectAtIndex:indexPath.row] getFirstName];
    cell.lastName.text = [[nameArray objectAtIndex:indexPath.row] getLastName];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

A:
I declare the array at the top and initialize it in the viewDidLoad function then furthermore the names are meant to be added to the array when I call the methods readURLOne, readURLTwo and readURLThree.

As I can see you are NOT calling readURLOne, readURLTwo and readURLThree - you are adding them to NSOperationQueue. In such a case your methods are called asynchronously and nameArray is probably updated after you check it at the end of viewDidLoad.
Change your method to:
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    nameArray = [[NSMutableArray alloc] init];
    NSOperationQueue *queue = [NSOperationQueue new];
    queue.maxConcurrentOperationCount = 1; // It is needed to avoid synchronisation problems with nameArray
    NSInvocationOperation *operation1 = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(readURLOne)object:nil];
    [queue addOperation:operation1];

    NSInvocationOperation *operation2 = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(readURLTwo)object:nil];
    [queue addOperation:operation2];

    NSInvocationOperation *operation3 = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(readURLThree) object:nil];
    [queue addOperation:operation3];

    NSOperation *finalOperation = [NSBlockOperation blockOperationWithBlock:^{
        NSLog(@"NAME ARRAY: %lu", (unsigned long)[nameArray count]);
    }];
    [finalOperation addDependency:operation1];
    [finalOperation addDependency:operation2];
    [finalOperation addDependency:operation3];
    [queue addOperation:finalOperation];
}

A: NSOperationQueues operate asynchronously, so there's no guarantee that they will be complete by the time you're accessing nameArray.
You could add this line before your NSLog:
[queue waitUntilAllOperationsAreFinished];

But really, I think you should probably just call the functions directly without using an NSOperationQueue.

On further inspection of the methods you're calling, it looks like you're performing network operations. This should definitely be done on a different thread like you've already done, so you really just need to add a callback for the completion. You could do this pretty simply by adding a finish operation:
  NSInvocationOperation *completionOperation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(urlDataRead) object:nil];

  // ...
  [completionOperation addDependency:operation];
  // ...
  [completionOperation addDependency:operation];
  // ...
  [completionOperation addDependency:operation];

  [queue addOperation:completionOperation];
}

- (void)urlDataRead {
  NSLog(@"NAME ARRAY: %lu", (unsigned long)[nameArray count]); //This is where I am trying to check if they are added to the array, the are not
}


text:
Q: Best way to synchronize sql What is the best way to synchronize SQL Server table fields (not data), stored procedures, views and functions?
Thank you

A: Red Gate SQL Compare.
There are several alternatives, including some at lower cost (or even free). But you often get what you pay for.
The worst option, in my opinion, is to roll your own. I blogged about why (and listed several of the alternatives) here:
http://bertrandaaron.wordpress.com/2012/04/20/re-blog-the-cost-of-reinventing-the-wheel/

A: There are tools such as Red Gate SQL Compare that will do this for you - saves a lot of hassle trying to reinvent the wheel.

A: As a good alternative to Red Gate Sql Compare I would recommend the following:
Visual Studio 2010 -> Database project -> Schema comparison.


text:
Q: Passing parameters to via GetAsync() I have an API that I want to test.  This is the signature of one method...
[HttpGet("{param}")]
 public async Task<IActionResult> Get(string param, string param2)
{
...
}

In the test project I structure the call this way...
HttpClient client = new HttpClient();
string uri = "http://localhost:63779/api/controller_name/param/";
HttpResponseMessage response = await client.GetAsync(uri);

param is part of the route but how do I get param2 to the method?

A: Pass param2 as query string ti the server. The client code:
HttpClient client = new HttpClient();
string uri = "http://localhost:63779/api/controller_name/param/?param2=SOME_VALUE";
HttpResponseMessage response = await client.GetAsync(uri);


text:
Q: Lutris doesn't work when I try to install it $ sudo apt install lutris
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies.
 lutris : Depends: python3-evdev but it is not installable
          Depends: cabextract but it is not installable
          Depends: fluid-soundfont-gs but it is not installable
          Depends: mesa-utils but it is not installable
          Recommends: gvfs-backends
          Recommends: libwine-development but it is not installable
          Recommends: winetricks but it is not installable
          Recommends: libc6-i386 but it is not going to be installed
          Recommends: lib32gcc1 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Here is the message that it gives me.
I already tried to upgrade my system.
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.

A: Late to the party but I found that everything works if you enable Canonical-supported free and open software (main) in the Software & Updates app.

A: I was able to install Lutris after enable all checkbox in Software & Updates as in the attached figure below.

*

*Canonical-supported free and open-source software (main)

*Community-maintained free and open-source software (universe)

*Proprietary drivers for devices (restricted)

*Software restricted by copyright or legal issues (multiverse)

A: i was able to solve this by installing build-essential following
https://railsblogs.rohityadav.in/2019/06/e-package-aptitude-has-no-installation.html

*

*follow the steps in the link until the last(install aptitude)

*restart

*apt-get update followed by apt-get upgrade followed by apt-get dist-upgrade

*and then sudo apt-get install --fix-missing lutris

there is no need to use aptitude


text:
Q: Why would a dictionary variable be undefined in async function I'm trying to figure out why the variable ROOT_FOLDER_LOCATION is undefined. The function is running as a google "cloud function" and it is triggered from ZOHO CRM in which it is sent URL encoded data containing the variables 'ID', 'firstName', 'lastName', 'Salesman'. I have tried getting this to work by 'awaiting' pretty much every line in the try-catch block, moving the salesmanID variable inside of the function, but it doesn't work. The salesman and workingRoot variables are both defined (salesman='Jim Schwartz' in my testing and workingRoot='abcdefgXv2'), so I don't understand why the ROOT_FOLDER_LOCATION variable is undefined.
const {google} = require('googleapis');
const axios = require('axios').default;
const FormData = require('form-data');

const SCOPES = ['https://www.googleapis.com/auth/drive'];
//IDs for client folders of salesmen
const salesmanID = {'Jim Schwartz': 'abcdefgXv2', 'Marks Shared Folder': '1M6NUf-abcdefg', 'Samanthas Shared Folder': 'abcdefgVZSMzhoVBU5wJ'};

exports.myFunction = async (req, res) => {

try{
  const params = new URLSearchParams(req.body);
  let zohoLeadID = params.get('ID');
  let firstName = params.get('firstName');
  let lastName = params.get('lastName');
  let CLIENT_NAME = `${lastName}, ${firstName}`
  let salesman = params.get('Salesman');

  let ROOT_FOLDER_LOCATION = salesmanID[salesman];
  let workingRoot = salesmanID['Jim Schwartz'];

  console.log(salesman);
  console.log(`workingRoot: ${workingRoot}`);
  console.log(`${ROOT_FOLDER_LOCATION}`);

  res.status(200).send('Success');
} catch (err) {
  console.log(err);
  res.status(500).send('Failed...');
}

};


text:
Q: How to write this LINQ query to get a particular claim from Identity oauth I have a list of claims in my object and I want to look for a particular claim with its name and find its value which is Boolean. I wrote the following query but I am getting the error saying that I can't use '&&' operator on string and Boolean operands.
bool isSSO = context.Ticket.Identity.HasClaim(c => c.Type == "IsSSO"&& c.Value);

Please advise.

A: The problem is that Claim.Value property is string, probably you are receiving values like "true" or "false". Try this:
bool isSSO = context.Ticket.Identity.HasClaim(c => c.Type == "IsSSO" && bool.Parse(c.Value));


text:
Q: Mysql Order By After Group? Hi I have Sql Result like

My Query is like
SELECT sales_flat_order.entity_id AS entity_id,
      CASE
          WHEN sales_flat_order.`grand_total` BETWEEN '0' AND '100.99' THEN '0->100.99'
          WHEN sales_flat_order.`grand_total` BETWEEN '101' AND '150.99' THEN >'101-150.99'
          WHEN sales_flat_order.`grand_total` BETWEEN '151' AND '200.99' THEN >'151-200.99'
          WHEN sales_flat_order.`grand_total` BETWEEN '201' AND '250.99' THEN >'201-250.99'
          WHEN sales_flat_order.`grand_total` BETWEEN '251' AND '300.99' THEN >'251-300.99'
          WHEN sales_flat_order.`grand_total` BETWEEN '301' AND '350.99' THEN >'301-350.99'
          WHEN sales_flat_order.`grand_total` BETWEEN '351' AND '400.99' THEN >'351-400.99'
          WHEN sales_flat_order.`grand_total` BETWEEN '401' AND '450.99' THEN >'401-450.99'
          WHEN sales_flat_order.`grand_total` BETWEEN '451' AND '500.99' THEN >'451-500.99'
          ELSE '501+'
      END AS 'order_range',
      CONCAT(MONTHNAME(sales_flat_order.created_at), ' - ', >YEAR(sales_flat_order.created_at)) AS 'Month',
      CONCAT('$', FORMAT(SUM(sales_flat_order.`grand_total`), 2)) AS 'Sales',
      sales_flat_order.`grand_total` AS Amount,
      COUNT(sales_flat_order.entity_id) AS 'Orders'
FROM sales_flat_order GROUP BY MONTH,order_range
ORDER BY Amount ASC

I need to order the result by Ascending 2nd Column 'Order Range'.
My expected answer should be like
Feb 2015 | 0-100  | XXX

Feb 2015 | 101-150| XXX

Feb 2015 | 150-200| XXX

Feb 2015 | 200-250| XXX

Feb 2015 | 250-300| XXX

A: You could use SUBSTRING_INDEX here:
ORDER BY
    Month,
    CAST(SUBSTRING_INDEX(order_range, '-', 1) AS UNSIGNED);

Here is a demo showing that this ordering logic works:
Demo
Edit:
Don't report the year and month as text, with the month first followed by the year, because you will also just be inviting sorting problems there as well.  Instead, order using DATE_FORMAT:
ORDER BY
    DATE_FORMAT(sales_flat_order.created_at, '%Y-%m'),
    CAST(SUBSTRING_INDEX(order_range, '-', 1) AS UNSIGNED);

A: Just update your  'order by' query part with the following:
ORDER BY MONTH, FIELD(order_range,
'0->100.99',
'101-150.99',
'201-250.99',
...
)


text:
Q: usebib: Printing abstract (including \par)
*

*Inspired by this answer/question, I wanted to use the usebib package to print the abstract.

*The following MWE gives an error and I do not see an obvious reason.

*Watch it, the abstract contains \par.

% Based on https://tex.stackexchange.com/questions/73678/
\documentclass{article}

\usepackage{biblatex}

\begin{filecontents}{\jobname.bib}
@misc{key,
  title = {title},
  year = {2000},
  abstract = {abstract \par abstract},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\usepackage[hidelinks]{hyperref}

% Load AFTER hyperref
\usepackage{usebib}

% Use BEFORE \bibinput
\newbibfield{abstract}
\bibinput{\jobname}

\begin{document}

\usebibentry{key}{title}
\usebibentry{key}{abstract}

\end{document}

See the usebib package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.28 \usebibentry{key}{abstract}

The key you used is wrong or the value to `abstract' has not been set

A: The command that loads the entries is not \long, sorry.
You can fix it:
\begin{filecontents*}{\jobname.bib}
@misc{key,
  title = {title},
  year = {2000},
  abstract = {abstract \par abstract},
}
\end{filecontents*}

\documentclass{article}
\usepackage{etoolbox}
\usepackage[hidelinks]{hyperref}
% Load AFTER hyperref
\usepackage{usebib}

% Use BEFORE \bibinput
\newbibfield{abstract}

\makeatletter
\patchcmd[\long]{\reuse@extract}{}{}{}{}
\makeatother

\bibinput{\jobname}

\begin{document}

\usebibentry{key}{title}
\usebibentry{key}{abstract}

\end{document}

Note. I removed biblatex because it's not needed. On the other hand, I believe you can extract fields using biblatex methods.
Alternatively, use the experimental expl3 version.
usebib3.sty
\RequirePackage{expl3,xparse,url}
\ProvidesExplPackage{usebib3}{2020/10/11}{v. 0.2}{Use fields read in bib files}

\prop_new:N \l__usebib_temp_prop
\prop_new:N \g__usebib_temp_prop
\seq_new:N \g_usebib_discard_seq

\NewDocumentCommand{\bibinput}{m}
 {
  \clist_map_function:nN { #1 } \usebib_main:n
 }
\NewExpandableDocumentCommand{\usebibentry}{mm}
 {
  \prop_item:cf { g_usebib_entry_#1_prop } { \str_lower_case:n { #2 } }
 }
\NewExpandableDocumentCommand{\usebibentryurl}{O{|}m}
 {
  \__usebib_url:nf { #1 } { \prop_item:cn { g_usebib_entry_#2_prop } { url } }
 }
\NewDocumentCommand{\newbibfield}{m}{}

\@ifpackageloaded{hyperref}
 {
  \cs_new_protected:Nn \__usebib_url:nn
   {
    \url{ #2 }
   }
 }
 {
  \cs_new_protected:Nn \__usebib_url:nn
   {
    \tl_rescan:nn { \url #1 #2 #1 }
   }
 }
\cs_generate_variant:Nn \__usebib_url:nn { nf }
\cs_generate_variant:Nn \prop_item:Nn { cf }

\NewDocumentCommand{\newbibignore}{m}
 {
  \seq_gput_right:Nx \g_usebib_discard_seq { \str_lower_case:n { #1 } }
 }

\cs_new_protected:Nn \usebib_main:n
 {
  \group_begin:
  \char_set_active_eq:NN @ \usebib_read_entry:w
  \char_set_catcode_active:n { `@ }
  \file_input:n { #1.bib }
  \group_end:
 }

\cs_new_protected:Npn \usebib_read_entry:w #1#
 {
  \seq_if_in:NxTF \g_usebib_discard_seq { \str_lower_case:n { #1 } }
   {
    \use_none:n
   }
   {
    \__usebib_read_entry:w
   }
 }

\cs_new_protected:Npn \__usebib_read_entry:w
 {
  \group_begin:
  \char_set_catcode_other:n { `@ }  % may appear in text
  \char_set_catcode_other:n { `\% } % can be used in URLs
  \char_set_catcode_other:n { `\# } % can be used in fields
  \__usebib_read_entry:n
 }

\cs_new_protected:Nn \__usebib_read_entry:n
 {
  \prop_gset_from_keyval:Nn \g__usebib_temp_prop { USEBIBREADKEY=#1 }
  \group_end:
  \__usebib_save_entry:
 }

\cs_new_protected:Nn \__usebib_save_entry:
 {
  \prop_clear:N \l__usebib_temp_prop
  \prop_map_inline:Nn \g__usebib_temp_prop
   {
    \str_if_eq:nnF { ##1 } { USEBIBREADKEY }
     {
      \prop_put:Nxn \l__usebib_temp_prop { \str_lower_case:n { ##1 } } { ##2 }
     }
   }
  \prop_new:c { g_usebib_entry_ \prop_item:Nn \g__usebib_temp_prop { USEBIBREADKEY } _prop }
  \prop_gset_eq:cN
   { g_usebib_entry_ \prop_item:Nn \g__usebib_temp_prop { USEBIBREADKEY } _prop }
   \l__usebib_temp_prop
 }
\cs_generate_variant:Nn \prop_put:Nnn { Nx }

Now you can do
\begin{filecontents*}{\jobname.bib}
@misc{key,
  title = {title},
  year = {2000},
  abstract = {abstract \par abstract},
}
\end{filecontents*}

\documentclass{article}

\usepackage[hidelinks]{hyperref}
% Load AFTER hyperref
\usepackage{usebib3}

% Use BEFORE \bibinput
\newbibfield{abstract}

\bibinput{\jobname}

\begin{document}

\usebibentry{key}{title}
\usebibentry{key}{abstract}

\end{document}


text:
Q: non-condecending term that has the meaning that is usually associated to 'first world' I've always thought of the 'first world' as countries with modern technology and science, proper education, viable economies, and freedom from other social issues which allows individuals to enjoy a higher standard of living.  In short the sort of country that would have general similar standards of living as the US or England.  By my personal definition, which seems to be the way most use the term within the US, places like Sweden, Japan,  and pretty much all of the EU would count as a first world countries.
I've meanwhile thought of third world nations as place with severe poverty, poor education or technology, and often other social issues preventing them from modernizing like war, corruption, or famine.
However, I looked it up today and found out that Wikipedia disagrees with my personal definition: https://en.wikipedia.org/wiki/First_World.  Essentially a first world nation is officially defined as "everyone the US liked during the cold war".  Japan, meanwhile, is defined as a third world nation; which it definitely would not be under the definition I always used.
Is there a better term that actually defines what I thought of as a first or third world country?  Preferable as non-derogatory as possible in the case of referring to a place as third-world?  I know any term for a place with poverty will inevitably have a negative connotation, but if I want to discuss, for instance, the mortality rates of a disease in 'first world' vs 'third world' conditions (as I use to interpret them) to analyze the effectiveness of modern sanitation and medicine...what is a good clinical term to define such areas?
Related, Do other places outside the US use the terms first world and third world?  if so how do they generally use them?

A: Did you look through the whole Wikipedia article? There's a subsection titled "Variations in Definitions" that has this to say:

Since the end of the Cold War, the original definition of the term First World is no longer necessarily applicable. There are varying definitions of the First World, however, they follow the same idea. John D. Daniels, past president of the Academy of International Business, defines the First World to be consisting of "high-income industrial countries." Scholar and Professor George J. Bryjak defines the First World to be the "modern, industrial, capitalist countries of North America and Europe." L. Robert Kohls, former director of training for the U.S. Information Agency and the Meridian International Center in Washington, D.C. uses First World and "fully developed" as synonyms.

This "high-income industrial countries" usage seems to match the way you've been using the term.

A: Industrialized probably has the most neutral connotation.  Developed implies (at least to some) that other nations are culturally undeveloped.

A: In Human Geography, More Developed Countries (MDCs) and Less Developed Countries (LDCs) are the generally agreed upon terms. These are relatively objective terms and do not imply condescension, although it is of course possible to take it one way or the other.

A: From my personal experience from conversations and reading, 'developed countries' is often used in the way that you understood first world.
Any country with progress in technology, health, etc. and the others are sometimes referred to as 'undeveloped' or 'developing' as in the case of India which is making strides to improve its status. As someone who has not left the U.S., I cannot speak for the second question regarding usage outside of the U.S.

A: You could even say things like agricultural, industrial, post industrial, etc. You can get very specific in your descriptions if you are talking about economic development.

A: MEDC = "More Economically Developed Country" ~ "First World"
LEDC = "Less Economically Developed Country" ~ "Third World"


text:
Q: Insert two inputs into one column in mySQL with PHP I am a beginner to php and mySQL and I am currently using dreamweaver for the GUI to help me learn.
I am trying to create a member registration form to register users into database.
What I aim to do is to have the username be generated from the first and last name of the user. For example: First name: John, Last name: Smith. username will automatically be generated as john.smith (disregarding the capital)
I read about concatenating in php and came up with the code:
GetSQLValueString($_POST['firstname'], "text").GetSQLValueString('.'.$_POST['lastname'], "text"),

However, when I checked the stored data in mySQL it returns firstname'.lastname. i.e. john'.smith. (Notice the extra apostrophe following the firstname)
This was my source: http://forums.phpfreaks.com/index.php?topic=294444.0, the original poster mentioned that he modified some code that dreamweaver used. But I can't figure out which one to change.
See below for my existing code so far:
<?php require_once('../Connections/connSQL.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{  if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 switch ($theType) {
case "text":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;
case "long":
case "int":
  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  break;
case "double":
  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  break;
case "date":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;
case "defined":
  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  break;
  }
    return $theValue;
 }
}

  $editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO member (m_firstname, m_lastname, m_username, m_password, m_workphone, m_address) VALUES (%s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['firstname'], "text"),
                       GetSQLValueString($_POST['lastname'], "text"),
                       GetSQLValueString($_POST['firstname'], "text").GetSQLValueString(' .'.$_POST['lastname'], "text"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['passwordcheck'], "text"),
                       GetSQLValueString($_POST['address'], "text"));

A: You probably want this:
GetSQLValueString($_POST['firstname'] . '.' . $_POST['lastname'], "text")

Concatenate the values and then escape the resulting string, instead of escaping the values first and then trying to concatenate the result.  If you really wanted to escape them first, you could do:
sprintf("CONCAT(%s, '.', %s)",
    GetSQLValueString($_POST['firstname'], "text"),
    GetSQLValueString($_POST['lastname'], "text"))

But there is no reason to.


text:
Q: Can we render post chat survey form to user(Agent) once chat window is closed instead of Customer? I have a requirement on salesforce live agent that instead of showing post chat survey form to customer, we need to display the form to agent and agent will complete the survey. Please guide me whether it is feasible or not.

A: We can use onChatEnded() method to display an feedback edit page to the agent in event handler.


text:
Q: Why is this code giving me a segfault before entering the do loop? can anyone tell my why this code is giving me a segmentation fault 11 before entering the do loop?
int parsePath(char *dirs[]){
    char *pathEnvVar;
    char *thePath;

    for(int i=0; i<MAX_ARGS; i++)
        dirs[i]=NULL;

    pathEnvVar = (char *) getenv("PATH");
    thePath = (char *) malloc(strlen(pathEnvVar) +1);
    strcpy(thePath, pathEnvVar);
    printf("the path is %s \n", thePath );
    /* Loop to parse thePath.  Look for a ':' delimiter between each path name */
    const char delim[2] = ":";
    char *token;
    int counter = 0;
    /* get the first token */
    token = strtok(thePath, delim);
   printf("got to line 80 \n");
   printf("token is %s \n", token);
   printf("token is %u \n", (int)token);
   printf("got to line 83 \n");
   /* walk through other tokens */
   do
   {
        printf("help me");
      counter++;
      strcpy(dirs[counter], token);
      printf("Path is %s", dirs[counter]);

   }while((token = strtok(NULL, delim)));
   return 0;
}

I'm confused because it prints "got to line 83" but not "Help me" so for some reason it won't enter the do loop?
Here is the output:
the path is /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin
got to line 80
token is /usr/bin
token is 2302687600
got to line 83
Segmentation fault: 11

A: The problem is on the line
strcpy(dirs[counter], token);

At the beginning, you initialize all elements in dirs as NULL. Thus, here on the above line you copies token into NULL.


text:
Q: center values in table in latex I have a problem in the table I created using latex.
The problem is that the values in the columns are not centered correctly. THe values with a minus sign in front just are further right than the rest. Is it possible to center them around the decimal point so as to look neater?

A: You are already using a package capable of that. siunitx introduces a column specifier S, which aligns the columns to the decimal point and formats the numbers to your \sisetup settings.
I optimized your code a little further:
\documentclass{article}
\usepackage{amsmath}
\usepackage{pdflscape}
\usepackage{booktabs}
\usepackage{siunitx}
\newcommand{\nm}[1]{\textnormal{#1}}
\begin{document}
\begin{landscape}
    \begin{table}[h!]
        \centering
        \begin{tabular}{lSSSSSSSS}
            \toprule
            \multicolumn{1}{l}{Model} &\multicolumn{4}{r}{Model1}    &\multicolumn{2}{r}{Model2}    &\multicolumn{2}{r}{Model3}    \\
            \cmidrule(lr){2-5}\cmidrule(lr){6-7}\cmidrule(lr){8-9}
                                      & {$n=1$} & {$n=2$} & {$n=3$} & {$n=4$} & {$n=5$} & {$n=6$} & {$n=7$} & {$n=8$} \\
            \midrule
            Mean(alg)$^*$             & 1.281   & 1.031   & 0.779   & 0.631   & 0.886   & 0.727   & 1.324   & 1.3145  \\
            Median(alg)               & 0.281   & 0.223   & 0.214   & 0.192   & 0.177   & 0.162   & 0.242   & 0.228   \\
            Mean(length) in $\rho$    & 11      & 91      & 327     & 489     & 76      & 64      & 86      & 90      \\
            Median(length) in  $\rho$ & 5.3     & 39      & 210     & 400     & 37      & 32      & 31.7    & 35      \\
            Cor(alg,deh)              & -0.332  & -0.30   & -0.31   & -0.25   & -0.28   & -0.31   & -0.20   & -0.24   \\
            \midrule
            $^*$  \\
            \bottomrule
        \end{tabular}
        \caption{Mean}
        \label{beta}
    \end{table}
\end{landscape}
\end{document}

Alternative
Now every cell is left justified, but you will have to replace all - with \mi.
\documentclass{article}
\usepackage{mathtools}
\usepackage{pdflscape}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{array}
\newcolumntype{L}{>{\phantom{$\mathbin{-}$}$}l<{$}}
\newcommand{\mi}{\mathllap{\mathbin{-}}}
\newcommand{\nm}[1]{\textnormal{#1}}
\begin{document}
\begin{landscape}
    \begin{table}[h!]
        \centering
        \begin{tabular}{lLLLLLLLL}
            \toprule
            \multicolumn{1}{l}{Model} &\multicolumn{4}{r}{Model1}    &\multicolumn{2}{r}{Model2}   &\multicolumn{2}{r}{Model3}    \\
            \cmidrule(lr){2-5}\cmidrule(lr){6-7}\cmidrule(lr){8-9}
                                      & n=1      & n=2     & n=3     & n=4     & n=5     & n=6     & n=7     & n=8 \\
            \midrule
            Mean(alg)$^*$             & 1.281    & 1.031   & 0.779   & 0.631   & 0.886   & 0.727   & 1.324   & 1.3145  \\
            Median(alg)               & 0.281    & 0.223   & 0.214   & 0.192   & 0.177   & 0.162   & 0.242   & 0.228   \\
            Mean(length) in $\rho$    & 11       & 91      & 327     & 489     & 76      & 64      & 86      & 90      \\
            Median(length) in  $\rho$ & 5.3      & 39      & 210     & 400     & 37      & 32      & 31.7    & 35      \\
            Cor(alg,deh)              & \mi0.332 & \mi0.30 & \mi0.31 & \mi0.25 & \mi0.28 & \mi0.31 & \mi0.20 & \mi0.24   \\
            \midrule
            $^*$ \\
            \bottomrule
        \end{tabular}
        \caption{Mean}
        \label{beta}
    \end{table}
\end{landscape}
\end{document}

A: Yes. The package dcolumn was designed exactly for this. See the short and easy documentation (2 pages) here: http://www.ctan.org/pkg/dcolumn

A: Here's a solution using the dcolumn package. In addition to using the d column type for the 8 columns with numbers, I would recommend using l for the first column.

\documentclass{article}
\usepackage[margin=1in]{geometry} % choose margins to suit your needs
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % a handy shortcut macro
\begin{document}
%\begin{landscape} % not needed for this example
\begin{table} [h!]
\centering
\begin{tabular}{ l *{2}{d{2.3}} *{2}{d{3.3}} *{3}{d{2.3}} d{2.4} }
\toprule
& \multicolumn{4}{c}{Model 1}
& \multicolumn{2}{c}{Model 2}
& \multicolumn{2}{c}{Model 3} \\
\cmidrule(lr){2-5} \cmidrule(lr){6-7} \cmidrule(l){8-9}
& \mc{$n=1$} & \mc{$n=2$} & \mc{$n=3$} & \mc{$n=4$}
& \mc{$n=5$} & \mc{$n=6$} & \mc{$n=7$} & \mc{$n=8$} \\
\midrule
Mean(alg)$^*$  & 1.281 & 1.031 & 0.779& 0.631 &0.886& 0.727& 1.324&1.3145\\
Median(alg) &0.281 & 0.223 & 0.214 & 0.192& 0.177&0.162 & 0.242&0.228\\
Mean(length) in $\rho$  &11 & 91 & 327 & 489 &76&64&86&90\\
Median(length) in $\rho$  &5.3 & 39 & 210 & 400&37&32&31.7&35 \\
Cor(alg,deh)  &-0.332 & -0.30 & -0.31 & -0.25 &-0.28&-0.31 & -0.20&-0.24\\
\midrule[\heavyrulewidth]
\multicolumn{9}{l}{$^*$ \footnotesize Some explanations} \\
\bottomrule
\end{tabular}
\caption{Mean} \label{beta}
\end{table}
%\end{landscape}
\end{document}


text:
Q: Searching for a column based on string, then sumif for multiple criteria in that column (excel 2007) I have a large data set on a sheet named Program Data that (very roughly) looks like this:
  5              12         13             28          32
Column E .... Column N   Column O ...  Column AB    Column AC ...

Existing        CCS       Auto           425.25       36.89
New             RCS       Auto            32.65      189.50
Existing        CCS       Auto           100.00       50.00

The numbers above the column names are significant and are how I am required to find/reference the columns, but they do NOT correlate with A=1, B=2, etc. I have a cell, AK2, that tells what the number above these column is. I need to create a formula that looks for the column that has the specified number, then sumif on that specific column. Right now I have the following formula:
=SUMIFS(INDEX('Program Data'!A:GA,0,MATCH("*"&Ak2&"*" ,'Program Data'!1:1,0)),

 'Program Data'!$N:$N,"CCS",'Program Data'!$E:$E,"Existing",'Program Data'!O:O,"Auto")

Where the above is searching for the number that is specified in AK2, then adding up everything in that column that is "CCS","Existing", and "Auto" (columns E, N, and O, respecively). So for the above table, if AK2=28, then I want the values in column AB, so the formula would return 525.25. If AK2=32, then I'd want column AC, so the formula would return 86.89.
The problem is that the formula above keeps getting an NA on the MATCH statement, though the text in AK2 and the number match perfectly and there are values that meet the criteria in the sumif statement. I can't figure out the problem. Any suggestions are appreciated.

A: You should dispense with the wildcards in MATCH function, try just
=SUMIFS(INDEX('Program Data'!A:GA,0,MATCH(AK2,'Program Data'!1:1,0)),'Program Data'!$N:$N,"CCS",'Program Data'!$E:$E,"Existing",'Program Data'!O:O,"Auto")


text:
Q: www URL loading incorrect SSL certificate I have an issue with two sites that are running on the same IP address. One as a virtual host. The issue is one of the sites loads correctly if you use the non-www address mountainx.com but if you go to the www address www.mountainx.com it tries to load the certificate for the other site givelocalguide.org.
I worked around this temporarily by adding a Redirect to givelocalguide.org that redirects back to mountainx.com but now I need to develop givelocalguide.org so have to take off the redirect. Why is the www version of www.mountainx.com loading an incorrect certificate? What is the relationship of these two sites? Why wouldn't it load the first site in the alphabetical list on that server?
Any help would be greatly appreciated.
<VirtualHost *:80>
       ServerAdmin     webmaster@example.com
       ServerName      example2.com
       ServerAlias     www.example2.com
       DocumentRoot    /srv/www/example2.com/public_html/
       ErrorLog        ${APACHE_LOG_DIR}/example2.com_error.log
       CustomLog       ${APACHE_LOG_DIR}/example2.com_access.log combined
</VirtualHost>

<VirtualHost 199.241.186.58:443>
       SSLEngine On
       SSLProtocol all -SSLv2 -SSLv3
       SSLCertificateFile      /etc/apache2/ssl/342rwqr424.crt
       SSLCertificateKeyFile   /etc/apache2/ssl/example2.com.key
       SSLCACertificateFile    /etc/apache2/ssl/gd_bundle-g2-g1.crt

       ServerAdmin     webmaster@example.com
       ServerName      example2.com
       DocumentRoot    /srv/www/example2.com/public_html/
       ErrorLog        ${APACHE_LOG_DIR}/example2.com_error_ssl.log
       CustomLog       ${APACHE_LOG_DIR}/example2.com_access_ssl.log combined
</VirtualHost>

root@hiphop:/etc/apache2/sites-available# vi example.com

<VirtualHost *:80>
       ServerAdmin     webmaster@example.com
       ServerName      example.com
       ServerAlias     www.example.com
       ServerAlias     hammer.example.com
       DocumentRoot    /srv/www/example.com/public_html/
       ErrorLog        ${APACHE_LOG_DIR}/example.com_error.log
       CustomLog       ${APACHE_LOG_DIR}/example.com_access.log combined
</VirtualHost>

<VirtualHost 199.241.186.58:443>
       SSLEngine On
       SSLProtocol all -SSLv2 -SSLv3
       SSLCertificateFile      /etc/apache2/ssl/342ew4233.crt
       SSLCertificateKeyFile   /etc/apache2/ssl/example.com.key
       SSLCACertificateFile    /etc/apache2/ssl/gd_bundle-g2-g1.crt

       ServerAdmin     webmaster@example.com
       ServerName      example.com
       DocumentRoot    /srv/www/example.com/public_html/
       ErrorLog        ${APACHE_LOG_DIR}/example.com_error_ssl.log
       CustomLog       ${APACHE_LOG_DIR}/example.com_access_ssl.log combined
</VirtualHost>

A: If your configuration posted is accurate it appears that you are missing:

ServerAlias www.example.org

In your virtual host config. Assuming your mountainx.com certificate is setup for mountainx.com and www.mountainx.com at godaddy you should be good to go.
More details:
https://httpd.apache.org/docs/2.4/mod/core.html#serveralias


text:
Q: How to build service and how to active that in CQ5 I am learning OSGI, CQ5 these days. I am trying to build a bundle that have service (My first code).
I successfully build a bundle and upload that bundle on CQ5, and install that also.
But component shows registered only, not active. Why ?
I also want to activate this service. How can I do this ? Someone on net said to make jsp. I also do that, but didn't get any response. Help me from this problem. I spent lot of time on this, lot of searching, but I didn't get any solution.
How can I use my service in CQ5, CRXDE(Adobe).
JSP code are :-
<% var service =   sling.getService(Packages.mh.osgitest.SayHello); %>
<%= service.sayHelloTest() %>

Above code is not working.
The snapshots of these are
Bundle

component

service

My codes are as :-
SayHello
package service.expose;

import org.apache.felix.scr.annotations.Service;

public interface SayHello {
    public void sayHelloTest();
}

SayHelloTestServlet                 // Servlet have no sense here.
package service.expose;

import java.io.IOException;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;

@Component
@Service(value = SayHello.class)
public class SayHelloTestServlet implements SayHello {

    public void sayHelloTest() {
        System.out.println("Testing Say Hello");
    }

    @Activate
    protected void activate() {
        System.out.println("service started");
    }

    @Deactivate
    protected void deactivate() {
        System.out.println("service stopped");
    }
}

A: Use @Component(immediate=true) to instantiate your service as soon as the bundle is activated as opposed to on-demand.


text:
Q: Aggregate functions over arrays I have a table like this:

+-----+----------------+
| ID  |  array300      |
+-----+----------------+
| 100 | {110,25,53,..} |
| 101 | {56,75,59,...} |
| 102 | {65,93,82,...} |
| 103 | {75,70,80,...} |
+-----+----------------+

array300 column is an array of 300 elements. I need to have arrays of 100 elements with every element representing the average of 3 elements of array300. For this example the answer will be like:
array100
{62.66,...}
{63.33,...}
{80,...}
{78.33,...}

A: Putting the pieces of Igor into another form:
 select id, array300, (
    select array_agg(z) from
    (
        select avg(x) from
        (
            select x, ntile(array_length(array300,1)/3) over() from unnest(array300) x
        ) y
        group by ntile
    ) z
) array100
from your_table

For a small example table like this
 id |       array300
----+-----------------------
  1 | {110,25,53,110,25,53}
  2 | {56,75,59,110,25,53}
  3 | {65,93,82,110,25,53}
  4 | {75,70,80,110,25,53}

the result is:
 id |       array300        |                   array100
----+-----------------------+-----------------------------------------------
  1 | {110,25,53,110,25,53} | {(62.6666666666666667),(62.6666666666666667)}
  2 | {56,75,59,110,25,53}  | {(63.3333333333333333),(62.6666666666666667)}
  3 | {65,93,82,110,25,53}  | {(80.0000000000000000),(62.6666666666666667)}
  4 | {75,70,80,110,25,53}  | {(75.0000000000000000),(62.6666666666666667)}
(4 rows)

Edit My first version used a fixes ntile(2). This only worked for source arrays of size 6. I've fixed that by using array_length(array300,1)/3 instead.

A: Try something like this:
SELECT id, unnest(array300) as val, ntile(100) OVER (PARTITION BY id) as bucket_num
FROM your_table

This SELECT will give you 300 records per array300 with same id and assing them the bucket_num (1 for firs 3 elements, 2 for next 3, and so on).
Then use this select to get the avg of elements in the bucket:
SELECT id, avg(val) as avg_val
FROM (...previous select here...)
GROUP BY id, bucket_num

Next - just aggregate the avg_val into array:
SELECT id, array_agg(avg_val) as array100
FROM (...previous select here...)
GROUP BY id

Details: unnest , ntile , array_agg , OVER (PARTITION BY )
UPD: Try this function:
CREATE OR REPLACE FUNCTION public.array300_to_100 (
  p_array300 numeric []
)
RETURNS numeric [] AS
$body$
DECLARE
  dim_start int = array_length(p_array300, 1); --size of input array
  dim_end int = 100; -- size of output array
  dim_step int = dim_start / dim_end; --avg batch size
  tmp_sum NUMERIC; --sum of the batch
  result_array NUMERIC[100]; -- resulting array
BEGIN

  FOR i IN 1..dim_end LOOP --from 1 to 100.
    tmp_sum = 0;

    FOR j IN (1+(i-1)*dim_step)..i*dim_step LOOP --from 1 to 3, 4 to 6, ...
      tmp_sum = tmp_sum + p_array300[j];
    END LOOP;

    result_array[i] = tmp_sum / dim_step;
  END LOOP;

  RETURN result_array;
END;
$body$
LANGUAGE 'plpgsql'
IMMUTABLE
RETURNS NULL ON NULL INPUT;

It takes one array300 and outputs one array100. To use it:
SELECT id, array300_to_100(array300)
FROM table1;

If you have any problems understanding it - just ask me.

A: I'm not able to answer your question completely, however I have found aggregation function for summing integer arrays. Perhaps someone (or you) can modify it to avg.
Source: http://archives.postgresql.org/pgsql-sql/2005-04/msg00402.php
CREATE OR REPLACE FUNCTION array_add(int[],int[]) RETURNS int[] AS '
  DECLARE
    x ALIAS FOR $1;
    y ALIAS FOR $2;
    a int;
    b int;
    i int;
    res int[];
  BEGIN
    res = x;

    a := array_lower (y, 1);
    b := array_upper (y, 1);

    IF a IS NOT NULL THEN
      FOR i IN a .. b LOOP
        res[i] := coalesce(res[i],0) + y[i];
      END LOOP;
    END IF;

    RETURN res;
  END;
'
LANGUAGE plpgsql STRICT IMMUTABLE;

--- then this aggregate lets me sum integer arrays...

CREATE AGGREGATE sum_integer_array (
    sfunc = array_add,
    basetype = INTEGER[],
    stype = INTEGER[],
    initcond = '{}'
);

Here's how my sample table looked  and my new array summing aggregate
and function:

#SELECT * FROM arraytest ;
 id | somearr
----+---------
 a  | {1,2,3}
 b  | {0,1,2}
(2 rows)

#SELECT sum_integer_array(somearr) FROM arraytest ;
 sum_integer_array
-------------------
 {1,3,5}
(1 row)

A: Is this any faster?
Edit: This is more elegant:
with  t as (select generate_series(1, 100,1) a , generate_series(101,200,1) b , generate_series(201,300,1) c)

    select
        id,
        array_agg((array300[a] + array300[b] + array300[c]) / 3::numeric order by a)  as avg
    from
        t,
        tmp.test2
    group by
        id

End of edit
Edit2
This is the shortest select I can think of:
select
    id,
    array_agg((array300[a] + array300[a+100] + array300[a+200]) / 3::numeric order by a)  as avg
from
    (select generate_series(1, 100,1) a) t,
    tmp.test2
group by
    id

End of edit2
with

t as (select generate_series(1, 100,1) a , generate_series(101,200,1) b , generate_series(201,300,1) c)

,u as (
    select
        id,
        a,
        (array300[a] + array300[b] + array300[c]) / 3::numeric as avg
    from
        t,
        tmp.test2 /* table with arrays - id, array300 */
    order by
        id,
        a
 )

select
    id,
    array_agg(avg)
from
    u
group by
    id


text:
Q: $this is not getting accessed in a controller when called from a twig file I'm trying to render meta tags by calling a controller named MetaController from a twig file.
<head>
    {{ render(controller('AppBundle:Meta:seoOptimizedMeta')) }}

The problem is when I try to access $this in the controller, I get blank pages. So, it seems the link to $this is lost when called from a twig file, so I wanted to know how am I supposed to get the $this pointer so as to carry out my database calling methods etc...
class MetaController extends Controller {
    public function seoOptimizedMetaAction()
    {
        $request = Request::createFromGlobals();
        $repo = $this->getDoctrine()->getRepository('AppBundle:Product');
        return new Response('<meta charset="UTF-8" />'); //testing
    }
}

For test sake,
class MetaController extends Controller {
    public function seoOptimizedMetaAction()
    {
        $request = Request::createFromGlobals();
        print_r($this);
        return new Response('<meta charset="UTF-8" />'); //testing
    }
}

The dev.log contains,
[2015-12-03 14:23:22] request.INFO: Matched route "homepage". {"route_parameters":{"_controller":"AppBundle\\Controller\\DefaultController::indexAction","_route":"homepage"},"request_uri":"http://localhost/mysnip/web/app_dev.php/"} []
[2015-12-03 14:23:22] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DumpListener::configure". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\TranslatorListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\SecurityListener::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DumpListener::configure". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\TranslatorListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\SecurityListener::onKernelController". [] []
[2015-12-03 14:23:22] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". [] []

And a simple blank page in the browser!

A: *

*I found out the problem of my error was my code, getting details of $this was probably too much for twig file to take in. So, print_r or var_dump should be strictly avoided.

*You can also get the get the RequestStack by $this->get('request_stack').

My problems have been solved, and thanks to @Yoshi for the suggestion.


text:
Q: Animating Sprite Sheets in Java using LibGdx I have some code here that takes a sprite sheet and divides it up into its individual sprites by taking in the length and width of my image and diving it by the rows and columns. This, works for my test sprite sheet, but not the one I'm actually going to be using for my game.
My Animation Class is here:
package Simple;

    import com.badlogic.gdx.Gdx;
    import com.badlogic.gdx.graphics.Texture;
    import com.badlogic.gdx.graphics.g2d.Batch;
    import com.badlogic.gdx.graphics.g2d.TextureRegion;
    import com.badlogic.gdx.graphics.g2d.Animation;

    public class RunningMan {
        private Texture texture;
        private TextureRegion[] walkFrames;
        private Animation walkAnimation;
        private float stateTime = 0f;
        private TextureRegion currentFrame;
        int rows = 5;
        int cols = 6;
        public RunningMan(Texture texture) {
            this.texture = texture;
            TextureRegion[][] tmp = TextureRegion.split(texture, texture.getWidth() / cols, texture.getHeight() / rows);  // split the sprite sheet up into its 30 different frames
            walkFrames = new TextureRegion[rows * cols];
            int index = 0;
            for(int i = 0; i < rows; i++) {
                for (int j = 0; j < cols; j++) {
                    walkFrames[index++] = tmp[i][j];    // Put the 30 frames into a 1D array from the 2d array
                }
            }
            walkAnimation = new Animation(0.06f, walkFrames);  // initialize the animation class
            stateTime = 0f;
        }

        public void draw(Batch batch) {
            stateTime += Gdx.graphics.getDeltaTime();   // stateTime is used to determine which frame to show
            if(stateTime > walkAnimation.getAnimationDuration()) stateTime -= walkAnimation.getAnimationDuration();  // when we reach the end of the animation, reset the stateTime
            currentFrame = walkAnimation.getKeyFrame(stateTime);    // Get the current Frame

            batch.draw(currentFrame,50,50); // draw the frame
        }
    }

My Class to run the Animation is here:
package Simple;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class Animation extends ApplicationAdapter {
    SpriteBatch batch;
    RunningMan man;

    @Override
    public void create () {
        batch = new SpriteBatch();
        man = new RunningMan(new Texture(Gdx.files.internal("WalkingMan.png")));
    }

    @Override
    public void render () {
        Gdx.gl.glClearColor(1, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        batch.begin();
        man.draw(batch);
        batch.end();
    }
}

When I use the WalkingMan.png, the code works flawlessly. But when I go to use any other sprite sheet, such as WalkingWoman.jpg (im not worried that this one is not transparent), the alignment is off when the columns and rows are adjusted accordingly. Any suggestions?
WalkingMan.png
WalkingWoman.jpg

A: The animation class seems to split the source image into frames by assuming that all frames in the spritesheet image are evenly spaced. So for the WalkingMan image, the 512x512px original is split into 30 frames each 85.33px wide (512 / 6 columns), and 102.4px high (512 / 5 rows).
If, as you say, you adjust the column and row numbers for the WalkingWoman image (which is 1300x935), you get 36 frames each 144.44px wide (1300 / 9 columns), and 233.75px high (935 / 4 rows).
The problem is that the WalkingWoman spritesheet does not have each frame evenly spaced. If you split the first frame out of the image, you get this:
see how her foot is cut off on the right
The WalkingMan image has each image placed in the spritesheet within a bounding box of identical size. You just need to make sure the WalkingWoman sheet has each frame evenly spaced in the same way.


text:
Q: Differences between ATMega2561 and ATmega2560 Because of sourcing issue we're replacing an ATmega2561 with an ATmega2560 in a BGA housing on a little adapter PCB.
The most obvious difference is the number of Pins. The ATmega2560 has 36 pins more than the ATmega2561 but they have the same functions (mostly).
Another Difference is the position of the ISP (in circuit serial programming) pins which are combined with different functions on different pins (they only write about the TQFP packages and forget the BGA Package despite it being in the same datasheet otherwise).

Luckily, there is still JTAG where the pins stay the same.
Now other than that, how "compatible" are they? Can I run machine code compiled for the ATmega 2561 (the one with less pins) on the ATmega 2560? Or are there internal differences for example in memory layout as well?

A: The ATmega2561 is a true subset of the ATmega2560. If your software doesn't use port H/J/K/L, USART 2/3, TC 4/5, it will run on the ATmega2561 as well. And vice versa.
That moving around of the ISP data pins is an oddity.


text:
Q: Class \GuzzleHttp\Client not found composer I  have been installing Guzzle using composer and try to use it,
but I get an error

Fatal error: Uncaught Error: Class 'Conf\GuzzleHttp\Client' not found in /var/www/html/4travelo_beta/config/RequestConf.php:28 Stack trace: #0 /var/www/html/4travelo_beta/config/RequestConf.php(85): Conf\RequestConf->__construct() #1 {main} thrown in /var/www/html/4travelo_beta/config/RequestConf.php on line 28

this is my directory structure :

and this is my code:
 namespace Conf ;

    require '../vendor/autoload.php';

    use GuzzleHttp\Client;
    use GuzzleHttp\Psr7;
    use GuzzleHttp\Psr7\Request;
    use GuzzleHttp\Psr7\Response;
    use GuzzleHttp\Psr7\Uri;

    class RequestConf
    {
     /**
        /**
         * @var Client HTTPClient object
         */
        private $httpClient;

        /**
         * HotelApiClient Constructor they initialize SDK Client.
         * @param int $timeout HTTP Client timeout
         */

        function __construct()
        {
            $this->$httpClient = new GuzzleHttp\Client(['base_url' => 'https://api.test.com/']);
        }
}

my composer.json :
    {
    "autoload": {
        "psr-4": {

            "Conf\\": "config/",
            "Model\\": "model/"
        }
    },
    "require": {
        "guzzlehttp/guzzle": "~6.0"
    }
}

i have been updating my composer but Guzzle class still not work, can someone tell me why ?

A: TL;DR Simply try = new Client(...), because you've already imported GuzzleHttp\Client, or just remove this import.
You are trying to create an instance of GuzzleHttp\Client, and because there are no imported namespaces like GuzzleHttp (with use), PHP tries to find the class in the current namespace. In the end you get the error about Config\GuzzleHttp\Client.
So it should be like:
 function __construct()
 {
      $this->httpClient = new Client(['base_url' => 'https://api.test.com/']); // Please also note removed '$' from httpClient, because it a field.
 }

A: You might need to use composer dumpautoload so it will update your autoload include file.


text:
Q: Easily position image with double-height than other images I want to make a page with 8 images like this:
img1 img2 img3
img4 img5 img8
img6 img7 img8

As you can see "img8" is double as tall as all the other images.
How do I do this in css?

A: As Scott says, there are different ways to do this. If you images have specific width and height, then see if my example fits you:
http://jsfiddle.net/J8TLV/

A: It's just basic floats:
.wrap {
    width: 150px;
    height: 150px;
}

.small {
    width: 50px;
    height: 50px;

    float: left;
}

.big {
    width: 50px;
    height: 100px;

    float: right;
}

I assumed a HTML structure like the one below:

1

2

3

4

5

8

6

7

Demo: http://jsfiddle.net/Eg8un/11/

A: Since they did the floats, I'll do the absolute positioning. The disadvantage is more css. The advantage is that source order can be maintained (images 1-8 are ordered so in the html). I toggled off Frexuz's jsfiddle http://jsfiddle.net/J8TLV/3/.
I thought I would update on another (related) advantage, that the images can be positioned anywhere in the "row" and "column" grid without reordering the images themselves (as you would need to with float).


text:
Q: How to copy files from sql server 2005 vm to sql server 2012 vm I want to copy a few files from E drive from my VM which has sql server 2005 and paste it to another VM which has sql server 2012.
I am not able to do it, as paste option is not available in my sql server 2012 vm.
What is wrong about this copy and paste.
Could anyone please help me out in this?

A: Assuming both machines are on the same network, you can create a folder share on one VM and access that share from the other VM.  BTW, this has nothing to do with SQL.   Sharing Folder on Windows


text:
Q: Video Lectures for Linear Algebra Are there any video lectures for linear algebra other than Strang's?. I'm looking for something more pure. Ideally, from a professor who follows a book similar to Hoffman and Kunze or Axler.
Thanks!

A: This series of video lectures by Jason Morton from Penn State follows Axler's Linear Algebra Done Right (3rd edition):
https://www.youtube.com/playlist?list=PLflMyS1QOtxwiN5oOuyY4W_8fZlTTnRcF
Website accompany the lectures:
http://jasonmorton.github.io/LinearAlgebra/

A: There is some material on vector spaces in the abstract algebra videos of Benedict Gross. The course text is Michael Artin's Algebra, as a guide to level.
http://www.extension.harvard.edu/open-learning-initiative/abstract-algebra

A: I have made a new series of videos to accompany Linear Algebra Done Right. These videos are available here: http://www.linear.axler.net/LADRvideos.html

A: http://www.youtube.com/watch?v=JibVXBElKL0
http://www.youtube.com/watch?v=VE0xIpf11Qo
you may like this one

A: illinios lecture purely based on axler book
https://felixleditzky.info/teaching/FT21/MATH416_linear_algebra.html#toc
A lecture series from iisc more rigourous than felix
https://youtube.com/playlist?list=PLG9Skd-hzSi47tz_2QrJXige0F5lK-jvx

A: http://www.khanacademy.org/math/linear-algebra
Here is one place to look


text:
Q: if element not excisted on page, how to pass that item? I have a new issue in web scraping?
I work on these 2 pages and I want to extract their location info as a part of web scraping process
Some items have exact lat long info and I could export them
But some has just a circle that represent approximate position of item
I want to check if this info existed extract location but if not pass to next item
But whatever I used not worked
here is my code:
from cgitb import text
from tkinter import END
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
from selenium.webdriver.common.keys import Keys
import pandas as pd
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait

options = webdriver.ChromeOptions()
options.add_argument("--incognito")

options.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})

translationTable = str.maketrans("ğĞıİöÖüÜşŞçÇ", "gGiIoOuUsScC")

driver = webdriver.Chrome(executable_path=r"D:\\Prohit\\chromedriver.exe",chrome_options=options)
#driver.maximize_window()

actions = ActionChains(driver)

url1 = 'https://www.hepsiemlak.com/istanbul-kadikoy-fenerbahce-satilik/daire/124037-400'
url2 = 'https://www.hepsiemlak.com/istanbul-kadikoy-acibadem-satilik/daire/2525-15017'

driver.get(url1)
#driver.execute_script("document.body.style.zoom='80%'")
try:
    element = WebDriverWait(driver, 120).until(
        EC.visibility_of_element_located((By.CLASS_NAME,'modal__close'))
    )
finally:
    driver.find_element(By.CLASS_NAME,'modal__close').click()

driver.find_element(By.XPATH,'//*[@id="__layout"]/div/div[1]/section[3]/div/div[1]/div/section[1]/div[2]/div[1]/ul/li[4]/a').click()
time.sleep(5)
#click on harita
driver.find_element(By.XPATH,'//*[@id="fullScreenWrapper"]/div/div[1]/button[2]/span').click()
time.sleep(3)

#-----------------------------

location_link=driver.find_element(By.XPATH,'//*[@id="mapBlock"]/div/div[1]/div/a').get_attribute("href")

print('location:',location_link.split('cbll=')[1].split('&cbp=11')[0])
time.sleep(5)
print('location link length',len(location_link))

the url1 has location info and i can access but url2 not and break the total process
this method does not work:
if(len(location_link>0)):
assign some info
have anyone suggesstions?

A: the true solution is:
    Location_Availability = driver.find_element(By.XPATH,'//*[@id="mapBlock"]/div/div[1]/div').find_elements_by_css_selector("*")
    #print('Location_Availability:',Location_Availability)
    #print(len(Location_Availability))

    if len(Location_Availability)>2:
        location=driver.find_element(By.XPATH,'//*[@id="mapBlock"]/div/div[1]/div/a').get_attribute('href').split('cbll=')[1].split('&cbp=11')[0]
        print('location:',location)
    else:
        print('no location')


text:
Q: $x^4+y^4 \geq \frac{(x^2+y^2)^2}{2}$ I'm doing some exercise to prepare for my multivariable analysis exam. I didn't understand the second part of this question.

Given the function
$$f(x,y)=(x^2+y^2+1)^2 - 2(x^2+y^2) +4\cos(xy)$$
Prove that the taylor polynomial of degree $4$ of $f$ is equal to
  $5+x^4+y^4$.

First, $4\cos(xy) = 4 - 2(xy)^2 + 4R_3 $
$(x^2+y^2+1)^2=x^4+2 x^2 y^2+2 x^2+y^4+2 y^2+1$
Therefore: $(x^2+y^2+1)^2 - 2(x^2+y^2)=x^4+2 x^2 y^2+y^4+1$
Therefore: $f(x,y)=x^4+y^4+5+4R_3$
I don't know exactly why I can now conclude that Taylor Polynomial of degree 4 must be $5+x^4+y^4$, but I don't know exactly why.

Now the second question is: $x^4+y^4 \geq \frac{(x^2+y^2)^2}{2}$

New edit
I understand this now thanks to hint of Hagen von Eitzen, thanks !
The third question is:

Determine what kind of stationary point you have in $(0,0)$.

A: Hint: The difference left minus right is $\frac12(x^4-2x^2y^2+y^4)$

A: Write $x^4=2x^4-x^4$ and similarly $y^4=2y^4-y^4$
$$(x^2-y^2)^2 \ge 0$$
$$x^4+y^4-2x^2y^2 \ge 0$$
$$2x^4-x^4+2y^4-y^4-2x^2y^2 \ge0$$
$$2x^4+2y^4 \ge x^4+y^4+2x^2y^2$$
$$x^4+y^4 \ge \dfrac{(x^2+y^2)^2}{2}$$

A: $$x^4 + y^4 \ge \frac{(x^2+y^2)^2}{2} \\
2x^4+2y^4\ge x^4+2x^2y^2+y^4 \\
x^4-2x^2y^2+y^4 \ge0 \\ (x^2-y^2)^2\ge0$$
Notice that $x^2-y^2\in R$, so all real number with an even exponent are always greater or iqual to zero.


text:
Q: Writing partitioned dataset to HDFS/S3 with _SUCCESS file in each partition when writing a partitioned dataset to HDFS/S3, a _SUCCESS file is written to the output directory upon successful completion. I'm curious if there is way to get a _SUCCESS file written to each partitioned directory ?

A: For the time being, you may be able to get your desired result by writing out files directly to path/to/table/partition_key1=foo/partition_key2=bar and not using the Parquet writer's partitionBy argument.
FWIW, I also believe that _SUCCESS files should be written out to every partition, especially given that SPARK-13207 and SPARK-20236 have been resolved.


text:
Q: How to select option class/value with jquery in select dropdown I would like to hide/show div based on select drop-down option value/class click. But i am unable to select do that because Chrome not supporting this functionality. Could anyone please help me to find out a simple way with that i can write jquery script on click for option class/value. On web i found that on click function does not work in chrome.
Here is my code.
<select id="dd1" style="width: 12%">
<option class="all" value="all">Select below 1</option>
<option id="opt1" class="opt1" value="opt1">option 1</option>
<option class="opt2" value="opt2">option 2</option>
<option class="opt3" value="opt3">option 3</option>
<option class="opt4" value="opt4">option 4</option>
</select>

<select id="dd2" style="width: 12%">
<option value="all">Select below 1</option>
<option class="opt5" value="opt5">option 5</option>
<option  class="opt6" value="opt6">option 6</option>
<option class="opt7" value="opt7">option 7</option>
<option class="opt8" value="opt8">option 8</option>
</select>

here is the jquery code

$(document).ready(function () {
$('.opt1').on('click',function(){

$('.modal1, .modal2, .modal3, .modal4, .modal5, .modal6, .modal7, .modal8, .modal9, .modal10, .modal11, .modal12, .modal13, .modal14, .modal15, .modal16, .modal17, .modal18, .modal19, .modal20, .modal21, .modal23, .modal24, .modal25, .modal26').show();
$('.modal22').hide();

$("#dd2 option[value='2']").remove();

});

$('.fids1').on('click',function(){
$('.modal22').show();
$('.modal1, .modal2, .modal3, .modal4, .modal5, .modal6, .modal7, .modal8, .modal9, .modal10, .modal11, .modal12, .modal13, .modal14, .modal15, .modal16, .modal17, .modal18, .modal19, .modal20, .modal21, .modal23, .modal24, .modal25, .modal26').hide();

$("#dd2 option[value='2']").remove();

});

});

A: You're thinking about it the wrong way:
$('.opt1').on('click',function(){
  //...
});

You don't want to perform an action when the <option/> is "clicked".  Instead, you want to perform an action when the <select/> value is changed to a specific value.
Something like this:
$('#dd1').on('change',function(){
  if ($(this).val() === 'opt1') {
    //...
  }
});


text:
Q: Interstitial Ads are not showing using AdMob I'm trying to add interstitial adds to my program.
I created the following AdsManager.
public class AdsManager {

    private Context context;
    private InterstitialAd mInterstitialAd;

    public AdsManager (Context context) {
        this.context = context;
        MobileAds.initialize(context, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(@NonNull InitializationStatus initializationStatus) {

            }
        });
    }

    public void createAds (AdView adView) {
        AdRequest adRequest = new AdRequest.Builder().build();
        adView.loadAd(adRequest);
    }

    public InterstitialAd loadInterstatialAd () {

        AdRequest adRequest = new AdRequest.Builder().build();

        mInterstitialAd.load(context, "ca-app-pub-3940256099942544/1033173712",
                adRequest, new InterstitialAdLoadCallback() {
                    @Override
                    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                        super.onAdFailedToLoad(loadAdError);
                        Log.d("InterstitsionalAds", "Error: " + loadAdError);

                    }

                    @Override
                    public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
                        super.onAdLoaded(interstitialAd);
                        mInterstitialAd = interstitialAd;
                        mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback() {
                            @Override
                            public void onAdClicked() {
                                super.onAdClicked();
                            }

                            @Override
                            public void onAdDismissedFullScreenContent() {
                                super.onAdDismissedFullScreenContent();
                            }

                            @Override
                            public void onAdFailedToShowFullScreenContent(@NonNull AdError adError) {
                                super.onAdFailedToShowFullScreenContent(adError);
                                Log.d("InterstitsionalAds", "Error: " + adError);
                            }

                            @Override
                            public void onAdImpression() {
                                super.onAdImpression();
                            }

                            @Override
                            public void onAdShowedFullScreenContent() {
                                super.onAdShowedFullScreenContent();
                                mInterstitialAd = null;
                            }
                        });
                    }
                });

        return mInterstitialAd;
    }

}

This is how I call it in my activity:
adsManager = new AdsManager(this);
mInterstitialAd = adsManager.loadInterstatialAd();

if (mInterstitialAd != null) {
    mInterstitialAd.show(ColoringActivity.this);
}

But after that nothing happens. Ads are not shown. The debugger says that mInterstitialAd is null.
I tried to call it in the activity itself, without the AdsManager class, but it still doesn't work.
I also use a test ad id that google recommends here (ca-app-pub-3940256099942544/1033173712)
My Manifest:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />

    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-8673003336752212~XXXXXXXXXX"/>

Also I added dependencies in my Build.Gradle (Module):
implementation 'com.google.android.gms:play-services-ads:21.3.0'

I would also like to add that my banner advertising works great. I do not understand what the problem is.

A: It looks like the ad is not loaded at the moment when you trying to show it.
adsManager = new AdsManager(this);
mInterstitialAd = adsManager.loadInterstatialAd(); // here you starting loading the ad

if (mInterstitialAd != null) { // and right after you want to show the ad
    mInterstitialAd.show(ColoringActivity.this);
}

I would recommend (as well as per google documentation) to call load method at the beginning of the activity lifecycle, and call show method when some event happened in the activity (user passed the level, clicked button etc.)


text:
Q: What's the distribution of $X$? Let X be a continuous, positive random variable. We also have that $E(X−a|X≥a)$ does not depend on $a$. What's the distribution of $X$?
I think the expected value is $E(X−a|X≥a)=\int (x-a) f(x-a) dx$, and it's derivate w.r.t a is $\int x f(x-a) dx + \int(x-a)f(x-a) dx$, and it must be 0, so we have that $-\int x f(x-a) dx = \int(x-a)f(x-a) dx$, but I can do nothing with it. How should I do it?

A: BY definition of expected value in terms of the distribution function,
$$
\frac{\int_a^\infty(x-a)f(x)\, dx}{\int_a^\infty f(x)\, dx}
$$
is independent of $a$; say its value is the constant $k$. Then
$$
\int_a^\infty(x-a)f(x)\, dx = k\int_a^\infty f(x)\, dx $$
$$
\int_a^\infty xf(x)\, dx = (k+a)\int_a^\infty f(x)\, dx
$$
$$
\frac{d}{da}\int_a^\infty xf(x)\, dx = \frac{d}{da}\left[(k+a)\int_a^\infty f(x)\, dx\right]
$$
$$
-af(a) = \frac{d}{da}\left[(k+a)\right]\int_a^\infty f(x)\, dx+(k+a) \frac{d}{da}\left[\int_a^\infty f(x)\, dx\right]
$$
$$
-af(a) = \int_a^\infty f(x)\, dx - (k+a) f(a)
$$
$$
\int_a^\infty f(x)\, dx = kf(a)
$$
$$
\frac{d}{da}\int_a^\infty f(x)\, dx = k \frac{df(a)}{da}
$$
$$
\frac{df(a)}{da} = -\frac1k f(a)
$$
$$f(a) = \alpha e^{-a/k}$$
which is an exponential distribution.

A: Hint: can you show that $X$ is memorylessness, i.e. satisfies $\mathbb{P}(X>t+s \ | \ X>t)=\mathbb{P}(X>s)$?
Since you didn't manage to show this yourself, a proof goes as follows: we know that we have a continuous, positive, random variable, and we are given that $\mathbb{E}(X-a\ | \ X\geq a)$ does not depend on $a\geq0$. I assume $a\geq0$ because otherwise the question does not make sense. Then we have $\mathbb{E}(X-a\ | \ X\geq a)=\mathbb{E}(X-0\ | \ X\geq 0)=\mathbb{E}(X)$ since $X$ is positive. Thus $$\int_{a}^{\infty}(x-a)\frac{f(x)}{\mathbb{P}(X\geq a)}\mathrm{d}x=\int_{0}^{\infty}xf(x)\mathrm{d}x,$$ and then by the change of variables $x\mapsto x+a$, $$\int_{0}^{\infty}xf(x)\mathrm{d}x=\int_{0}^{\infty}x\frac{f(x+a)}{\mathbb{P}(X\geq a)}\mathrm{d}x.$$ Then, because this equality holds for any $a\geq0$, we conclude $f(x)=\frac{f(x+a)}{\mathbb{P}(X\geq a)}$. Now we take the integral over the region $[b,\infty]$ for a $b\geq0$, and we see that $$\mathbb{P}(X> b)=\mathbb{P}(X\geq b)=\frac{\mathbb{P}(X\geq a+b)}{\mathbb{P}(X\geq a)}=\frac{\mathbb{P}(X> a+b)}{\mathbb{P}(X> a)}=\mathbb{P}(X>a+b\ | \ X>a),$$ as desired.


text:
Q: ggplot2 pdf import in Adobe Illustrator missing font AdobePiStd I created several simple ggplot2 plots and saved them to PDF files using the following commands:
p <- ggplot(plotobject, aes(x=Pos, y=Pval),res=300)
ggsave(plot=p,height=6,width=6,dpi=200, filename="~/example.pdf")

If I now open this example.pdf in Adobe Illustrator I get the following error:

The font AdobePiStd is missing.  Affected text will be displayed using
  a substitute font.

Is there a way in ggplot2 to specify a font (I presume this is for the dots/points) that Adobe will understand or otherwise is there a way to get this font working in Adobe?
/edit just to clarify, the text/labels/titles are all just fine its the dots that are missing for the font
/edit2 I got a working solution by just using the EPS output in ggsave, but still would love to find out a way to also be able to just open/import ggplot2 plots in PDF format directly in AI

A: This seems to be a perverse problem in which Adobe Illustrator cannot find a font (AdobePiStd) that is distributed with Adobe Reader and thus is likely present.
If you search your computer, you are likely to find it.  On my WindowsXP system, it was in:
C:\Program Files\Adobe\Reader 10.0\Resource\Font
After finding it, you can install it and other fonts in that folder, which should enable Illustrator to find them.
For other font/pdf problems in R, the embedFonts function in grDevices package is useful.

A: Use useDingbats=FALSE for the pdf output, then Illustrator will no complain.
pdf("example.pdf", useDingbats=FALSE)
ggplot(plotobject, aes(x=Pos, y=Pval),res=300)
dev.off()

A: Although changing the fonts used by AI works well, an alternative is to restrict ggplot2 from using Dingbats in the first place by adding the argument 'useDingbats' to your ggsave command eg:
ggsave(plot=p,height=6,width=6,dpi=200, filename="~/example.pdf", useDingbats=FALSE)

A: I ran into this problem as well on Mac OS X 10.8.2.
This resolved the issue for me:
font='/Library/Application Support/Adobe/PDFL/10.9/Fonts/AdobePiStd.otf'
cp $font /Library/Fonts/

On your system, find the file with find:
find / -name AdobePiStd.otf 2>/dev/null

/Applications/Adobe Photoshop CC 2018/Adobe Photoshop CC 2018.app/Contents/Required/PDFL/Resource/Fonts/AdobePiStd.otf
/Applications/Adobe Illustrator CC 2018/Adobe Illustrator.app/Contents/Required/PDFL Resource/Resource/Fonts/AdobePiStd.otf
/Applications/Adobe Acrobat DC/Adobe Acrobat.app/Contents/Resources/Resource/Font/AdobePiStd.otf

A: EDIT 2018 The question under was for the initial confusion face. The answer to this question is pdf(useDingbats = FALSE) as stated in numerous answers above. I won't delete this answer, in case you want to read about fonts (which might become a problem too).
OLD ANSWER AI does not recognize Helvetica type fonts. In my computer it doesn't matter that much, since it automatically replaces the font with something suitable. Of course you'd want to change the font in some cases. I often do it manually in AI (just select all the text and change the font type). Here is a thread on how to change the font in ggplot2: Modifying fonts in ggplot2
Ps. There is also another thread that might be helpful: Fonts in R plots

A: You can download the font AdobePiStd - just Google it, download and install. After you reboot, the font should display correctly. You can then use the 'Find Font ...' utility within Illustrator to change it if you wish.

A: For dots or points that don't' display correctly in a pdf, I just substitute Zapf Dingbats for the missing font in Adobe Illustrator. For simple plot markers, this does the job most of the time.

A: Another option that in simple cases might solve the problem is to in illustrator select the textobjects not displayed correctly and change the font. Helvetica Neue works for me.

A: I could solve the problem just by adding alpha specification. If you don't need any transparency you can chose an alpha value of 0.9 ...
example:
ggplot() + geom_point(aes(x=..,y=.., color=...), alpha=0.8)