text:
Q: property 'name' does not exist on type 'FormComponent' Here is the error Message:

WARNING in Invalid background value at 160:282. Ignoring.
WARNING in Invalid background value at 184:60084. Ignoring.
ERROR in src/app/form/form.component.html(14,48): : Property 'name' does not exist on type 'FormComponent'.
src/app/form/form.component.html(27,69): : Property 'homePhone' does not exist on type 'FormComponent'.
src/app/form/form.component.html(32,67): : Property 'cellPhone' does not exist on type 'FormComponent'.
src/app/form/form.component.html(37,71): : Property 'officePhone' does not exist on type 'FormComponent'.
src/app/form/form.component.html(168,21): : Property 'homePhone' does not exist on type 'FormComponent'.
src/app/form/form.component.html(169,21): : Property 'cellPhone' does not exist on type 'FormComponent'.
src/app/form/form.component.html(170,21): : Property 'officePhone' does not exist on type 'FormComponent'.
src/app/form/form.component.html(189,11): : Property 'NaN' does not exist on type 'FormComponent'.
src/app/form/form.component.html(14,48): : Property 'name' does not exist on type 'FormComponent'.
src/app/form/form.component.html(27,69): : Property 'homePhone' does not exist on type 'FormComponent'.
src/app/form/form.component.html(32,67): : Property 'cellPhone' does not exist on type 'FormComponent'.
src/app/form/form.component.html(37,71): : Property 'officePhone' does not exist on type 'FormComponent'.

Here is my form.component.html

    <form #calculatingForm="ngForm" (ngSubmit)="onSubmit(calculatingForm)" class="ui big form">

ProShine Quote Calculator

                Client Name
                <input type="text" name="name" [(ngModel)]="name" #client="ngModel" required autofocus>

                    No Client Name Entered

Please Enter A Name

                Home Phone
                  <input type="tel" name="homePhone" id="homePhone" [(ngModel)]="homePhone" placeholder="(123) 456-7890"
       [textMask]="{mask: mask}">

                Cell Phone
                <input type="tel" name="cellPhone" id="cellPhone" [(ngModel)]="cellPhone" placeholder="(123) 456-7890"
       [textMask]="{mask: mask}">

                Office Phone
                <input type="tel" name="officePhone" id="officePhone" [(ngModel)]="officePhone" placeholder="(123) 456-7890"
       [textMask]="{mask: mask}">

                Total Number of Panes
                <input type="number" name="totalPanes" id="totalPanes" [(ngModel)]="totalPanes" #panes="ngModel" required>

                    You Didn't Enter A Number

Please Enter the Number of Panes

                Number of Floor Panes
                <input type="number" name="floorPanes" id="floorPanes" [(ngModel)]="floorPanes">

                Number of Outside Ladder Panes
                <input type="number" name="outsideLadderPanes" id="outsideLadderPanes" [(ngModel)]="outsideLadderPanes">

                Number of Indoor AND Outdoor Ladder Panes
                <input type="number" name="ladderPanesInAndOut" id="ladderPanesInAndOut" [(ngModel)]="ladderPanesInAndOut">

                  Created By
                  <select name="currentUser" id="currentUser" class="ui fluid dropdown " [(ngModel)]="currentUser" required>
                    <option value="">-- Select --</option>
                    <option value="Jason Walle">Jason Walle</option>
                    <option value="Aubree Walle">Aubree Walle</option>
                  </select>

Additional Options

                  Referral By
                  <input type="text" name="referral" id="referral" [(ngModel)]="referral" >

                    Discount
                    <input type="text" name="clientDiscount" id="clientDiscount" [(ngModel)]="clientDiscount" >

                    Discount Type
                    <select name="discountType" id="discountType" class="ui fluid dropdown " [(ngModel)]="discountType" required>
                    <option value="">-- Select --</option>
                    <option value="Percentage">Percentage(%)</option>
                    <option value="Dollars">Dollars($)</option>
                  </select>

      <button type="submit" class="ui blue button">Calculate</button>
      <button type="button" class="ui olive button" (click)="calculatingForm.reset()">New Client</button>

    </form>

    <button (click)="goBack()" class="ui blue button">  Go Back</button>

Client Name: {{ clientName }}

Home Phone #: {{homePhone}}

Cell Phone #: {{cellPhone}}

Office Phone #: {{officePhone}}

# of Floor Panes:
{{floorPanes}}

# of OUTSIDE Ladder Panes:
{{outsideLadderPanes}}

# of Inside AND Outside Ladder Panes:
{{ladderPanesInAndOut}}

Client Discount: - ${{discountPrice}}

Total Quote: ${{estimatedQuote}}

Created By {{currentUser}} on {{currentDate | date:'fullDate'}}

  <button class="ui orange button" (click)="downloadPDF()">Export As PDF</button>

Here is my form.component.ts file
import { NavigationComponent } from './../navigation/navigation.component';
import { Estimate } from './../estimate';
import { NgForm, FormsModule } from "@angular/forms";
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-form',
  templateUrl: './form.component.html',
  styleUrls: ['./form.component.css']
})

export class FormComponent implements OnInit {

  constructor(
  ) { }

