text:
Q: I think i have a problem with the parenthesces Im sorry i have posted codes the entire day, now i have this one and i have no idea why its not working. I have an error that doesnt tells me exactly what my problem is, someone told me to turn on the warnings so it could be easier but i dont know how do to that. If you give this code a monomian, it should give you the monomian as a string. The monomian is a (a,b), so thats why the code is full of fst and snd.
showMon :: Monomio -> String
showMon = \m -> case (fst m) == 0 of{ True -> " ";
                                    False -> case (fst m) == 1 of{ True -> case (snd m) == 0 of{ True -> "1";
                                                                                False -> case (snd m) == 1 of{ True-> "x";
                                                                                False -> "x^" ++ (show (snd m));}}
                                                                   False -> case (fst m) < 0 of{ True -> case (snd m) == 0 of{ True -> show 1;
                                                                                False -> case (snd m) == 1 of { True -> "-x";
                                                                                False -> "-x^" ++ show (snd m);}}
                                                                                False -> case snd m == 0 of{ True -> show 1;
                                                                                False -> case snd m == 1 of{ True-> (show fst m) ++ "x";
                                                                                False-> (show fst m) ++ "x^" ++ show (snd m);}}}}}

Polinomios.hs:146:108: error:
    Unexpected case expression in function application:
        case (snd m) == 0 of
          True -> "1"
          False
            -> case (snd m) == 1 of
                 True -> "x"
                 False -> "x^" ++ (show (snd m))
    You could write it with parentheses
    Or perhaps you meant to enable BlockArguments?
    |
146 |                                                                     False -> case (fst m) == 1 of{ True -> case (snd m) == 0 of{ True -> "1";     |

A: As far as I can tell, you can reduce this entire function down to a few simple cases.
showMon (m, n) | m < 0 = "-" ++ showMon (negate m, n)  -- negative terms
showMon (0, _) = " "  -- empty term
showMon (m, 0) = show m -- terms with x^0
showMon (m, n) = let coeff = if m == 1 then "" else (show m)
                     exp = if n == 1 then "" else ("^" ++ show n)
                 in coeff ++ "x" ++ exp -- other terms, with coefficients and exponents of 1 dropped

A case expression can handle multiple different values. If you do need to match against a Boolean value, that's what the if expression is for.
if x then y else z

is equivalent to
case x of
  True -> y
  otherwise -> z

A: Here's your code, re-indented for clarity. It is still quite hard to read.
showMon :: Monomio -> String
showMon = \m -> case (fst m) == 0 of
  { True -> " ";
    False -> case (fst m) == 1 of
      { True -> case (snd m) == 0 of
          { True -> "1";
            False -> case (snd m) == 1 of
              { True-> "x";
                False -> "x^" ++ (show (snd m));
              }
          } -- **
        False -> case (fst m) < 0 of
          { True -> case (snd m) == 0 of
              { True -> show 1;
                False -> case (snd m) == 1 of
                  { True -> "-x";
                    False -> "-x^" ++ show (snd m);
                  }
              } -- **
            False -> case snd m == 0 of
              { True -> show 1;
                False -> case snd m == 1 of
                  { True-> (show fst m) ++ "x";
                    False-> (show fst m) ++ "x^" ++ show (snd m);
                  }
              }
          }
      }
  }

In the points marked with -- ** above a semicolon is missing, making the compiler produce a weird error message, since we are essentially trying to apply a case expression to some arguments in this way.
Some suggestions to improve this:
You don't have to use fst,snd, you can pattern match on the input argument. Instead of \m -> ..., you can use \(m1,m2) -> ... and then use the two components directly.
You don't have to check fst m == 0, fst m == 1 in that way. You can instead use (trying to mimic your style)
case m1 of  -- recall m1 is (fst m)
  { 0 -> .... ;  -- it is 0
    1 -> .... ;  -- it is 1
    _ -> ....    -- it is something else
  }

In principle, with guards you can even incorporate checks like your fst m < 0.


text:
Q: Wix Installer - Changing a CustomAction on a Patch I am using Wix Toolset to create .msi and .msp files. I currently have a custom action defined in my applicaton's .wxs file that is run whenever the application is upgraded via a patch or an reinstall of a newer version of the app. This CustomAction runs at the appropriate time and is working correctly.
I need to modify the ExecCommand property of the CustomAction a little bit. I would like it so that the .msp file I create will result in the modified CustomAction to run on update. I modified the .wxs file for the newer version of the application, created a patch between the two versions and verified that this will not run the updated custom action.
Is there any way to update a CustomAction with a patch?  Is there something else I need to put into the PatchFamily portion into the patch's .wxs file? It currently is very simple and only contains two ComponentRef tags of two new files that are added for the patch.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Show that vectors are linearly dependent if and only if one of the vectors is a linear combination of the others.
Show that vectors $v_1$,...,$v_k \in \Bbb R^n$ are linearly dependent if and only if one of these vectors is a linear combination of the others.

I know that $v_1$,...,$v_k$ being linearly dependent means that there exists $c_1$,...,$c_k \in \Bbb R^n$, not all zero, such that $c_1v_1+\dots+c_1v_k = 0$ (vector). Also a linear combination of $v_1,\dots,v_k$ means that a vector $u = c_1v_1+\cdots+c_kv_k$. I am unsure of where to go with this information.

A: Chose an index $j$ such that $c_j\ne 0$ and then divide everything by $c_j$. What can you deduce from there?

A: Hints:

*

*For the forward direction, since one of the $c_i$'s is nonzero, you can solve for $v_i$ in terms of the other vectors (you can divide by $c_i$ because its nonzero).

*For the backwards direction, if $v_i$ is a linear combination of the others, then
$$
v_i=a_1v_1+a_2v_2+\cdots+a_{i-1}v_{i-1}+a_{i+1}v_{i+1}+\cdots a_nv_n.
$$
Observe that $v_i$ is missing from the RHS.  Put all your vectors on one side and show that you can write $0$ as a linear combination and some of the coefficients (at least one) is nonzero.


text:
Q: How Do You Conditionally Write data to CSV Using Column Value in Python? I am trying to write data to a csv file from a DataFrame (df), but only if the Unique ID of the df row does not already exist in the csv file. So in other words, only write into the csv file if the unique ID does NOT already exist.
So far what I have is this, which writes the data perfectly fine into the csv (I have only put the relevant parts of the code);
columns = [item for sublist in columns for item in sublist]
columns = list(dict.fromkeys(columns))
df = pandas.DataFrame(merged)
df.drop(df.columns[[0, 1, 20, 21, 22, 23]], axis = 1, inplace = True)

df.to_csv("MyData.csv", mode='a', header=None, index=False)

Now, to compare the columns in the pandas df to the corresponding csv column, I have done this;
col_list = ["Unique ID"]
df2 = pandas.read_csv("MyData.csv", usecols=col_list)
#print(df2["Unique ID"])

for csvdata in df2["Unique ID"]:
    for dfdata in df.iloc[:, 17]:
        if dfdata == csvdata:
            print("match")

This only works as far as advising me if there's a match i.e. if an ID in the Unique ID of the df exists in the destination csv file. What I need is to put in a condition which will only send the rows from the df where the unique identifier in the Unique ID column (index 17) does not exist in the csv file.
Any help would be appreciated.
Best Regards,


text:
Q: Firebase setDoc() not creating document I'm creating a new user with auth which is working then taking that newly create uid to create a new document with the same.
const currentUser = await auth.createUserWithEmailAndPassword(email, pass);
        console.log('user registered')
        await setDoc(doc(db, "users", currentUser.user.uid),{
            forname: "Peter",
            surname: "Parker"
        })
        console.log('user profile added')
    dispatch({type:'USER_REG', payload: currentUser});

The reg process fires off without issue as I get the console log then the program just waits, its like setDoc is running but never completing and I have no idea why.
Any help is appreciated.

A: Try:
import { getAuth, signInWithEmailAndPassword } from "firebase/auth";

const auth = getAuth();
await auth.createUserWithEmailAndPassword(auth, email, pass).then(async(userRec)=>{
    const user = userRec.user;
    await await setDoc(doc(db, "users", user.uid),{
        forname: "Peter",
        surname: "Parker"
    }).catch((error)=>{
        console.log(error);
    });
}).catch((error)=>{
    console.log(error);
});


text:
Q: Allow SOLR core only for a single user I can't find any information on how to allow access to specific SOLR core just for a single user. I am using SOLR7. This is what I've got:
security.json
{
  "authentication": {
    "blockUnknown": true,
    "class": "solr.BasicAuthPlugin",
    "credentials": {
      "test_admin": "xxx",
      "infographics": "xxx",
      "test_user": "xxx"
    },
    "": {
      "v": 0
    }
  },
  "authorization": {
    "class": "solr.RuleBasedAuthorizationPlugin",
    "permissions": [
      {
        "name": "all",
        "role": "admin",
        "index": 1
      },
      {
        "name": "update",
        "role": "general",
        "index": 2
      },
      {
        "name": "read",
        "role": [
          "general",
          "infographics",
          "test_user"
        ],
        "index": 3
      },
      {
        "name": "collection-admin-read",
        "role": "general",
        "index": 4
      },
      {
        "name": "core-admin-read",
        "role": "general",
        "index": 5
      },
      {
        "name": "core-specific-permission",
        "collection": "test-core",
        "role": "test_user",
        "before": 3,
        "index": 6
      }
    ],
    "user-role": {
      "test_admin": [
        "admin",
        "general"
      ],
      "infographics": "infographics",
      "test_user": "test_user"
    },
    "": {
      "v": 0
    }
  }
}

I've added a permission for collection "test-core":
  {
    "name": "core-specific-permission",
    "collection": "test-core",
    "role": "test_user",
    "before": 3,
    "index": 6
  }

I authenticate with test_user when calling: /solr/test-core/select?q=*:*, this works fine, but it also can access other cores, for e.g.: /solr/other-core/select?q=*:*.
If I remove test_user from read permission:
      {
        "name": "read",
        "role": [
          "general",
          "infographics"
        ],
        "index": 3
      },

then I am not able to query any core. Getting 403. For test_user I'd like to allow access to only this core /solr/test-core/select?q=*:* and nothing else. Any idea how can I achieve this?


text:
Q: Spring Boot and Keycloak configuration in properties raise a NullPointerException then 500 status code I am currently working on a project and I have to deal with Spring Boot and keycloak.
I want a configuration that is in the application.properties of spring.
Here is a part of my configuration file:
keycloak.enabled = true
keycloak.auth-server-url=${SSO_URL:http://MYIP:8082/auth/}
keycloak.realm=${SSO_REALM:approfox-dev}
keycloak.resource=${SSO_CLIENT:approfox-dev-login}
keycloak.ssl-required=none
keycloak.public-client=true
keycloak.principal-attribute=preferred_username

But when I try to access to any API endpoint, I got an 500 Internal Server Error with juste a NullPointerException. I do not know from where or why this exception occures. It seems that the application properties file is not loading by keycloak because when I use keycloack.json and the method that load it, it works.
@Configuration
@EnableWebSecurity
@KeycloakConfiguration
@ComponentScan(basePackageClasses = KeycloakSecurityComponents.class)
@ConditionalOnProperty(
    value = "keycloak.enabled",
    havingValue = "true",
    matchIfMissing = false
)
class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) {
        SimpleAuthorityMapper grantedAuthorityMapper = new SimpleAuthorityMapper();
        grantedAuthorityMapper.setPrefix("ROLE_");

        KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();
        keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(grantedAuthorityMapper);
        auth.authenticationProvider(keycloakAuthenticationProvider);
    }
    @Bean
    @Override
    @ConditionalOnMissingBean(HttpSessionManager.class)
    protected HttpSessionManager httpSessionManager() {
        return new HttpSessionManager();
    }

    // Keycloak Spring Boot resolver not working
    @Bean
    public KeycloakSpringBootConfigResolver KeycloakConfigResolver() {
        return new KeycloakSpringBootConfigResolver();
    }

    @Bean
    @Override
    protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
        return new RegisterSessionAuthenticationStrategy(
                new SessionRegistryImpl());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        super.configure(http);
        http.csrf()
                .disable()
                .cors()
                .and()
                .authorizeRequests()
                .antMatchers("/exemple1")
                .hasRole("student")
                .antMatchers("/exemple2")
                .hasRole("admin")
                .anyRequest()
                .permitAll();
    }

    // keycloak.json working...
    /**
     * Overrides default keycloak config resolver behaviour (/WEB-INF/keycloak.json) by a simple mechanism.
     * <p>
     * This example loads other-keycloak.json when the parameter use.other is set to true, e.g.:
     * {@code ./gradlew bootRun -Duse.other=true}
     *
     * @return keycloak config resolver
     */
    /*@Bean
    public KeycloakConfigResolver keycloakConfigResolver() {
        return new KeycloakConfigResolver() {

            private KeycloakDeployment keycloakDeployment;

            @Override
            public KeycloakDeployment resolve(HttpFacade.Request facade) {
                if (keycloakDeployment != null) {
                    return keycloakDeployment;
                }

                String path = "/keycloak.json";
                InputStream configInputStream = getClass().getResourceAsStream(path);

                if (configInputStream == null) {
                    throw new RuntimeException("Could not load Keycloak deployment info: " + path);
                } else {
                    keycloakDeployment = KeycloakDeploymentBuilder.build(configInputStream);
                }

                return keycloakDeployment;
            }
        };
    }*/
}

