Sunday, October 8, 2023

Android Auto "Got it. Let me get some more information so I can help you with that."

I received this error message when asking Android Auto to text "Dad."

 "Got it. Let me get some more information so I can help you with that. Tap the notification on your screen." 

Something very close to that. The problem was there was no notification on the screen no matter how many times I tried. It dawned on me to tap my voice command button in the search bar on the home screen when I wasn't attached to the car. I got a similar message, but now it asked me to setup Google Assistant. Interestingly, I could ask it to text a specific number, not a name, and it would do that. So it was having a problem accessing contacts. 

I loath Google Assistant and it basically taking over my phone, so I have long had it disabled. So, I figured out how to restore just permissions to my contacts. 

I opened Settings -> Apps and scrolled below the app list to "Assistant." On the next screen, scroll down a mile to "Your Data in the Assistant." On the following screen, scroll down to "Contact info from your devices." Select that then on the NEXT screen toggle it on. Problem solved!

I don't know if I manually turned this off at some point or if I denied access to another app that updated Assistant or just an update did it. Either way, I hope this helps someone.

Wednesday, May 4, 2022

React-window not refreshing FixedSizedList on state change

Admittedly, I'm fairly new to react and react-native is more my playground, but here was the issue.  I wanted to use react-window for a list of checkboxes.  The list was populated from a database of values where some were already selected.  Those values were in the state.  When a user clicks a checkbox, it should update the state and change the "checked" value of the box to the opposite of the current value.

Here's the issue -- react-window only re-renders when you scroll.  That's what it's designed to do to minimize data being loaded.  So, what I would get is everything working, but the checkboxes wouldn't change from checked to unchecked (and vice versa) unless I clicked THEN scrolled.

I tried LOTS of ways to get around this including using the scrollToItem method to try to get the window to scroll down and then back.  That partially worked.  I also tried using getElementById (going back to my old HTML days) but that doesn't work in React, and refs with 400 items seemed out of the question.  There was mention on gitHub of a resetAfterIndex method, but I couldn't get it to work.

Finally, I was able to force a refresh by using the "overscanCount" prop of the FixedSizeList.  The rows function  stayed the same, but I set a state variable called "overScan," set the FixedSizeList prop of overscanCount to that state variable, and then had the dataCheck funcion update the overScan state variable everytime it was called.  This forced the FixedSizeList to refresh anytime a checkbox was checked.

I don't LOVE the solution, but I could find no other way to make this work.  Best of luck!


Original Code


rows = ({ index, style }) => {
    var data = this.state.myData[index]
    return (
      <ListItem style={style} component="div" disablePadding >
        <ListItemButton role={undefined} onClick={()=>this.dataCheck(data.value)} dense >
          <ListItemIcon>
              <Checkbox checked={data.selected} />
          </ListItemIcon>
          <ListItemText primary={`${data.descr} - ${data.label}`} />
        </ListItemButton>
      </ListItem>
    );
  }

  dataCheck = (checkValue) => {
    let data = this.state.myData
    let dataIndex = findIndex(data, {'value': checkValue})
    if(data[dataIndex].selected == false){
      data[dataIndex].selected = true
    } else {
      data[dataIndex].selected = false
    }
    this.setState({myData: data})
    }
  }

  render(){
    return (
      <Box component='main' flexGrow={1} width={'96%'} sx={{ p: '2%' }} display={'flex'} justifyContent={'flex-start'}
        flexDirection={'column'}>
          <FixedSizeList height={300} width={'100%'} itemCount={this.state.myData.length} itemSize={40} >
            {this.rows}
          </FixedSizeList>
</Box>
)
}

New code with overScan as a state variable.

I don't LOVE the solution, but I could find no other way to make this work.  Best of luck!


  dataCheck = (checkValue) => {
    let data = this.state.myData
    let dataIndex = findIndex(data, {'value': checkValue})
    if(data[dataIndex].selected == false){
      data[dataIndex].selected = true
    } else {
      data[dataIndex].selected = false
    }
    if(this.state.overScan == 1){
      this.setState({myData: data, overScan: 2})
    } else {
      this.setState({myData: data, overScan: 1})
    }
    }
  }

  render(){
    return (
      <Box component='main' flexGrow={1} width={'96%'} sx={{ p: '2%' }} display={'flex'} justifyContent={'flex-start'}
        flexDirection={'column'}>
          <FixedSizeList overscanCount={this.state.overScan} height={300} width={'100%'} itemCount={this.state.myData.length} itemSize={40} >
            {this.rows}
          </FixedSizeList>
</Box>
)
}

Saturday, June 28, 2014

There is extraneous text following the logical expression on a DO IF command. SPSS Error

I recently received the following error running an SPSS syntax with an "include" statement.

There is extraneous text following the logical expression on a DO IF command.

Now, I've been delinquent in setting up a number of syntax files to use as includes since I switched back to SPSS from SAS (not by my choice), so this threw me for a loop (no pun intended).

Oddly, if I ran the syntax that was calling the include then opened the include syntax and ran it separately, there was no problem.

What it turns out is that, if you're using a syntax file as an include, you cannot have leading space before your commands and arguments.  In my regular syntax files I add tabs to command arguments to show the separation, eg:

Do if thisvariable eq 'hello'.
     Compute thatvariable = 'hi'.
End if.

This runs fine in a syntax file, but if you use that syntax as an include, you get "There is extraneous text following the logical expression on a DO IF command."

Just switch to:

Do if thisvariable eq 'hello'.
Compute thatvariable = 'hi'.
End if.

I don't know how many other people in the world will ever experience this as it may just be my habit to add space like that, but I hope it helps someone!

*Edit - July 20th