  // =========== Text Mask ==============
  mask: any[] = ['+','1',' ', '(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]

// =========== Variables ===========
submitted = false;
// isOn = false;

costPerPane = 0.00;
costForLadder = 0.00;
costForFloorPanes = 0.00;
estimatedQuote = 0.00;
// quoteDemo = new Estimate("Phil",12,12,0,0,0);

clientName:string = "";
clientHomePhone:string;
clientCellPhone:string;
clientOfficePhone:string;
currentUser:string;
currentDate:string;
referral:string;

totalPanes:number;
floorPanes:number;
outsideLadderPanes:number;
ladderPanesInAndOut:number;
clientDiscount:number;
discountType:string;
discountPrice:any;

onSubmit(calculatingForm :NgForm){

  this.submitted = true;

  //Getting Form Input Values
  this.clientName = calculatingForm.form.get('name').value;
  this.clientHomePhone = calculatingForm.form.get('homePhone').value;
  this.clientCellPhone = calculatingForm.form.get('cellPhone').value;
  this.clientOfficePhone = calculatingForm.form.get('officePhone').value;

  this.totalPanes = calculatingForm.form.get('totalPanes').value;
  this.floorPanes = calculatingForm.form.get('floorPanes').value;
  this.outsideLadderPanes = calculatingForm.form.get('outsideLadderPanes').value;
  this.ladderPanesInAndOut = calculatingForm.form.get('ladderPanesInAndOut').value;

  this.clientDiscount = calculatingForm.form.get('clientDiscount').value;
  this.discountType = calculatingForm.form.get('discountType').value;

  this.currentUser = calculatingForm.form.get('currentUser').value;
  this.currentDate = Date.now().toString();

//  ============ TOTAL QUOTE ==========
  this.estimatedQuote = (this.costForFloorPanes + this.costForLadder);

  //------ Discount Amount ----------
  if (this.discountType == "Percentage") {
    this.clientDiscount /= 100;
    this.discountPrice = (this.estimatedQuote * this.clientDiscount);
    this.estimatedQuote -= (Math.round(this.discountPrice));
    this.discountPrice = (Math.round(this.discountPrice)).toString();
    // this.estimatedQuote = (Math.ceil(this.estimatedQuote));

  }else if(this.discountType == "Dollars"){
    this.discountPrice = this.clientDiscount.toString();
    this.estimatedQuote -= this.clientDiscount;

  }else{
    this.estimatedQuote = this.estimatedQuote;
  }

}//End of onSubmit

  public goBack(){
    this.estimatedQuote = 0.00;

    this.submitted = false;
  }
  public downloadPDF(){
    return xepOnline.Formatter.Format('content', {render: 'download'});
  }

  ngOnInit() {

  }

}

The error seems to be in the HTML:
[(ngModel)]="stufffffffs"

A: You have taken the wrong ngModel binding, the variables you have taken in component are not taken in form
In component you have taken,
clientName:string = "";clientHomePhone:string;clientCellPhone:string;

but in form you took,
Name:string = "";HomePhone:string;CellPhone:string;

You forgot to prepend client
Eg;
<input type="text" name="name" [(ngModel)]="name" #client="ngModel" required autofocus>

Should be,
<input type="text" name="name" [(ngModel)]="clientName" #client="ngModel" required autofocus>

so, replace all the occurrences with the same.

A: Use the same variables with ngModel that are defined in the component. It basically means there is a property in the component, that it is referring to. But as there is no such variable as "homePhone" in component, hence it is giving an error.

[(ngModel)]="clientHomePhone" instead of [(ngModel)]="homePhone"

<input type="tel" name="homePhone" id="homePhone" [(ngModel)]="clientHomePhone" placeholder="(123) 456-7890" [textMask]="{mask: mask}">

Similarly, for all other inputs for which the error is coming.
Read this for how ngModel works.


text:
Q: Issue having ReturnType inferred in a config parameter of a function I've simplified my use case to this playground:
Playground
And here is the same code:
function createEntityComponentSystem<
    Config extends {
        [SystemName in SystemNames]: {
            createComponent: () => Record<string, any>;
            run: (
                component: ReturnType<Config[SystemName]['createComponent']>,
            ) => void;
        }
    },
    SystemNames extends (keyof Config) & string,
>(config: Config) {
    // Create Entity Component System
}

createEntityComponentSystem({
    systemA: {
        createComponent: () => ({ x: 0, y: 0 }),
        run: (
            // Why isn't this inferred as { x: number; y: number } ?
            // In fact, if I change this to:
            // component: { x: string; y: string; }
            // the compiler throws an error, because it KNOWS
            // that component should be { x: number; y: number; }
            // so why can't it infer it?
            component,
            // Uncomment to try:
            // component: { x: string; y: string; },
        ) => {
        },
    }
});

If you're wondering why this exists in a record of SystemName of SystemNames, it's because it's for an Entity Component System. The systems are provided as a single config object, because I'm able to actual validate many type constraints between them when done this way. This is the single outlying issue I'm encountering, as inference has otherwise worked great.

A: I unfortunately cannot give details as to why your solution does not work--although the main issue seems to be referring to Config inside of Config. Either way, here's how you can make it infer...

Let's assume we had the type
type Config = {
  systemA: {
      x: number;
      y: number;
  };
}

We can write a type Converter<T> such that Convert<Config> outputs the type you want for the function (object with createComponent and run typings):
type Converter<Cfg> = {
  [SystemName in keyof Cfg]: Component<Cfg[SystemName]>
}

interface Component<R> {
  createComponent: () => R;
  run: (component: R) => void;
}

If we run Converter<Config>, We're taking each key of our Config type and doing something like:
Component<Config['systemA']>
// Which is the same as
Component<{ x: number; y: number }>
// which is the same as
{
  createComponent: () => { x: number; y: number; };
  run: (component: { x: number; y: number; }) => void;
}

Now, we don't want to have to manually define this Config type above, but that's ok! We can actually have TypeScript infer this type instead:
function createEntityComponentSystem<Config>(
  config: Converter<Config>
) {}

And this will work! In your example in the original problem, it will infer Config to be:
{
  systemA: {
      x: number;
      y: number;
  };
}

and, therefore, be able to correctly identify the type of the component parameter.

The trick here is not having TypeScript directly infer what you want, but infer an intermediate type, which you then convert to your more complex type.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Nested For Next Loop with embedded If then elseif statements not picking up values. Cells in worksheet remain empty I'm working with two workbooks - the first has a portion of each line item of my credit card statement and a corresponding category while the other workbook is downloaded directly from my credit card's website. My goal is to identify which category each line item on the statement belongs to and then summarize the information in the first workbook.
The code executes without any errors, but the table where all the information is supposed to be remains empty. When I replace, for example, the variable that is supposed to take the value for 'electricity' with 'test', the word 'test' appears in my first workbook. I'm suspecting that I've made a mistake somewhere in the nested for-next section of my code but am unable to identify what it is. Thank you for letting me share!
Sub Open_And_Transfer_Statement()

'Determine User-Identified Statement and Open Corresponding Workbook

Dim Month, Year, Company As String

Month = Range("L3")
Year = Range("M3")
Company = Range("N3")

Workbooks.Open Filename:="C:\Users\MyName\Downloads\" & Company & " Statements\" & Year & "\" & Month & ".xls"

'Begin Transfering Each Statement Item to Corresponding Category in Dashboard

Dim yLastRow, y As Integer
Dim xLastRow, x As Integer
Dim Clothes, Electronics, Online_Shopping, Other, Vaping_Products, Flight_Travel, Gas, Vehicle_Payments, Cable_Internet, Car_Insurance, Electricity, Liquor As Currency
Dim Restaurants, Bloomberg, Gym, Netflix, Prime_Video, Seeking_Alpha, Spotify, WSJ, Hannahford, Market_Basket, Trader_Joes, Vitamin_Shoppe, Wholesale_Clubs As Currency
Dim Housing_Subtotal, Transportation_Subtotal, Groceries_Subtotal, Subscriptions_Subtotal, Dining_Out_Subtotal, Merchandise_Subtotal, Credit_Payments_Subtotal, Income_Taxes_Subtotal, Rewards_Subtotal As Currency

yLastRow = Workbooks("January.xls").Sheets("January").Range("C10000").End(xlUp).Row
xLastRow = Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("C10000").End(xlUp).Row

For x = 2 To xLastRow
    For y = 14 To yLastRow
        If InStr(Range("C" & y).Value, Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("C" & x)) > 0 Then
            If Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 11 Then
                Clothes = Clothes + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 11 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 15 Then
                Electronics = Electronics + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 15 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 18 Then
                Online_Shopping = Online_Shopping + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 18 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 28 Then
                Other = Other + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 28 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 35 Then
                Vaping_Products = Vaping_Products + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 35 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 41 Then
                Flight_Travel = Flight_Travel + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 41 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 42 Then
                Gas = Gas + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 42 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 43 Then
                Vehicle_Payments = Vehicle_Payments + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 43 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 44 Then
                Cable_Internet = Cable_Internet + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 44 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 45 Then
                Car_Insurance = Car_Insurance + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 45 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 46 Then
                Electricity = Electricity + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 46 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 50 Then
                Liquor = Liquor + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 50 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 75 Then
                Restaurants = Restaurants + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 75 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 76 Then
                Bloomberg = Bloomberg + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 76 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 77 Then
                Gym = Gym + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 77 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 78 Then
                Netflix = Netflix + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 78 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 79 Then
                Netflix = Netflix + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 79 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 80 Then
                Prime_Video = Prime_Video + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 80 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 81 Then
                Seeking_Alpha = Seeking_Alpha + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 81 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 82 Then
                Spotify = Spotify + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 82 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 83 Then
                WSJ = WSJ + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 83 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 84 Then
                Hannahford = Hannahford + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 84 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 85 Then
                Market_Basket = Market_Basket + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 85 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 86 Then
                Trader_Joes = Trader_Joes + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 86 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 87 Then
                Vitamin_Shoppe = Vitamin_Shoppe + Range("D" & y).Value
            ElseIf Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value > 87 And Workbooks("Personal Financial Dashboard.xlsm").Sheets("Categories").Range("E" & x).Value <= 88 Then
                Wholesale_Clubs = Wholesale_Clubs + Range("D" & y).Value
            End If
        End If
    Next y
Next x

Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Activate

Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D10") = Electricity
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D11") = Cable_Internet
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D12") = Housing_Subtotal

Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D15") = Vehicle_Payments
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D16") = Car_Insurance
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D17") = Gas
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D18") = Flight_Travel
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D19") = Transportation_Subtotal

Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D22") = Market_Basket
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D23") = Hannahford
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D24") = Trader_Joes
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D25") = Wholesale_Clubs
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D26") = Groceries_Subtotal

Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D29") = Netflix
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D30") = Gym
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D31") = Spotify
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D32") = Bloomberg
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D33") = WSJ
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D34") = Prime_Video
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("D35") = Subscriptions_Subtotal

Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("I8") = Restaurants
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("I9") = Liquor
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("I10") = Dining_Out_Subtotal

Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("I13") = Clothes
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("I14") = Online_Shopping
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("I15") = Electronics
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("I16") = Vaping_Products
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("I17") = Other
Workbooks("Personal Financial Dashboard.xlsm").Sheets("Comprehensive_Monthly_Budget").Range("I18") = Merchandise_Subtotal

Workbooks("January.xls").Close

End Sub

A: Your code works for me so I suspect you may have hidden spaces in the source data. Use TRIM() to remove them. Try
Option Explicit

Sub Open_And_Transfer_Statement()

    'Determine User-Identified Statement and Open Corresponding Workbook

    Dim wb As Workbook, wsCateg As Worksheet, wsBudget As Worksheet
    Dim sCateg As String, s As String, n As Integer, a, amount As Currency
    Dim t0 As Single: t0 = Timer

    ' dashboard
    Set wb = Workbooks("Personal Financial Dashboard.xlsm")
    Set wsCateg = wb.Sheets("Categories")
    Set wsBudget = wb.Sheets("Comprehensive_Monthly_Budget")

    ' statement
    Dim wbSrc As Workbook, wsSrc As Worksheet
    Dim Month As Integer, Year, Company As String, sFilename As String
    With wsBudget
        Month = Range("L3")
        Year = Range("M3")
        Company = Range("N3")
    End With
    sFilename = "C:\Users\MyName\Downloads\" & Company & " Statements\" & Year & "\" & Month & ".xls"

    Set wbSrc = Workbooks.Open(sFilename, , 1) ' read only
    Set wsSrc = wbSrc.Sheets(1) ' January

    'Begin Transfering Each Statement Item to Corresponding Category in Dashboard
    Dim yLastRow As Long, y As Long
    Dim xLastRow As Long, x As Long
    Dim Clothes, Electronics, Online_Shopping, Other, Vaping_Products, _
        Flight_Travel, Gas, Vehicle_Payments, Cable_Internet, Car_Insurance, _
        Electricity, Liquor As Currency
    Dim Restaurants, Bloomberg, Gym, Netflix, Prime_Video, Seeking_Alpha, Spotify, _
        WSJ, Hannahford, Market_Basket, Trader_Joes, Vitamin_Shoppe, _
        Wholesale_Clubs As Currency
    Dim Housing_Subtotal, Transportation_Subtotal, Groceries_Subtotal, _
        Subscriptions_Subtotal, Dining_Out_Subtotal, Merchandise_Subtotal, _
        Credit_Payments_Subtotal, Income_Taxes_Subtotal, Rewards_Subtotal As Currency

    ' copy categories into array
    Dim arCateg
    xLastRow = wsCateg.Cells(Rows.Count, "C").End(xlUp).Row
    arCateg = wsCateg.Range("C1:E" & xLastRow).Value2

    ' scan statement
    yLastRow = wsSrc.Cells(Rows.Count, "C").End(xlUp).Row
    For y = 14 To yLastRow ' statement

        s = Trim(wsSrc.Cells(y, "C"))
        amount = wsSrc.Cells(y, "D")

        For x = 2 To xLastRow ' categ

            sCateg = trim(arCateg(x, 1)) ' col C
            n = arCateg(x, 3) ' col E

            If InStr(s, sCateg) > 0 Then
                If n <= 11 Then
                    Clothes = Clothes + amount
                ElseIf n > 11 And n <= 15 Then
                    Electronics = Electronics + amount
                ElseIf n > 15 And n <= 18 Then
                    Online_Shopping = Online_Shopping + amount
                ElseIf n > 18 And n <= 28 Then
                    Other = Other + amount
                ElseIf n > 28 And n <= 35 Then
                    Vaping_Products = Vaping_Products + amount
                ElseIf n > 35 And n <= 41 Then
                    Flight_Travel = Flight_Travel + amount
                ElseIf n > 41 And n <= 42 Then
                    Gas = Gas + amount
                ElseIf n > 42 And n <= 43 Then
                    Vehicle_Payments = Vehicle_Payments + amount
                ElseIf n > 43 And n <= 44 Then
                    Cable_Internet = Cable_Internet + amount
                ElseIf n > 44 And n <= 45 Then
                    Car_Insurance = Car_Insurance + amount
                ElseIf n > 45 And n <= 46 Then
                    Electricity = Electricity + amount
                ElseIf n > 46 And n <= 50 Then
                    Liquor = Liquor + amount
                ElseIf n > 50 And n <= 75 Then
                    Restaurants = Restaurants + amount
                ElseIf n > 75 And n <= 76 Then
                    Bloomberg = Bloomberg + amount
                ElseIf n > 76 And n <= 77 Then
                    Gym = Gym + amount
                ElseIf n > 77 And n <= 78 Then
                    Netflix = Netflix + amount
                ElseIf n > 78 And n <= 79 Then
                    Netflix = Netflix + amount
                ElseIf n > 79 And n <= 80 Then
                    Prime_Video = Prime_Video + amount
                ElseIf n > 80 And n <= 81 Then
                    Seeking_Alpha = Seeking_Alpha + amount
                ElseIf n > 81 And n <= 82 Then
                    Spotify = Spotify + amount
                ElseIf n > 82 And n <= 83 Then
                    WSJ = WSJ + amount
                ElseIf n > 83 And n <= 84 Then
                    Hannahford = Hannahford + amount
                ElseIf n > 84 And n <= 85 Then
                    Market_Basket = Market_Basket + amount
                ElseIf n > 85 And n <= 86 Then
                    Trader_Joes = Trader_Joes + amount
                ElseIf n > 86 And n <= 87 Then
                    Vitamin_Shoppe = Vitamin_Shoppe + amount
                ElseIf n > 87 And n <= 88 Then
                    Wholesale_Clubs = Wholesale_Clubs + amount
                End If
            End If
        Next x
    Next y