I have searched all over internet I can't find anything about that issue...
My POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
    </parent>
    <groupId>xxx</groupId>
    <artifactId>xxxx</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>xxxx</name>
    <description>xxxx</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-spring-boot-starter</artifactId>
            <version>8.0.1</version>
        </dependency>

        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-spring-boot-adapter</artifactId>
            <version>8.0.1</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.18</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.keycloak.bom</groupId>
                <artifactId>keycloak-adapter-bom</artifactId>
                <version>3.3.0.Final</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
<!--            <plugin>-->
<!--                <artifactId>maven-assembly-plugin</artifactId>-->
<!--                <version>3.1.1</version>-->
<!--                <configuration>-->
<!--                    <descriptorRefs>-->
<!--                        <descriptorRef>project</descriptorRef>-->
<!--                    </descriptorRefs>-->
<!--                </configuration>-->
<!--                <executions>-->
<!--                    <execution>-->
<!--                        <id>make-assembly</id>-->
<!--                        <phase>package</phase>-->
<!--                        <goals>-->
<!--                            <goal>single</goal>-->
<!--                        </goals>-->
<!--                    </execution>-->
<!--                </executions>-->
<!--            </plugin>-->
        </plugins>
    </build>

</project>


text:
Q: DeprecationWarning: Creating streaming responses with `HttpResponse` is deprecated. Use `StreamingHttpResponse`? Why am I seeing this error? Is there any problem in the django method below?
def email_send(request):

    data = json.loads(request.body)

    email_conf = getEmailConf(data)
    mail_message = getFormattedMsg(data)
    try:
        t = threading.Thread(target=send_mail,args=[email_conf['subject'],mail_message , email_conf['from_addr'],[email_conf['to_addr'],]],kwargs={'fail_silently':False})
        t.setDaemon(True)
        t.start()
    except:
        print "Exception in sending Mail:"
        print data
        print email_conf
    response= email_conf['response']
    try:
        if data['id']==8:
            response={'redirect2thankupage'}
    except:
        pass
    return HttpResponse(response)

A: Django is warning you that in a future release, HttpResponse will only accept strings as content.
In the case where data['id'] == 8 you are passing a set.  You can probably just pass a string here.
For reference, see the docs here and here.


text:
Q: PHP LDAP Distinguish user from computer Is there a way to query with LDAP and leave out computers in the result?
There are users and computers inside the OU, and I only want to display the Users with their cn, title,address etc...
Thanks!

A: You need to add the following to your LDAP filter (!(objectClass=computer)). This will exclude computer objects.
You can read more on LDAP filters in this LDAP Filter Syntax article.


text:
Q: c# Left-shift operator << as the «for loop» «iterator» I need to iterate through every bit of a byte. There are many ways to do it but my curiosity got piqued when trying to use a for loop with the "shift-left" operator as the iterator. This is what I would like to do.
for (byte i = 0x01; i <= 0x80; i << 1)
{
    value = value ^ i;
}

In this situation how could I use the shift-left operator (i << 1) for iteration?
In a typical for loop, you would have (int i=0; i < 10; i++) the iterator being i++ for incrementing by one.

A: You can use the compound assignment form of the operator like i <<= 1. Or you can simply use i = i << 1.


text:
Q: How do I setState in my react-leaflet component I cannot update state in my componentDidMount using setState. I have an axios call that handles the asynchronous call to my api and loads an anonymous function which should update state when the user clicks on the geoJSON layer. For some reason the redux store is not being updated on click and remains the initial state of an empty string. My code is below
import React from 'react';
import L from 'leaflet';
import {apiKey} from './apiKey';
import { connect } from 'react-redux';
import axios from 'axios';
import {districtStyle, districtHighlightStyle, mapStyle} from './styles';

class Map extends React.Component {

  componentDidMount() {

    let districtsJSON = null;

    this.map = L.map('map').setView([31.15, -99.90], 6);

    L.tileLayer(`https://{s}.tile.thunderforest.com/pioneer/{z}/{x}/{y}.png?apikey=${apiKey}`, {
      attribution: 'Pioneer Basemap by Thunderforest, a project by Gravitystorm Limited.'
    }).addTo(this.map);

    const districtsUrl = 'http://localhost:8000/gerrymander/api/districts/';
    axios.get(districtsUrl).then(
      response => {
        districtsJSON = response.data;

        const txDistricts = L.geoJson(districtsJSON, {
          style: districtStyle,
          onEachFeature: (feature, layer) => {
            layer.on({
              click: (e) => {
                if (lastClickedLayer !== e.target) {
                  txDistricts.setStyle(districtStyle);
                }
                e.target.setStyle(districtHighlightStyle);
                let lastClickedLayer = e.target;
                // Set state to the target layer's clicked district
                this.setState({ district: e.target.feature.properties.namelsad })
              }
            });
          }
        }).addTo(this.map);
      }
    )
    console.log(this.props.district);
  }

  render() {
    return

  }
}

const mapStateToProps = state => {
  return {
    district: state.district,
  }
}

export default connect(mapStateToProps)(Map);


text:
Q: Shure MV7 USB Microphone seems to work with Thinkpad but not XPS I have two Linux laptops. Both are running Kubuntu 20.04.2 and are using a 5.10 kernel. One laptop is a Lenovo Thinkpad T14s AMD, and the other is a Dell XPS 13. Both have pulseaudio 13.99.1 installed.
I also have a Shure MV7 USB microphone and two different docks; one is USB-C, the other is a TB3 dock that falls back to USB-C (the T14s AMD doesn't support TB3, the XPS does).
Using either dock, the Thinkpad is able to work with the microphone. Using either dock, the XPS 13 is unable to work with the microphone. A MacBook Pro having TB3 does work with the microphone using either dock.
Here is the dmesg output from the working Thinkpad:
[18915.145402] usb 4-1.3: new full-speed USB device number 16 using xhci_hcd
[18915.321247] usb 4-1.3: New USB device found, idVendor=14ed, idProduct=1012, bcdDevice= 0.02
[18915.321253] usb 4-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=128
[18915.321255] usb 4-1.3: Product: Shure MV7
[18915.321257] usb 4-1.3: Manufacturer: Shure Inc
[18915.770689] hid-generic 0003:14ED:1012.0013: hiddev0,hidraw7: USB HID v1.11 Device [Shure Inc Shure MV7] on usb-0000:06:00.3-1.3/input3
[18915.781579] input: Shure Inc Shure MV7 as /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.3/4-1.3:1.4/0003:14ED:1012.0014/input/input44
[18915.841698] hid-generic 0003:14ED:1012.0014: input,hidraw8: USB HID v1.11 Device [Shure Inc Shure MV7] on usb-0000:06:00.3-1.3/input4
[18916.649623] retire_capture_urb: 203 callbacks suppressed

Here is the lsusb output from the working Thinkpad:
Bus 004 Device 016: ID 14ed:1012 Shure Inc. EMV Smartcard Reader

Here is the dmesg output from the non-working XPS:
[56983.419316] usb 5-2.1.4: new full-speed USB device number 116 using xhci_hcd
[56983.577231] usb 5-2.1.4: New USB device found, idVendor=14ed, idProduct=1012, bcdDevice= 0.02
[56983.577237] usb 5-2.1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=128
[56983.577240] usb 5-2.1.4: Product: Shure MV7
[56983.577242] usb 5-2.1.4: Manufacturer: Shure Inc
[56983.607384] hid-generic 0003:14ED:1012.03C9: hiddev0,hidraw2: USB HID v1.11 Device [Shure Inc Shure MV7] on usb-0000:04:00.0-2.1.4/input3
[56983.608569] input: Shure Inc Shure MV7 as /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.03CA/input/in
put508
[56983.667617] hid-generic 0003:14ED:1012.03CA: input,hidraw3: USB HID v1.11 Device [Shure Inc Shure MV7] on usb-0000:04:00.0-2.1.4/input4

... a few seconds pass ...

[56986.435299] usb 5-2.1.4: 1:1: usb_set_interface failed (-32)
[56986.443559] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.451594] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.460171] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.468548] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.477551] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.485375] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.493197] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.501384] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.509453] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.518465] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.526489] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.534350] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.542324] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.550625] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.559931] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.568032] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.576003] usb 5-2.1.4: 1:1: usb_set_interface failed (-71)
[56986.576367] usb 5-2.1.4: USB disconnect, device number 116
[56986.576411] usb 5-2.1.4: 1:1: usb_set_interface failed (-19)
[56986.576675] usb 5-2.1.4: 1:1: usb_set_interface failed (-19)
[56986.577389] usb 5-2.1.4: 1:1: usb_set_interface failed (-19)
[56986.577419] usb 5-2.1.4: 1:1: usb_set_interface failed (-19)
[56986.577445] usb 5-2.1.4: 1:1: usb_set_interface failed (-19)
[56986.577601] usb 5-2.1.4: 1:1: usb_set_interface failed (-19)
[56986.577740] usb 5-2.1.4: 1:1: usb_set_interface failed (-19)
[56986.578196] usb 5-2.1.4: 1:1: usb_set_interface failed (-19)
[56986.578223] usb 5-2.1.4: 1:1: usb_set_interface failed (-19)
[56986.578247] usb 5-2.1.4: 1:1: usb_set_interface failed (-19)
[56986.578371] usb 5-2.1.4: 1:1: usb_set_interface failed (-19)

