text:
Q: Nuxt Error : Cannot read properties of null (reading 'addEventListener') default.vue and index.vue not rendering I'm using nuxt.js and vuesax as an UI framework, I did modify my default.vue in /layouts with a basic navbar template exemple from vuesax.
Then I used @nuxtjs/router-extras to rename my "/" and redirect it to /login, I also used a vuesax input type template in my index.vue to see if I could render my /login page (navbar + input) but it is showing be this error:
client.js?06a0:103 TypeError: Cannot read properties of null (reading 'addEventListener')
at VueComponent.handleScroll (vuesax.js?574d:24324:1)
at VueComponent.mounted (vuesax.js?574d:24382:1)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1863:1)
at callHook (vue.runtime.esm.js?2b0e:4235:1)
at Object.insert (vue.runtime.esm.js?2b0e:3158:1)
at invokeInsertHook (vue.runtime.esm.js?2b0e:6390:1)
at Vue.patch [as __patch__] (vue.runtime.esm.js?2b0e:6609:1)
at Vue._update (vue.runtime.esm.js?2b0e:3960:1)
at Vue.updateComponent (vue.runtime.esm.js?2b0e:4075:1)
at Watcher.get (vue.runtime.esm.js?2b0e:4495:1)

again I'm very new, heres some code:
default.vue
<template>

    <vs-navbar target-scroll="#padding-scroll-content" padding-scroll center-collapsed v-model="active">
      <template #left>

      </template>
      <vs-navbar-item :active="active === 'wallet'" id="wallet">
        Wallet
      </vs-navbar-item>
      <vs-navbar-item :active="active === 'profil'" id="profil">
        Profil
      </vs-navbar-item>
      <template #right>
        <vs-button>Login</vs-button>
      </template>
    </vs-navbar>
    <Nuxt />

</template>

index.vue
<template>

    hello
    <vs-input
      type="password"
      v-model="value"
      label-placeholder="Password"
      :progress="getProgress"
      :visiblePassword="hasVisiblePassword"
      icon-after
      click-icon="hasVisiblePassword = !hasVisiblePassword">
      <template #icon>

      </template>
      <template v-if="getProgress >= 100" #message-success>
        Secure password
      </template>
    </vs-input>

</template>

<router>
{
"path": "/login"
}
</router>

middleware/redirect.js
export default function(req, res, next) {
  const redirects = [
    {
      from: "/",
      to: "/login"
    }
  ]
  const redirect = redirects.find((r) => r.from === req.url)
  if (redirect) {
    res.writeHead(301, { Location: redirect.to })
    res.end()
  } else {
    next()
  }
}

A: Vuesax is not really maintained anymore, latest commit being from 20th September 2020.
Hence why it's not part of the Nuxt CLI anymore.
If you're new, I recommend starting by using something more simple, well supported and maintained like Vuetify, Buefy, Tailwind or at least any other one available in the list.

Even starting directly with Nuxt without any prior Vue knowledge is quite risky.

Back to the topic, even if we fix the issues regarding a specific install issue here, we will probably face some others down the road. And since the project is not maintained anymore, it's pretty sure that at some point we will see a blocker of some sort.
Don't expect Vuesax to work with the new Nuxt3 at all for example. So yeah, sorry it's not an answer to your question but I feel like it's better if I tell you that now that later (after days of debugging).

PS: you're trying to use res.writeHead in a client-side middleware (redirect.js). If you want a redirect, you'll need to use more of a $router.push here to use the Vue router.


text:
Q: How to create library with classes that extends sdk? Let's say I have class
public class Point extends Point2D.Double{ // Point2D is of course from sdk

public void myMethod(){}
    //some actions
}

The problem is when I include this code as a library from .jar file to my another project I only have access to myMethod() and not to any fields and methods from Point2D.Double class.
to give example:
import com.mylibrary.Point

public class SomeClass{
     public SomeClass(){
     Point myPoint = new Point(1,2);

     myPoint.myMethod(); // ok
     myPoint.getX(); // not ok althought there is getX() method in Point2D.Double class
     }
}

How can I get access to both compiled codes?

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to get the time zone or local time of Alexa device I want to get the "time zone" set in the settings or local date time of the Alexa device. Is there any API available for it? Or is there any option to get the date-time of the user using his postal code?
Any help will be highly appreciable?

A: It is now possible to get a user's timezone and other related data using the Alexa Settings API. Also see the related blogpost for more information on this API release.
The endpoint you'll be interested in is the following:
GET /v2/devices/{deviceId}/settings/System.timeZone

You simply need to provide the user's device ID, which is part of the received intent. The response will contain a timezone name, for instance "Europe/London".

A: Yes, there is a native Alexa API that you can use. Here is a perfect solution for what you're looking for. What you will need is a device ID and an API access token. Also, few tools like axios ( npm i axios) and zip-to-country-code (npm i zipcode-to-timezone) more info here Enhance Your Skill With Address Information Also, before you implement this code make sure to go to Alexa dev portal and turn on permissions See image below. Cheers!
            const apiAccessToken = this.event.context.System.apiAccessToken;
            const deviceId = this.event.context.System.device.deviceId;
            let countryCode = '';
            let postalCode = '';

            axios.get(`https://api.amazonalexa.com/v1/devices/${deviceId}/settings/address/countryAndPostalCode`, {
              headers: { 'Authorization': `Bearer ${apiAccessToken}` }
            })
            .then((response) => {
                countryCode = response.data.countryCode;
                postalCode = response.data.postalCode;
                const tz = ziptz.lookup( postalCode );
                const currDate = new moment();
                const userDatetime = currDate.tz(tz).format('YYYY-MM-DD HH:mm');
                console.log('Local Timezone Date/Time::::::: ', userDatetime);
            })

A: If you are using ASK sdk v2. There's a better way to get the timezone.
const getCurrentDate = async (handlerInput) => {
    const serviceClientFactory = handlerInput.serviceClientFactory;
    const deviceId = handlerInput.requestEnvelope.context.System.device.deviceId;

    try {
        const upsServiceClient = serviceClientFactory.getUpsServiceClient();
        return userTimeZone = await upsServiceClient.getSystemTimeZone(deviceId);
    } catch (error) {
        if (error.name !== 'ServiceError') {
            return handlerInput.responseBuilder.speak("There was a problem connecting to the service.").getResponse();
        }
        console.log('error', error.message);
    }
}


text:
Q: Octave image update fails after output window resized I'm using octave to process some video and provide it's output on different processing stages. I'm loading video frame by frame and using set(self.image_object, 'CData', self.data); for image update.
After I resize output window, set function fails with set: invalid handle (= -1.39375).
%fist frame display
self.image_object = imshow(self.data);

...

%new frame arrives and I try to set display it's content in already created image output
set(self.image_object, 'CData', self.data);

It seems like after output window is resized my image_object becomes invalid.
Any ideas are appreciated.

A: Well, I don't know whether this answer worth leaving here, but the reason of a crash was subplot recreation. So in preudocode my program was quite similar to following:
loop
    imageA = get_updated_image_A();
    imageB = get_updated_image_B();

    create_subplot();
    display_image(imageA);

    create_subplot();
    display_image(imageB);
end loop

So in octave it was causing execution failure after output window was resized. After I changed my code in a following way, everything started to work as intended:
loop
    imageA = get_updated_image_A();
    imageB = get_updated_image_B();

    if(is_first_iteration)
        create_subplot();
    endif
    display_image(imageA);

    if(is_first_iteration)
        create_subplot();
    endif
    display_image(imageB);
end loop


text:
Q: Rails 3.2 - Writing cookie value without encoding We have a few web applications that share a cookie value ssoid.
When the user logs into our Rails application, we want to set the ssoid value in the cookie but Rails is URL encoding the value by default.
cookies[:ssoid] = session[:token]

Value written to the cookie store is
ABCpRyan0fLwMamiT%2F9GGk2o%2FAPckq1C8PbHCotxmgUk%3D

instead of
ABCpRyan0fLwMamiT/9GGk2o/APckq1C8PbHCotxmgUk=

Is there a way to avoid this?

A: I think that you can use the memcached gem to store cookies in one commun place and share that cookie across multiple apps you can also take a look at sharing session across rails apps on different subdomains as a subdomain is seen as a different site or app
I hope that I could help.


text:
Q: PYODBC--Data source name not found and no default driver specified import pyodbc
connection = pyodbc.connect('Driver = {SQL Server};Server=SIWSQL43A\SIMSSPROD43A;'
                            'Database=CSM_reporting;Trusted_Connection=yes;')

Error:
connection = pyodbc.connect('Driver = {SQL Server};Server=SIWSQL43A\SIMSSPROD43A;'
    pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

A: Local Ms Sql database server need or {ODBC driver 17 for SQL Server}
Azure Sql Database need{ODBC driver 13 for SQL SERVER}
Check installed drivers here => Installed ODBC Drivers
Format for connection to Azure Sql Database is :
import pyodbc
conn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};'
                      'SERVER=tcp:nameServer.database.windows.net,1433;'
                      'DATABASE=Name database; UID=name; PWD=password;')

Format for connection to Ms SQL Databse Local:
import pyodbc
conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};'
                      'SERVER=server.name;' // example Doctor-Notebook\\MSSQLEXPRESS
                      'DATABASE=database.name; Trusted_connection = yes')

A: Do not put a space after the Driver keyword in the connection string.
This fails on Windows ...
conn_str = (
    r'DRIVER = {SQL Server};'
    r'SERVER=(local)\SQLEXPRESS;'
    r'DATABASE=myDb;'
    r'Trusted_Connection=yes;'
)
cnxn = pyodbc.connect(conn_str)

... but this works:
conn_str = (
    r'DRIVER={SQL Server};'
    r'SERVER=(local)\SQLEXPRESS;'
    r'DATABASE=myDb;'
    r'Trusted_Connection=yes;'
)
cnxn = pyodbc.connect(conn_str)

A: I faced this issue and was looking for the solution. Finally I was trying all the options from the https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-Windows , and for my MSSQL 12 only "{ODBC Driver 11 for SQL Server}" works. Just try it one by one. And the second important thing you have to get correct server name, because I thought preciously that I need to set \SQLEXPRESS in all of the cases, but found out that you have to set EXACTLY what you see in the server properties. Example on the screenshot:

A: I am also getting same error. Finally I have found the solution.
We can search odbc in our local program and check for version of odbc. In my case I have version 17 and 11 so. I have used 17 in connection string

'DRIVER={ODBC Driver 17 for SQL Server}'

A: You could try:
import pyodbc
# Using a DSN
cnxn = pyodbc.connect('DSN=odbc_datasource_name;UID=db_user_id;PWD=db_password')

Note: You will need to know the "odbc_datasource_name". In Windows you can search for ODBC Data Sources. The name will look something like this:
Data Source Name Example

A: The below code works magic.
 SQLALCHEMY_DATABASE_URI = "mssql+pyodbc://<servername>/<dbname>?driver=SQL Server Native Client 11.0?trusted_connection=yes?UID" \
                              "=<db_name>?PWD=<pass>"

A: I'm using Django 2.2
and got the same error while connecting to sql-server 2012. Spent lot of time to solve this issue and finally this worked.
I changed driver to

'driver': 'SQL Server Native Client 11.0'

and it worked.

A: Below connection string is working
import pandas as pd
import pyodbc as odbc