Interestingly, if you have a subcommand that starts with a forward-slash you DO need a tab or set of blank spaces if it's part of an include.

For instance, this throws an error

Aggregate
/Outfile *
/Break id
/total = sum(avariable).
execute.

This will not.

Aggregate
   /Outfile *
   /Break id
   /total = sum(avariable).
execute.

Perhaps I'm just bad at SPSS and there was an unwritten rule that all subcommands and nothing else should start with a tab.  Oh well.  INCLUDE treats these all very unusually, in my opinion. 

Friday, June 21, 2013

Microsoft Word Space Above a Horizontal Line

It seems a more annoying change to MS Word 2010 is the lack of ease with which one could drop in a horizontal line and move it around.  You COULD simply add a shape through Insert -> Shapes -> Line, but I find that to be more work.

To add a horizontal line now you use the Borders menu.



















The problem being that when you do add the line, there is a huge gap between the previous text and the line created.





The only solutions I found online were work-arounds like adding a shape or using a paragraph border.  I HATE work-arounds like that.  It doesn't solve the problem, it just uses something else.  I want to know how to move that line up!

So, the real solution is to select the line, go into the Font menu, click the Advanced tab, and change the Position from Normal to Raised.  Then, change the number of Points to raise the line by.  At a 26 pt font I chose 18 pts.
























Voila!






Now you can adjust the font size and the raised size of the line to get exactly the spacing you want.

Saturday, March 9, 2013

SPSS Macro Variables in SQL

I'm back to SPSS instead of SAS, and this was driving me crazy.  In SPSS 20, I was trying to pass a macro variable into my SQL so I could change the SQL each time I called the macro.  It would simply look like this:

Start getbydate macro with myvar (to be assigned when the macro was called)

Select *
from thistable
where date < myvar

End macro

run getbydate myvar = 2013-03-01 00:00:00

That's obviously not proper SPSS syntax, but it gives the general idea of how using macro variables in SQL should work.

Here's the actual SQL, a little changed.


GET DATA
   /TYPE=ODBC
   /CONNECT= Connect info goes here
   /SQL="SELECT * "+
   "FROM stage_history "+
   "Where stage_dte < '2013-03-01 00:00:00' and term = 'Fall' "+
   /ASSUMEDSTRWIDTH=255.
CACHE.
EXECUTE.
DATASET NAME PointInTime.

Pretty simple.  I want to grab data from the stage_history table for any date before March 1, 2013.  But, I wanted to be able to change that date easily and reuse it throughout code.  So, I should be able to write a macro and assign a variable called 'startdate' and then replace the date in the SQL with !startdate.

The thing is, the SQL has a problem parsing this.  If you put !startdate in single quotes like this:

   "Where stage_dte < '!startdate' and term = 'Fall' "+

If you do that, SPSS thinks you're looking for the text !startdate.  That's no good.

So, you need to start by escaping the SQL command using double quotes around !startdate.

   "Where stage_dte < "!startdate" and term = 'Fall' "+

Now, we have the problem that we need single quotes to actually be part of the SQL.  This is where the !Quote() function comes in. It will place single quotes around the macro variable !startdate.

   "Where stage_dte < "!quote(!startdate)" and term = 'Fall' "+

Now the SQL is correct.  You just have to be sure when calling the macro you place the !startdate value in single quotes (see below).  Otherwise, you'll get an error about crossing numeric and string variables.

Here is the finished product.

DEFINE !getpit (startdate = !tokens(1)).


GET DATA
   /TYPE=ODBC
   /CONNECT= Connect info goes here
   /SQL="SELECT * "+
   "FROM stage_history "+
   "Where stage_dte < "!quote(!startdate)" and term = 'Fall' "+
   /ASSUMEDSTRWIDTH=255.
CACHE.
EXECUTE.
DATASET NAME PointInTime.


!ENDDEFINE.

!getpit startdate = '2012-03-01 00:00:00'.

I hope that helps some others out there!

Thursday, December 8, 2011

Error - CFForm, CFDiv, ColdFusion.Navigate, AJAX, and input="button"

I was killing myself trying to figure out what was going wrong here.  I had a cfform inside a cfdiv that was refreshing the entire page instead of refreshing through AJAX.  The idea was that a button was going to be used for the submit action, which would call a js function to use cfnavigte to refresh the cfdiv.  It went something like this.

<cfdiv id="refreshdiv">
     <cfform name="refreshform">
          <input type="hidden" value="#thatvalue#" name="valuetoupdate">
          <input type="button" src="images/mybutton.jpg" onClick="refreshfunction('refreshform')" />
     </cfform>
</cfdiv>

Javascript:

function refreshfunction(form) {
coldfusion.navigate(http://....../update.cfm,'refreshdiv',null,null,Post,form);
};

In any other case, that would submit the form and cause an AJAX refresh of just the div leaving any content before or after unaffected.  The example though refreshes the entire page.

I finally pieced this apart to realize that type="button" is the culprit.  I switched to a regular img tag instead of the input tag and it worked fine.  Maybe that's common knowledge, but I had no idea.  What a PITA.

Friday, November 18, 2011

SAS Error "Width specified for format F is invalid."

I came across the SAS error "ERROR: Width specified for format F is invalid." As that provides absolutely no hint as to what the actual problem is, it took me forever to figure it out.

What I've determined is it's a result of importing a file using proc import. Apparently there is some variable SAS doesn't like in that file (if you know exactly why, I'm all ears).

The solution is to write a "format _all_;" statement in a data step for the file before anything else is done to it. Something like this:

proc import datafile="your file" out=mydataset replace;
run;

data mydataset;
set mydataset;
format _all_;
run;

I hope it helps!