... device appears again immediately ...

[56986.915092] usb 5-2.1.4: new full-speed USB device number 117 using xhci_hcd
[56987.069247] usb 5-2.1.4: New USB device found, idVendor=14ed, idProduct=1012, bcdDevice= 0.02
[56987.069251] usb 5-2.1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=128
[56987.069254] usb 5-2.1.4: Product: Shure MV7
[56987.069256] usb 5-2.1.4: Manufacturer: Shure Inc
[56987.101511] hid-generic 0003:14ED:1012.03CB: hiddev0,hidraw2: USB HID v1.11 Device [Shure Inc Shure MV7] on usb-0000:04:00.0-2.1.4/input3
[56987.102673] input: Shure Inc Shure MV7 as /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.03CC/input/in
put509
[56987.159557] hid-generic 0003:14ED:1012.03CC: input,hidraw3: USB HID v1.11 Device [Shure Inc Shure MV7] on usb-0000:04:00.0-2.1.4/input4

Here is the lsusb output from the non-working XPS:
Bus 005 Device 014: ID 14ed:1012 Shure Inc.

Any ideas on how I can get the microphone working with the XPS 13? Plugging it in using a basic USB-A to USBC adapter also does not work.
Note that the XPS draws 45W of power, while the Thinkpad draws 65W, so I don't believe the issue is that the dock cannot power both the XPS and the mic simultaneously.
Update 2021-02-27:
I updated the kernel on the XPS to 5.11 but that didn't help.
Here's a bunch of output from various commands. For most of them I removed entries that weren't related to the MV7.
/proc/asound/cards
Working Thinkpad:
 5 [MV7            ]: USB-Audio - Shure MV7
                      Shure Inc Shure MV7 at usb-0000:06:00.3-1.1.3, full speed

Non-working XPS:
2 [MV7            ]: USB-Audio - Shure MV7
                     Shure Inc Shure MV7 at usb-0000:04:00.0-2.1.4, full speed

sudo inxi -SA
Working Thinkpad:
System:    Host: thinkpad Kernel: 5.10.13-051013-generic x86_64 bits: 64 Desktop: KDE Plasma 5.18.5
           Distro: Ubuntu 20.04.2 LTS (Focal Fossa)
Audio:     Device-1: Advanced Micro Devices [AMD/ATI] driver: snd_hda_intel
           Device-2: Advanced Micro Devices [AMD] Raven/Raven2/FireFlight/Renoir Audio Processor
           driver: snd_rn_pci_acp3x
           Device-3: Advanced Micro Devices [AMD] Family 17h HD Audio driver: snd_hda_intel
           Device-4: Logitech OrbiCam type: USB driver: snd-usb-audio,uvcvideo
           Device-5: Lenovo type: USB driver: hid-generic,snd-usb-audio,usbhid
           Device-6: Shure EMV Smartcard Reader type: USB driver: hid-generic,snd-usb-audio,usbhid
           Sound Server: ALSA v: k5.10.13-051013-generic

Non-working XPS:
System:    Host: xps Kernel: 5.11.0-051100-generic x86_64 bits: 64 Console: tty 5
           Distro: Ubuntu 20.04.2 LTS (Focal Fossa)
Audio:     Device-1: Intel driver: sof-audio-pci
           Device-2: Logitech OrbiCam type: USB driver: snd-usb-audio,uvcvideo
           Device-3: Lenovo USB2.0 Hub type: USB driver: hid-generic,snd-usb-audio,usbhid
           Device-4: Shure type: USB driver: hid-generic,snd-usb-audio,usbhid
           Sound Server: ALSA v: k5.11.0-051100-generic

sudo lshw -C multimedia
Working Thinkpad:
  *-usb:1
       description: Audio device
       product: Shure MV7
       vendor: Shure Inc
       physical id: 3
       bus info: usb@4:1.1.3
       version: 0.02
       capabilities: usb-2.00 audio-control
       configuration: driver=usbhid maxpower=100mA speed=12Mbit/s

Non-working XPS:
  *-usb:1
       description: Audio device
       product: Shure MV7
       vendor: Shure Inc
       physical id: 4
       bus info: usb@5:2.1.4
       version: 0.02
       capabilities: usb-2.00 audio-control
       configuration: driver=usbhid maxpower=100mA speed=12Mbit/s

dpkg -l | grep alsa
Working Thinkpad:
ii  alsa-base                                     1.0.25+dfsg-0ubuntu5                        all          ALSA driver configuration files
ii  alsa-topology-conf                            1.2.2-1                                     all          ALSA topology configuration files
ii  alsa-ucm-conf                                 1.2.2-1ubuntu0.5                            all          ALSA Use Case Manager configuration files
ii  alsa-utils                                    1.2.2-1ubuntu2                              amd64        Utilities for configuring and using ALSA
ii  libsox-fmt-alsa:amd64                         14.4.2+git20190427-2                        amd64        SoX alsa format I/O library

Non-working XPS:
ii  alsa-base                                     1.0.25+dfsg-0ubuntu5                        all          ALSA driver configuration files
ii  alsa-topology-conf                            1.2.2-1                                     all          ALSA topology configuration files
ii  alsa-ucm-conf                                 1.2.2-1ubuntu0.5                            all          ALSA Use Case Manager configuration files
ii  alsa-utils                                    1.2.2-1ubuntu2                              amd64        Utilities for configuring and using ALSA

I then installed the libsox-fmt-alsa package on the XPS, but that didn't help.
grep intel /etc/modprobe.d/alsa-base.conf
Working Thinkpad:
options snd-intel8x0m index=-2

Non-working XPS:
options snd-intel8x0m index=-2

I also ran the command dpkg -L linux-modules-<version>-generic | grep snd on the two machines, output to a file, scrubbed the kernel version, and diffed the output. The only differences are that the XPS has more kernel modules loaded than the Thinkpad. Here's the cleaned-up diff:
> /lib/modules/.../kernel/sound/soc/adi/snd-soc-adi-axi-i2s.ko
> /lib/modules/.../kernel/sound/soc/adi/snd-soc-adi-axi-spdif.ko
> /lib/modules/.../kernel/sound/soc/codecs/snd-soc-adau1372-i2c.ko
> /lib/modules/.../kernel/sound/soc/codecs/snd-soc-adau1372-spi.ko
> /lib/modules/.../kernel/sound/soc/codecs/snd-soc-adau1372.ko
> /lib/modules/.../kernel/sound/soc/codecs/snd-soc-lpass-va-macro.ko
> /lib/modules/.../kernel/sound/soc/codecs/snd-soc-lpass-wsa-macro.ko
> /lib/modules/.../kernel/sound/soc/codecs/snd-soc-nau8315.ko
> /lib/modules/.../kernel/sound/soc/codecs/snd-soc-pcm5102a.ko
> /lib/modules/.../kernel/sound/soc/codecs/snd-soc-simple-mux.ko
> /lib/modules/.../kernel/sound/soc/fsl/snd-soc-fsl-xcvr.ko

I then went through and ran sudo modprobe -r snd-* for each of the listed modules and replugged the microphone. The dmesg failures still stream through in the same way.
udevadm monitor -u
Working Thinkpad:
UDEV  [215394.300375] add      /class/usbmisc (class)
UDEV  [215394.390245] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4 (usb)
UDEV  [215394.394469] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.0 (usb)
UDEV  [215394.394585] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.1 (usb)
UDEV  [215394.396165] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.2 (usb)
UDEV  [215394.396764] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.3 (usb)
UDEV  [215394.397311] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.4 (usb)
UDEV  [215394.397745] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.0/sound/card4 (sound)
UDEV  [215394.398833] bind     /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.1 (usb)
UDEV  [215394.399652] bind     /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.2 (usb)
UDEV  [215394.400337] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.3/0003:14ED:1012.00A3 (hid)
UDEV  [215394.400933] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.4/0003:14ED:1012.00A4 (hid)
UDEV  [215394.402051] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.0/sound/card4/pcmC4D0p (sound)
UDEV  [215394.402290] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.3/usbmisc/hiddev0 (usbmisc)
UDEV  [215394.403642] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.0/sound/card4/pcmC4D0c (sound)
UDEV  [215394.405980] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.4/0003:14ED:1012.00A4/input/input218 (input)
UDEV  [215394.406090] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.3/0003:14ED:1012.00A3/hidraw/hidraw8 (hidraw)
UDEV  [215394.407149] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.4/0003:14ED:1012.00A4/hidraw/hidraw9 (hidraw)
UDEV  [215394.407695] bind     /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.3/0003:14ED:1012.00A3 (hid)
UDEV  [215394.409578] bind     /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.3 (usb)
UDEV  [215394.415733] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.0/sound/card4/controlC4 (sound)
UDEV  [215394.417798] bind     /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.0 (usb)
UDEV  [215394.455823] add      /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.4/0003:14ED:1012.00A4/input/input218/event22 (input)
UDEV  [215394.457949] bind     /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.4/0003:14ED:1012.00A4 (hid)
UDEV  [215394.460696] bind     /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.4 (usb)
UDEV  [215394.468706] bind     /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4 (usb)
UDEV  [215394.472079] change   /devices/pci0000:00/0000:00:08.1/0000:06:00.3/usb4/4-1/4-1.1/4-1.1.4/4-1.1.4:1.0/sound/card4 (sound)