sql_conn = odbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER=SERVER_NAME;DATABASE=DATABASE_NAME;UID=USERNAME;PWD=PASSWORD;')

query = "SELECT * FROM admin.TABLE_NAME"
df = pd.read_sql(query, sql_conn)
df.head()

A: I have had the same error on python3 and this help me:
conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};'
                      'SERVER=YourServerName;'
                      'DATABASE=YourDatabaseName;UID=USER_NAME;PWD=PASS_WORD;')

remember python is case-sensitive so you have to mention DRIVER,SERVER,... in upper case.
and you can visit this link for more information:
https://learn.microsoft.com/en-us/sql/connect/python/pyodbc/step-3-proof-of-concept-connecting-to-sql-using-pyodbc?view=sql-server-ver15

A: In my case, the exact same error was caused by the lack of the drivers on Windows Server 2019 Datacenter running in an Azure virtual machine.
As soon as I installed the drivers from https://www.microsoft.com/en-us/download/details.aspx?id=56567, the issue was gone.

A: I've met same problem and fixed it changing connection string like below.
Write
'DRIVER={ODBC Driver 13 for SQL Server}'

instead of
'DRIVER={SQL Server}'

A: for error : pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
No space between the driver and event
connection = Driver={SQL Server Native Client 11.0};
"Server=servername;"
"Database=dbname;"
"Trusted_Connection=yes;"

A: Apart from the other answers, that considered the connection string itself, it might simply be necessary to download the correct odbc driver. My client just faced this issue when executing a python app, that required it.
you can check this by pressing windows + typing "odbc".
the correct driver should appear in the drivers tab.