    With wsBudget
       .Activate

       .Range("D10") = Electricity
       .Range("D11") = Cable_Internet
       .Range("D12") = Housing_Subtotal

       .Range("D15") = Vehicle_Payments
       .Range("D16") = Car_Insurance
       .Range("D17") = Gas
       .Range("D18") = Flight_Travel
       .Range("D19") = Transportation_Subtotal

       .Range("D22") = Market_Basket
       .Range("D23") = Hannahford
       .Range("D24") = Trader_Joes
       .Range("D25") = Wholesale_Clubs
       .Range("D26") = Groceries_Subtotal

       .Range("D29") = Netflix
       .Range("D30") = Gym
       .Range("D31") = Spotify
       .Range("D32") = Bloomberg
       .Range("D33") = WSJ
       .Range("D34") = Prime_Video
       .Range("D35") = Subscriptions_Subtotal

       .Range("I8") = Restaurants
       .Range("I9") = Liquor
       .Range("I10") = Dining_Out_Subtotal

       .Range("I13") = Clothes
       .Range("I14") = Online_Shopping
       .Range("I15") = Electronics
       .Range("I16") = Vaping_Products
       .Range("I17") = Other
       .Range("I18") = Merchandise_Subtotal
    End With
    wbSrc.Close False
    MsgBox "Done in " & Format(Timer - t0, "0.00 seconds")
End Sub


text:
Q: Minecraft Pocket Edition connection problems Before I was able to connect my iPhone and iPad on the same wifi to play in Minecraft PE.  Now the world will show up on my other device and searches and then says cannot connect to server.  I checked to make sure the servers are visible and we have the same versions of the game.  Any help would be great.

A: Make sure that the Local Server Multiplayer option is turned on. If that does not work, try using External Servers instead of Wifi.

A: And also wih your problem make sure Your Local Multiplayer is on if still does not work try connecting to a different wifi /neighbors-wifi/street-wifi/ any wifi if still does not work try redownloading the game if there is a world that you love and you don't wanna get rid of it then plug in a iPhone/iPod/iPad  charger in your computer then download Ifunbox or iexplorer this is only for windows or Mac though and then plug your iPad in the charger open ifunbox you might need to set it up first though then go to applications show more minecrft pe the I  think the second folder that shows up press that then games then com.mojang then minecraftwor... And then the world that oh really like should be in there then drag it out on your desktop then delete minecraft get it back on purchased and then leave your iphone/iPod/iPad in the charger though if it says not charging that's fine we'll anyways then turn the application off  then on again go back where you were then drag the folder back where it was and then bam!


text:
Q: ValueOf() in javascript From my database.js I export mongoose models for my three user types:
module.exports = {
    root: rootCol,
    advisor: advisorCol,
    student: studentCol,
};

In my api.js, I get usertype from req.body.type which will be either (root, advisor or student)
When I try:
var models = require('../database.js');