Non-working XPS:
UDEV  [235.479054] add      /class/usbmisc (class)
UDEV  [236.099173] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4 (usb)
UDEV  [236.104541] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3 (usb)
UDEV  [236.104950] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4 (usb)
UDEV  [236.107060] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.2 (usb)
UDEV  [236.107348] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.1 (usb)
UDEV  [236.107964] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0 (usb)
UDEV  [236.109051] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3/0003:14ED:1012.007B (hid)
UDEV  [236.109557] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.007C (hid)
UDEV  [236.109746] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3/usbmisc/hiddev0 (usbmisc)
UDEV  [236.112068] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0/sound/card1 (sound)
UDEV  [236.116508] bind     /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.1 (usb)
UDEV  [236.116590] bind     /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.2 (usb)
UDEV  [236.118343] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.007C/input/input90 (input)
UDEV  [236.118689] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0/sound/card1/pcmC1D0c (sound)
UDEV  [236.119072] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0/sound/card1/pcmC1D0p (sound)
UDEV  [236.127047] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3/0003:14ED:1012.007B/hidraw/hidraw4 (hidraw)
UDEV  [236.127116] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.007C/hidraw/hidraw5 (hidraw)
UDEV  [236.128600] bind     /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3/0003:14ED:1012.007B (hid)
UDEV  [236.131412] bind     /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3 (usb)
UDEV  [236.132076] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0/sound/card1/controlC1 (sound)
UDEV  [236.135173] bind     /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0 (usb)
UDEV  [236.162197] add      /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.007C/input/input90/event12 (input)
UDEV  [236.163989] bind     /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.007C (hid)
UDEV  [236.166410] bind     /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4 (usb)
UDEV  [236.171088] bind     /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4 (usb)
UDEV  [236.172704] change   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0/sound/card1 (sound)
UDEV  [238.530899] remove   /class/usbmisc (class)
UDEV  [238.532306] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0/sound/card1/pcmC1D0p (sound)
UDEV  [238.532452] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0/sound/card1/controlC1 (sound)
UDEV  [238.532504] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3/usbmisc/hiddev0 (usbmisc)
UDEV  [238.532544] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3/0003:14ED:1012.007B/hidraw/hidraw4 (hidraw)
UDEV  [238.532876] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0/sound/card1/pcmC1D0c (sound)
UDEV  [238.534155] unbind   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.1 (usb)
UDEV  [238.534212] unbind   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.2 (usb)
UDEV  [238.534672] unbind   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3/0003:14ED:1012.007B (hid)
UDEV  [238.535377] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0/sound/card1 (sound)
UDEV  [238.536409] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3/0003:14ED:1012.007B (hid)
UDEV  [238.537504] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.2 (usb)
UDEV  [238.537605] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.1 (usb)
UDEV  [238.539728] unbind   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0 (usb)
UDEV  [238.540881] unbind   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3 (usb)
UDEV  [238.543144] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.0 (usb)
UDEV  [238.543923] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.3 (usb)
UDEV  [238.562540] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.007C/input/input90/event12 (input)
UDEV  [238.610007] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.007C/input/input90 (input)
UDEV  [238.610090] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.007C/hidraw/hidraw5 (hidraw)
UDEV  [238.611055] unbind   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.007C (hid)
UDEV  [238.611641] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4/0003:14ED:1012.007C (hid)
UDEV  [238.612897] unbind   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4 (usb)
UDEV  [238.613937] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4/5-2.1.4:1.4 (usb)
UDEV  [238.615092] unbind   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4 (usb)
UDEV  [238.616111] remove   /devices/pci0000:00/0000:00:07.0/0000:02:00.0/0000:03:02.0/0000:04:00.0/usb5/5-2/5-2.1/5-2.1.4 (usb)

This output then repeats in a loop, much like with the dmesg output.

A: You may try a solution method similar to what was used in this question Only "Dummy output" (sound) in Ubuntu 20.04 after reboot - Broken driver / module
There, the problem was with sound output. This is related but not the same.
Try using a comparison between systems that work and do not work (as you already started to do).
Check a few informational commands.
I am copying here what was used in that other case.
Some of the tests pertain to both cases.
Minor variations should also help.
$ cat /proc/asound/cards
$ lsmod | grep snd
$ dpkg -L linux-modules-<your version>-generic | grep snd
$ inxi -SA
$ lspci -nnk | grep -A 1 Audio
$ uname -a
$ lshw -C multimedia
$ dpkg -l | grep alsa
$ grep intel /etc/modprobe.d/alsa-base.conf

Please post the output, and also take some time to pinpoint (what you judge as) meaningful differences and indicate them, so others can help you better.
You may be missing a package, driver, etc.
If you are lucky, it is only a linux-modules-... package.

A: First, the MV7 worked fine on my desktop pc using Ubuntu (18.04).
After I re-plugged some USB devices, I had similar issues: connecting/disconnecting loop with the message:
1:1: usb_set_interface failed (-71)

Although the (USB) webcam and video streams were stuttering. I reverted the replugging and everything was fine again: The "fix" for me is, using a USB2 and NOT a USB3 slot for the MV7.
Looks like the USB3 issue is not only related to the MV7: https://askubuntu.com/a/1199300.

A: I have Ubuntu 20.04 on a Dell XPS 15 9550 and was facing the same issue where the mic would reboot infinitely.
Based on on this answer, it seems the problem is PulseAudio communicating with the mic in a way that makes the mic's firmware crash.
I replaced PulseAudio with PipeWire and now the MV7 works perfectly. I used the following PPA: https://github.com/pipewire-debian/pipewire-debian#1-ppa-configuration
Be sure to follow the instructions about disabling the PulseAudio service and give the system a reboot after the fact.


text:
Q: Conditioning tri-state logic I have a variable that takes a value out of tri-state booleans:
asap = true
asap = false
asap = nil

Ruby's conditionals interpret them as truthy or falsey. Especially, nil is not distinguished from false.
asap = nil
unless asap
  puts 'False'
end
# => 'False'

A statement that distinguishes false from nil is:
if asap == false
  puts 'False'
end

but RubyMine 6.3.3 complains that the expression could be simplified, and suggests unless asap. Is there  a different (right) way to do the conditioning?

A: TLDNR;
if FalseClass === asap
  puts 'False'
end

Tri-state usually suggests that there are three possible branches, which forces me to think that neither if nor ternary ? is generally applicable.
puts case asap
     when FalseClass then 'False'
     when TrueClass then 'True'
     when NilClass then 'Nil'
     else 'You are kidding on me, aren't you?'
     end

Hope it helps.
UPD: The more I think about it, the more I am inclined to think that ternary is fine as well:
puts asap.nil? ? 'Nil' : asap ? 'True' : 'False'

UPD2: Actually, the tri-equal comparision operator, which is transparently used in case and which apparently evaluates to true for false === false and true === true might satisfy IDEA aka RubyMine as well:
if asap === false
  puts 'False'
end

UPD3: As @sawa mentioned in the comment, IDEA is wrong here since nil == false evaluates to false and therefore == false is not generally equal to unless.