A: Create a DSN something like this (ASEDEV) for your connection and try to use DSN instead of DRIVER like below:
enter code here
import pyodbc
cnxn = pyodbc.connect('DSN=ASEDEV;User ID=sa;Password=sybase123')
mycur = cnxn.cursor()
mycur.execute("select * from master..sysdatabases")
row = mycur.fetchone()
while row:
    print(row)
    row = mycur.fetchone()`

A: I was facing the same issue whole day wasted and I tried all possible ODBC Driver values
import pyodbc
connection = pyodbc.connect('Driver = {SQL Server};Server=ServerName;'
                            'Database=Database_Name;Trusted_Connection=yes;')

In place of Driver = {SQL Server} we can try these option one by one or just you can use with you corresponding setting, somehow in my case the last one works :)
Driver={ODBC Driver 11 for SQL Server} for SQL Server 2005 - 2014
Driver={ODBC Driver 13 for SQL Server} for SQL Server 2005 - 2016
Driver={ODBC Driver 13.1 for SQL Server} for SQL Server 2008 - 2016
Driver={ODBC Driver 17 for SQL Server} for SQL Server 2008 - 2017

Driver={SQL Server} for SQL Server 2000
Driver={SQL Native Client} for SQL Server 2005
Driver={SQL Server Native Client 10.0} for SQL Server 2008
Driver={SQL Server Native Client 11.0} for SQL Server 2012

A: You need to download Microsoft ODBC Driver 13 for SQL Server
from Microsoft ODBC Driver 13

A: Thank you Avinash.
brilliant. I tried to connect to MS Azure database using PyCharm. It worked.
server = ''
database = ''
username = ''
password = ''
driver = 'SQL Server Native Client 11.0'
connection1 = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';PORT=1433;DATABASE='+database+';UID='+username+';PWD='+ password + ';TDS_Version=8.0')
print("Connected.")

A: Try below:
import pyodbc

server = 'servername'

database = 'DB'

username = 'UserName'

password = 'Password'

cnxn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)

cursor = cnxn.cursor()

cursor.execute('SELECT * FROM Tbl')

for row in cursor:
    print('row = %r' % (row,))

A: Have you installed any product of SQL in your system machine ?
You can download and install "ODBC Driver 13(or any version) for SQL Server" and try to run if you havent alerady done.

A: Make sure you have all drivers and db engine installed
https://www.microsoft.com/en-us/download/details.aspx?id=54920

A: server = '123.45.678.90'
database = 'dbname'
username = 'username'
password = 'pwork'
driivver = '{ODBC Driver 17 for SQL Server}'
samgiongzon='DRIVER='+driivver+';SERVER='+server+\
                 ';DATABASE='+database+';UID='+username+\
                 ';PWD='+password+';Trusted_Connection=no;'
pyodbc.connect(samgiongzon, autocommit=True)

it worked for me; you need to install driver from here

https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver15

or (in ubuntu) sudo apt-get install unixodbc-dev if you get an error with pip install pyodbc

A: if any one are trying to access the database which is hosted in azure then try to give the driver as ODBC Driver 17 for SQL Server


text:
Q: How do I find the lowest $n$ for which $a^n \equiv 1 \pmod{b}$? This is mostly related to doing large modular exponentiation by hand. For example, a problem I was doing was to find the last 3 digits of $7^{9729}$; that is, find $7^{9729}\bmod{1000}$.
Using the simplest concept for Euler's theorem, I found that $7^{400}\equiv 1\pmod{1000}$, since $\varphi(1000)=400$. Using Carmichael's theorem, I found a smaller number, $7^{100}\equiv 1\pmod{1000}$, as $\lambda(1000)=100$. Now, by manually multiplying it out, I found that $7^{20}\equiv 1 \pmod{1000}$, and that is the first $n$ for which that is true, meaning I just need to find $7^9 \bmod{1000}$, making the answer 607.
Is there a way to arrive at this answer without multiplying it out each time for every number I get? For example, could I do something like $13^{12937}\bmod{1000}$ without sitting around modding out multiples of $13^4$? (I know that the first $n$ for 13 would be 100, so no less than using Carmichael's theorem, but I want to know if there are other ways to find numbers lower than those given by Carmichael's theorem)

A: If $\rm\: gcd(a,10)=1\:$ then order of $\rm\: a\:$ in $\:\mathbb Z/1000 \:$ must be a divisor of $100 = \lambda(1000)$. You can compute the order simply and quickly by computing in order  $\rm a^2, a^4, a^5, a^{10}, a^{20}, a^{25}, a^{50}\:$ by squaring or multiplying previous entries. This requires at most 5 squaring and 2 multiplication operations $\rm (mod\ 1000)$. Obviously the same sort of optimized divisor lattice searching works for any modulus.
Alternatively we can use the following well-known simple order algorithm for groups (based upon the Order Test), from Cohen's book A Course in Computational Algebraic Number Theory.

This thesis is a good reference on order algorithms in generic groups. Here's the abstract:

A: As I discuss in my answer to this question, this is a hard quantity to compute in general.  For practical purposes you should use exponentiation by squaring to test the possibilities (and you should definitely use exponentiation by squaring for computing remainders in general; this is how computer algebra systems do it).  Note that using Carmichael's theorem is not trivial, as it requires that you know the prime factorization of $b$.


text:
Q: Android Datepicker change text view Text when value changed I have a datepicker which has value of between 1-9 when the user scrolls to 1 I want it to say Night and the remaining 8 to change the text view to night. Currently my application just jumps to the last if statement and I can't seem to figure out why, it probably a small problem but I can't see it, could some one please spot my error?
Global Variables
NumberPicker numberOfDaysPicker;
int datepicker;

Oncreate
    numberOfDaysPicker.setMaxValue(9);
    numberOfDaysPicker.setMinValue(1);
    numberOfDaysPicker.setWrapSelectorWheel(true);
    datepicker = numberOfDaysPicker.getValue();

numberOfDaysPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
      @Override
      public void onValueChange(NumberPicker picker, int oldVal, int newVal) {

          if (datepicker == 1) {

              nights.setText("Night");

          } else if (datepicker < 1) {

              nights.setText("Day");

          }
      }

  });

A: Use:
if (picker.getValue() == 1) {

    nights.setText("Night");

} else if (picker.getValue() > 1) {

    nights.setText("Day");

}

The value returned from picker will give you the changed value.
I also changed the else if to > so that any other number will be changed to "Day"


text:
Q: Shiny Pauses Between Reactive Functions I have a general question about shiny reactive functions with some pseudo code to demonstrate essentially what I am trying to do. I essentially am wondering why even though each of my reactive functions are very quick, but when I am running the shiny app, there seems to be a significant delay between each of the functions. Thus, what seems to be making the app slow is not my individual functions but rather whatever is happening in between my reactive functions. This is pseudo code for what I am trying to do with some comments. If you need a complete reproducible example, it may take me awhile to create one, but I will eventually finish it. As for now, I am trying to just explain my thought process and see if this is some higher-level conceptual thing about reactive functions that I should take a look at to solve my speed issue.
## Global variables: long_list, initial_df

shinyApp(ui = fluidPage(
              titlePanel("Example"),
              sideBarLayout(
                 sideBarPanel(

                    ## long_list is a variable that contains all of the possible choices.
                    ## There are many choices.

                    selectInput("symbols",
                                "Possible Choices",
                                long_list)

                    ## Have a few conditional panels. These
                    ## contain date range sliders and tables.

                    conditionalPanel(
                        tableOutput("table1")
                        tableOutput("table2")
                                .
                                .
                                .
                        tableOutput("table10")
                    ),
                    conditionalPanel(
                        tableOutput("table11")
                    )
                 ...),
                 mainPanel(

                    ## many plots being rendered

                    rCharts::showOutput("plot1", "nvd3"),
                    rCharts::showOutput("plot2", "nvd3"),
                            .
                            .
                            .
                    rCharts::showOutput("plot10", "nvd3"),
                    conditionalPanel(
                         ## some condition
                         rCharts::showOutput("plot11", "nvd3")
                    )
                ...)
              )
            ),
     server = function(input, output) {

              ## returns a data frame that reacts to a change in some input,
              ## such as a radio button or a slider, and then returns a
              ## dataframe that my plotting functions will use. It filters
              ## a global data frame by a certain symbol in this pseudo example.
              ## This makes the data frame of interest smaller and thus results
              ## in different plots depending on which symbol the user chooses.

              filtered_data_frame <- reactive({

                 ## df is a global variable that contains a pre-calculated data frame.

                 if(!is.null(input$symbols)) {
                    return(dplyr::filter(df, symbol == input$symbols))
                 }

                 ## if the initial check does not pass (we have a null symbol)
                 ## then we return NULL. This is for validation in the
                 ## plotting functions to do nothing if this function returns
                 ## NULL

                 return(NULL)
              })

              output$plot1 <- rCharts::renderChart2({

                  ## checks to make sure the function above returns a non-null
                  ## result before proceeding. Otherwise does nothing (empty string "")

                  validate(
                      need(!is.null(filtered_data_frame()), "")
                  )

                  ## nvd3 plot using rCharts

                  g <- nPlot(...)
                  g
              })

              output$plot2 <- rCharts::renderChart2({
                  validate(
                      need(!is.null(filtered_data_frame()), "")
                  )
                  g <- nPlot(...)
                  g
              })

              ## This continues for say 11 plots, (i.e. output$plot3...output$plot11)
              ## and similarly the for say 11 tables, (i.e output$table1...output$table11)
              ## The tables render data frames.
    }
)

Now each of the reactive functions, (i.e. filtered_data_frame(), output$plot1, output$table1...output$plot11, output$table11) are all individually very quick. I put a print statement for the start of each function and the end of each of function and they almost pretty instantaneously one after the other. For example:
 output$plot1 <- rCharts::renderChart2({
     validate(...)

     print("start")
     ...
     g <- nPlot(...)
     ...
     print("end")

     ## g is the name of the plot I return

     g
})

I have these "start" and "end" print statements for each of my reactive functions, and each individual function runs very quickly, but there are pauses between one function's "end" and another function's "start" that I cannot explain. I am not too sure what is causing these long pauses. I spent a lot of time optimizing each of my functions only to find out that most of the time did not seem to be within the functions but perhaps something slow with the reactive nature of shiny. Is there a way to reduce the long pauses between reactive functions in shiny? If more information is needed, I can provide a full reproducible example, but again it would probably take awhile to make an application that has as long of pauses as mine does.
I did notice that when I used a larger dataset as input (a larger dataset for the initial_df global variable), my app did run slower, but again not so much within each of the functions but rather long pauses between functions. Does anyone have any insight into this issue? Any help is greatly appreciated! Thank you!


text:
Q: How to detect a certain increment in a for-loop without a separate variable? Basically, every time in a for/loop how do you know when you hit a certain increment?
A way to do is to use a second variable as a counter, like this:
int i2 = 0;
for(int i=0;i<70;i++){
  if(i2==7){ i2=0; @Model.Value  }
  i2++;
}

This writes @Model.Value once for every 7 times it loops.
Is there a way to avoid using a second variable (i2)--A shorthand way to do something like this?

A: Use modular arithmetic:
for (int i = 0; i < 70; i++)
{
    if (i % 7 == 0)
        // Do stuff
}

A: I think you want to use the modulus operator, which returns the remainder after doing a division operation. Since you want it to happen every seventh iteration, you would use % 7. Since your index is starting at zero, you also want to add 1 to i when doing the division, or else it will start on your eighth iteration (when i is seven).
for (int i = 0; i < 70; i++)
{
    if((i + 1) % 7 == 0) @Model.Value;
}

A: Follow this format
 for (;;)
     statement;

In your example you would accomplish your task by writing:
for (int iii = 0; iii < 70; iii++){
   if (iii % 7 == 0)
   (@Model.Value)
   }


text:
Q: Cannot Open Remote Connection to Postgres, FirewallD Issue? I have tried everything I could find to establish a remote connection to my Postgres 9.6 database running on a CentOS 7 gcloud VM.
I have set the following in pg_hba.conf:
host all all MYPUBLICIP/24 md5

postgres.conf:
listen_addresses = '*'
port = 5432

Setup firewalld like in this article: How to Configure 'FirewallD' in RHEL/CentOS 7 and Fedora 21 - Part 3
Result of firewall-cmd --list-all:
trusted (active)
  target: ACCEPT
  icmp-block-inversion: no
  interfaces:
  sources: 50.236.122.225/24
  services: postgresql
  ports: 5432/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

There is no interface. I tried adding one using firewall-cmd --zone=public --change-interface=eth0 but that did change anything.
I tried using iptables instead but without success. Iptables is now removed so it cannot interfere.


text:
Q: iOS-How to display Gold color I'm trying to set the background color of my view to gold. I've found RGB values for several tones of this value. For this I simply do this:
[myView.backgroundColor=[UIColor colorWithRed:252.0 green:194.0 blue:0 alpha:1.0]];

But i just get the same color as for the yellow. The same is true for silver color. I get the same color as for white. Is there a way to achieve this or iOS does not support this?

A: UIColor takes color percentages, from 0-1, instead of 0-255. Divide those RGB values by 255.0 to get the desired color.
UIColor Reference

A: Xcode 11 Swift 5
you can work with color literals !
var gold = #colorLiteral(red: 0.9882352941, green: 0.7607843137, blue: 0, alpha: 1)

It renders like this ...

A: color values are between 0 to 1.0f
myView.backgroundColor=[UIColor colorWithRed:252.0/255.0
                                 green:194.0/255.0 blue:0 alpha:1.0];

A: Metallic appearance cannot be accurately expressed by a solid color because part of what gives metal it's characteristic look is it's sheen.  The same is true of fluorescence.  If you're attempting to simulate a metallic surface then you need to simulate metallic sheen.

A: Gold is not a RGB color, gold is reflective, this means it reflects the color of everything else but with a warm yellow coloring.
Check this out for a good gold gradient: Gold gradient on deviant art


text:
Q: javascript percentage rounding I have a value of 0.9019497053624151. It needs to display 90, so it is ideal to use the ff formula? by the way this is a percentage

console.log(Math.round(0.9019497053624151 * 10) / 10 * 100);

I tried rounding it off to 1 decimal place and then * 100, should I round it to 1 or 2 decimal places?
What do you call this percentage rounding? That from a value of 0.9019497053624151% the expected result is 90%

A: Your question is 100% clear, but you should round it to 2 decimal places if you want only whole percents.
Also because you are using the round function, just multiply it by 100 (i.e. convert to percentage) and let it round to the nearest whole if that is what you are trying to accomplish.

console.log(Math.round(0.9019497053624151 * 100));

A: Are you trying to write precentage of random number or something like that?
Math.floor(Math.random() * 100) + 1 %

Math.random creates a float like [0,1[
Math.floor returns the largest integer less than or equal to a given number.

A: You can use the toFixed method (see documentation here)
You can specify the number of decimal you want. Example :

console.log(0.9119497053624151.toFixed(2));
console.log(0.9119497053624151.toFixed(4));
console.log(0.9119497053624151.toFixed(1));
console.log(0.9.toFixed(2));

You can then easely multiply it by 100 as you want :)
myNumber.toFixed(2) * 100


text:
Q: How to get rid of "[podname] not installed..." warning? I (for the life of me) cannot get rid of this warning.

Basically, I originally had the pod SwiftLint installed, but I eventually decided to remove it. To do this, I thought simply removing the line 'pod SwiftLint' from my Podfile, then performing the Terminal command git install would do the trick. Well it did...mostly...except lo and behold, this warning appeared.
Now, I've tried everything I can possibly think of to get rid of this warning, but I have been unsuccessful. Does anybody know how to get rid of this??
Things I've tried:

*

*Deintegrated Cocoapods and then re-added only the pods I wanted (I.e. NOT SwiftLint).

*Deleted the project's DerivedData folder

*Reinstalled SwiftLint and then deleted it again with the command pod install --no-repo-update

*Other things which I can't remember

Any help would be much appreciated, thank you.

A: When you were installing SwiftLint, you probably followed the instructions in the "Xcode" section of their README, to add a build phase that runs this script:
if which swiftlint >/dev/null; then
  swiftlint
else
  echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

This script tries to run swiftlint whenever you build the project, and if swiftlint is not found, it outputs the warning that you see.
If you are not using SwiftLint anymore, you can just remove this build phase:


text:
Q: Chrome extension and history.onVisited event I'm new to the Chrome extensions development, and i have the following questions:
My extension should work in background, with no UI, and show an alert dialog every time the user visits a specific web page. So it should work always, in backround, when the browser is executed.
I was trying with the following code without results:
manifest.json
{
  "name": "My First Extension",
  "version": "1.0",
  "description": "The first extension that I made.",
  "background_page": "background.html",
  "permissions": [
    "history"
  ]
}

background.html
<html>
<head>
<script>
chrome.history.onVisited.addListener(function(HistoryItem result) {
    if (result.url == "http://my.url.com") {
        alert("My message");
    }
});
</script>
</head>
</html>

What's wrong with this code?
Thanks

A: Take HistoryItem out of the function and you are fine:
<html>
<head>
<script>
chrome.history.onVisited.addListener(function(result) {
    if (result.url == "http://my.url.com/") {
        alert("My message");
    }
});
</script>
</head>
</html>

Also note that I added the slash at the end of "http://my.url.com/" since that is what will be returned in result.url.

A: Test this:
<script>
chrome.history.onVisited.addListener(function(e) { console.log(e)})
</script>

it's clearly


text:
Q: Meaning for `survived its reign...` The context of this part of text is Chaos:
Prophets foretell if its coming... Historians record its passing.
And the only ones who can fully understand it are those who have survived its reign...
Could you please explain the phrase who have survived its reign...
I understand it in this way: The chaos conquered on the planet, and somewhere ages hence after it has gone, people who survived are the only ones who can fully understand it.

A: Your current understanding is correct. 'Those who have survived' refers to everyone who was alive during the chaos who still was alive after the chaos.


text:
Q: PhoneGap Backbone App Events fire on new view This is a tricky problem to explain but I will try my best:
In Short: I have a Phonegap application that is using Backbone. When a touch event (on element A) is triggered on a view (lets say View A) and that event navigates to a new view (View B). An event is fired on an element (element B) on View B if element B is in the same position as element A.
Detailed: As mentioned above, the application makes use of Backbone. The problem only occurs on a mobile device and not on a browser on my machine. I have implemented jQuery Touch events to work with normal jQuery.
Snippet from my Router:
routes : {
    "cart" : "cart",
    "menu" : "menu"
},
cart: function (args, options) {
    var options = options || {};
    var view = App.Router.loadView(new App.Views.CartView(options), {access:true});
    return view;
},
menu: function (args, options) {
    var options = options || {};
    var view = App.Router.loadView(new App.Views.MenuView(options));
    return view;
},
loadView: function (view, options) {
    var options = options || {},
        returnview = view;

    if (App.view) {
        //Close views and subviews
        _.each(App.view.subViews, function (subView) {
            subView.close();
        });
        App.view.close();
    }
    App.view = returnview;
    return $('#app-content').append(App.view.render().$el);
}

Snippet from MenuView
events: {
    'tap #cart': function () {
        App.Router.navigate('cart', {trigger:true});
    }
},

Snippet from my CartView
'change #article-stock': function (e) {
    alert('this should not happen!')
}

The scenario presents itself when I tap on an element on my menu (#cart), which in turn calls navigate, which creates the new view (CartView). CartView has a checkbox that is in the same position as where the #cart element was on the previsou view. When CartView is rendered the checkbox is toggled and I receive the alert, even though there was not event on that view. Its as if the event on the previous view bubbles through to the next view.
I obviously don't intent for this to happen. Does anyone know why this occurs, and how can this be prevented?
I hope I explained the issue well enough.
I have searched for a solution to my problem, but the only results I find are relating to events firing twice on the same view and not a single event firing on multiple views

A: Whilst going through my questions today I saw this one, and thought I would post my solution to this problem if anybody ever has the same issue.
I was never able to fully figure out what the actual cause of the problem was, my guess is that it is just the way the Android browser handles events, but by adding e.preventDefault(); to my events fixed it:
Snippet from MenuView
events: {
    'tap #cart': function (e) {
        e.preventDefault();
        App.Router.navigate('cart', {trigger:true});
    }
},

Snippet from my CartView
'change #article-stock': function (e) {
    e.preventDefault();
    alert('this should not happen!')
}


text:
Q: using libcurl with chilkat getting errors i'm using chilkat and libcurl in same project when i build the project with

Runtime Library => Multi-threaded DLL (/MD)

then i get these errors and warning:
Error   4   error LNK1169: one or more multiply defined symbols found
Error   1   error LNK2005: __invoke_watson already defined in MSVCRT.lib(MSVCR90.dll)
Error   2   error LNK2005: __strdup already defined in LIBCMT.lib(strdup.obj)
Warning 3   warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

and when build with

Runtime Library => Multi-threaded (/MT)

Error   54  error LNK1169: one or more multiply defined symbols found
Error   44  error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
Error   45  error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
Error   11  error LNK2005: ___iob_func already defined in LIBCMT.lib(_file.obj)
Error   39  error LNK2005: __beginthreadex already defined in LIBCMT.lib(threadex.obj)
Error   47  error LNK2005: __close already defined in LIBCMT.lib(close.obj)
...

A: Chilkat offers both "Multithread DLL" and "Multithread" (i.e. static) libs.  Make sure you link with ChilkatRelDll.lib instead of ChilkatRel.lib
This error occurred due to linking ChilkatRel.lib in Multithread DLL Runtime Project which occurs same lib file more than one time, which occurred multiple definitions of a function. these symbols are present in libcmt.lib
You can resolve this problem by using Runtime Library as Multi-threaded DLL (/MD) and
Adding "libcmt.lib" to the "Ignore Specific Library" field doesn't get me past this problem.

A: Chilkat offers both "Multithread DLL" and "Multithread" (i.e. static) libs.  Make sure you link with ChilkatRelDll.lib instead of ChilkatRel.lib


text:
Q: Sparse Mixed Model with lme4 or other package I use mixed models on a large file (500000 rows).
My model formula looks like this:
Y ~ 0 + num1:factor1 + num1:factor2 + num2:factor3 + factor4 + (0 + num3|subject) +  (0 + num4|subject) + (1|subject),
where num - numeric variables; factor - categorical variables/factors.
Since categorical variables have many unique levels, the fixed effects matrix is very sparse (sparsity ~0.9).
Fitting such a matrix if it is handle as dense requires a lot of time and RAM.
I had the same problem with linear regression.
My dense matrix was 20GB, but when I converted it to sparse it became only 35 MB.
So, I refused to use lm function and instead it used two another functions:

*

*sparse.model.matrix (to create a sparse model/design matrix) and

*MatrixModels:::lm.fit.sparse (to fit a sparse matrix and calculate coefficients).

Can I apply a similar approach to mixed models?
What functions / packages can I use to implement this?
That is, my main question is whether it is possible to implement mixed models with sparse matrices?
What functions should I use to create X and Z sparse model matrices?
Then, which function should I use for fitting the model with sparse matrices to get coefficients?
I would be very-very grateful for any help with this!

A: *

*As of version 1.0.2.1 on CRAN, glmmTMB has a sparseX argument:

sparseX: a named logical vector containing (possibly) elements named
"cond", "zi", "disp" to indicate whether fixed-effect model
matrices for particular model components should be generated
as sparse matrices, e.g. 'c(cond=TRUE)'. Default is all
'FALSE'

You would probably want glmmTMB([formula], [data], sparseX=c(cond=TRUE)) (glmmTMB uses family="gaussian" by default).
glmmTMB is not quite as fast for linear mixed models as lme4 is: I don't know what your mileage will be (but will be interested to here). There is also some discussion here about how to hack the equivalent of sparse model matrices in lme4 (by letting the many-level factor be a random effect with a large fixed variance).


text:
Q: Based on HTML forms I have been trying to create a form in which when we click the button with respective values from 1 to 10 then the selected number gets written in the input "Name".
The code is as follow:

function validateForm() {
  var x = document.forms["myForm"]["fname"].value;
  if (isNaN(x) || x < 1 || x > 10) {
    alert("Number should be between 1 to 10");
    return false;
  }
}

function click(theid) {
  var text = theid.toString();
  var val = document.forms["myForm"][text].value;
  val = Number(val);
  document.forms["myForm"]["fname"].value = val;
}
<!DOCTYPE html>

  <form name="myForm" onsubmit="return validateForm()" method="post">
    Name: <input type="text" name="fname" id="fname"><input type="submit" value="Submit">

    <input type="button" value="1" id="one" name="one" onclick="click('one')">
    <input type="button" value="2" id="two" onclick="click('two')">
    <input type="button" value="3" id="three" onclick="click('three')">
    <input type="button" value="4" id="four" onclick="click('four')">
    <input type="button" value="5" id="five" onclick="click('five')">
    <input type="button" value="6" id="six" onclick="click('six')">
    <input type="button" value="7" id="seven" onclick="click('seven')">
    <input type="button" value="8" id="eigth" onclick="click('eigth')">
    <input type="button" value="9" id="nine" onclick="click('nine')">
    <input type="button" value="10" id="ten" onclick="click('ten')">
  </form>

Number clicked is not being written in the input

A: Try this, I changed the name of click() to myFunction()

       <!DOCTYPE html>

      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width">
      <title>JS Bin</title>

               <!DOCTYPE html>

                <form name="myForm" onsubmit="return validateForm()" method="post">
                Name: <input type="text" name="fname" id="fname"><input type="submit" value="Submit">

                <input type="button" value="1" id="one" name="one" onclick="myFunction('one')">
                <input type="button" value="2" id="two" onclick="myFunction('two')">
                <input type="button" value="3" id="three" onclick="myFunction('three')">
                <input type="button" value="4" id="four" onclick="myFunction('four')">
                <input type="button" value="5" id="five" onclick="myFunction('five')">
                <input type="button" value="6" id="six" onclick="myFunction('six')">
                <input type="button" value="7" id="seven" onclick="myFunction('seven')">
                <input type="button" value="8" id="eigth" onclick="myFunction('eigth')">
                <input type="button" value="9" id="nine" onclick="myFunction('nine')">
                <input type="button" value="10" id="ten" onclick="myFunction('ten')">
                </form>


text:
Q: Django urlpatterns, instances? From the official docs:

urlpatterns should be a list of url() instances.

For example:
from django.conf.urls import include, url

urlpatterns = [
    url(r'^index/$', index_view, name='main-view'),
    url(r'^weblog/', include('blog.urls')),
    ...
]

Here is where I get confused, url() is not just a function ? Why they use OO terminology or thats valid or I missing something?

A: This is just loose phrasing. url() is a function that returns a RegexULRPattern instance; but you'd never instantiate that class directly yourself, url() is the interface to it.


text:
Q: How to format a date string to a full text DD MM YYYY? I know this question have been often asked, but I havn't found a way to format a date string to full text without any library.
Example:
"2020-10-23T13:00:48.207Z" =>  "October, 23rd 2020".
It would bother me to install a full date library just for a simple string. Also, is it possible to get this date in any language ("23 Octobre 2020" for exemple)?

A: "Without any library" is a though call without knowing your environment, but most browsers support Intl.DateTimeFormat

console.log(
  new Intl.DateTimeFormat('en-US', { dateStyle: 'full' }).format(new Date())
// => "Wednesday, December 16, 2020"
);


text:
Q: How to disable Rule: one-line in TSLint  clearFile()
 {
      (<HTMLInputElement>document.getElementById('uploadFile')).value = "";
 }

Gives
[tslint] misplaced opening brace

.
And if I use the opening braces in same line of function, it doesn't give me warning like
clearFile(){
      (<HTMLInputElement>document.getElementById('uploadFile')).value = "";
 }

This rule is called "one-line" rule
And how to configure it in TSLint to handle first type of braces style
Thanks in advance

A: If you want to globally turn of Goto {ProjectDirectoty}/tslint.json and add "one-line" : false in rules
One-line has 5 sub rules as "check-catch", "check-finally", "check-else", "check-open-brace", "check-whitespace". You can understand it from name, like for catch you should or not write opening braces in same or next line.
{
"extends": "../tslint.json",
"rules": {
    "one-line" : false,
    "directive-selector": [
        true,
        "attribute",
        "app",
        "camelCase"
    ],
    "component-selector": [
        true,
        "element",
        "app",
        "kebab-case"
    ]
}

}
If you want to turn off only specific subrule, use something like this
"one-line": [true, "check-catch", "check-finally", "check-else"]

It will turn on for these 3 rules and off for other 2 rules
And if you want to disable in a particular file
/* tslint:disable:rule1 rule2 rule3... */ in that file


text:
Q: Git Flow: creating, testing, and deploying "feature" branches I've been using git-flow at my company for a little while now and have come across a certain situation various times that boggles me.  I'm trying to figure out a best practice to integrate new features to an existing published site via git-flow, where I will need to test these features and then publish them in separate groupings.
I have set up both a staging and production site.  I deploy from my develop branch to the staging site and run a git-flow release when my develop branch looks good and I want to deploy my changes from master to the production site.  This works fine as long as I can publish all of my changes all at once.  I have recently had many requests from clients to publish change orders in chunks - meaning I will be working on 4 features and they will want 2 of those features published in 1 week and the other 2 in 2 weeks.  I figured that just using git-flow feature branches and "finishing" the branches that need to be published together would solve my issues, but it has left me with many more questions
When I create a feature branch for each of the new features, I find many times that I need to use some css or js that I had committed to another feature branch (because it also pertained to that branch).  I also have a feeling that I'm going to have to deal with a lot of merge conflicts when I git-flow "finish" these branches back into develop (because their commits share a lot of the same files).  The client also wants to see an active version of all of the changes that I'm making, and when I have them siloed into different feature branches, I'm not sure how to show them together unless I merge or rebase them into the develop branch and push to the staging site.  This would ruin my opportunity to publish them in batches.  I thought about maybe creating another branch for testing and rebase my feature branches on this branch, but I'm not sure if that will solve my issues because my feature branches are still isolated when I'm working on them.
I can't seem to find any workflows that will allow me to meet these requirements, so I would greatly appreciate any help.

A: I recently did some research in aims of solving the same issue and settled on a "branch per feature" strategy. The name suggests much of the strategy, but here are some great articles that describe it in detail:
http://www.acquia.com/blog/pragmatic-guide-branch-feature-git-branching-strategy
https://github.com/affinitybridge/git-bpf/wiki/Branch-per-feature-process
Hope this helped


text:
Q: Python 2.7 Pysinstaller with pysftp lib I'm trying to write a very simple SFTP uploading utility that I can deploy to multiple Windows machines so I'd like to compile it as an exe using pyinstaller (I have also tried py2exe).
I am having issues with getting the compilation to work; when I run the .exe after building it, it crashes and gives an error window that says "Failed to execute script".
I assume this has something to do with the pysftp library (only other import in the script is 'os') - does anyone have any suggestions on next steps?
EDIT: I'm thinking there is something off with the lib I am trying to use (potentially how it is installed?). In order to try to circumvent that issue I am now trying to use paramiko directly (which is the lib that pysftp leverages). I get the same exact issue trying to use this lib - Failed to Execute script.
Thanks.

A: I have the same issue. When I try to compile this simple pysftp script with pyinstaller, it seems it is trying to execute the script during the compilation.
import pysftp
sftp = pysftp.Connection('1.2.3.4', username = 'username', password = 'password', port = 'port')
#
# ... do sftp operations
sftp.listdir()
#
sftp.close()
test = raw_input('Press enter..')`