 models.req.body.type.valueOf().findOne({ ....

It says the thing doesn't have findOne method. I'm trying to access models.root or models.advisor without having to use if else statements. Is there any way I can achieve this?

A: models.req.body.type means something like that:
{
  "models": {
   "req": {
    "body":{
     "type": ....
   }
  }
 }
}

To make Javascript resolves variable to its value, you have to use
models[req.body.type].
It means getting a property's value in models by that property's name (the value of req.body.type)


text:
Q: Task Scheduler shared hosting I am using a shared host that which doesn't support CRON/TaskScheduler (it is a windows Godaddy server).
I need to search on email server for new emails on each 1 hour, I have the script on PHP.
Can I use PERL to emulate a task on certain times, or is there any other alternatives?

A: Perhaps a little "outside the box", but you could expose your code as a channel If This Then That (https://ifttt.com/) understands (for instance, an RSS feed), and then create a recipe that starts on a timer, and reads your "feed", kicking off your code?


text:
Q: USB flash drive shown as empty on windows 7 after VirtualBox messed it up Ok, I have a SanDisk 8gb flash usb pen.
I was using it nicely until VirtualBox (Meh.. oracle... messing up software since years) messed it up.
Basically this is what happened:
I could use this usb pen correctly and see the files in it on this PC. I could use it on any other pc (I work as programmer, I put my hands on lot of PCs). Some days ago at home, I was using VirtualBox with Windows 8 on it and I wanted to try to plug in the usb pen drive to see if I could exchange data between the virtual machine and other PCs (long story about this particular choiche of transferring data).
What I did was go on virtualbox menu-->devices and click my usb.
From then, my usb didn't got recognised either by VirtualBox (I wasn't expecting anything more) and ALSO, from my desktop PC. I can use it with any other computer, see the files in it, cancel/write data, browse the folders, etc etc.
Tryed to uninstall the driver and plug it back, but nothing.
What's happening, and how can I fix it?

A: WARNING REGISTRY ENTRIES SHOULD BE DEALT WITH CAREFULLY. CREATE BACKUPS OF ANY KEY BEFORE DELETING THEM.
Open registry editor:
from the start menu or command prompt type regedit.exe
press ENTER
In the left hand panel navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USBSTOR
find the entry for the usb device in question.
Right click it.
from the context menu select delete. (OR Export to create a back-up in the location of your choice. I have a folder on my desktop called regFiles I use for back-ups).
Plug the USB device in to re-associate it with the host, hopefully this will reset the relationship. If that works, delete the back-up of the registry key you made before deleting it from the registry (you won't need the old one because it's created a new one).
In order to delete the registry key you need to set permission for yourself. You need to do this step for all subkeys.
right click the (sub)key select permissions from the context menu > select advanced. At the top, select the owner tab. select the account you want to give ownership to. click apply click ok. This should take you back to the security tab of the permissions click `owner rights check the box for full control. Click apply. Click OK. Repeat for all sub keys. (This may take a while, but once you take ownership of all the subkeys you can delete them.
(To save time, you can take ownership of all the subkeys, then at the main key go to the security tab of the advanced permissions window and select:
Replace all child object permissions with inheritable permissions from this object)


text:
Q: Get location after moving node How to get current location after moving node to save to database new loc.
myDiagram.addDigramListener("SelectionMoved",
  function(e) {
    let part = e.subject.part;
    console.log(part)
  }
)

But the part always is null, why?

A: I was able to use the following code to get new location and key

myDiagram.addDiagramListener("SelectionMoved", function(event) {

  // https://gojs.net/latest/api/symbols/Part.html#location
  // * PART
  var selectedNode = event.diagram.selection.first();

  console.log("selectedNode",selectedNode);
  console.log("selectedNodeKey",selectedNode.key);
  console.log("selectedNode", selectedNode.location.toString());
  console.log("selectedNode", selectedNode.location.x);
  console.log("selectedNode", selectedNode.location.y);
  console.log("locationObject", selectedNode.locationObject);

  //Save new location
  // key: selectedNode.key
  // location-x: selectedNode.location.x
  // location-y: selectedNode.location.y

});

A: e.subject is a collection, which is the selection of all moved Parts. There may be more than one part moved.
If you are reasonably sure that there is only one Part moved, you can write:
myDiagram.addDigramListener("SelectionMoved",
  function(e) {
    let part = e.subject.first();
    console.log(part.toString())
  }
)

But if you just want to save the location to the DB, why not make a two-way data binding on Location? The flowchart example demonstrates this:
// The Node.location comes from the "loc" property of the node data,
// converted by the Point.parse static method.
// If the Node.location is changed, it updates the "loc" property of the node data,
// converting back using the Point.stringify static method.
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),


text:
Q: redefine C-x C-e to evaluate custom language expression I've defined a major mode for my language.
I'm trying to redefine C-x C-e so that when I'm in my major mode, it'd evaluate the expression using "my" custom interpreter.
Suppose my interpreter is just a command-line program that could be invoked like this:
$my-interpreter <some expression>

I imagine, all I need to do is to do a system call, passing the expression "before point" as argument and print the return value in the echo area.
How hard could it be, right?
Problem: I have no idea where to start!
Any hint?
Thanks.

A: You can take a look at shell-command and its relatives, along with thing-at-point.  Here's a really simple example that uses an "interpreter" (just the shell echo command) to echo the word at point:
(defun my-interpreter ()
  (interactive)
  (let ((arg (thing-at-point 'word)))
    (when arg
      (shell-command (concat "echo " arg)))))

(Edit in response to comment.)
If you have defined a keymap for your major mode, you can bind C-x C-e in you major mode with a call to define-key.  Otherwise, you can just bind it locally with (local-set-key (kbd "C-x C-e") 'my-interpreter).
It occurred to me that you might be interested in building in interactive functionality like a REPL.  To do so, you might consider comint-mode; see the EmacsWiki and this post from Mastering Emacs to get inspired.


text:
Q: Select top 20 results from database with option to view more I have a SQL query which loads the first 20 picture results from a database, I would like to give users the option to view more than 20 if they want to, or even create a tab to see the next 20 pictures, I'm stumped on how to input this code I'm sure its straight forward but I'm in a brain fart mode and really need to get over this hurdle.

A: Look into LImit and offset features in MYSQL
https://dev.mysql.com/doc/refman/5.0/en/select.html
Excerpt from above link:
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).
With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
SELECT * FROM tbl LIMIT 5,10;  # Retrieve rows 6-15

To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:
SELECT * FROM tbl LIMIT 95,18446744073709551615;

With one argument, the value specifies the number of rows to return from the beginning of the result set:
SELECT * FROM tbl LIMIT 5;     # Retrieve first 5 rows


text:
Q: Plot Time on x axis but keeping the date sequence I have big data frame created in python as shown below. it has four columns. I am plotting Time on Xaxis, and A  and B on Yaxis. As time is in 24hour format so when a new day starts the time offcourse start back from 0:0 as can be seen in row 275.
I want to plot Time on X axis with date sequence to follow so my data looks continous. Appreciate if anyone can help with a code. Thanks alot
Data Frame

       "Date"    "Time"       "A"       "B"
0    2017-07-31  14:52:55  -0.032374  -0.027602
1    2017-07-31  14:54:55  -0.032313  -0.027549
2    2017-07-31  14:56:56  -0.032256  -0.027405
3    2017-07-31  14:58:55  -0.032316  -0.027591
4    2017-07-31  15:00:55  -0.032418  -0.027704
5    2017-07-31  15:02:57  -0.032416  -0.027550
6    2017-07-31  15:04:56  -0.032415  -0.027666
..          ...       ...        ...        ...
275  2017-08-01  00:00:56  -0.031791  -0.027092
276  2017-08-01  00:02:56  -0.031779  -0.027155
277  2017-08-01  00:04:56  -0.031901  -0.027234
278  2017-08-01  00:06:55  -0.031903  -0.027206
..          ...       ...        ...        ...
360  2017-01-08  02:50:55  -0.032319  -0.027562

I have attached my plot. It can be seen that the data starting on the new date has shift to the left side of the plot which i dont want. I want it to continue from the last time of the previous day.


text:
Q: Laravel 5.3 Rest API Setup I am building Backend for my Mobile App in Laravel 5.3. I ll be sending/receiving and updating data using laravel REST API.
I want Few data/info to be provided to Guest user who is using my mobile app. and few info/data to registered users.
I want to make use of REST API
I tried dingo which is recommended by many people. But problem is it is not supported with laravel 5.3 and its documentation is also not upto date.
Can anyone please suggest any package or code tutorial that i can follow to achieve my goal.

A: Definitely recommend checking out Laravel Passport and upgrading to 5.4. Laravel Passport. That'll be the best option going forward as that's the way Laravel is moving towards. Other libraries will die off for laravel support as this moves to popularity.

A: I can suggest PHP-CRUD-API (I'm the author). Below is the short tutorial to get started.
In order to add the automatic API library you need to run:
php composer.phar require symfony/psr-http-message-bridge
php composer.phar require zendframework/zend-diactoros
php composer.phar require mevdschee/php-crud-api

Change the "routes/api.php" to the following content to define our new API route:
<?php

use Psr\Http\Message\ServerRequestInterface;
use Tqdev\PhpCrudApi\Api;
use Tqdev\PhpCrudApi\Config;

Route::any('/{any}', function (ServerRequestInterface $request) {
    $config = new Config([
        'username' => 'php-crud-api',
        'password' => 'php-crud-api',
        'database' => 'php-crud-api',
        'basePath' => '/api',
    ]);
    $api = new Api($config);
    $response = $api->handle($request);
    return $response;
})->where('any', '.*');

Replace the string "php-crud-api" in the above code to match the username, password and database of your setup (preferably reading them from environment variables). You should see your application running at:
http://127.0.0.1:8000/api/records/posts
Replace "posts" with the name of any table in your database. If everything works as expected, then you should see the contents of the table in JSON format.
source: https://tqdev.com/2019-automatic-rest-api-laravel


text:
Q: Box2dx: Cancel force on a body? I'm doing pathfinding where I use force to push body to waypoints. However, once they get close enough to the waypoint, I want to cancel out the force. How can I do this? Do I need to maintain separately all the forces I've applied to the body in question?
I'm using Box2dx (C#/XNA).
Here is my attempt, but it doesn't work at all:
   internal PathProgressionStatus MoveAlongPath(PositionUpdater posUpdater)
    {
        Vector2 nextGoal = posUpdater.Goals.Peek();
        Vector2 currPos = posUpdater.Model.Body.Position;
        float distanceToNextGoal = Vector2.Distance(currPos, nextGoal);
        bool isAtGoal = distanceToNextGoal < PROXIMITY_THRESHOLD;

        Vector2 forceToApply = new Vector2();
        double angleToGoal = Math.Atan2(nextGoal.Y - currPos.Y, nextGoal.X - currPos.X);
        forceToApply.X = (float)Math.Cos(angleToGoal) * posUpdater.Speed;
        forceToApply.Y = (float)Math.Sin(angleToGoal) * posUpdater.Speed;

        float rotation = (float)(angleToGoal + Math.PI / 2);

        posUpdater.Model.Body.Rotation = rotation;

        if (!isAtGoal)
        {
            posUpdater.Model.Body.ApplyForce(forceToApply, posUpdater.Model.Body.Position);
            posUpdater.forcedTowardsGoal = true;
        }

        if (isAtGoal)
        {
            // how can the body be stopped?

            posUpdater.forcedTowardsGoal = false;
            //posUpdater.Model.Body.SetLinearVelocity(new Vector2(0, 0));
            //posUpdater.Model.Body.ApplyForce(-forceToApply, posUpdater.Model.Body.GetPosition());
            posUpdater.Goals.Dequeue();

            if (posUpdater.Goals.Count == 0)
            {
                return PathProgressionStatus.COMPLETE;
            }
        }

UPDATE
If I do keep track of how much force I've applied, it fails to account for other forces that may act on it.
I could use reflection and set _force to zero directly, but that feels dirty.

A: If you just want to stop the body dead (cancelling out all forces acting on it) you can just put it to sleep:
posUpdater.Model.Body.SetAwake( false )

This clears the body's linear and angular forces and velocities. Sleeping bodies also don't collide with other sleeping bodies and generally take up less CPU time, as effectively their physics is switched off.
If you actually want the body to take part in physics after it's stopped dead, just wake it immediately:
posUpdater.Model.Body.SetAwake( false )
posUpdater.Model.Body.SetAwake( true)

This may lead to "unnatural" looking results if the body was in the middle of colliding with other things of course.


text:
Q: How to exclude strings in grep command? I have an array which contains list of strings.
Example: array = ("Sample","Test","Check").
I need to pass this to grep command to exclude these string while getting results.
So, In the output I should not have ("Sample","Test","Check") terms.
Please help me.

A: It can be done the following way:
grep -v -e string_to_exclude_1 -e string_to_exclude_2 file_name

For example, the following command excludes check.xml and test.xml from a file named sample.txt
grep -v -e check -e test sample.txt

sample.txt contains the following:
one.xml
two.xml
three.xml
test.xml
check.xml


text:
Q: Trying to load obj & mtl file with Three.js in React Native Main objective : Load animated models exported from Maya into React Native app
Exported files : obj, mtl & png file
I have setup https://github.com/react-community/react-native-webgl in my React Native project and it is working properly.
Now, when I am trying to load the MTL file using the MTLLoader, I am getting following error:
Can't find variable: document
Apparently, the MTLLoader is calling TextureLoader which internally calls some load function which has 'document' reference. So what could be the solution to this ?
Here are the two files that I am using:
three.js
const THREE = require("three");
global.THREE = THREE;
if (!window.addEventListener)
    window.addEventListener = () => { };
// require("three/examples/js/renderers/Projector");
require("three/examples/js/loaders/MTLLoader");
require("three/examples/js/loaders/OBJLoader");
export default THREE;

ThreeView.js
import React, { Component } from "react";
import { StyleSheet, View } from "react-native";
import { WebGLView } from "react-native-webgl";
import THREE from "./three";
import { image } from "src/res/image";

export default class ThreeView extends Component {
    requestId: *;
    componentWillUnmount() {
    cancelAnimationFrame(this.requestId);
}
onContextCreate = (gl: WebGLRenderingContext) => {
    const rngl = gl.getExtension("RN");

    const { drawingBufferWidth: width, drawingBufferHeight: height } = gl;
    const renderer = new THREE.WebGLRenderer({
        canvas: {
            width,
            height,
            style: {},
            addEventListener: () => { },
            removeEventListener: () => { },
            clientHeight: height
        },
        context: gl
    });
    renderer.setSize(width, height);
    renderer.setClearColor(0xffffff, 1);

    let camera, scene;
    let cube;

    function init() {
        camera = new THREE.PerspectiveCamera(75, width / height, 1, 1100);
        camera.position.y = 150;
        camera.position.z = 500;
        scene = new THREE.Scene();

        var mtlLoader = new THREE.MTLLoader();
        mtlLoader.load('female-croupier-2013-03-26.mtl', function (materials) {
            materials.preload();

            var objLoader = new THREE.OBJLoader();
            objLoader.setMaterials(materials);
            objLoader.load('female-croupier-2013-03-26.obj', function (object) {
                scene.add(object);
            }, onLoading, onErrorLoading);
        }, onLoading, onErrorLoading);
    }
    const onLoading = (xhr) => {
        console.log((xhr.loaded / xhr.total * 100) + '% loaded');
    };
    const onErrorLoading = (error) => {
        console.log('An error happened', error);
    };
    const animate = () => {
        this.requestId = requestAnimationFrame(animate);
        renderer.render(scene, camera);

        // cube.rotation.y += 0.05;

        gl.flush();
        rngl.endFrame();
    };

    init();
    animate();
};
render() {
    return (
        <View style={styles.container}>
            <WebGLView
                style={styles.webglView}
                onContextCreate={this.onContextCreate}
            />
        </View>
    );
}
}

const styles = StyleSheet.create({
container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center"
},
webglView: {
    width: 300,
    height: 300
}
});

A: This error is as others have said caused by threejs trying to use features from a browser which react-native does not have.
I've gotten so far as to be able to load the textures (which is the stage you're getting the error from) by monkey patching the texture loader to use the loader in react-native-webgl. Add this in your init function (right near the top preferably).

//make sure you have defined renderer and rngl

/*

const renderer = new THREE.WebGLRenderer(...)

const rngl = gl.getExtension("RN");

*/

const loadTexture = async function(url, onLoad, onProgress, onError) {
      let textureObject = new THREE.Texture();
      console.log("loading",url,'with fancy texture loader');
      let properties = renderer.properties.get(textureObject);

      var texture = await rngl.loadTexture({yflip: false, image: url});

      /*
      rngl.loadTexture({ image: url })
        .then(({ texture }) => {
        */
          console.log("Texture [" + url + "] Loaded!")
          texture.needsUpdate = true;
          properties.__webglTexture = texture;
          properties.__webglInit = true;
          console.log(texture);

          if (onLoad !== undefined) {
            //console.warn('loaded tex', texture);
            onLoad(textureObject);
          }

      //});

      return textureObject;

  }

  THREE.TextureLoader.prototype.load = loadTexture;

This solves the problem of loading textures and I can see them load in Charles but they still don't render on a model so I'm stuck past that point. Technically a correct answer but you'll be stuck as soon as you've implemented it. I'm hoping you can comment back and tell me you've gotten further.

A: I had a similar setup and encountered same issue. My option was to switch to JSONLoader which doesn't need document to render in react-native. So, I just loaded my model in Blender with a three-js addon, then exported it as json. Just check out this process of adding a three-js adon to Blender
https://www.youtube.com/watch?v=mqjwgTAGQRY
All the best

A: this might get you closer:
The GLTF format supports embedding texture images (as base64).  If your asset pipeline allows it, you could convert to GLTF and then load into three/react-native.
I had to provide some "window" polyfills for "decodeUriComponent" and "atob" because GLTFLoader uses FileLoader to parse the base64:
I've successfully loaded embedded buffers, but you'll need more polyfills to load textures.  TextureLoader uses ImageLoader, which uses document.createElementNS

A: You are using the MTLLoader which uses TextureLoader, and the TextureLoader uses the ImageLoader.
The imageloader uses the document.createElementNS() function.
what i did to solve this was to directly call the THREEjs TextureLoader:
let texture = new THREE.Texture(
     url //URL = a base 64 JPEG string in this case
     );

(for the use of Texture check the Texture documentation)
Then i used the Image class from React native (instead of the THREEjs Image, which requires the DOM to be constructed) to give that to the Texture as a property:
import { Image } from 'react-native';

var img = new Image(128, 128);
img.src = url;
texture.normal = img;

And then finally map the texture over the target material:
const mat = new THREE.MeshPhongMaterial();
mat.map = texture;

In the  react native documentation it will explain how the react native Image element can be used, it supports base64 encoded JPEG.
Maybe there's a way for you to single out the part where it calls for the TextureLoader and replace that part with this answer. Let me know how it works out.
side note, i havent tried to display this yet in my webGLView, but in the logs it looked like normal threejs objects, it's worth the try

A: Use TextureLoader from expo-three
import { TextureLoader } from "expo-three";

export function loadTexture(resource) {
  if (textureCache[resource]) {
    return textureCache[resource].clone();
  }

  const texture = new TextureLoader().load(resource);

  texture.magFilter = NearestFilter;
  texture.minFilter = NearestFilter;

  textureCache[resource] = texture;
  return texture;
}

Source: https://github.com/EvanBacon/Expo-Crossy-Road/blob/master/src/Node/Generic.js


text:
Q: pandas apply and return multiple values I have a function as below. I want to apply it over a row of a dataframe and return 2 values and then copy those 2 values in 2 columns. My both approaches fail (last 2 lines)
data1 = [['Alex',10,5,0],['Bob',12,4,1],['Clarke',13,6,0],['brke',15,1,0]]
df5 = pd.DataFrame(data1,columns=['Name','Age','weight','class'],dtype=float)
#print (df)
def calculate_distance2(row):
    return pd.Series([row['Age']+row['weight'],row['Age']-row['weight']])

df5.apply(calculate_distance2, axis=1)

df5[['distance0'],['d6']]= df5.apply(calculate_distance2, axis=1)
df5['distance0'],df5['d6']= df5.apply(calculate_distance2, axis=1)

df5

A: IIUC
def calculate_distance2(row):
    return [row['Age']+row['weight'],row['Age']-row['weight']]
df5['distance0'],df5['d6']=calculate_distance2(df5)
df5
     Name   Age  weight  class  distance0    d6
0    Alex  10.0     5.0    0.0       15.0   5.0
1     Bob  12.0     4.0    1.0       16.0   8.0
2  Clarke  13.0     6.0    0.0       19.0   7.0
3    brke  15.0     1.0    0.0       16.0  14.0


text:
Q: Fully qualified name with dollar sign in SSDT project I was working on a tsql project, and I have noticed that the existing code used a syntax that I have not seen before. They have put a dollar sign in front of the database name for fully qualified address.
Here is one example :
SELECT  c.AccountCode, FROM **[$(SmartAdmin)]**.dbo.Customers c

If I rename the database name as SmartAdmin.dbo.Customers, Visual Studio throws error says "contains an unresolved reference to an object".
It appears to be a Visual Studio related thing, can anyone explain what is this and
whether I can remove it.
Please see the attached screenshots, the last one comes from project solution file.

A: The [$(SmartAdmin)] syntax is used in an SSDT project to reference objects in other databases. To be precise, it is SQLCMD syntax.
If you have a database reference to SmartAdmin, and if the reference is set up so that [$(SmartAdmin)] properly references it, then that is not the problem. It looks like the problem is the other two references to [SmartAdmin]. Change them to look like [$(SmartAdmin)].dbo.whatever.

Example of why these references are useful: I just edited a stored procedure I had in SSDT to misspell a column name. Within seconds, the column name was underlined in red. I then deleted the database reference the column name depended on. The red underline went away. I added the database reference back, and the column was once again underlined in red. I corrected the column name, and the red underline went away.
Without the database reference, I would have had to wait until the stored procedure was deployed, or possibly executed, to see the error. With the database reference, I found out about the problem in the editor. Just like code.

A: It appears to me that your database is actually called $(SmartAdmin)
As the error suggests "contains an unresolved reference to an object". which means when you change the database name to SmartAdmin, it cannot find a database with this name on server.
If you want to change the database name you will need to execute the following statement and then you will be able to use that name in your statements.
USE master;
GO

EXEC sp_renamedb '$(SmartAdmin)', 'SmartAdmin';
GO

USE SmartAdmin;  --<-- Now you will be able to connect to this database
GO                 -- without the dollar ($) sign.

A: This issue relates to Database Project External Database References. When you add another solution to a database project, you can specify the "Database Variable Name", in my case, it is $(SmartAdmin).
Please see this link for more information.
Thanks everybody for answering my question.


text:
Q: How to persist the arrangement of cells with ActiveRecord I'm building a Rails application with a dashboard composed of a sorted collection of cells. The ultimate goal is to allow the user to arrange the cells and have that persisted to the database, but I'm unable to fathom the architecture required to make this happen.
I'm less concerned about the UI/UX of dragging and dropping cells, and more concerned about the models required to represent this in a SQL database with ActiveRecord.
Any help would be appreciated. Thanks!

A: This is a pretty solved problem, there are numerous gems that will handle this for you.
Typically you'd add a "position" integer column to the table, and sort by that when you select records. When you want to move an item A to a new position after item B, you first add 1 the position of all records that are sorted after B to make a new space for A, and then to set A's position to B.position + 1. This way, sorting involves only two writes.


text:
Q: Kubuntu 15.04 very slow despite very high CPU usage for every task It seems that every task that is run on my system uses an excessive amount of CPU power. Monitoring CPU use via conky or top, opening a page in Firefox or searching for something in google suddenly spikes my CPU use to 100%.
Same for editing files in vim, or opening a pdf. Opening a document in Okular causes Xorg, kwin_x11, plasmashell, preload, and okular to spike to 20 to 30% CPU use.
I would think little of this, but my computer is unbearably slow. I cannot edit text files, navigate the web, or open documents without a huge CPU spike. Even writing this post in firefox is causing 30-50% CPU use via firefox, and 10 to 30% CPU use via Xorg
Any help and ideas are much appreciated.
EDIT
$ sudo modprobe msr
$ sudo rdmsr -a 0x19a
0
0
0
0

Suspend
$ sudo rdmsr -a 0x19a
0
0
0
0

CPU still at 500MHz. Should I do something about this?
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
powersave
powersave
powersave
powersave

Lastly,
$ cd /sys/class/thermal
$ grep -r . *
cooling_device0/type:Processor
cooling_device0/power/control:auto
cooling_device0/power/async:disabled
cooling_device0/power/runtime_enabled:disabled
cooling_device0/power/runtime_active_kids:0
cooling_device0/power/runtime_active_time:0
grep: cooling_device0/power/autosuspend_delay_ms: Input/output error
cooling_device0/power/runtime_status:unsupported
cooling_device0/power/runtime_usage:0
cooling_device0/power/runtime_suspended_time:0
cooling_device0/cur_state:0
cooling_device0/max_state:3
cooling_device1/type:Processor
cooling_device1/power/control:auto
cooling_device1/power/async:disabled
cooling_device1/power/runtime_enabled:disabled
cooling_device1/power/runtime_active_kids:0
cooling_device1/power/runtime_active_time:0
grep: cooling_device1/power/autosuspend_delay_ms: Input/output error
cooling_device1/power/runtime_status:unsupported
cooling_device1/power/runtime_usage:0
cooling_device1/power/runtime_suspended_time:0
cooling_device1/cur_state:0
cooling_device1/max_state:3
cooling_device2/type:Processor
cooling_device2/power/control:auto
cooling_device2/power/async:disabled
cooling_device2/power/runtime_enabled:disabled
cooling_device2/power/runtime_active_kids:0
cooling_device2/power/runtime_active_time:0
grep: cooling_device2/power/autosuspend_delay_ms: Input/output error
cooling_device2/power/runtime_status:unsupported
cooling_device2/power/runtime_usage:0
cooling_device2/power/runtime_suspended_time:0
cooling_device2/cur_state:0
cooling_device2/max_state:3
cooling_device3/type:Processor
cooling_device3/power/control:auto
cooling_device3/power/async:disabled
cooling_device3/power/runtime_enabled:disabled
cooling_device3/power/runtime_active_kids:0
cooling_device3/power/runtime_active_time:0
grep: cooling_device3/power/autosuspend_delay_ms: Input/output error
cooling_device3/power/runtime_status:unsupported
cooling_device3/power/runtime_usage:0
cooling_device3/power/runtime_suspended_time:0
cooling_device3/cur_state:0
cooling_device3/max_state:3
cooling_device4/type:intel_powerclamp
cooling_device4/power/control:auto
cooling_device4/power/async:disabled
cooling_device4/power/runtime_enabled:disabled
cooling_device4/power/runtime_active_kids:0
cooling_device4/power/runtime_active_time:0
grep: cooling_device4/power/autosuspend_delay_ms: Input/output error
cooling_device4/power/runtime_status:unsupported
cooling_device4/power/runtime_usage:0
cooling_device4/power/runtime_suspended_time:0
cooling_device4/cur_state:-1
cooling_device4/max_state:50
thermal_zone0/mode:enabled
thermal_zone0/temp:27800
thermal_zone0/type:acpitz
thermal_zone0/power/control:auto
thermal_zone0/power/async:disabled
thermal_zone0/power/runtime_enabled:disabled
thermal_zone0/power/runtime_active_kids:0
thermal_zone0/power/runtime_active_time:0
grep: thermal_zone0/power/autosuspend_delay_ms: Input/output error
thermal_zone0/power/runtime_status:unsupported
thermal_zone0/power/runtime_usage:0
thermal_zone0/power/runtime_suspended_time:0
grep: thermal_zone0/emul_temp: Permission denied
thermal_zone0/trip_point_0_temp:105000
thermal_zone0/trip_point_0_type:critical
thermal_zone0/policy:step_wise
thermal_zone0/passive:0
thermal_zone1/mode:enabled
thermal_zone1/temp:29800
thermal_zone1/type:acpitz
thermal_zone1/cdev2_trip_point:1
thermal_zone1/power/control:auto
thermal_zone1/power/async:disabled
thermal_zone1/power/runtime_enabled:disabled
thermal_zone1/power/runtime_active_kids:0
thermal_zone1/power/runtime_active_time:0
grep: thermal_zone1/power/autosuspend_delay_ms: Input/output error
thermal_zone1/power/runtime_status:unsupported
thermal_zone1/power/runtime_usage:0
thermal_zone1/power/runtime_suspended_time:0
thermal_zone1/cdev3_trip_point:1
grep: thermal_zone1/emul_temp: Permission denied
thermal_zone1/trip_point_0_temp:105000
thermal_zone1/trip_point_0_type:critical
thermal_zone1/trip_point_1_temp:95000
thermal_zone1/trip_point_1_type:passive
thermal_zone1/policy:step_wise
thermal_zone1/cdev0_trip_point:1
thermal_zone1/cdev1_trip_point:1
thermal_zone2/mode:disabled
thermal_zone2/temp:20000
thermal_zone2/type:INT3400 Thermal
thermal_zone2/power/control:auto
thermal_zone2/power/async:disabled
thermal_zone2/power/runtime_enabled:disabled
thermal_zone2/power/runtime_active_kids:0
thermal_zone2/power/runtime_active_time:0
grep: thermal_zone2/power/autosuspend_delay_ms: Input/output error
thermal_zone2/power/runtime_status:unsupported
thermal_zone2/power/runtime_usage:0
thermal_zone2/power/runtime_suspended_time:0
grep: thermal_zone2/emul_temp: Permission denied
thermal_zone2/policy:user_space
thermal_zone2/passive:0
thermal_zone3/temp:26800
thermal_zone3/type:TMEM
thermal_zone3/power/control:auto
thermal_zone3/power/async:disabled
thermal_zone3/power/runtime_enabled:disabled
thermal_zone3/power/runtime_active_kids:0
thermal_zone3/power/runtime_active_time:0
grep: thermal_zone3/power/autosuspend_delay_ms: Input/output error
thermal_zone3/power/runtime_status:unsupported
thermal_zone3/power/runtime_usage:0
thermal_zone3/power/runtime_suspended_time:0
grep: thermal_zone3/emul_temp: Permission denied
thermal_zone3/trip_point_0_temp:53000
thermal_zone3/trip_point_0_type:passive
thermal_zone3/trip_point_1_temp:0
thermal_zone3/trip_point_1_type:passive
thermal_zone3/trip_point_2_temp:103000
thermal_zone3/trip_point_2_type:critical
thermal_zone3/trip_point_3_temp:100000
thermal_zone3/trip_point_3_type:hot
thermal_zone3/trip_point_4_temp:71000
thermal_zone3/trip_point_4_type:passive
thermal_zone3/trip_point_5_temp:63000
thermal_zone3/trip_point_5_type:active
thermal_zone3/trip_point_6_temp:58000
thermal_zone3/trip_point_6_type:active
thermal_zone3/policy:user_space
thermal_zone4/temp:44000
thermal_zone4/type:x86_pkg_temp
thermal_zone4/power/control:auto
thermal_zone4/power/async:disabled
thermal_zone4/power/runtime_enabled:disabled
thermal_zone4/power/runtime_active_kids:0
thermal_zone4/power/runtime_active_time:0
grep: thermal_zone4/power/autosuspend_delay_ms: Input/output error
thermal_zone4/power/runtime_status:unsupported
thermal_zone4/power/runtime_usage:0
thermal_zone4/power/runtime_suspended_time:0
grep: thermal_zone4/emul_temp: Permission denied
thermal_zone4/trip_point_0_temp:0
thermal_zone4/trip_point_0_type:passive
thermal_zone4/trip_point_1_temp:0
thermal_zone4/trip_point_1_type:passive
thermal_zone4/policy:user_space

CPUFREQ EDIT
Seems to fix my life. Sort of. Governor is ondemand and my computer is no longer lethargic. The modprobe and rdmsr commands gave identical output, only that my CPU seemed fine before and after suspend. However, applications still appear to use an oddly high percentage of CPU use.
Thanks a lot for the help. I'd be happy to keep debugging.

A: Your computer (typically Dell LapTops on battery after resume from suspend) might be suffering from a situation whereby sometimes Clock Modulation becomes enabled. In its current form the intel_pstate driver is incompatible with Clock Modulation and it will drive the target pstate to minimum, regardless of load.
For your computer the minimum pstate is 6 and I think your processor has the extra Clock Modulation percentage bit, for a minimum modulation percentage of 83.3%, so the expected CPU frequency would be about 525MHz.
I believe the magnitude of this issue is not understood, and I am attempting to acquire supporting evidence (and I have a little now).
I also believe that the issue occurs when using the acpi-cpufreq CPU scaling driver, but its response is completely different. So much so that the typical user would probably not even notice. (and I have no evidence to support that claim other than having the tested the response curve of the driver to various Modulation percentages.)
Would you be willing do do the tests described in this answer? And also when using the acpi-cpufreq driver instead of the intel_pstate driver.
If you prefer to just get a fix and move on, then I would suggest disabling the intel_pstate driver, and your system will default to using the acpi-cpufreq driver.
To disable the intel_pstate driver edit, as sudo, /etc/default/grub and add intel_pstate=disable to the GRUB_CMDLINE_LINUX_DEFAULT line. Example, with other stuff that I use:
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 intel_pstate=disable net.ifnames=1 biosdevname=0 crashkernel=384M-:128M"

You will need to run sudo update-grub afterwards.


text:
Q: Android: Display a .gif from the internet I know that, in Android, it's possible to store .gifs in Movie objects and then manipulate the frame with setTime(). And when I try to display a .gif from a resource, it works fine.
Unfortunately, displaying a .gif from a URL is much less successful. Here is the relevant code:
    public void setMovieURL(String url) throws MalformedURLException, IOException {
        movie = Movie.decodeStream(fetch(url));
    }

    private static InputStream getStreamFromURL(String url) throws MalformedURLException, IOException {
        return fetch(url);
    }

    public static InputStream fetch(String address) throws MalformedURLException,IOException {
        URL url = new URL(address);
        InputStream content = url.openStream();
        return content;
    }

Movie is set to a non-null value, but its height, width, and duration are all 0. An IOException is triggered in InputStream (because reset() is called), but it is also caught within InputStream. That may or may not be relevant.
I'm don't understand why that doesn't work. I'm at my wits end, and my alternatives are downloading the file and saving it, or dealing with byte arrays.

A: The same situation happens even when reading gif from file in internal storage(not from resources).
The way to solve it - download to byte[], and use ByteArrayInputStream to init movie.


text:
Q: how to handle multiple paypal buttons on the same form I have three items, and next to each have the paypal "addtocart" button.  each button works if it's the only one on the page ... I believe that's because each button is wrapped in it's own form tags.  How can I get multple buttons on the page?
I have tried single form tag, renaming the cmd buttons and image, but then they just go to the paypal home page.  How can I do this?

A: It sounds like you're using a regular Buy Now button.  You need to make sure you're using an actual Add to Cart button.  The buttons will still be within their own form tags, but they're a little different to handle the different tasks.  Then you'll also include (optionally) a View Cart button.
Here's another guide that should be useful.


text:
Q: How do I write the not/negate higher order function in swift? I am a Javascripter and I love using the not/negate function:
function not (predicateFunc) {
    return function () {
        return !predicateFunc.apply(this, arguments);
    };
}

I am trying to do the same thing with swift:
func not <A> (_ f: @escaping (_ A: Any) -> Bool) -> (A) -> Bool {
    return { a in !f(a) }
}

But I am getting errors like
generic parameter 'T' could not be inferred

and
Cannot convert value of type '(_) -> Bool' to expected argument type '(Any) -> Bool'

The outcome I am looking for is when I have a function like this:
func isEmpty<T: Collection>(collection: T) -> Bool {
    return collection.count == 0
}

I can just create a notEmpty function like this:
let notEmpty = not(isEmpty)

And then use it like
   notEmpty([3,4,5]) // true

What am I doing wrong?

A: Using Any is a code smell. You can just extend Collection directly:
extension Collection {
    var notEmpty: Bool {
        return !isEmpty
    }
}

[1, 3, 5].notEmpty // true

Your functional definition of not can work like this:
func not <A> (_ f: @escaping (_ a: A) -> Bool) -> (A) -> Bool {
    return { a in !f(a) }
}

But to call it you would need something like this:
let arrayNotEmpty = not { (array: [Int]) in array.isEmpty }
arrayNotEmpty([1, 3, 5]) // true

A: You have two errors:

*

*You're using A as both the type parameter and as the argument name.

*You're using Any as the argument type instead of using the type parameter (A) as the argument type.

Try this:
func not<A>(predicate: @escaping (A) -> Bool) -> (A) -> Bool {
    return { !predicate($0) }
}

Note that in this version, I'm not using argument names for the predicate argument. You don't need an argument name in the declaration ((A) -> Bool) and I'm using the anonymous argument name ($0) in the body.

Okay, so you want to write this:
func isEmpty<T: Collection>(collection: T) -> Bool {
    return collection.count == 0
}

func not<A>(_ predicate: @escaping (A) -> Bool) -> (A) -> Bool {
    return { !predicate($0) }
}

let notEmpty = not(isEmpty)

And you get this error:
let notEmpty = not(isEmpty)
               ^ Generic parameter 'A' could not be inferred

The problem is that this code tries to create a generic closure, but Swift doesn't support generic closures.
That is to say, what would the type of nonEmpty be? It would be something like:
<A: Collection>(A) -> Bool

and Swift doesn't support that.


text:
Q: Normal distribution sum probability Let $X_{1},X_{2},.......,X_{7}$ are independent with $X_{i} \in N(0,1)$.How can I find $P(X_{1}^2+X_{2}^2+......+X_{7}^2 <9.04)$
What I have tried to do:
$X_{1}^2+X_{2}^2+......+X_{7}^2 \in N(0,7)$, so we need to find $Φ(\frac{9.04-0}{\sqrt{7}})$

A: It's not quite true that $X_1^2 + X_2^2 + \dots + X_7^2 \sim N(0, 7)$; this would be true if you weren't squaring each of the variables, but you are. (Note in particular that that expression can't be negative, but any true normally-distributed variable must have that ability.)
Instead, that expression has another distribution entirely. Do you happen to know what that is already?

A: The sum of squares of normal random variables follow a chi-square distribution. You need to use the density of that distribution to find your answer.


text:
Q: Java 7 keytool Elliptic Curve Encryption I'm trying to create a keystore using keytool with a keyalg ECC.
This should be possible according to Oracle.
I quote:

Area: Tools
Synopsis: The keytool and jarsigner tools now support the ECC algorithm in keypair generation and jar signing.
RFE: 6870812

I'm using the 32-bit version 1.7.0_07, and I've tried keytool with -keyalg ECC, ECIES, ECDSA,... but I always get Cannot derive signature algorithm.
Am I using the wrong Java version? Am I using the wrong name for ECC?

A: Here is the source for the algorithm selection. The allowed values are DSA, RSA and EC. These values are not documented anywhere as far as I can tell.

A: I believe you have to install the unlimited strength policy for JCE to work with all algorithims. If you haven't done so already, it's at the bottom of this page: http://www.oracle.com/technetwork/java/javase/downloads/index.html


text:
Q: Find the supremum and infinum of $(a_n)$ and $(b_n)$. For reference I am currently taking Introduction to Abstract Math, and have taken Calculus 1, Discrete Math, and Linear Algebra.
Given $(a_n),(b_n),(m_n)$ defined in this post, how would I find the supremum of $(a_n)$ and $(b_n)$, knowing that $\forall n \geq 1, (a_n < \sqrt{2} < b_n = a_n + 2^{-n})$? I am not allowed to use the formal definition of convergence. I have already proved each sequence is monotonic, and that $(a_n)$ is increasing and that $(b_n)$ is decreasing on my own. I am not sure how to go about solving this, given how complicated each of the sequences are. How would I start solving this kind of problem?

A: HINT: For each $n\ge 1$ you know that $a_n<\sqrt2<a_n+2^{-n}$. Clearly $\sup_na_n\le\sqrt2$, so the real question is whether $\sup_na_n$ could be strictly less than $\sqrt2$. Suppose that $\sup_na_n=s<\sqrt2$. What happens if $n$ is so large that $2^{-n}<\sqrt2-s$?
It's also clear that $\inf_nb_n\ge\sqrt2$, so for this one you want to ask yourself whether it's possible for $\inf_nb_n$ to be strictly greater than $\sqrt2$; use the same general idea as I used above.


text:
Q: Preview html in browser like it is displayed in wkhtmltopdf Is there any browsers that use the same engine (webkit 2.2.4 I believe) to display CSS as wkhtmltopdf does?
I am trying to create a print document and it looks perfect on newest Chrome/Firefox but it looks totally broken when i print it via wkhtmltopdf.
I have used prefixing to help me along this journey, but now I have come across something weird that probably requires some CSS hacks to fix and in that case, I would like to have an easier debugging tool.
What I am trying to achieve here is do debug the print in a browser using the same engine as wkhtmltopdf, so I don't have to print the file and open it each time I do some changes.

A: Seems Safari versions from 8 and down looks the same as wkhtmltopdf.
So maybe webkit 538.35.8? This works for me for now by using Browserstack.
The closest Google Chrome version i could find was using webkit 537.36 - Chrome version 27.0.1453, before going over to Blink. I have not tried this out.


text:
Q: How do I use the csv module to add a column? I've got a csv file with a matrix of data. When the initial csv file is opened in Notepad it looks like this:
"AAA,15.0"
"BBB,45.0"
"CCC,60.0"
I then want to process this data, adding another column to get something formatted as follows:
"AAA,15.0,50.0"
"BBB,45.0,30.0"
"CCC,60.0,20.0"
So.......
I open the original file into Python using:
with open((FilePath"/XXX.csv"), 'rt') as csvfile:
   NewData = list(csv.reader(csvfile, delimiter=';'))

print(NewData)

The first time I do this the code produces a list of strings (which I'm actually happy about - I want this format)...
['AAA,15.0,50.0', 'BBB,45.0,30.0', 'CCC,60.0,20.0']
But then next time I try to add a column I end up with....
[['AAA,15.0,50.0'], ['BBB,45.0,30.0'], ['CCC,60.0,20.0']]
So, each time my code runs it adds an additional layer of 'listing'.
What do I need to do to keep the initial formatting of a list of strings? I imagine it's because I'm opening the file with the list() command. What should I be using?

Further details as requested.........
Distilling this further...My code is...
import csv

FilePathSB="C:/Users/"

with open((FilePathSB+"/Master.csv"), 'rt') as csvfile:

   xMatrix = list(csv.reader(csvfile, delimiter=';'))

####Do something to the data like add another column of numbers

#SaveAs same file

with open(FilePathSB+"/Master.csv", "w") as output:
   writer=csv.writer(output,lineterminator='\n')
   for val in xMatrix:
      writer.writerow([val])

Note that there is some data manipulation that occurs while the file is open but this doesn't impact the problem I have so I've left the code out.
Opening the file and then saving it is adding a layer of 'listing' each time the code runs. I'd like the formatting to remain unchanged (ie so despite being opened and then resaved I'd like the data format to be the same as the initial matrix shown below).
So the first time the code runs it opens the initial csv data of:
"AAA,24:17"
"BBB,21:18"
"CCC,16:40"

and changes the format to saves it as:
"['AAA,24:17']"
"['BBB,21:18']"
"['CCC,16:40']"

If I run the code again it takes this data and changes it to:
"[""['AAA,24:17']""]"
"[""['BBB,21:18']""]"
"[""['CCC,16:40']""]"

And if I run it again I end up with:
"['[""[\'AAA,24:17\']""]']"
"['[""[\'BBB,21:18\']""]']"
"['[""[\'CCC,16:40\']""]']"

A: The csv Reader is meant to parse your file row by row, and return a list for each one.
If we had a file like:
header1|header2
      1|      A
      2|      B

when we parsed this csv file using the "|" character as a delimiter, we'd get:
[['header1', 'header2'], ['1', 'A'], ['2', 'B']]

This is exactly what we're supposed to expect in this case. However, if we parsed it with some other character as the delimiter, we'd still get:
[['header1|header2'], ['1|    A'], ['2|    B']]

This is what you're doing, because your csv reader is primed to expect a delimiter of ";", while your actual csv has (apparently) a delimiter of ",".
After reading your csv in using reader, you'll have a list of lists, where each inner list represents a row.  Think of it as looking like this:
[
 row1,
 row2,
 row3
]

where each row looks like:
[cell1, cell2, cell3]

If you want to add a new column to each row, you'll have to iterate over all the rows:
for current_row in rows:
    # use current row here

and use the .append() method of a list to add the new column.
    current_row.append('new_value')

Finally, you can use csv.writer to write your rows to another file. See csv.writerows


text: Q: Number of k-MSTs in a graph I am wondering if there exists a theorem similar to the Matrix-Tree theorem of Kirchhof for finding the number of k-MSTs (Minimum Spanning Trees connecting exactly $k$ vertices in a graph). I am particularly interested in Algebraic Graph Theory and formulae similar to that of Kirchhof relating this number to the properties of the matrices associated with the super-graph [partially] spanned by these k-spanning trees. If it helps, the specific case I am interested in only concerns a connectivity graph that has binary weights on its edges and so the adjacency matrix is in the form of $\mathbf{A}\subset\{0,1\}^{n\times n}$. It goes without saying that eventually, it would be interesting to enumerate the k-MSTs, but that would go beyond the fundamental question. Any hint will be greatly appreciated!


text:
Q: Normal tangent vector and normal vector problem Consider the following vector function.
$$r(t) = \left\langle 2t \cdot \sqrt{2}, e^{2t}, e^{-2t}\right\rangle$$
(a) Find the unit tangent and unit normal vectors $T(t)$ and $N(t)$.
$T(t) =$
$N(t) =$
(b) Use this formula to find the curvature.
$κ(t) =$
I am getting bogged down in the math. I know how to calculate the three things but I am having trouble getting the derivative of $T(t)$ after solving for it. I have gotten $T(t)$ to equal $$\frac{1}{2 e^{2t} + 2 e^{-2t}} \left\langle 2 \cdot \sqrt{2}, 2 e^{2t},-2 e^{-2t}\right\rangle$$.
Thank you!

A: It looks fine...
$$\left|\left|\left(2\sqrt 2\,,\,2e^{2t}\,,\,-2e^{-2t}\right)\right|\right|^2=8+4(e^{4t}+e^{-4t})=4(e^t+e^{-t})^2=16\cosh^2 t$$


text:
Q: Inserting a TermVector into Lucene Learning how to use Lucene!
I have an index in Lucene which is configured to store term vectors.
I also have a set of documents I have already constructed custom term vectors for (for an unrelated purpose) not using Lucene.
Is there a way to insert them directly into the Lucene inverted index in lieu of the original contents of the documents?
I imagine one way to do this would be to generate bogus text using the term vector with the appropriate number of term occurrences and then to feed the bogus text as the contents of the document. This seems silly because ultimate Lucene will have to convert the bogus text back into a term vector in order to index.

A: I'm not entirely sure what you want to do with these term vectors ultimately (score? just retrieve?) but here's one strategy I might advocate for.
Instead of focusing on faking out the text attribute of term vectors, consider looking into payloads which attach arbitrary metadata to each token. During analysis, text is converted to tokens. This includes emitting a number of attributes about each token. There's standard attributes like position, term character offsets, and the term string itself. ALL of these can be part of the uninverted term vector. Another attribute is the payload which is arbitrary metadata you can attach to a term.
You can store any token attribute uninverted as a "term vector" including payloads, which you can access at scoring time.
To do this you need to

*

*Configure your field to store term vectors, including term vectors with payload

*Customize analysis to emit payloads that correspond to your terms. You can read more here

*Use an IndexReader.getTermVector to pull back Terms. From that you can get a TermsEnum. You can then use that to get a DocsAndPositionEnum which has an accessor for the current payload

*If you want to use this in scoring, consider a custom query or custom score query


text:
Q: Concatenate Values from a Range based on a Lookup I'm working on a budget for a project with multiple phases. There is a possibility that not all phases will be worked on so I've added some lookups and SUMIF formulas so that I can get a summary of my included and excluded effort and dollar amounts. That all works fine. Now I'd like to hide my row of lookups (row 1), but still have a way of identifying which phases of the project are included and which are excluded. Obviously I could manually concatenate them together, but if the phases being included/excluded change then I need to remember to update those formulas (and it's not nearly as fun as doing all in a formula). Here's how my sheet looks:

The TEXTJOIN function seems like it should work (i.e. =TEXTJOIN(CHAR(10), TRUE, C2:N2)), but I can't wrap my head around how to make the range parameter dependent on my lookup row. I played around with INDEX using something like =TEXTJOIN(CHAR(10), TRUE, INDEX(A2:M2,,(A1:M1="Yes")*COLUMN(A1:M1))), but didn't have any luck. At the end of the day I want to have something like:

Phase 1   Phase 2   Phase 5

Please note that the above data should all appear in the same cell - using the line feed character, CHAR(10), as the delimiter in the TEXTJOIN function will make all of the phases appear on a new line within a single cell. I do not want to fill formulas through multiple cells. Thanks in advance for any help.

A:
Please take a look at the picture. I had a similar issue in the past (and brought it to StackOverflow, at which point I was helped by @ScottCraner, original post here:
Doing an array formula lookup
Basically,
1) You set up the array you are looking through - in my case, its $A$2:$A$6, in your case it will be $B$2:$M$2.
2) You then nest the COUNTIFS function inside of a match function. The function does the following:
  A) It checks whether the name of phase X has already shown up in column E when you are copy/pasting down
  B) If it has, move on to the next one
  C) If it hasn't, output
3) Of note: this is an array formula, so the formula itself is checking through every cell. So it looks at cell A2; if the cell in B2 is "Yes", and "Phase 1" isn't in range in column E, then put in phase 1. Because it is, its there. Then it looks at cell A3; if the cell in B3 is "Yes", the same thing for phase 2. Then it looks at cell A4; because B4 is "No", the *(B2:B6="Yes") will throw an error. and so on
4) Place error catching brackets around the function.

A: A less elegant way to go about this, which doesn't require array formulas would be to use the secondary column's "Yes/No" as an index.  This assumes the value in the secondary column is redundant- and repeating the primary column's "Yes" or "No."
In C1: =CONCATENATE(B1,COUNTIFS($A$1:B1,B1)) -
Repeat relatively for E1, G1, etc.
Somewhere separate (the below formula assumes Row 1 of the same worksheet), you could then use: =IFERROR(INDEX($2:$2,MATCH(CONCATENATE("Yes",ROW()),$1:$1,0)-1),"")
To look up "Yes1", returning "Phase 1" and autofill downward.  IFERROR is used here to return blank when you run out of "Yes" results.


text:
Q: User input using Scanner class How get string input from user using scanner.
e.g:
Scanner get = new Scanner(System.in);

String name = get.nextString();

But calling doesn't work with string but it works with integers or double data types.

A: You have to use new Scanner().nextLine() or just new Scanner().next() because there is no nextString() method in the Scanner;

A: You should call next() method instead of nextString().


text: Q: Can I connect a native application to a chrome extension? I was wondering if it is possible to connect a host application to a chrome extension. I am interested to know if the communication can be made precisely this way: host -> extension.


text:
Q: Rotating matrix 90 degrees left side in c++ example code I tried using this code but I'm unable to get the required output. I gave a 3*3 matrix as input
1 2 3|4 5 6| 7 8 9 and resultant matrix expected is 7 4 1 | 8 5 6 | 9 6 3 .
#include <bits/stdc++.h>
using namespace std;

int main(){
int size;
cin>>size;
int matrix[size][size];
for(int i=0;i<size;i++){
    for(int j=0;j<size;j++){
        cin>>matrix[i][j];
    }
}
cout<<"Original Matrix"<<endl;
for(int i=0;i<size;i++){
    for(int j=0;j<size;j++){
        cout<<matrix[i][j]<<" ";
    }
    cout<<endl;
}
cout<<"After left rotating"<<endl;
int tempMatrix[size][size];
for(int i=0;i<size;i++){
    for(int j=0;j<size;j++){
        tempMatrix[i][j]=matrix[j][i];
    }
}
for(int i=0;i<size;i++){
    for(int j=0;j<size;j++){
        cout<<tempMatrix[i][j]<<" ";
    }
    cout<<endl;
}
return 0;

}

A:     #include <bits/stdc++.h>
    using namespace std;

    int main()
    {
        int size;
        cin>>size;
        int matrix[size][size];
        for(int i=0;i<size;i++)
        {
            for(int j=0;j<size;j++)
            {
                cin>>matrix[i][j];
            }
        }
        cout<<"Original Matrix"<<endl;
        for(int i=0;i<size;i++)
        {
            for(int j=0;j<size;j++)
            {
                cout<<matrix[i][j]<<" ";
            }
            cout<<endl;
        }
        cout<<"After left rotating"<<endl;
        int tempMatrix[size][size];
        for(int i=0;i<size;i++)
        {
            for(int j=0;j<size;j++)
            {
                tempMatrix[i][j]=matrix[size-j-1][i];
            }
        }
        for(int i=0;i<size;i++)
        {
            for(int j=0;j<size;j++)
            {
                cout<<tempMatrix[i][j]<<" ";
            }
            cout<<endl;
        }
        return 0;
    }

Hope this works.
Thanks.


text:
Q: mysql_fetch_object() warning I'm trying to output a table from my database by using PHP, but shows "mysql_fetch_object(): supplied argument is not a valid MySQL result resource".
// Connect to MySQL server
$conn = mysql_connect('localhost','root','') or die(mysql_error());

// Select database
mysql_select_db('bakery') or die(mysql_error());

$sql = "Select * From customer";
$result = mysql_query($sql,$conn);

echo "
";
echo "
custid
custname
ccn
phoneno
address
city
zip
";
while($row = mysql_fetch_object($sql))
echo "
$row->custid
$row->custname
$row->ccn
$row->phoneno
$row->address
$row->city
$row->zip
";
echo "
";

A: Instead of
while($row = mysql_fetch_object($sql))

It should be
while($row = mysql_fetch_object($result))  //<--- Pass the $result

As the error states... The mysql_fetch_object expects a resource , but you had passed a string (That was main error behind this)

This(mysql_*) extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. Switching to PreparedStatements is even more better to ward off SQL Injection attacks !


text:
Q: GAE datastore: filter by date interval I have this model:
class Vehicle(db.Model):
    ...
    start_production_date = db.DateProperty()
    end_production_date = db.DateProperty()

I need to filter, for example, all vehicles in production within, say, 2010:
I thought I could do:
q = (Vehicle.all()
    .filter('start_production_date >=', datetime(2010, 1, 1))
    .filter('end_production_date <', datetime(2011, 1, 1)))

buy I get BadFilterError:
BadFilterError: invalid filter: Only one property per query may have inequality filters (<=, >=, <, >)..

so, how do I acheive this? Moreover this seems to me a quite common task.

A: One approach is to change your model to something like this:
class Vehicle(db.Model):
    ...
    start_production_date = db.DateProperty()
    start_production_year = db.IntegerProperty()
    start_production_month = db.IntegerProperty()
    start_production_day = db.IntegerProperty()

    end_production_date = db.DateProperty()
    end_production_year = db.IntegerProperty()
    end_production_month = db.IntegerProperty()
    end_production_day = db.IntegerProperty()

Update these new values on every put (you could override put) and the simply:
# specific year

q = (Vehicle.all()
    .filter('start_production_year =', 2010))

# specific year, different months

q = (Vehicle.all()
    .filter('start_production_year =', 2010)
    .filter('start_production_month IN', [1, 2, 3, 4]))

# different years

q = (Vehicle.all()
    .filter('start_production_year IN', [2010, 2011, 2012]))

A: I went with this solution:
I set in model a ListProperty item containing all years the model was crafted:
vhl.production_years = range(start_production_date.year, end_production_date + 1)

Then test:
q = (Vehicle.all()
    .filter('production_years =', 2010))


text:
Q: How to replicate virtual box linux server to my own server? I have one virtual box linux server which shows only command prompt...
And I want to have that server files and Database to my another server...
How can I achieve that?

A: there are several options for start if use the same virtualization technology on the virtual box and the new server you could just create snapshot from your virtual box and than try to run that snapshot on the new server. http://wiki.qemu.org/Documentation/CreateSnapshot
The other solution will be to transfer all of your data manually, for that you will need to:

*

*Export all your databases the corresponding tools for that type of
database ( eg. mysqldump for MySQL server )

*Transfer all files from old to the new server using rsync

*Install the same software stack / control panels you've had on the virtual box on the new server.

*Recreate the FTP, MYSQL users and restore files from the transferred data into the same locations as on the virtual box

*Import the databases from the exported database files using the corresponding tools for that server.

This should do the trick :)


text:
Q: Zooming to point in PictureBox I have PictureBox which is inside Panel. Panel has set property AutoScroll == true, PictureBox has Sizemode == Zoom. How to simply implement zoom to point in this code?
public partial class frmMain : Form
{
    string imageFilename = @"c:\Temp\test.jpg";
    private Image _currentImage;
    private float _zoom = 1.0f;
    private Point _currMousePos;

    public frmMain()
    {
        InitializeComponent();

        RefreshImage(imageFilename);
        pictureBox.MouseWheel += PictureBox_MouseWheel;
    }

    private void RefreshImage(string fileName)
    {
        _currentImage = Image.FromFile(fileName);
        pictureBox.Invalidate();
    }

    private void PictureBox_MouseWheel(object sender, MouseEventArgs e)
    {
        if (e.Delta > 0)
        {
            _zoom += 0.1F;
        }
        else if (e.Delta < 0)
        {
            _zoom = Math.Max(_zoom - 0.1F, 0.01F);
        }

        MouseEventArgs mouse = e as MouseEventArgs;
        _currMousePos = mouse.Location;

        pictureBox.Invalidate();

        // how to calculate Panel.AutoScrollPosition?
    }

    private void pictureBox_Paint(object sender, PaintEventArgs e)
    {
        ((Bitmap)_currentImage).SetResolution(e.Graphics.DpiX, e.Graphics.DpiY);
        e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
        e.Graphics.ScaleTransform(_zoom, _zoom);
        e.Graphics.DrawImage(_currentImage, 0, 0);
        pictureBox.Size = new Size((int)(float)(_currentImage.Width * _zoom),
            (int)(float)(_currentImage.Height * _zoom));
    }
}

Or should I choose a completely different way of zooming?


text:
Q: How to create multiple file upload button with add and remove button in angular? My question is how to create a new file upload button/input with add and remove button in Angular 12. we should be able to add as many upload button/input we want.

A: You can use ngx dropzone. Using ngx dropzone you can add or drag and drop multiple files in a single time.For using this u can follow the steps in the following link.
https://www.npmjs.com/package/ngx-dropzone