text:
Q: Multidimensional Array Looping in cellForRowAtIndexPath Swift I have a multidimensional array that I want to display the values of  onto one UILabel in each respective cell.
My arrays look like this:
var arrayExample = [["beverages", "food", "suppliers"]["other stuff, "medicine"]]
I'm looping through these values in the cellForRowAtIndexPath in order for it to display on different cells (on a UILabel) the appropriate values:
if let onTheLabel: AnyObject = arrayOfContactsFound as? AnyObject {

                for var i = 0; i < objects!.count; i++ {

                    cell?.contactsUserHas.text = "\(onTheLabel[indexPath.row][i])" as! String

                    print("arrayOfContactsFound Printing! \(onTheLabel)")

                }

            }

When printing to the console I get:
arrayOfContactsFound Printing! (
        (
        beverages,
        "supply chain",
        pharmacuticals
    )
)

But on my label I get "beverages". That's it. How can I get the other 2 values (or X amount if there are more or less than 3 values)?
My for in loop is obviously not doing the trick. Assuming I can optimize/fix that to display all the values?
Thanks in advance.

A: In your loop you're setting the text of your label multiple times. Each time you set it it doesn't accumulate, it completely replaces the current text with the new text. You'll want something like this:
    // Remove the cast and the loop in your code example, and replace with this
    let items = arrayOfContactsFound[indexPath.row]
    let itemsString = items.joinWithSeparator(" ")
    cell?.contactsUserHas.text = itemsString

Another thing to note is your cast doesn't quite make a lot of sense.
var arrayExample = [["beverages", "food", "suppliers"]["other stuff, "medicine"]]

So arrayExample is of type [[String]]. I'm assuming each cell in your table view represents one of the arrays of strings in your array. So each cell represents one [String]. So your items should be arrayExample[indexPath.row]. The cast to AnyObject doesn't make too much sense. If anything you'd be casting it to [[AnyObject]], but there's no reason to because the compiler should already know it's [[String]].


text:
Q: How to determine what configuration options were used for MySQL server from Ubuntu Packages? How can I get compilation options that was used for mysql-server from Ubuntu packages?
I fetched sources using:
apt-get source mysql-server

But I have to run configure:
./configure

Only then I have compilation options, but they are not the same with that used for compilation.
I need exactly the same compilation options for Pinba plugin

A: command line: mysqlbug
Look for Configure command: at the bottom for all the options.


text:
Q: Responsive 4:3 image crop within columns I've created a three-column layout using Flexbox and each column has a width of 31.3%. Then, each column contains an image that occupies 100% of its column's width. Since there are no fixed widths, I'm struggling to crop and resize the images at a 4:3 aspect ratio.
This is my structure:

Event title

Event date

Event venue

          Cu cum quem eros periculis, volutpat tractatos accommodare eu has, ex singulis assueverit usu.
          Learn More

          Buy Tickets

Series title

Event title

Event date

Event venue

          Cu cum quem eros periculis, volutpat tractatos accommodare eu has, ex singulis assueverit usu.
          Learn More

Series title

Event title

Event date

Event venue

          Cu cum quem eros periculis, volutpat tractatos accommodare eu has, ex singulis assueverit usu.
          Learn More

CSS:
.events-row {
  display: flex;
  justify-content: space-around;
  padding-bottom: 30px;
}

.events-row .event-card {
  background-color: #666;
  flex-basis: 31.3%;
}

.events-row .event-card .event-card-img {
  position: relative;
  height: 295px;
}

.events-row .event-card .event-card-img:hover {
  opacity: 0.5;
}

.events-row .event-card .event-card-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.events-row .event-card .event-card-img .series-caption {
  position: absolute;
  top: 0;
  left: 0;
  padding: 5px 10px;
  font-size: 1.5em;
  color: white;
  background-color: black;
}

.events-row .event-card .event-card-info {
  padding: 15px;
  text-align: left;
  color: #333;
}

.events-row .event-card .event-card-info h1 {
  font-size: 2.5em;
  color: black;
}

.events-row .event-card .event-card-info h2 {
  line-height: 1.5;
}

.events-row .event-card .event-card-info p {
  padding: 15px 0;
  font-size: 1.75em;
}

.events-row .event-card .event-card-info p a {
  font-size: 1.1em;
}

.events-row .event-card .event-card-info .button-cont {
  text-align: center;
}

.events-row .event-card .event-card-info .button-cont .button {
  display: inline-block;
  margin: 30px;
  padding: 10px 30px;
  font-size: 1.8em;
}

Pen: http://codepen.io/ourcore/pen/NbOwaV.

A: Here is a jQuery solution: http://codepen.io/blainerw/pen/XNxEpd
The markup (HTML) is the same.
The CSS is a little different. I removed the heights from .events-row .event-card .event-card-img and .events-row .event-card .event-card-img img.
.events-row {
  display: flex;
  justify-content: space-around;
  padding-bottom: 30px;
}

.events-row .event-card {
  background-color: #666;
  flex-basis: 31.3%;
}

.events-row .event-card .event-card-img {
  position: relative;
}

.events-row .event-card .event-card-img:hover {
  opacity: 0.5;
}

.events-row .event-card .event-card-img img {
  display: block;
  width: 100%;
  object-fit: cover;
}

.events-row .event-card .event-card-img .series-caption {
  position: absolute;
  top: 0;
  left: 0;
  padding: 5px 10px;
  font-size: 1.5em;
  color: white;
  background-color: black;
}

.events-row .event-card .event-card-info {
  padding: 15px;
  text-align: left;
  color: #333;
}

.events-row .event-card .event-card-info h1 {
  font-size: 2.5em;
  color: black;
}

.events-row .event-card .event-card-info h2 {
  line-height: 1.5;
}

.events-row .event-card .event-card-info p {
  padding: 15px 0;
  font-size: 1.75em;
}

.events-row .event-card .event-card-info p a {
  font-size: 1.1em;
}

.events-row .event-card .event-card-info .button-cont {
  text-align: center;
}

.events-row .event-card .event-card-info .button-cont .button {
  display: inline-block;
  margin: 30px;
  padding: 10px 30px;
  font-size: 1.8em;
}

And then used a jQuery function to check the width of the column and add the appropriate height to the image.
function calcHeight() {

  var heightCalc = $('.event-card').width() * 0.75;

  $('.events-row .event-card .event-card-img img').height(heightCalc);

}

$(document).ready(function(){

  calcHeight();

});

$(window).resize(function() {

  calcHeight();

});


text:
Q: Unable to record an upload file scenario in JMeter though it is possible by manual effort with specific browser settings I am working on upload file module that works on internet explorer only and it requires following browser setting mandatory:
"Include local directory path when uploading files to server" should be enabled.
A failure message "Unable to upload file" displays when we do not make required setting in browser while manual attempt else it works fine.
Now when I am trying to record the scenario in JMeter, getting same error message even I made required browser settings.
Note: Additionally, I tried to include these calls by copying from browser tools and paste it in JMeter transaction but get the same result in response.
Have any one experience the same or can help me out?
Thanks,
Nitin

A: Few things to consider:

*

*Make sure that you use Java implementation of HTTP Request

*Make sure that "Use multipart/form-data for POST" is checked

*Make sure that you provide a file within "Send Files With the Request" field providing correct path, parameter name and mime-type

If all above has already been applied and you still experience problems I would recommend to capture the data being sent by Internet Explorer with a sniffer (Fiddler, Wireshark, etc.) and compare it to data, being sent by JMeter. They must be the same. If they aren't - you'll need to customize it using HTTP Header Manager, HTTP Cookie Manager, etc. If JMeter is not flexible enough to set all the required parameters via GUI, i.e. still tries to send full path of file instead of just filename or vice versa, you can always go deeper and manually build multi-part post request via Java Request Sampler (see SleepTest and JavaTest source code for details) or via Beanshell which is 100% compatible with Java syntax but may be harder to debug due to it's script nature.
Path to SleepTest and JavaTest files is follows:
/src/protocol/java/org/apache/jmeter/protocol/java/test/JavaTest.java
/src/protocol/java/org/apache/jmeter/protocol/java/test/SleepTest.java

JMeter sources are available from JMeter download page

A: Steps to upload the image using jmeter:

*

*locate the image in bin folder Select Post method and check the "Use
multipart/form-data for POST" in HTTP Request

*Provide details of Send files With the Request in HTTP Request

*Record the Upload scenario and stop button in Jmeter (Image wouldn't upload while recording in Jmeter)

*Now before running the script, Go to upload response and give the full path of image in "Send files with request field"

*Now Run the script. You can able to see the image


text:
Q: Making text appear over time with javascript I am trying to create a simple web page when I ran into a problem that I might need everyone to help me solve. Say I was writing some text in font, and I want
text to appear right under it under 10 seconds. Is this possible? I've tried Google already. It's results weren't so decent.

A: As your question was not very clear, I guess this might (or might not) be what you are looking for:

setTimeout(function() {
    document.getElementById('element').innerHTML += '
More text';
}, 10000);

Some text

A: Kinda rough, but gets the point across if what you want is text to display directly under some other text. (However, looks like you simply wanted a paragraph line break using
.)

setTimeout(function(){
    var _text = document.getElementById('text-over'),
        under = document.createElement('span');

    under.className = 'text-under';
    under.textContent = 'Under';

    _text.append(under);

    console.log(_text, under);
}, 10000);
#text-over {
  position: relative;
  display: inline-block;
}
.text-under {
  position: absolute;
  bottom: -20px;
  left: 0;
}

  Text will go under there.

A: This can be achieved using CSS animations:

.more {
  animation: fadein 10s steps(1, end);
}

@keyframes fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

Some text

Some more


text:
Q: Magento how to add extra fields for static block I've been trying to add extra fields to the static block so it will be easier to update.
How can I add a simple textfield or maybe a image upload field?
See example: http://i.stack.imgur.com/2HtDC.jpg
Thanks in advance!

A: For this, you need to overwrite this class Mage_Adminhtml_Block_Cms_Block_Edit_Form. This class is used to add fieldsets and fields for cms_block. Take a look on the _prepareForm() method inside it.
If you put this code, just after Title field,
    $fieldset->addField('sub_title', 'text', array(
        'name'      => 'sub_title',
        'label'     => Mage::helper('cms')->__('Sub Title'),
        'title'     => Mage::helper('cms')->__('Sub Title'),
        'required'  => true,
    ));

you can see your sub-title text field in static blocks. However Do not edit a core file directly. You need to write a custom module that should overwrite this class. Your Module config file should contain this code
File : app/code/local/Namespace/Module/etc/config.xml
<config>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                     <cms_block_edit_form>Namespace_Module_Block_Adminhtml_Cms_Block_Edit_Form</cms_block_edit_form>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>

This will allow you to rewrite the class. What you need to do now is define the rewrite class now and in there you need to rewrite _prepareForm(). It should some what look like this.
Location :  app/code/local/Namespace/Module/Block/Adminhtml/Cms/Block/Edit/Form.php
<?php
class Namespace_Module_Block_Adminhtml_Cms_Block_Edit_Form extends Mage_Adminhtml_Block_Cms_Block_Edit_Form {

     protected function _prepareForm()
    {
        //put all the code inside parent class here
        //then place the below content in appropriate place

        $fieldset->addField('sub_title', 'text', array(
            'name'      => 'sub_title',
            'label'     => Mage::helper('cms')->__('Sub Title'),
            'title'     => Mage::helper('cms')->__('Sub Title'),
            'required'  => true,
        ));
        return parent::_prepareForm();

    }
}

Try based on this idea
EDIT
Please note, it will allow you to put new field in cms > block, howver to save this, you need to define model for your module. You have two options. Add a new field to save your new field in Cms > Block table or create your own table and store this value in that field along with the referene to cms >block table. This is out of box  and you should implement it your own way.
Happy coding

A: In adition to @Rajeev
You need get the parent form in this way...
<?php
    class Namespace_Module_Block_Adminhtml_Cms_Block_Edit_Form extends Mage_Adminhtml_Block_Cms_Block_Edit_Form {

         protected function _prepareForm()
        {
          $form = parent::_prepareForm()->getForm();
          $fieldset = $form->addFieldset('fieldset_example', array('legend'=>Mage::helper('core')->__('My example fieldset')));
          $fieldset->addField('sub_title', 'text', array(
                'name'      => 'sub_title',
                'label'     => Mage::helper('cms')->__('Sub Title'),
                'title'     => Mage::helper('cms')->__('Sub Title'),
                'required'  => true,
            ));
            return $this;
        }
    }

A: My suggestion is, rather add an extra field, you can add a <div>...</div> to in the content are by removing what you see is what you get editor(just click on the show / hide Editor).
And for image you can direct upload images by clicking on the inset/edit image option from the menu.
It will be simpler than creating custom fields.


text:
Q: How do I get Pylint message IDs to show up after pylint-1.0.0? Starting with pylint-1.0.0 the --include-ids argument is no longer allowed.
How do I get:
************* Module foo.bar
E:199,11: Module 'yaml' has no 'scanner' member (no-member)
************* Module foo.baz
W:153,27: Unused variable '_filenames' (unused-variable)

to show the IDs (e.g. W0142), for each warning?

A: The new way to specify this is the command line parameter '--msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'.

A: The proper command which can be used is
python3 -m pylint --msg-template="{path}||{msg_id}||{symbol}||{category}||{line}||{column}||{msg}" sscript.py


text:
Q: How to find the time and step between status change I'm trying to query a dataset about user status changes. and I want to find out the time it takes for the status to change, and the steps in between(number of rows).
Example data:

user_id
Status
date

1
a
2001-01-01

1
a
2001-01-08

1
b
2001-01-15

1
b
2001-01-28

1
a
2001-01-31

1
b
2001-02-01

2
a
2001-01-08

2
a
2001-01-18

2
a
2001-01-28

3
b
2001-03-08

3
b
2001-03-18

3
b
2001-03-19

3
a
2001-03-20

Desired output:

user_id
From
to
days in between
Steps in between

1
a
b
14
2

1
b
a
16
2

1
a
b
1
1

3
b
a
12
3

A:   with main as (

    select
      *,
      dense_rank() over(partition by user_id order by date) as rank_,
      row_number() over(partition by user_id, status  order by date) as rank_2,
      row_number() over(partition by user_id, status  order by date) -  dense_rank() over(partition by id order by date) as diff,
      row_number() over(partition by user_id  order by date)  as row_num,
      lag(status) over(partition by user_id order by date) as prev_status,
      concat(lag(status) over(partition by user_id order by date) , ' to ' , status) as status_change
    from table
    ),

  new_rank as (
    select
      *,
      rown_num - diff as row_num_diff,
      min(date) over(partition by user_id, status, rown_num - diff) as min_date
    from main
    ),

  prev_date as (
    select
      *,
      lag(min_date) over(partition by user_id order by date) as prev_min_date
    from new_rank
    )
    select
      status as from,
      prev_status as to,
      date_diff(prev_min_date, min_date, DAY)  as days_in_between
    from prev_date
    where status !=prev_status and prev_status is not null

Does this seem to work? I tried to solve this but it's very hard to solve it without a fiddle plus:

*

*you may remove the extra steps/ranks that I have added, I left them there so you can visually see what they are doing

*I don't get your steps logic so it is missing from the code

A: You might consider below another approach.
WITH partitions AS (
  SELECT *, COUNTIF(flag) OVER w AS part FROM (
    SELECT *, ROW_NUMBER() OVER w AS rn, status <> LAG(status) OVER w AS flag,
      FROM sample_data
    WINDOW w AS (PARTITION BY user_id ORDER BY date)
  ) WINDOW w AS (PARTITION BY user_id ORDER BY date)
)
SELECT user_id,
       LAG(ANY_VALUE(status)) OVER w AS `from`,
       ANY_VALUE(status) AS `to`,
       EXTRACT(DAY FROM MIN(date) - LAG(MIN(date)) OVER w) AS days_in_between,
       MIN(rn) - LAG(MIN(rn)) OVER w AS steps_in_between
  FROM partitions
 GROUP BY user_id, part
QUALIFY `from` IS NOT NULL
WINDOW w AS (PARTITION BY user_id ORDER BY MIN(date));

Query results


text:
Q: Customer Adresses rest api - add created_at I need to return on the webservice /rest/V1/customers/ the created_at and updated_at fields from the table customer_address_entity. Any help?
thanks !

A: You have to create extension attributes. Please follow below links for the reference:
https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html


text:
Q: Tooltips for the netbeans IDE How do I get tooltip help from Netbeans 7.3?
And side-by-side dropdown boxes which divert me to the correct classes and methods?
Thanks
Jack

A: You can get tooltip help from the IDE by hovering a line that has some sort of light bulb on the left of your code like below:

Then Pressing Alt-Enter the IDE will give you a list of suggestions of how you can improve/modify your code.
Also you can get the auto complete functionality by pressing CTRL+SPACE in the code editor. This will bring up any javadoc information about the Method/Object/etc like below:


text:
Q: SwiftUI List with NavigationLink and Buttons I have a List of counters - every element in the List is a counter with a number and plus/minus buttons users can click to increase or decrease the counter. Now I added a NavigationLink so that users can go to a detail view of every counter. The problem is now wherever you click on the list the detail view gets always pushed - even if you click on one of the buttons (counter increases then the detail view gets pushed via the NavigationLink) - I only want to use the NavigationLink if the user clicks on the number or somewhere else but of course not if the users clicks on of the buttons. How can this be done?
NavigationView {
        List {
            ForEach(counters, id: \.self) { counter in
                NavigationLink(destination: SingleCounterView(currentCounter: counter)) {
                    CounterCell(counter: counter)
                }
            }
        }
        .buttonStyle(PlainButtonStyle())
        .listStyle(GroupedListStyle())
}

A: I've made this test, to show a CounterCell with plus and minus buttons in a NavigationView. If you tap on the buttons the counter increments, if you tap on the chevron or outside the buttons the destination appears.
@State var counters = ["a","b","c"]

var body: some View {
    NavigationView {
        List {
            ForEach(counters, id: \.self) { counter in
                NavigationLink(destination: Text(counter)) {
                    CounterCell(counter: counter)
                }
            }
        }
        .buttonStyle(PlainButtonStyle())
        .listStyle(GroupedListStyle())
    }.navigationViewStyle(StackNavigationViewStyle())
}

struct CounterCell: View {

@State var counter: String
@State var inc = 0

var body: some View {
    HStack {
        Button(action: { self.inc += 1 }) {
            Text("plus")
        }
        Button(action: { self.inc -= 1 }) {
            Text("minus")
        }
        Text(" counter: \(counter) value: \(inc)")
    }
}
}


text:
Q: YUV420 to BGR image from pixel pointers I am capturing raw output from a decoder which is YUV420. I have got three pointers: Y(1920*1080), U(960*540) and V(960*540) separately.
I want to save the image as JPEG using OpenCV. I tried using cvtcolor of opencv
cv::Mat i_image(cv::Size(columns, rows), CV_8UC3, dataBuffer);
cv::Mat i_image_BGR(cv::Size(columns, rows), CV_8UC3);
cvtColor(i_image, i_image_BGR, cv::COLOR_YCrCb2BGR);
cv::imwrite("/data/data/org.myproject.debug/files/pic1.jpg", i_image_BGR);

But, here is the output image which is saved:

Can someone please suggest what is the proper way of saving the image?
YUV Binary files for reference

A: Following is the process to convert the provided YUV files into RGB image.

*

*Read Y, U and V binary files into byte buffers

*Create OpenCV Mat object from the created buffers.

*Resize U and V Mats to the size of Y.

*Merge Y and resized U and V.

*Convert from YUV to BGR

Be advised that the resizing step is just an optimized way of repeating the values of U and V. This is only valid in the case where Y has twice the resolution of U and V in both dimensions. This approach should be invalid for arbitrary size images (not tested).
Here is the code for the above-mentioned process.
#include <iostream>
#include <vector>
#include <opencv2/opencv.hpp>

std::vector<unsigned char> readBytesFromFile(const char* filename)
{
    std::vector<unsigned char> result;

    FILE* f = fopen(filename, "rb");

    fseek(f, 0, SEEK_END);  // Jump to the end of the file
    long length = ftell(f); // Get the current byte offset in the file
    rewind(f);              // Jump back to the beginning of the file

    result.resize(length);

    char* ptr = reinterpret_cast<char*>(&(result[0]));
    fread(ptr, length, 1, f); // Read in the entire file
    fclose(f); // Close the file

    return result;
}

int main(int argc, char** argv)
{
    cv::Size actual_size(1920, 1080);
    cv::Size half_size(960, 540);

    //Read y, u and v in bytes arrays
    auto y_buffer = readBytesFromFile("ypixel.bin");
    auto u_buffer = readBytesFromFile("upixel.bin");
    auto v_buffer = readBytesFromFile("vpixel.bin");

    cv::Mat y(actual_size, CV_8UC1, y_buffer.data());
    cv::Mat u(half_size, CV_8UC1, u_buffer.data());
    cv::Mat v(half_size, CV_8UC1, v_buffer.data());

    cv::Mat u_resized, v_resized;
    cv::resize(u, u_resized, actual_size, 0, 0, cv::INTER_NEAREST); //repeat u values 4 times
    cv::resize(v, v_resized, actual_size, 0, 0, cv::INTER_NEAREST); //repeat v values 4 times

    cv::Mat yuv;

    std::vector<cv::Mat> yuv_channels = { y, u_resized, v_resized };
    cv::merge(yuv_channels, yuv);

    cv::Mat bgr;
    cv::cvtColor(yuv, bgr, cv::COLOR_YUV2BGR);
    cv::imwrite("bgr.jpg", bgr);

    return 0;
}

Compiled and tested with following command:

g++ -o yuv2rgb -std=c++11 yuv2rgb.cpp -L/usr/local/lib -lopencv_core
  -lopencv_imgcodecs -lopencv_highgui -lopencv_imgproc

Following output image is generated by executing the above code:

A: I think OpenCV matrix for your input yuv420 planar image should have 1 channel format instead of 3 channel. Place there Y channel, then U, then V. I found a very similar question HERE Planar YUV420 and NV12 is the same

A: For those who came here for YUV 420 to BGR/RGB Conversion (First Google search Result),
Please refer to this code:
#include "opencv2/opencv.hpp"
#include "opencv2/opencv_modules.hpp"
#include <iostream>
#include <fstream>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
    Size iSize(512,512);
    int iYUV_Size = iSize.width * (iSize.height + iSize.height / 2);

    Mat mSrc_YUV420(cv::Size(iSize.width,iSize.height+ iSize.height / 2),CV_8UC1);

    ifstream FileIn;
    FileIn.open("Sample_YUV420_512x512.yuv", ios::binary | ios::in);

    if (FileIn.is_open())
    {
        FileIn.read((char*)mSrc_YUV420.data, iYUV_Size);
        FileIn.close();
    }
    else
    {
        printf("[Error] Unable to Read the Input File! \n");
    }

    Mat mSrc_BGR(cv::Size(iSize.width, iSize.height), CV_8UC1);

    cv::cvtColor(mSrc_YUV420, mSrc_BGR, COLOR_YUV2BGR_I420);

    imshow("Input YUV Image", mSrc_YUV420);

    imshow("Input RGB Image", mSrc_BGR);

    cv::waitKey();

    return 0;
}


text:
Q: Proof on Fubini's Theorem The Fubini's Theorem states that for any two $\sigma$-finite measure spaces $(S,\mathcal{S},\mu)$ and $(T,\mathcal{T},\upsilon)$, there exists a unique measure $(\mu \otimes \upsilon)(A\times B)=\mu A \cdot \upsilon B$, $\forall A\in\mathcal{S},B\in\mathcal{T}$.
Further more, for any measurable function $f:S\times T\rightarrow\Bbb{R}_+$,
$$(\mu\otimes\upsilon)f=\int\mu(ds)\int f(s,t)\upsilon(dt)=\int\upsilon(dt)\int f(s,t)\mu(ds)$$
Prove the following:
$$\Bbb{E}(\xi^p)=p\int^{\infty}_0 P(\xi>t)t^{p-1}dt$$
Where $\xi$ is a non-negative random varibale and $\xi^p=p\int^{\infty}_0 1\{t<\xi\}t^{p-1}dt$.
Can someone e give me some hints on the proof ? Thanks.

A: We have, just expanding the definitions:
$$\begin{align}
\Bbb E(\xi^p) &= \int \xi^p \, \mathrm dP = \int \left(p \int_0^\infty 1_{\{t < \xi\}}t^{p-1} \,\mathrm dt\right)\,\mathrm dP
\end{align}$$
Can you see what Fubini's Theorem has to do with this?

A: \begin{align}
\Bbb E(\xi^p) =
&
\int \xi^p \, \mathrm d P
\\
=
&
\int \left( \int_0^\infty 1_{\{t < \xi\}}pt^{p-1} \,\mathrm dt\right)\,\mathrm d P
\\
=
&
 \int_0^\infty \left( \int 1_{\{t < \xi\}}pt^{p-1} \,\mathrm d P \right) \,\mathrm dt
\\
=
&
 \int_0^\infty \left( \int_{\{t < \xi\}}pt^{p-1} \,\mathrm d P \right) \,\mathrm dt
\\
=
&
 \int_0^\infty pt^{p-1} \left( \int_{\{t < \xi\}} \,\mathrm d P \right) \,\mathrm dt
\\
=
&
 \int_0^\infty pt^{p-1} P(t < \xi) \,\mathrm dt
\\
\end{align}


text:
Q: Download APK file using PHP I am trying to download an android APK file using php in my PC browser using Chrome.
My app is located in a particular path in the server.  If I manually FTP the file from server and transfer to my android mobile it installed perfect.  But when I downloaded using PHP and transfer the downloaded file to Mobile and while installing it throws 'there was a problem while parsing the package'.
Here is my PHP code I use to download
header('Content-Type: application/vnd.android.package-archive');
header('Content-Disposition: attachment; filename="' . $file_name . '"');
readfile($file_path);
return true;

fyi...
$file_name is the apk file file 'myfile.apk'
$file_path is the full absolute path of the file in server ('d:\abcd\xyz\xampp\htdocs\apkstore\myfile.apk')

I found one observation while trying to open the APK file using 7-zip.
When I open the file using 7-zip it throws an error 'Cannot open the file xxx as archive'
After I added the below PHP code
header("Content-length: " . filesize($file_path));

Now when I open the file using 7-zip it opens the file but the size of the downloaded file is greater than the original file.  And when I open this file in mobile the same error 'there was a problem while parsing the package'
To cut my long story short, I am trying to download an APK file from server to localhost using PHP and I'm able to make it work.

A: I managed to make it work by adding ob_end_flush()
header('Content-Type: application/vnd.android.package-archive');
header("Content-length: " . filesize($file_path));
header('Content-Disposition: attachment; filename="' . $file_name . '"');
ob_end_flush();
readfile($file_path);
return true;


text:
Q: Batch file to start all programmes in the start folder of XP I need start all folders in a the Windows "Start/Programs/Startup folder" of an XP machine, explorer is disabled to stop top people playing and remove the Start and Task-bar.
I can run a batch file at start-up but how do I write the batch to run ALL programs in the "Start/Programs/Startup folder" the programs in the folder may change but the batch needs to remain the same
I am able to open each file individually using the below code but I really need to be able to open everything in the folder to avoid problems in the future
start "" /b "C:\Documents and Settings\User\Start Menu\Programs\Startup\PROG.appref-ms"

A: This is an interesting request--one that I would question the motive behind, but since you asked, here's a way you could accomplish it:
@echo off
set DIR=C:\Your\Directory
for %%a in ("%DIR%\*") do "%%a"

A: I have tried the code below, that batch starts but nothing starts
%DIR%=C:\Documents and Settings\Pete\Start Menu\Programs\Startup
for %%a in (%DIR%\*) do "%%a"

Running the batch from the desktop also doesn't run the programs in the start folder, the DIR address is taken from windows explorer when I navigated to the folder with the short cuts in


text:
Q: Question about websocket and loction.replace I try to use Deno ws to reload the document, but it will throw an error after second reload
Uncaught ConnectionReset: Socket has already been closed throw new Deno.errors.ConnectionReset("Socket has already been closed");
var ws = new WebSocket("ws://127.0.0.1:8080/ws")
    ws.onopen = function () {
      ws.send('ws open')
      console.log('ws open');
    }
    ws.addEventListener("message", (e) => {
      if (e.data === 'fileUpdate') {
        // ws.send('close')
        location.replace(location.href);
      }
    })

seem location.replace(location.href) raise an error
any solution?

A: The error is happening because you're sending a message after the socket is closed.
When you do: location.replace(location.href); the page is refreshed and the current socket is closed.
You can either catch the error, or check for ws.isClosed before sending the message.
for await (const e of ws) {
  if (e === 'close') {
    ob.remove("fileUpdate")
    continue
  }
  ob.on("fileUpdate", () => {
    console.log('sending')
    if(!ws.isClosed)
       ws.send("fileUpdate")
  })
}

While that will fix the error, it won't fix the cause. Your ob.on('fileUpdate') event is firing after the socket is closed. You should clear that listener on the WebSocket close event, you can do that using ws.isWebSocketCloseEvent
import { acceptWebSocket, isWebSocketCloseEvent } from "https://deno.land/std@0.51.0/ws/mod.ts";
/* ... */
for await (const e of ws) {
  if(isWebSocketCloseEvent(e) || e === 'close') {
    // clear listeners here
    ob.remove("fileUpdate")
    // if e === 'close' you may want to close the socket
  }
}

A: here is Deno code :
import { Application } from "https://deno.land/x/abc/mod.ts";
import { acceptWebSocket } from "https://deno.land/std@0.51.0/ws/mod.ts";
new Application()
  .file("/", "./index.html")
  .file("/module.js", "./module.js")
  // .file("sw.js", "ServiceWorker.js")

  .get('/ws', async (c: any) => {
    const { conn, headers, r: bufReader, w: bufWriter } = c.request;
    const ws = await acceptWebSocket({
      conn,
      headers,
      bufReader,
      bufWriter,
    });
    for await (const e of ws) {
      if (e === 'close') {
        ob.remove("fileUpdate")
        continue
      }
      ob.on("fileUpdate", () => {
        ws.send("fileUpdate")
      })
    }
  })
  .start({ port: 8080 })

ob like this :
class Ob {
  private list: ObList[] = []
  send(event: string) {
    this.list.forEach((e: ObList) => {
      if (e.event === event) {
        e.cb && e.cb()
      }
    })
  }
  on(event: string, cb: Function) {
    this.list.push({ event, cb })
  }
  remove(event:string){
    this.list=this.list.filter((e:ObList)=>{
      return e.event!==event
    })
  }
}

the framework is abc


text:
Q: "Select distinct case when..." query conversion from raw PHP to Laravel query builder I have a table in my database named 'messages' and the basic columns are message_from,message_to, message. I need to list the other users who sent messages to me or I sent messages to whom. And I am trying to convert a raw PHP query in Laravel.
Raw Query:
$user_id = 'my_user_id';

Select Distinct case when message_from = '$user_id' then message_to else message_from end as
contact from messages where '$user_id' in (message_from, message_to) ORDER BY id DESC

My Conversion to Laravel:
$user_id = Auth::user()->user_id;

$messages = DB::table('messages')
            ->selectRaw("(SELECT DISTINCT CASE WHEN message_from = '$user_id' THEN message_to
              ELSE message_from END as messages FROM messages WHERE '$user_id' IN
              (message_from,message_to)")
            ->latest()
            ->get();

But unfortunately, it's not working. I am getting this error:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;
 check the manual that corresponds to your MariaDB server version for the right syntax to use near
'from `messages` order by `created_at` desc' at line 1 (SQL: select (SELECT DISTINCT CASE WHEN
 message_from = 'client-20220215L0pu1xDTy9S3SKf8055449' THEN message_to ELSE message_from END as
 messages WHERE 'client-20220215L0pu1xDTy9S3SKf8055449' IN (message_from,message_to) from
`messages` order by `created_at` desc)

A: What is wrong in your current query is you slammed the entire query in the select part of the query builder, which will not work because Laravel will try to build the rest of the query around it so will look like SELECT (SELECT CASE...FROM...WHERE) FROM ... which is clearly not the query you wanted it to perform.
Your query would look better like:
DB::table('messages')
   ->selectRaw("CASE WHEN message_from = ? THEN message_to
              ELSE message_from END as messages", [ $user_id ])

            ->where('message_from', $user_id)
            ->orWhere('message_to', $user_id)
            ->latest()
            ->distinct()
            ->get();

Note that I changed the WHERE $user_id IN (message_from, message_to) to WHERE message_from = $user_id OR message_to = $user_id because the other syntax can also only be done with a raw query.
Also notice the parameters used in selectRaw rather than injecting the user_id which may be dangerous (depending on context it is unclear whether $user_id comes from user input directly or indirectly).


text:
Q: Android UI transition not as expected I am trying to launch an SMS app (Messenger/Hangouts) from my app. But the UI transition is not as expected. On launch, my app moves to the background and SMS app is launched from below the screen and this transition is slow and very much visible to the user.
I want the transition to be as fast as possible without showing any animation. I tried overridePendingTransition(0,0) and setting the Intent flag (FLAG_ACTIVITY_NO_ANIMATION), still does not help.
What should I be doing to acheive this?

A: This snippet of code works fine for me:
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setData(Uri.parse("sms:"));
overridePendingTransition(0,0);
startActivity(sendIntent);

Please paste the relevant code you have used for the same if the above does not work and I can look into it. Hope this helps!


text:
Q: getTimezoneOffset does not work all the time I register the following javascript on my web page.  When the user posts back, SOMETIMES the txtTimeZoneOffSet hidden field comes back as blank. When I test on my computer, I always get a value.  It happens on different browsers (I.E, FireFox, and Safari).
I am trying to get the users offset, so when they enter a date, I can convert it to UTC on the server and deal with everything in the same timezone, then when I render dates back out to them, I make sure it is in their timezone.
<script type='text/javascript'>
      $(window).load(function () {
            var d = new Date();
            var tz = d.getTimezoneOffset();

            $('#txtTimeZoneOffSet').val(tz / 60);
        });
</script>

Does anyone see why this would not work 100% of the time?

A: The jQuery looks fine to me, so I don't see why it wouldn't work unless JavaScript was disabled or you didn't load jQuery.
However, you are worked on a flawed assumption that the user's current offset will be the same for all dates.  In any time zone that has daylight saving time, it could be wrong.
The better approach would be to convert to UTC on the browser.  Or at least use the date/time in question in the call to getTimezoneOffset.
UPDATED ANSWER
In response to your question, the code you have now will get the current offset already.  You are just not guaranteed that it will be the same offset for any date they might enter.  For example:
<input type="text" id="someDate" />

var someDateString = $('#someDate').val();
var dt = new Date(someDateString);
var offset = dt.getTimezoneOffset();

Since the value of the text input is variable, in many time zones you will get a different offset for January than you will for June.  So the better thing would be to just convert it to UTC on the browser:
var someDateString = $('#someDate').val();
var dt = new Date(someDateString);
var s = dt.toISOString();

The string s will be in ISO8601 format, and will already be converted to UTC.
Of course, if it were me I would do this using moment.js - since it gives you much better control of how the input string is parsed.
This approach is usually good enough.  HOWEVER, if there is any chance you will have to do this conversion on the server, perhaps because the user is not present, then you must know their time zone.  Not just the offset, but the actual time zone.  See "Time Zone != Offset" in the timezone tag wiki.
The best way is to ask them for it.  A map-based picker like this one is a nice touch.  You can even guess at a default selection using jsTimezoneDetect.  Ultimately you are after a string identifier like America/New_York that you can use on your server.  In .Net you can use these with the TZDB provider in Noda Time.
If you don't want any fancy libraries, you can stick with Windows time zones, and present a dropdown list from TimeZoneInfo.GetSystemTimeZones(), where the .Id is the key and the .DisplayName is the value.


text:
Q: undefined reference to cv::Formatter::get(char const*) opencv I followed the tutorial trainHOG Tutorial  for training Images in OpenCV
I have included all libraries, include files.
I tried running the code on Win7x64, code blocks IDE, opencv 2.4.7
I am getting following errors when I compiled the code :
D:\opencv\build\x64\mingw\lib\libopencv_ts247.a(ts_perf.cpp.obj):ts_perf.cpp:(.text.unlikely._ZN2cvlsERSoRKNS_3MatE+0x15)||undefined reference to `cv::Formatter::get(char const*)'|
D:\opencv\build\x64\mingw\lib\libopencv_ts247.a(ts_perf.cpp.obj):ts_perf.cpp:(.text$_ZN12_GLOBAL__N_115PerfEnvironment8TearDownEv+0xb)||undefined reference to `cv::setNumThreads(int)'|
Pls help me solve the errors.


text:
Q: Material Design dark theme colors overlay I want use Material Design dark theme guidelines (https://material.io/design/color/dark-theme.html) in HTML code, but i can't find info, how to overlay colors for get lighter colors (example: Dark gray (#121212) background and bit lighter panels).
I know that some JS frameworks support this, but i want use pure HTML/CSS.
How to make this?

A: I'm not sure if this is exactly what you're describing, but you can create an element with a background-color that has adjustable transparency using an RGBA color. IE to do a 50% translucent white overlay: background-color: rgba(255,255,255,0.5).

.container {
  background-color: darkred;
  height: 200px;
  width: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.content {
  background-color: rgba(255, 255, 255, 0.5);
  height: 100px;
  width: 100px;
}

  test

You could also layer your colors using gradient background-images, which would let you do the layering in a single element. This lets you stack the colors:

.content {
  height: 200px;
  width: 200px;
  background-image: linear-gradient(rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.5) 100%), linear-gradient(darkred 0%, darkred 100%);
}

  test

Make sure to put the top layer first in the rule.


text:
Q: Download huge number of images in the most efficient and fast way In my app, I am needing to download about 6,000 images. I realize this is a lot, but it is needed.
Currently I am using doing the following:
NSArray *photos = @[hugeAmountOfPhotoObjects];
for (ZSSPhoto *photo in photos) {
    [self downloadImageWithURL:photo.mobileURL progress:^(double progress) {

    } completion:^(UIImage *image) {

        // Save the image

    } failure:^(NSError *error) {

    }];
}

...
- (void)downloadImageWithURL:(NSURL *)url progress:(void (^)(double progress))progress completion:(void (^)(UIImage *image))completion failure:(void (^)(NSError *error))failure {

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
    [request setTimeoutInterval:600];
    self.operationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount;
    AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
    requestOperation.responseSerializer = [AFImageResponseSerializer serializer];
    [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        completion(responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [self processOperation:operation error:error failure:failure];
    }];
    [requestOperation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
        double percentDone = (double)totalBytesRead / (double)totalBytesExpectedToRead;
        progress(percentDone);
    }];
    [self.operationQueue addOperation:requestOperation];

}

The problem here is that it takes forever to download using this method, and some of my users are reporting crashing because of high memory usage.
Is there a better method that I could be using to download such a large number of image files?

A: You could try this somewhat recursively
NSMutableArray *undownloaded;

- (void) startDownload {

    undownloaded = [photos mutableCopy]; //get a list of the undownloaded images

    for(int i = 0; i < 3;i++) //download 3 at a time
        [self downloadImage];
}

- (void) downloadImage {

    if(undownloaded.count > 0){

        ZSSPhoto *photo = undownloaded.firstObject;
        [undownloaded removeObjectAtIndex:0];

        [self downloadImageWithURL:photo.mobileURL progress:^(double progress) {

        } completion:^(UIImage *image) {

            // Save the image

            [self downloadImage];

        } failure:^(NSError *error) {

            [self downloadImage];
            //[undownloaded addObject:photo]; //insert photo back into the array maybe to retry? warning, could cause infinite loop without some extra logic, maybe the object can keep a fail count itself

        }];
    }
}

warning: untested code, may need some tweaking

A: The speed problem can be solved (the speed will increase, but it might still be slow) with multithreading, downloading all the images at the same time instead of one per time. However, the memory problem is a bit more complicated.
ARC will release all the images after everything is finished, but right before that you gonna have 6,000 images in the device memory. You could optimize the images, reduce their resolution or download them in steps, like Google Images do (you download the images that will be visible at first, then when the user scrolls down you load the images in the new visible area; downloading the images only when they are needed).
Considering that you are downloading enough images to give a memory problem, you will probably take a lots of space in your user's device if you download all of them, and the 'steps' solution may solve that as well.
Now, let's suppose you must download all of them at the same time and space isn't a problem: I suppose that if you put the downloadImageWithURL:progress: method inside a concurrent queue, the images are gonna be freed from memory just after saving (it's just a supposition). Add this to your code:
dispatch_queue_t defaultPriorityQueueWithName(const char* name)
{
    dispatch_queue_t dispatchQueue = dispatch_queue_create(name, DISPATCH_QUEUE_CONCURRENT);
    dispatch_queue_t priorityQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_set_target_queue(dispatchQueue, priorityQueue);
    return dispatchQueue;
}

And change your code to that:
dispatch_queue_t threadItemLoadImage = defaultPriorityQueueWithName("DownloadingImages");
NSArray *photos = @[hugeAmountOfPhotoObjects];
for (ZSSPhoto *photo in photos)
{
    dispatch_async(threadItemLoadImage, ^
    {
        [self downloadImageWithURL:photo.mobileURL progress:^(double progress) {

        } completion:^(UIImage *image) {

            // Save the image

        } failure:^(NSError *error) {

        }];
    });
}

You will need to remove setDownloadProgressBlock: in case it updates some view, since they will be downloaded simultaneously. Also, a warning: totalBytesExpectedToRead not always will be correctly retrieved at first, containing 0, which might make your app crash for dividing by zero as well in some rare occasions. In future cases, when you need to use setDownloadProgressBlock:, check totalBytesExpectedToRead value before doing that division.


text:
Q: WPF binding to 2D array I've been learning WPF and MVVM. I am trying to create a chess game. I have the game state represented as a 2D (8x8) array of pieces. The board is displayed as a UniformGrid of 64 elements. Everytime the game state changes, I loop through the game state array and update each square on the displayed board accordingly. Is there a better (more WPF) way to do this? I thought I could somehow bind each of the squares of the displayed board to the game state and define a value convertor that would access the array but I don't really know how to do that. I would appreciate any help.

A: Maybe switch to using ObservableCollection and bind it with, say a ListBox's ItemsSource property. also Consider extending the collection class to support 2d indexer so that you can manipulate cells the same way you did with the 2d array:
public class ObservableCollectionC<T> : ObservableCollection<T>{
    public ObservableCollectionC(IEnumerable<T> p) : base(p){ }
    public T this[int m, int n]{
        get  { return this[m*8+n]; }
        set  { this[m*8+n] = value; }
    }
}


text:
Q: Improper app resolution on emulator An app I am creating in Android Studio is spanning about 350dp by width and 390dp by height. When running the app on Nexus 5 emulator, part of the app UI is cut out. The emulator only displays about 200dp of the app's width; meaning that part of it is cut out.
The emulator does not show the whole GUI and at the same time, its packing part of GUI horizontally instead of spacing them accordingly as I created it. Also the the theme background is not also displayed as I chose fro the theme combobox rather it displays the default theme of a blue at upper title bar.

A: setting specified height and width will cause different phone screens to display differently. I would recomend as you are using android studio to use relative or linier layouts in your activity layout xml insted of setting specified display height and width.


text:
Q: JQuery window resize for Elementor Pro popups I'm relatively new to JQuery. I'm using Elementor Pro to build my website.
Problem Statement: Trigger Elementor popup content on browser resize.
The code I'm using right now is as follows:
  $(window).resize(function(){
  var win = $(this); //this = window
  if (win.height() < 768)
  {
      elementorProFrontend.modules.popup.showPopup({ id: 1234 });
      alert("Resize detected!");}
  });

The problem: The popup doesn't trigger on browser resize. Can someone please guide me on fixing this? Your help will be much appreciated. Thank you!

A: Just replace all the $ symbol in your code with jQuery and make sure you are resize browser in vertical code:
jQuery(window).resize(function(){
 var win = jQuery(this); //this = window
 if (win.height() < 768) {
  elementorProFrontend.modules.popup.showPopup({ id: 1234 });
  alert("Resize detected!");}
});


text: Q: I need to identify day, month and year selected in datetimepicker and validate the date I need to set up a calendar in datetimepicker with simple rules, day can't be less than 01, day can't be greater than 31, month can't be less than 01, month can't be greater than 12, year can't be less than 0001 and also identify the leap year to set February with 28 or 29 days.