text:
Q: Content pulled in via jQuery AJAX is not associating with previous functions I'm using the jQuery .load() function to pull in data to populate a div with. The content I'm pulling in has CSS selectors that should match up with jQuery click functions I've written. However, when I load in the data, although the correct CSS selectors are there, when I click on areas that should invoke a response from jQuery, nothing happens.
Do I need to do some sort of reload?
Here's the code I've got for the jQuery AJAX:
$(document).ready(function() {
// AJAX functionality for drupal nodes
$(".ajax_node").click(function() {
    var ajax_src = $(this).attr("href"); // we're gonna load the href

    // empty target div and load in content
    // the space in the string before the #id is necessary
    $("#ajax_area").empty().load(ajax_src + " #ajax_wrapper");
    return false; // stops the link from following through
});

// General AJAX functionality
$(".ajax").click(function() {
    var ajax_src = $(this).attr("href");
    $("#ajax_area").empty().load(ajax_src);
    return false;
});
});

A: It's not working because you're essentially recreating the elements when you pull them in via load and you need to rebind the event handlers. I recommend using jQuery's live binding

A: Instead of this format:
$(".ajax_node").click(function() {

Use .live() for current and future elements, like this:
$(".ajax_node").live('click', function() {

The why: .live() listens for the event to bubble up at the DOM root, or document.  It's a single event handler bound there...it doesn't matter when an element was added, they all bubble the click the same, when the click gets there: it checks the selector, if it matches it runs the handler.
Why your current method doesn't work: It's finding all the elements that match that selector at that time and binding the handler...new elements aren't there, so don't get that handler.  You have 2 options to solve this, either use .live() which works in a different way, as described above, or re-bind the handler to that selector in the content of the request, like this:
function callback(data) { //your success callback, e.g. .load(url, callback)
  $(".ajax_node", data).click(myFunction);
}

In your case, I think .live() is much easier, you generally do the second with widgets and such, not strictly event handlers...but whatever floats your boat.


text:
Q: Translation of data during import I am importing approx 350,000 lines from a CSV file into MySQL using PHP (Symfony Framework if that matters) I am reading in each line and inserting into the SQL table as I go. This will be a daily process - and the number of lines will increase.
I have to translate 2 of the columns to a number (which is a foreign key). I want to know the most efficient way of doing it. I am experimenting with using a lookup table in MySQL and also an array in PHP - but I am wondering if there is a more efficient way.
There are approx 60 different combinations the 2 columns could be, here is an example of the translation table I have
Feature         Type          CODE
ANZIRL          Voice Call    8
BT2DT2          Data Call     6
BT2IL2          Voice Call    1
BT2UK2          Voice Call    2
DG2DG2          Voice Call    4
DG2DT2          Data Call     3
DG2EC           Voice Call    1
DG2EDQ          Voice Call    5
DG2EZY          Voice Call    7

And the CSV will be as follows
DG2DG2,x,x,x,Voice Call,x,x
DG2DT2,x,x,x,Data Call,x,x

etc...
I need to insert that into my table as
x,4,x,x
x,3,x,x

etc ....

A: I would batch import the CSV file into MySQL as is (i.e. create a table that mirrors CSV field layout), and then run a query against the CSV import table to get the foreign key code.
Something like:
INSERT into sometable (code,other,fields)
SELECT code, other, fields
FROM codes c
JOIN csvtable ct
WHERE ct.feature = c.feature AND ct.type = c.type

Basic idea is to not perform processing on row-by-row basis in PHP or MySQL, but to get all the data into MySQL and then run some version of above query to efficiently do the foreign key translation in 1-step.
If you go row-by-row with 350,000+ records, that will be a fairly slow process, php is not terribly efficient...


text:
Q: Unexpected types from UINT32_C, UINTN_C
7.20.4.1 Macros for minimum-width integer constants
  ... The macro UINTN_C(value) shall expand to an integer constant expression corresponding to the type uint_leastN_t. For example, if uint_least64_t is a name for the type unsigned long long int, then UINT64_C(0x123) might expand to the integer constant 0x123ULL.  C11dr §7.20.4.1 1

The type of UINTN_C() and friends are not as expected.  See "Expected" comments in code output.
A) Is my compiler implementation wrong and the constant type should be uint_leastN_t?
or
B) Should the type of constant from UINTN_C(value) be the minimum of uint_leastN_t, int, unsigned and type needed to encode the value?
or
C) something else?

I had expected that the type of the constants to correspond to uint_leastN_t, but it appears to not be so under 2 conditions:
**1 If the macro corresponding type is below int/unsigned, the constant is int/unsigned
**2 If the value exceeds the range of the uint_leastN_t, then the type becomes a wider type constant.

§6.4.4.1 "The type of an integer constant is the first of the corresponding list in which its value can be represented ... (long list follows).

#include <limits.h>
#include <stdio.h>

#define type_of(X) _Generic((X), \
  unsigned long long: "unsigned long long", \
  unsigned long: "unsigned long", \
  unsigned: "unsigned", \
  int: "int", \
  unsigned short: "unsigned short", \
  default: "?" \
  )

int main() {
  uint_least16_t u16 = 0;
  uint_least32_t u32 = 0;
  uint_least64_t u64 = 0;
  printf("%zu %s\n", sizeof(u16), type_of(u16));
  printf("%zu %s\n", sizeof(u32), type_of(u32));
  printf("%zu %s\n", sizeof(u64), type_of(u64));
  puts("");
  printf("%zu %s\n", sizeof((uint_least16_t) UINT16_C(0)), type_of((uint_least16_t) UINT16_C(0)));
  printf("%zu %s\n", sizeof UINT16_C(0), type_of(UINT16_C(0)));
  printf("%zu %s\n", sizeof UINT16_C(0x1234), type_of(UINT16_C(0x1234)));
  printf("%zu %s\n", sizeof UINT16_C(0x12345), type_of(UINT16_C(0x12345)));
  printf("%zu %s\n", sizeof UINT32_C(0x12345678), type_of(UINT32_C(0x12345678)));
  printf("%zu %s\n", sizeof UINT32_C(0x123456789), type_of(UINT32_C(0x123456789)));
  return 0;

  //round_frac_test(-2.05446162500000000e+06, 205);
  round_frac_test(fp_rand(), 6);
  round_frac_tests(10000);
  puts("Done");
  return 0;
}

Output
2 unsigned short
4 unsigned
8 unsigned long long

2 unsigned short
4 int       // Expected 2 unsigned short, see **1
4 int       // Expected 2 unsigned short, see **1
4 int       // Expected 2 unsigned short, see **2
4 unsigned
8 unsigned long long  // Expected 4 unsigned, see **2

I am using (GNU C11 (GCC) version 5.4.0)
In forming this post, I am leaning toward B, yet I am looking for your rational for confirmation -one way of the other.   If B is so, a disappointing part is that UINTN_C() could result in a signed type.
I suppose that is what the "minimum-width" part is about.

A: This is covered in the parent subsection, 7.20.4.
In the portion you quoted:

The macro UINTN_C(value) shall expand to an integer constant expression corresponding to the type uint_leastN_t.

it says "corresponding to", not that the expansion is actually of that type.  The meaning of "corresponding to" is explained in 7.20.4p3:

Each invocation of one of these macros shall expand to an integer
  constant expression suitable for use in #if preprocessing directives.
  The type of the expression shall have the same type as would an
  expression of the corresponding type converted according to the
  integer promotions. The value of the expression shall be that of the
  argument.

Since the macros are intended to be used in an #if directive, they cannot use casts (the preprocessor doesn't understand casts or type names).
In practice, such a constant expression will almost always be implicitly converted to the appropriate type, so the fact that its actual type differs from what you might expect is not generally a problem.
As for a value outside the range of uint_leastN_t, that's also covered in the parent subsection, in 7.20.4p2:

The argument in any instance of these macros shall be an unsuffixed
  integer constant (as defined in 6.4.4.1) with a value that does not
  exceed the limits for the corresponding type.

This is a "shall" outside a constraint, so violating it causes undefined behavior.  Don't do that.
(When reading the C standard, it's generally a good idea to check the parent subsections for wording that might clarify or override what you're reading. I've been bitten by this myself.)

A: On the host with 16 bit short and 32 bit integers unsigned short numbers are promoted to int. So the those macros are defined as:
#define INT16_C(x) (x)
#define UINT16_C(x) (x)

with no 'U' suffix for the unsigned short

If an int can represent all values of the original type (as restricted
  by the width, for a bit-field), the value is converted to an int;

Those macros do only expand to the corresponding constants (or integer literals using more common language), and do not create any objects, and have to usable in the #if. So no casts are allowed. Macros do not perform any range checks as well.
int16_t x0 = 123;
uint16_t x1 = 123;    // no sign suffix needed
int32_t x2 = 2147483647;
uint32_t x3 = 2147583647U;  //sign suffix theoreticaly needed as int and unsigned int have the same rank
int64_t x4 = 9223372036854775807LL;
uint64_t x5 = 9237372036854775807ULL; //same as above


text:
Q: Android emulator throws system UI not responding Although this question has been answered quite some times before but the solution is not working for me.
My android emulator throws system UI not responding over and over. I've tried the below solution:
1.Open AVD Manager. enter image description here
2.Click to edit button for your device. enter image description here
3.Select Hardware in the Graphics drop down menu.

Using:

*

*android studio version: 4.1.3

*flutter: Flutter 2.0.6

Can anyone provide any solution?

A: Hey there you do not need to all that stuff just go to your AVD manager and click that down arrow i.e DropDown arrow and click on cold boot but make sure you are not running the device at that time as it may cause some error. It is not a permanent solution to the problem it works fine for 4-5 hours as I m not able to find the perfect solution. So it works for me and I hope it works for you too. Whoever seeing this after 2025 Please Reply me to see if I m alive. Bye!


text:
Q: Azure Functions error - establishing connection failed I have Azure Data Factory, which calls Azure Durable Functions.
I had success working connection until Terraform did some unknown changes.
Where the issue could be?

Error in Azure Data Factory:
An error occured while sending the request.
Unable to connect to the remote server.
A connection attempt failed because the connected party did not properly respond after a
period
of time, or establishing connection failed because connected host has failed to response
xx.xx.xx.xx:xxx.

A:
Error in Azure Data Factory: An error occured while sending the request. Unable to connect to the remote server. A connection attempt failed because the connected party did not properly respond after a period of time, or establishing connection failed because connected host has failed to response xx.xx.xx.xx:xxx.

I believe this error occurs due to firewall issues like some blocking rules didn't allow it to reach out to the data source. Please try using the following steps:

*

*Allow access from all networks under Firewalls and Virtual Networks of the storage account.

*As mentioned in the Azure Data Factory Security and access control troubleshooting guide, there are 2 cause like public endpoint in Managed VNet is not reliable to Azure Blob Storage and the other is Azure Blob Storage, Data Lake Gen2 are not supported through public endpoint connection from the Managed VNet Service. Please check the troubleshooting guide for the few workarounds given by Microsoft for this kind of error.


text:
Q: Different errors in using left_join in r I am trying to interpolate two series but I get different errors when it comes to use left_join. These are the two series:
df1 = structure(list(Date = structure(c(11690, 11725, 11753, 11781,
11809, 11844, 11872, 11900, 11942, 11970, 11998, 12026, 12061,
12089, 12117, 12145, 12180, 12208, 12243, 12265, 12299, 12327,
12362, 12390, 12425, 12453, 12481, 12509, 12544, 12572, 12600,
12631, 12663, 12698, 12726, 12754, 12796, 12817, 12845, 12880,
12907, 12936, 12971, 12996, 13027, 13062, 13090, 13118, 13160,
13181, 13209, 13244, 13272, 13307, 13335, 13363, 13392, 13426,
13454, 13489, 13524, 13552, 13580, 13615, 13643, 13670, 13699,
13726, 13762, 13790, 13825, 13853, 13888, 13916, 13944, 13979,
14007, 14035, 14063, 14098, 14126, 14154, 14189, 14217, 14259,
14280, 14308, 14336, 14371, 14399, 14427, 14462, 14490, 14525,
14553, 14581, 14623, 14644, 14672, 14707, 14735, 14770, 14798,
14826, 14854, 14889, 14917, 14945, 14987, 15008, 15036, 15071,
15099, 15134, 15162, 15190, 15225, 15253, 15281, 15316, 15351,
15379, 15407, 15434, 15463, 15497, 15526, 15554, 15589, 15617,
15652, 15680, 15715, 15743, 15771, 15799, 15827, 15862, 15890,
15918, 15953, 15980, 16016, 16044, 16079, 16107, 16135, 16163,
16198, 16226, 16254, 16289, 16317, 16345, 16380, 16408, 16457,
16467, 16499, 16540, 16556, 16589, 16632, 16648, 16681, 16730,
16740, 16772, 16821, 16832, 16870, 16912, 16922, 16954, 17003,
17014, 17052, 17094, 17106, 17143, 17185, 17198, 17234, 17283,
17287, 17325, 17367, 17379, 17416, 17465, 17471, 17514, 17556,
17563, 17598, 17647, 17652, 17696, 17738, 17744, 17787, 17829,
17836, 17878, 17920, 17928, 17962, 17996, 18017, 18053, 18102,
18109, 18151, 18193, 18201, 18242), class = "Date"), Fit = c(-1.68038051095608,
-2.12317945962401, -2.71086209338424, -3.22489682411764, -2.51769032592554,
-1.33242532610804, -2.13564807610995, -2.13564807610995, -2.03415137348661,
-1.58909921518124, -0.68844714029518, -1.94691881575563, -1.16714425518695,
-2.15153420569546, -2.04779261960842, -0.867515299774483, -1.47986823637587,
-0.650513604798111, -1.61361732632524, -1.61361732632524, -1.48596960028163,
-2.20004804407501, -2.64689217553021, -2.67436545120372, -3.48049123019991,
-2.28510809912552, -2.32172665536549, -1.76823348887895, -2.763353378483,
-2.09381469041352, -2.08400217235893, -2.08400217235893, -1.59720187270177,
-2.06034560841579, -2.56317571167687, -1.32635640217861, -1.48729782102413,
-2.00732693090646, -3.40272319833461, -2.49810610074565, -3.32810591309226,
-1.92402348117091, -1.35397391665409, -1.35397391665409, -1.76640461987233,
-2.51735528772741, -2.35332514240503, -2.35272634525907, -2.68468172493552,
-2.92171051216825, -3.16925509035157, -2.23093489115309, -3.06530983495044,
-2.30445613039677, -3.30583207178147, -2.82188405397887, -2.82188405397887,
-2.51962207875813, -2.66982767393931, -2.98041595989062, -2.55306093500464,
-3.36871970472208, -2.6201699311654, -2.49494986723432, -2.78910296607766,
-2.57178346785915, -3.28445145020619, -3.28445145020619, -2.42213276484722,
-2.38709926337358, -2.99568739417641, -2.65138790450656, -1.58074660422518,
-1.91906056315361, -2.90337379582732, -2.20117735700684, -1.29303194740331,
-2.2494711668963, -1.53224235243069, -2.04481468859739, -0.929377541149286,
-0.0656900034556943, -2.20508088335906, -0.578502434372448, -0.858925093713048,
-2.96970181427872, -2.97862851965814, -3.31779605911778, -2.08207766441392,
-2.4848907725881, -1.99650762208841, -2.17076028347941, -1.27061305909,
-1.92537835567221, -1.49409886851971, -2.32667673830125, -1.90852299188928,
-2.88390697795999, -2.9172411130509, -3.5788915130035, -2.92151370364156,
-2.71478221054495, -3.40505963822921, -3.21129210245385, -2.66481268506047,
-3.27494238949828, -3.37230078139583, -3.53346393522174, -3.99626066800013,
-3.41713548837371, -3.67409843863548, -3.50182175058264, -3.37467436298585,
-3.40580625489191, -2.99003362011982, -3.66653724632765, -3.61588309823573,
-3.18167532125541, -3.35619362672467, -2.8806023910338, -2.23185392156432,
-0.626338062660262, -2.00482507082523, -1.7359344838577, -0.800609837957656,
-1.93997314433068, -0.93482911672218, -2.63652739226028, -1.93546315176661,
-1.17524044037369, -2.274143231604, -2.69679235052359, -2.23731851002543,
-1.86716852238077, -0.716926538642468, -1.30258784685856, -1.08194224250233,
-0.930472602419788, 1.13081617308243, 2.57874064965174, -0.388461792958877,
-0.340421132850094, 0.638071432169484, -1.57318833539501, 4.40961161388978,
1.62060735764472, -0.674369921428344, 1.76679629890753, -0.748857461264583,
0.520407646064921, -0.575555044309392, 4.34511452569889, 3.34194433067617,
3.21304624521961, 1.97147139745885, 3.45052500620869, -0.399783726365629,
-0.399783726365629, -0.519126753266423, -0.924795366280377, -0.924795366280377,
4.49023560078066, 2.40210157814194, 2.40210157814194, 3.48634734098189,
2.72330542145941, 2.72330542145941, 2.44175433903678, 1.83754103018167,
1.83754103018167, 2.00744190890702, 2.84495436947268, 2.84495436947268,
3.68678762972081, 3.16657087164265, 3.16657087164265, 2.54382298188246,
3.23525009614645, 3.23525009614645, 2.25680930181096, 1.44116917115332,
1.44116917115332, -0.510916286085479, -0.212859586548733, -0.212859586548733,
-0.740774827758169, -0.740774827758169, -0.740774827758169, -0.740774827758169,
-0.41701391913469, -0.41701391913469, -1.22601225946438, -0.632288989161026,
-0.632288989161026, -1.04309509051099, -1.17291896442253, -1.17291896442253,
-1.17291896442253, -1.17291896442253, -1.17291896442253, -1.11302828507398,
-2.78220449305609, -2.78220449305609, -2.86224137302201, -2.86224137302201,
-2.86224137302201, 1.34122649704384, 1.33515381941954, 1.33515381941954,
2.56866171677324, 0.963485086246604, 0.963485086246604, 4.22653525972732,
5.35095831479335, 5.35095831479335, 3.93448842430935)), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -216L))

df2 = structure(list(Fit = c(-3.36981025066699, -2.83074686834444,
-3.4112766646918, -2.45754914212114, -2.16728424394746, -3.61860873481586,
-3.61860873481586, -2.2916834860219, -1.37942237747605, -3.95034004701435,
-1.46235520552567, -2.91367969639407, -3.95034004701435, -3.57714232079105,
-2.16728424394746, -2.20875065797227, -2.6648812122452, -2.74781404029482,
-2.00141858784822, -3.07954535249331, -3.07954535249331, -3.24541100859256,
-3.36981025066699, -2.49901555614595, -2.6648812122452, -3.95034004701435,
-3.0380789384685, -3.24541100859256, -3.12101176651812, -2.58194838419558,
-2.83074686834444, -3.4112766646918, -2.6648812122452, -2.99661252444369,
-3.61860873481586, -2.99661252444369, -3.57714232079105, -2.74781404029482,
-3.20394459456775, -2.25021707199708, -2.37461631407152, -3.61860873481586,
-3.36981025066699, -2.95514611041888, -3.61860873481586, -3.32834383664218,
-2.74781404029482, -3.20394459456775, -2.00141858784822, -3.12101176651812,
-3.66007514884067, -3.47347628572902, -3.95034004701435, -3.45274307871661,
-3.45274307871661, -2.83074686834444, -3.95034004701435, -2.99661252444369,
-3.61860873481586, -2.16728424394746, -3.70154156286548, -2.37461631407152,
-2.83074686834444, -2.12581782992265, -3.32834383664218, -2.6648812122452,
-3.0380789384685, -3.20394459456775, -3.4112766646918, -2.83074686834444,
-2.91367969639407, -3.95034004701435, -2.6648812122452, -3.36981025066699,
-2.2916834860219, -3.45274307871661, -2.37461631407152, -1.54528803357529,
-2.91367969639407, -3.49420949274142, -2.95514611041888, -3.32834383664218,
-2.45754914212114, -3.57714232079105, -3.36981025066699, -3.45274307871661,
-3.95034004701435, -3.16247818054293, -2.83074686834444, -3.36981025066699,
-2.6648812122452, -2.6648812122452, -2.45754914212114, -3.32834383664218,
-3.66007514884067, -3.36981025066699, -3.95034004701435, -2.83074686834444,
-2.91367969639407, -3.45274307871661, -2.20875065797227, -2.6648812122452,
-3.95034004701435, -3.95034004701435, -2.74781404029482, -2.83074686834444,
-2.99661252444369, -3.57714232079105, -3.95034004701435, -1.54528803357529,
-2.45754914212114, -2.91367969639407, -3.20394459456775, -2.83074686834444,
-3.70154156286548, -1.29648954942642, -3.36981025066699, -2.20875065797227,
-2.45754914212114, -3.24541100859256, -2.6648812122452, -1.87701934577378,
-2.83074686834444, -2.37461631407152, -3.95034004701435, -3.07954535249331,
-2.6648812122452, -2.99661252444369, -2.91367969639407, -3.49420949274142,
-3.61860873481586, -3.20394459456775, 0.44509983961565, 0.776831151814141,
-2.37461631407152, -3.61860873481586, -0.259829198806142, -2.37461631407152,
3.72094654757574, -1.37942237747605, -3.12101176651812, 0.196301355466782,
-2.20875065797227, -0.923291823203123, -2.58194838419558, 0.569499081690084,
0.486566253640461, 1.56469301828556, -1.62822086162492, 3.59654730550131,
-0.923291823203123, -2.2916834860219, -0.633026925029444, 0.486566253640461,
2.14522281463291, 1.15002887803744, 2.60135336890584, 2.97455109512914,
1.02562963596301, 1.89642433048405, 2.97455109512914, 3.38921523537725,
3.22334957927801, 3.47214806342688, 1.77202508840961, 4.05267785977424,
3.30628240732763, -0.0939635427068968, -0.342762026855765, -0.0939635427068968,
1.23296170608707, -0.342762026855765, -0.425694854905387, -3.36981025066699,
-0.674493339054255, -1.08915747930237, -1.37942237747605, -2.08435141589784,
-1.46235520552567, -1.46235520552567, -2.83074686834444, -2.25021707199708,
-3.0380789384685, 3.05748392317876, 1.15002887803744, 2.68428619695546,
0.196301355466782, 2.26962205670735, 2.85015185305471, 2.85015185305471
), Date = c("2002-01-03", "2002-02-07", "2002-03-07", "2002-04-04",
"2002-05-02", "2002-06-06", "2002-07-04", "2002-09-12", "2002-10-10",
"2002-11-07", "2002-12-05", "2003-01-09", "2003-02-06", "2003-03-06",
"2003-04-03", "2003-05-08", "2003-06-05", "2003-07-10", "2003-09-04",
"2003-10-02", "2003-11-06", "2003-12-04", "2004-01-08", "2004-02-05",
"2004-03-04", "2004-04-01", "2004-05-06", "2004-06-03", "2004-07-01",
"2004-09-02", "2004-10-07", "2004-11-04", "2004-12-02", "2005-01-13",
"2005-02-03", "2005-03-03", "2005-04-07", "2005-05-04", "2005-06-02",
"2005-07-07", "2005-09-01", "2005-10-06", "2005-11-03", "2005-12-01",
"2006-01-12", "2006-02-02", "2006-03-02", "2006-04-06", "2006-05-04",
"2006-06-08", "2006-07-06", "2006-08-03", "2006-10-05", "2006-11-02",
"2006-12-07", "2007-01-11", "2007-02-08", "2007-03-08", "2007-04-12",
"2007-05-10", "2007-06-06", "2007-07-05", "2007-09-06", "2007-10-04",
"2007-11-08", "2007-12-06", "2008-01-10", "2008-02-07", "2008-03-06",
"2008-04-10", "2008-05-08", "2008-06-05", "2008-07-03", "2008-08-07",
"2008-09-04", "2008-10-02", "2008-11-06", "2008-12-04", "2009-01-15",
"2009-02-05", "2009-03-05", "2009-04-02", "2009-05-07", "2009-06-04",
"2009-07-02", "2009-08-06", "2009-09-03", "2009-10-08", "2009-11-05",
"2009-12-03", "2010-01-14", "2010-02-04", "2010-03-04", "2010-04-08",
"2010-05-06", "2010-06-10", "2010-07-08", "2010-08-05", "2010-09-02",
"2010-10-07", "2010-11-04", "2010-12-02", "2011-01-13", "2011-02-03",
"2011-03-03", "2011-04-07", "2011-05-05", "2011-06-09", "2011-07-07",
"2011-08-04", "2011-09-08", "2011-10-06", "2011-11-03", "2011-12-08",
"2012-01-12", "2012-02-09", "2012-03-08", "2012-04-04", "2012-05-03",
"2012-06-06", "2012-07-05", "2012-08-02", "2012-09-06", "2012-10-04",
"2012-11-08", "2012-12-06", "2013-01-10", "2013-02-07", "2013-03-07",
"2013-04-04", "2013-05-02", "2013-06-06", "2013-07-04", "2013-08-01",
"2013-09-05", "2013-10-02", "2013-11-07", "2013-12-05", "2014-01-09",
"2014-02-06", "2014-03-06", "2014-04-03", "2014-05-08", "2014-06-05",
"2014-07-03", "2014-08-07", "2014-09-04", "2014-10-02", "2014-11-06",
"2014-12-04", "2015-01-22", "2015-03-05", "2015-04-15", "2015-06-03",
"2015-07-16", "2015-09-03", "2015-10-22", "2015-12-03", "2016-01-21",
"2016-03-10", "2016-04-21", "2016-06-02", "2016-07-21", "2016-09-08",
"2016-10-20", "2016-12-08", "2017-01-19", "2017-03-09", "2017-04-27",
"2017-06-08", "2017-07-20", "2017-09-07", "2017-10-26", "2017-12-14",
"2018-01-25", "2018-03-08", "2018-04-26", "2018-06-14", "2018-07-26",
"2018-09-13", "2018-10-25", "2018-12-13", "2019-01-24", "2019-03-07",
"2019-04-10", "2019-06-06", "2019-07-25", "2019-09-12", "2019-10-24",
"2019-12-12")), class = "data.frame", row.names = c(NA, -190L
))

I then used these codes to interpolate the series:
# first series
monthss <- data.frame(Date = seq(as.Date("2002-01-03"), as.Date("2019-12-12"), by = "month"), stringsAsFactors = F)
df1 <- left_join(x = monthss, y = df1, by = "Date")
df1 <- na.approx(object = df1$'as it comes from the previous step', rule = 2)

# second series

df2 <- left_join(x = monthss, y = df2, by = "Date")
df2 <- na.approx(object = df2$'as it comes from the previous step', rule = 2)

However, in the first case, I get a weird result when using left_join (I get too many NAs that don't correspond to the missing dates), while in the second case, when using left_join, I get Error: cannot join a Date object with an object that is not a Date object. For this error, I tried to look for some solutions online, but what I found doesn't help.
Can anyone help me fix this?
Thanks!

A: You get the left_join error in the second case because df2$Date is not of class Date. This fixes the second join:
library(lubridate)
# second series
df2$Date <- lubridate::date(df2$Date) #convert Date variable to date
df2 <- left_join(x = monthss, y = df2, by = "Date")
df2 <- na.approx(object = df2$'as it comes from the previous step', rule = 2)

Changing this will fix the first join:
# first series
monthss <- data.frame(Date = seq(as.Date("2002-01-03"), as.Date("2019-12-12"), by = "day"), stringsAsFactors = F)

You did a sequence by month and thus only got the dates for each month where the day is "3" e.g., 2002-01-03, 2002-02-03 etc. Thus you only got joins for Dates ending on "03" but not for other dates that you have Fit values for in df1.


text:
Q: My PHP else { // statement }; doesn't show up when no results are found using LIKE in SQL (pictures provided) <?php
include 'conn.inc.php';

$keyPressed = mysqli_escape_string($conn, $_POST['keyPressed']);

if (!empty($keyPressed)) {
    $sql = "SELECT name, type FROM businesses WHERE name LIKE '$keyPressed%' ORDER BY name";
    $result = mysqli_query($conn, $sql);
    if (mysqli_num_rows($result) > 0) {
        while ($row=mysqli_fetch_assoc($result)) {
            echo "

",
                    $row['name'],
                " (",$row['type'],")","

                <button type='button'>PIN</button>

";
        }
    } else {
        echo "0 results";
    }
} else {
    echo "Search a business and click \"Pin\" to add it to the map.";
}
?>

What I want to do should be pretty simple. I feel like I'm just missing a keyword or something.

*

*Get keystrokes from a javascript file and pass them through Ajax into this file, under the variable $keyPressed

*Find businesses by 'name' in my database

*Echo "0 Results" if keystrokes don't match any name in the database

Problem: Every time $keyPressed doesn't match a 'name', letter for letter, in my database column 'name', I get a blank return value(nothing prints to the screen). I want it to echo "0 results" if my keystrokes no longer match LIKE 'name' in my database.
I've tried putting the else statement at the end of

*

*if ($result = mysqli_query($conn, $sql)

hoping that if there are no results it will echo

*

*else {echo "0 results"};

but it's just echoing a blank space as if it's finding some sort of blank result.
All pictures of my issue are provided excluding the javascript file (which I know is not the issue).

A: as per PHP doc mysqli_query() For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.
try this
if ($result = mysqli_query($conn, $sql) && mysqli_num_rows($result)){
 ...
}else{
 ...
}


text:
Q: Routes do Slim Framework PHP Olá pessoal estou com problema ao utilizar a framework Slim... quando tento acessar via get a raiz "/" eu consigo normal, mas quando tento acessar outros metodos como "/hello" ele simplesmente n vai, da erro
" Not Found
The requested URL /slim/clientes was not found on this server."
nem mesmo com a demo esse erro persiste
segue meu codigo ...
    <?php
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->response()->header('Content-Type', 'application/json;charset=utf-8');

$app->get('/', function () {
echo "SlimProdutos";
});

$app->get('/hello', function (){
    echo "Ola";
});

$app->run();

?>

segue o .htaccess
RewriteEngine On
#RewriteBase /var/www/slim

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

A: Bom dia.
Não tenho muita experiência com o Slim, mas a forma que já fiz e funcionou foi assim:
$app->get('/hello', function() use ($app) {
 ...
}

Meu .htaccess, ficou assim:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]

Espero ter ajudado.


text:
Q: Approximation for an expectation expression Let $\mathbf{x} \in \mathbb{C}^M$ is an unknown distributed random vector (certainly not gaussian), and matrix $\mathbf{A}\in \mathbb{C}^{M \times M}$ which is fix (known). Also, assume we know the covariance of $\mathbf{x}$ or $\mathbb{E}[\mathbf{x}\mathbf{x}^{\mathrm H}]$.  Now, I'm looking for any approximation or bound for the following expression in terms of $\mathbb{E}[\mathbf{x}\mathbf{x}^{\mathrm H}]$;
$\mathbb{E}[\mathbf{x}\mathbf{x}^{\mathrm H} \mathbf{A} \mathbf{x}\mathbf{x}^{\mathrm H}]$

A: There is no such approximation or bound. E.g., suppose that $M=1$, $\mathbf A=[1]$, and $\mathbf x$ is a (random $1\times1$ matrix whose only entry is) a real-valued random variable with pdf $p$ given by the formula
$$p(x)=cx^{-4}\,1(|x|>a)$$
for real $x$, where $a:=1/\sqrt3$ and $c:=a/2$.
Then $\mathbb{E}[\mathbf{x}\mathbf{x}^{\mathrm H}]=[1]$, but
$\mathbb{E}[\mathbf{x}\mathbf{x}^{\mathrm H} \mathbf{A} \mathbf{x}\mathbf{x}^{\mathrm H}]=[\infty]$.


text:
Q: how to write a word to a database that is between 2 Apostrophes? I have a table in my database of type nvarchar(50);
I want to write to that specific column that string 'Tal' - Tal between 2 apostrophes.
When I'm trying to do so what is recorded in my DB is "Tal" - Tal between 2 quotation marks.
My database is an SQL database and so are my scripts.
How this can be solved?

A: The standard way to do what you want is this.
 insert into mytable ( mycolumn ) values ('''Tal''');

The first and last ' are the start and end markers for the string.  Each '' within these characters means '.  Refer to page 89 of the SQL 92 specification at http://www.andrew.cmu.edu/user/shadow/sql/sql1992.txt

A: I think escaping is the key to your question. For SQL apostrophes are special characters, thus they have to be escaped by '' (two apostrophes). Have you checked that your scripts do not add the second apostrophe for you? Probably you have to add Tal without the apostrophes.
Escape % seems to be DB dependant. Oracles uses \%, others accespt [%] and some seem to have a keyword ESCAPE. You have read the documentation of your database, look for "escape characters".

A: Try inserting like this using the backslash \'Tal\'.


text:
Q: PowerShell to open gzip stream Web searches for $s=New-Object IO.MemoryStream(,[Convert]::FromBase64String()) show numerous Pastebin's for similar events, but I cannot figure out how to decode it myself.  The original base64 I decode with
param(
[Parameter(Mandatory=$True)]
[string]$b64
)
[System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String("$b64"))

which gives me this:
$s=New-Object IO.MemoryStream(,[Convert]::FromBase64String("Encrypted-String"))
IEX (New-Object IO.StreamReader(New-Object IO.Compression.GzipStream($s,[IO.Compression.CompressionMode]::Decompress))).ReadToEnd();

I have been unable to figure out how to use PowerShell to decompress the "Encrypted-String" so I can analyze what's happening.
I've seen similar posts but nothing answers my question of how to decode it myself.  Any help is greatly appreciated.

A: I apologize for the formatting, I am still learning the nuances of posting questions/anwers on here.  I also apologize if my question wasn't clear, but after much luck with today's research (been trying to figure this out for the past year).
I found a link (https://blog.kenaro.com/2010/10/19/how-to-embedd-compressed-scripts-in-other-powershell-scripts/) which gave me enough information to build this script.  Thank you Ingo Karstein for your blog and all who viewed and asked for clarification.
The gzip stream is part of the results that needed further analysis which I was unable to figure out.
I create a folder in my Temp with the name of the machine that I obtained the suspicious batch file from that calls the encoded powershell command; remove all but the base64 code and rename it to a .txt file.  I then run the code below with the computername and the file name to see what the attacker was doing.  The answer that works for me:
(
[Parameter(Mandatory=$True)]
[string]$HostIP,
[Parameter(Mandatory=$True)]
[string]$file
)

New-Item C:\Temp\$HostIP\Results -ItemType Directory

$b64 = Get-Content C:\Temp\$HostIP\$file.txt -Raw
Write-Host
$results = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String("$b64"))
$results | Out-File C:\Temp\$HostIP\Results\unicode_$file.txt

$ec64 = Get-Content C:\Temp\$HostIP\Results\unicode_$file.txt
$eb64 = $ec64|%{$_.split('"')[1]}

$data = [System.Convert]::FromBase64String("$eb64")
$ms = New-Object IO.MemoryStream
$ms.Write($data, 0, $data.Length)
$ms.Seek(0,0) | Out-Null

$cs = New-Object IO.Compression.GZipStream($ms, [IO.Compression.CompressionMode]::Decompress)
$sr = New-Object IO.StreamReader($cs)
$t = $sr.readtoend()
$t | Out-File C:\Temp\$HostIP\Results\decompressed_$file.txt

$dcb64 = Get-Content C:\Temp\$HostIP\Results\decompressed_$file.txt
$dc64 = $dcb64|%{$_.split('"')[1]}

$utf = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("$dc64"))
$utf | Out-File C:\Temp\$HostIP\Results\utf8_$file.txt

$asc = [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String("$dc64"))
$asc | Out-File C:\Temp\$HostIP\Results\ascii_$file.txt

$utf8 = "C:\Temp\$HostIP\Results\utf8_$file.txt"
$ascii = "C:\Temp\$HostIP\Results\ascii_$file.txt"

(Get-Content "$utf8") -replace "`0", "" | Set-Content "C:\Temp\$HostIP\Results\utf8_no-null_$file.txt"
(Get-Content "$ascii") -replace "`0", "" | Set-Content "C:\Temp\$HostIP\Results\ascii_no-null_$file.txt"

'


text:
Q: Upload both the Gradle build generated jars to the jfrog artifactory using jfrog artifactory plugin. Currently uploading only one When I run my gradle build both in my local and on the CI environment like Jenkins, it generates 2 jar files like shown below.
-rw-r--r-- 1 root root 497871506 Mar 10 00:45 abc-eds-audit-service-0.18.0-SNAPSHOT.jar
-rw-r--r-- 1 root root  245119 Mar 10 00:45 abc-eds-audit-service-0.18.0-SNAPSHOT-plain.jar

But when publishing using the com.jfrog.artifactory its publishing only the -plainjar file and not the other jar which includes everything. I want to be able to publish the other one too named
abc-eds-audit-service-0.18.0-SNAPSHOT.jar
[pool-1-thread-1] Deploying artifact: https://abc.jfrog.io/abc/libs-snapshot-local/com/xyz/abc/eds/audit/abc-eds-audit-service/0.18.0-SNAPSHOT/abc-eds-audit-service-0.18.0-SNAPSHOT-plain.jar
[pool-1-thread-1] Deploying artifact: https://abc.jfrog.io/abc/libs-snapshot-local/com/xyz/abc/eds/audit/abc-eds-audit-service/0.18.0-SNAPSHOT/abc-eds-audit-service-0.18.0-SNAPSHOT.module
[pool-1-thread-1] Deploying artifact: https://abc.jfrog.io/abc/libs-snapshot-local/com/xyz/abc/eds/audit/abc-eds-audit-service/0.18.0-SNAPSHOT/abc-eds-audit-service-0.18.0-SNAPSHOT.pom

Below is a snippet of my build.gradle
plugins {
    id 'org.springframework.boot' version '2.6.3'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
    id 'java-library'
    id 'project-report'
    id 'maven-publish'
    id 'com.jfrog.artifactory' version '4.27.1'

}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
}

artifactory {
  publish {
    contextUrl = 'https://abc.jfrog.io/abc/'   //The base Artifactory URL for the publisher
    //A closure defining publishing information
    repository {
      repoKey = 'libs-snapshot-local'
      username = project.getProperty("artifactory_user")
      password = project.getProperty("artifactory_password")
      maven = true
    }
    defaults {
        //publications ('mavenJava')
        publications 'ALL_PUBLICATIONS'
        publishBuildInfo = true
        publishArtifacts = true
        publishPom = true
        publishIvy = true
    }
  }
  // Redefine basic properties of the build info object
  clientConfig.setIncludeEnvVars(true)
  clientConfig.setEnvVarsExcludePatterns('*password*,*secret*')
  clientConfig.setEnvVarsIncludePatterns('*not-secret*')
  clientConfig.info.addEnvironmentProperty('test.adding.dynVar',new java.util.Date().toString())
  clientConfig.info.setBuildName('new-strange-name')
  clientConfig.info.setBuildNumber('' + new java.util.Random(System.currentTimeMillis()).nextInt(20000))
  clientConfig.timeout = 600 // Artifactory connection timeout (in seconds). The default timeout is 300 seconds.
  clientConfig.setInsecureTls(false) // Set to true to skip TLS certificates verification (false by default).
}


text:
Q: css 3D rotate not working on safari and ios safari (did use -webkit- and everything) I use css 3D rotate to flip the picture, it works great on Chrome and Firefox.
But when using safari, while the picture flip to the back side, it just flash and disappeared.
I already use -webkit-backface-visibility:hidden  and -webkit-transform.
I've also tried to fix it by adding -webkit-backface-visibility:hidden to the container (.inner) of front and back pictures as well. This makes the picture sticks but the buttons freeze too.
How could I fix it?
To see the question clearly, please open in safari:
HTML:

rotate

                  <button class="truthButton">Ok</button>

                  <button class="flipButton">No</button>

CSS:

/*==============
       Flip card
===============*/
.flip-card {
    background-color: transparent;
    -webkit-perspective: 1000px;
            perspective: 1000px;
  }

  .inner {    /*also tag*/
    position: relative;
    /*
    width: 100%;
  height: 100%; */
    -webkit-transition: 0.6s;
            transform 0.6s;
    -webkit-transform-style: preserve-3d;
            transform-style: preserve-3d;
    -webkit-box-shadow: 0px 2px 8px 0 black;
            box-shadow: 0px 2px 8px 0 black;
  }

  .flip-card:hover .inner {
    -webkit-transform: rotateY(180deg);
            transform: rotateY(180deg);
  }

  .front, .back {
    position: absolute;
    /* width: 100%;
  height: 100%; */
    /* -webkit-transform-style: preserve-3d;
            transform-style: preserve-3d; */
    -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
  }

  .back {
    transform: rotateY(180deg);
    width: 20em;
    height: 15em;
    background-position: center; /* Center the image */
    background-repeat: no-repeat; /* Do not repeat the image */
    background-size: cover; /* Resize the background image to cover the entire container */
  }

  .flipButton{
    bottom: 3%;
    right: 20%;
  }
  .truthButton{
    bottom: 3%;
    left: 20%;
  }
  .flipButton,
  .truthButton{
    position: absolute;
    color: var(--clr-pink);
    border: 1px solid var(--clr-blue);
    border-radius: 10px;
    padding: .2em .3em;
    font-size: var(--fs-body);
    background-color: var(--clr-blue);;
    background-repeat:no-repeat;
    cursor:pointer;
    overflow: hidden;
    outline:none;
    transition: transform 0.6s;
  }
  .truthButton::after,
  .flipButton::after {
      content: 'K';
      font-size: .1em;
      color: var(--clr-blue);
      position: absolute;
      bottom: 0;
      right: 0;
  }
  .truthButton:hover,
  .flipButton:hover {
    color: var(--clr-blue);
    background:var(--clr-pink);
    border: 1px solid var(--clr-pink);
    transform: scale(1.1);
  }
  /*==============
           HEADER
    ===============*/
  header {
    max-width: 100%;
    margin: 0 auto;
  }

  .title a {
    font-size: var(--fs-h2);
  }

  .title,
  .usTitle,
  li,
  p {
    color: var(--clr-blue);
    text-align: center;
    /* font-weight: 700; */
  }
  p{
    font-size: var(--fs-h3);
  }
  .usTitle {
    font-size: var(--fs-h2);
  }

  li {
    border: 1px solid var(--clr-blue);
    border-radius: 10px;
    padding: .5em 0;
    margin: .5em 0;
  }

  li:hover {
    border: 1px solid var(--clr-pink);
    /* background: var(--clr-pink); */
  }

  a {
    color: var(--clr-blue);
    font-size: var(--fs-h3);
    font-weight: 500;
  }

  a:hover {
    color: var(--clr-pink);
  }

  @media (min-width: 700px) {
    header {
      max-width: 100%;
    }
    nav {
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-pack: center;
          -ms-flex-pack: center;
              justify-content: center;
    }
    li {
      padding: .5em;
      margin: .5em;
    }
  }

  /*==============
           TAGS
    ===============*/
  .tags {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
        flex-wrap: wrap;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
    /*space-evenly*/
  }

  /*==============
           TAG
    ===============*/
  .r4 {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
  }

  .r4 .number {
    margin-right: 3em;
  }

  .r4 .date {
    margin-right: 1.5em;
  }

  .r6 {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: end;
        -ms-flex-pack: end;
            justify-content: flex-end;
  }

  .r1 img {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    max-width: 18em;
    width: 80%;
    margin: 0 auto;
  }

  /*compare to position absolute this is better solution to position skyteam*/
  .tag {
    /* position: relative; */
    max-width: 100%;
    width: 20em;
    height: 15em;
    display: -ms-grid;
    display: grid;
    -ms-flex-line-pack: center;
        align-content: center;
    background: #fff;
    /* background:url("https://cdn.pixabay.com/photo/2017/08/01/14/14/white-2565766__480.jpg"); */
    -ms-grid-rows: (0.3fr)[8];
        grid-template-rows: repeat(8, 0.3fr);
        grid-template-areas: "r1" "r2" "r3" "r4" "." "r6" "r7" "r8";

    /* -webkit-backface-visibility: hidden; */
  }

  /*==============
           BASE
    ===============*/
  *,
  *::before,
  *::after {
    -webkit-box-sizing: border-box;
            box-sizing: border-box;
  }

  :root {
    --clr-dark: #232323;
    --clr-pink: #ff3385;
    --clr-blue: #80d4ff;
    --ff-main: 'Roboto Mono', monospace;
    --fs-h1: 3rem;
    --fs-h2: 2.5rem;
    --fs-h3: 1.8rem;
    --fs-body: 1.25rem;
  }

  html,
  body {
    background: #232323;
    font-family: var(0ff-main);
  }

  a,
  li {
    cursor: pointer;
    text-decoration: none;
    list-style: none;
  }

  @media (min-width: 360px) and (max-width: 480px) {
    :root {
      --fs-h1: 1.5rem;
      --fs-h2: 1.25rem;
      --fs-h3: .8rem;
      --fs-body: 0.25rem;
    }
  }
  .ny{
    background-image: url(https://cdn.pixabay.com/photo/2016/10/28/13/09/usa-1777986__480.jpg);
  }