text:
Q: Maven downloads Spring-AOP 3.0.0.RC3 instead of 3.1.1.Final I am trying to upgrade spring-aop from Maven. I tried to delete all Spring files from my .m2 repo, however, when I run mvn dependency:tree I see 3.0.0.RC3 instead of 3.1.1.final...
Dependency tree:
[INFO] com.abercrombie.loyalty:LoyaltyProvider:war:0.0.1-SNAPSHOT
[INFO] +- org.springframework:spring-aop:jar:3.0.0.RC3:compile
[INFO] +- org.springframework:spring-beans:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:3.1.1.RELEASE:compile
[INFO] |  \- org.springframework:spring-asm:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:3.1.1.RELEASE:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-expression:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:3.1.1.RELEASE:compile
[INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-web:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.1.1.RELEASE:compile
[INFO] +- com.thoughtworks.xstream:xstream:jar:1.3.1:compile
[INFO] |  \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] +- com.ibm.db2:db2jcc:jar:2.10.113:compile
[INFO] +- com.ibm.db2:db2jcc_license:jar:2.10.113:compile
[INFO] +- org.hibernate:hibernate-core:jar:3.5.6-Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.1:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] |  +- javax.transaction:jta:jar:1.1:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.5.8:compile
[INFO] +- org.hibernate:hibernate-annotations:jar:3.5.6-Final:compile
[INFO] |  +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] |  \- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
[INFO] +- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] |  \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.5.6:compile
[INFO] +- javassist:javassist:jar:3.12.1.GA:compile
[INFO] +- cglib:cglib:jar:2.2.2:compile
[INFO] |  \- asm:asm:jar:3.3.1:compile
[INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.1.12:compile
[INFO] |  \- javax.xml.bind:jaxb-api:jar:2.1:compile
[INFO] |     +- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] |     \- javax.activation:activation:jar:1.1:compile
[INFO] +- com.sun.jersey:jersey-core:jar:1.11:compile
[INFO] +- com.sun.jersey:jersey-server:jar:1.11:compile
[INFO] \- com.sun.jersey.contribs:jersey-spring:jar:1.11:compile
[INFO]    \- com.sun.jersey:jersey-servlet:jar:1.11:compile

POM Dependencies
<spring.version>3.1.1.RELEASE</spring.version>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-aop</artifactId>
   <version>${spring.version}</version>
</dependency>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-beans</artifactId>
   <version>${spring.version}</version>
</dependency>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
   <version>${spring.version}</version>
   </dependency>
<dependency>

how do I get it using 3.1.1.Final?

A: One of your other dependencies is almost definitely transitively pulling in a different version of spring. I confirmed that if I add a dependency on jersey-spring I get an older version of spring-aop. You can fix it by just adding a dependencyManagement section. To demonstrate the problem, try putting the following into an empty maven project:
<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>3.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey.contribs</groupId>
        <artifactId>jersey-spring</artifactId>
        <version>1.11</version>
    </dependency>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>
    </dependencies>
</dependencyManagement>

Look at the output of mvn dependency:tree. You will see the correct spring-aop version. Then delete the dependencyManagement section. It will be an older version. Delete the dependency on jersey-spring and you get the correct version of spring-aop again.

A: My guess would be that you may have dependency declared somewhere else (e.g. dependencyManagement section in this or parent project). Try to run mvn help:effective-pom to see the actual pom and then work from there.

A: Spring AOP depend on other jar use mvn dependency:tree to see full details . Which jar is dependent on other.


text:
Q: How can I replace a particular column in a data frame based on a condition (categorical variables)? I need to replace the salary status to 1 or 0 respectively if the salary is greater than 50,000 or less than or equal to 50,000 in a df.

The DataFrame shape:30162*13
I have tried this:
data2['SalStat']=data2['SalStat'].map({"less than or equal to 50,000":0,"greater than 50,000":1})

I also tried data2['SalStat']
and loc without any success.
How can I do the same?

A: I think your solution is nice.
If want match only by substring, e.g. by greater use Series.str.contains for boolean mask with converting to 0,1:
data2['SalStat']=data2['SalStat'].str.contains('greater').astype(int)

Or:
data2['SalStat']=data2['SalStat'].str.contains('greater').view('i1')

A: Try this
def status(d): return 0 if d == 'less than or equal to 50,000' else 1
data2['SalStat']  = list(map(status ,data2['SalStat']))

redpajama_set_name: RedPajamaStackExchange


text:
Q: httpClient.getConnectionManager() is deprecated - what should be used instead? I have inherited the code
import org.apache.http.client.HttpClient;
...
HttpClient httpclient = createHttpClientOrProxy();

    try {
        HttpPost postRequest = postRequest(data, url);
        body = readResponseIntoBody(body, httpclient, postRequest);
    } catch( IOException ioe ) {
        throw new RuntimeException("Cannot post/read", ioe);
    } finally {
        httpclient.getConnectionManager().shutdown();  // ** Deprecated
    }

private HttpClient createHttpClientOrProxy() {
    HttpClient httpclient = new DefaultHttpClient();

    /*
     * Set an HTTP proxy if it is specified in system properties.
     *
     * http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html
     * http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientExecuteProxy.java
     */
    if( isSet(System.getProperty("http.proxyHost")) ) {
        log.warn("http.proxyHost = " + System.getProperty("http.proxyHost") );
        log.warn("http.proxyPort = " + System.getProperty("http.proxyPort"));
        int port = 80;
        if( isSet(System.getProperty("http.proxyPort")) ) {
            port = Integer.parseInt(System.getProperty("http.proxyPort"));
        }
        HttpHost proxy = new HttpHost(System.getProperty("http.proxyHost"), port, "http");
// @Deprecated methods here... getParams() and ConnRoutePNames
        httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
    }
    return httpclient;
}

getConnectionManager() reads "
@Deprecated
ClientConnectionManager getConnectionManager()

Deprecated. (4.3) use HttpClientBuilder.
Obtains the connection manager used by this client.

The docs for HttpClientBuilder seem sparse and simply say:
Builder for CloseableHttpClient instances.

However if I replace HttpClient with CloseableHttpClient the method still seems @Deprecated.
How can I use a non-Deprecated method?

A: Instead of creating a new instance of HttpClient, use the Builder. You would get a CloseableHttpClient.
e.g usage:
CloseableHttpClient httpClient = HttpClientBuilder.create().setProxy(proxy).build()

Instead of using getConnectionManager().shutdown(), use the close() method instead on CloseableHttpClient.


text:
Q: jquery mobile button icons-36-white.png shows wrong icon My problem in short is that when i ovveride .ui-icon background image url() to icons-36-white.png it returns ( gear ) for data-icon="home", ( - ) for data-icon="delete" and so forth for all icons, they are mismatched!
I tried to change the url to url(http://code.jquery.com/mobile/1.3.2/images/icons-36-white.png), yet it still gives me this funky issue!!
Please advice...
html:
Home

css:
#mainNav .ui-icon {
    width: 36px;
    height: 36px;
    /*background-image: url(../themes/images/icons-36-white.png);*/
    background-image: url(http://code.jquery.com/mobile/1.3.2/images/icons-36-white.png);
}

A: Place it in your css file...
 .ui-icon-plus, .ui-icon-minus, .ui-icon-delete, .ui-icon-arrow-r,
    .ui-icon-arrow-l, .ui-icon-arrow-u, .ui-icon-arrow-d, .ui-icon-check,
    .ui-icon-gear, .ui-icon-refresh, .ui-icon-forward, .ui-icon-back,
    .ui-icon-grid, .ui-icon-star, .ui-icon-alert, .ui-icon-info, .ui-icon-home, .ui-icon-bars, .ui-icon-edit,
    .ui-icon-search, .ui-icon-searchfield:after,
    .ui-icon-checkbox-off, .ui-icon-checkbox-on, .ui-icon-radio-off, .ui-icon-radio-on {
        background-image: url(images/icons-36-white.png);
        -moz-background-size: 864px 18px;
        -o-background-size: 864px 18px;
        -webkit-background-size: 864px 18px;
        background-size: 864px 18px;
    }
    .ui-icon-alt .ui-icon {
        background-image: url(images/icons-36-black.png);
    }
    .ui-icon-plus {
        background-position:    0 50%;
    }
    .ui-icon-minus {
        background-position:    -36px 50%;
    }
    .ui-icon-delete {
        background-position:    -72px 50%;
    }
    .ui-icon-arrow-r {
        background-position:    -108px 50%;
    }
    .ui-icon-arrow-l {
        background-position:    -144px 50%;
    }
    .ui-icon-arrow-u {
        background-position:    -179px 50%;
    }
    .ui-icon-arrow-d {
        background-position:    -215px 50%;
    }
    .ui-icon-check {
        background-position:    -252px 50%;
    }
    .ui-icon-gear {
        background-position:    -287px 50%;
    }
    .ui-icon-refresh {
        background-position:    -323px 50%;
    }
    .ui-icon-forward {
        background-position:    -360px 50%;
    }
    .ui-icon-back {
        background-position:    -395px 50%;
    }
    .ui-icon-grid {
        background-position:    -431px 50%;
    }
    .ui-icon-star {
        background-position:    -467px 50%;
    }
    .ui-icon-alert {
        background-position:    -503px 50%;
    }
    .ui-icon-info {
        background-position:    -538px 50%;
    }
    .ui-icon-home {
        background-position:    -575px 50%;
    }
    .ui-icon-search,
    .ui-icon-searchfield:after {
        background-position:    -611px 50%;
    }
    .ui-icon-checkbox-on {
        background-position:    -647px 50%;
    }
    .ui-icon-checkbox-off {
        background-position:    -683px 50%;
    }
    .ui-icon-radio-on {
        background-position:    -718px 50%;
    }
    .ui-icon-radio-off {
        background-position:    -754px 50%;
    }
    .ui-icon-bars {
        background-position:    -788px 50%;

    }.ui-icon-edit {
        background-position:    -824px 50%;
    }
}


text:
Q: Using forward slash as path separator in Unix and Windows I'm doing some file management in a Python 2.7 application in both Unix and Windows. This results in having to do alot of path concatenation with os.path.join.
Now I want the os.path functions (e.g. join, relpath) to return a string with forward slashes as path separators on both Unix and Windows. Is there some global setting I can use or is it necessary to use another function to convert the result of the functions?


text:
Q: I keep getting configChanges: String types not allowed error. Even with target API set to 13 error: Error: String types not allowed (at 'configChanges' with value
    'keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize').

Here is all my relevant code.
In the manifest:
    android:minSdkVersion="8"
    android:targetSdkVersion="13"

    android:name="com.google.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout
        |uiMode|screenSize|smallestScreenSize"/>

SOLVED!!!
   The problem was the break in the tags on configChanges. They needed to be all on one line together. Do not split the line for readability, leave it together.

A: I had this problem, but I was building my app with api 8. I also had api 13 as minimum sdk version. This is how to get it working: right click on your project>properties>android>choose android 3.2 or higher. This worked for me

A: Even if your target is 13, I guess this will not work on devices with api less than 13 because the changed value is not just a TAG in the manifest, but it is a VALUE of a TAG. Therefore, the system will parse these values regardless of its api and will throw an exception when it finds an unknown VALUE.
To solve this, you will have to build the project twice: for api < 13 and for api >=13.
Correct me if I am mistaken (:


text:
Q: Stripe on Ruby on Rails - Creating config/initializers/stripe.rb Following the Stripe setup document for Ruby on Rails (https://stripe.com/docs/checkout/rails), it says that the config/initializers/stripe.rb will be created when the app is started.
I have shutdown the server and the restarted the server several times, but this file isn't being created under the path identified in the documentation.
What am I doing wrong? Appreciate the help.

A: Create this file manually. Initializers are not generated on application start. They are read by Rails to configure your specific application.
Create config/initializers/stripe.rb and fill it with the following.
Rails.configuration.stripe = {
  :publishable_key => ENV['PUBLISHABLE_KEY'],
  :secret_key      => ENV['SECRET_KEY']
}

Stripe.api_key = Rails.configuration.stripe[:secret_key]

Set your secret key and publishable key in your ENVs. Restart your application after the change or you won't see any difference.
I can see how you would be confused, Stripe documentation says "An initializer is a good place to set these values, which will be provided when the application is started." They mean the values you set in that file will be provided to the application instance.

A: I really disliked the anti-pattern that Stripe Gem has, instead I end up overriding the Stripe::StripeConfiguration (even here we can see naming redundancy ) Here is my solution:
## Stripe Initializer
## {Rails.root}/config/initializers/stripe.rb

# frozen_string_literal: true

require 'stripe'

module Stripe
  class StripeConfiguration
    def api_key=(key_value)
      @api_key = key_value || Rails.application.credentials.stripe.secret_key
    end
  end
end

Rails.configuration.stripe = {
  publishable_key: Rails.application.credentials.stripe.secret_key,
  secret_key: Rails.application.credentials.stripe.secret_key
}

Stripe.api_key = Rails.configuration.stripe[:secret_key]

NOTE: for the Stripe team, their implementation in no way gives an extra security layer, anyone who can have access to the console/credentials will be able to read it so it makes no sense that they override it on each request. You can always assign an attribute with an operator.
PS: I'm working on an app that would improve that security (Comming Soon)


text:
Q: What is the best way to do SO style routes (dashes as spaces) Just wondering what the best way to do SO style routes is.
What is the best way to do SO style routes (dashes as spaces)
What's the best way to create routes like this?

A: I've found ASP.NET MVC and Clean SEO Friendly URLs on Dominic Pettifer's blog.

It works on a white-list principle, allowing all 0-9 and a-z characters through, dealing with a few special cases, and converting everything else to -hyphens-. You'll notice that spaces are being converted to hyphens as well, and you might be tempted to use underscores instead. Don't! There are sound SEO benefits for using hyphens in that search engines bots treat them as spaces.

A: Here's one way.
Here's another.
It's called a slug btw.

A: I think the best way would be to replace any non-alphanumeric character with a dash. You could search for this regex [^\w]+ and replace with -.


text:
Q: Testing LetsEncrypt certificate renewal I'm working on a solution to fetch and renew certificates from Letsencrypt.org automatically. Ironically the normally short lifespan of only three months is a problem for me when it comes to testing renewal.
I am aware of the --force-renew switch, but I'd like to avoid that, because then my test code would differ from my productive code.
Is there a way to tell letsencrypt to issue a test certificate with an even shorter lifespan, say one day? Or is there maybe a way to invalidate a certificate prematurely without incurring side effects? (I'm thinking about revoking, but I fear that may have some unintended consequences I'm not seeing)
Is there maybe some other way to test this in some totally different way I'm not thinking about at all?


text:
Q: Database Design for Product Inventory Stock (SuperMarket) In my past years, I made simple store app, where I made simple product table like this :
ID,Name,IDCategory,Size,Qty,buyprice,sellprice

the Quantity field is in product table, and when in the transaction, I would just add or subtract it on that table.
And now, in my new supermarket application, I know I need to design more complex table for keeping track of the stock item quantities because the product now has an expiration date, different buyprice (and maybe sell price too). this is the only way to ensure the financial report to be accurate, where we could get the actual profit of each transaction.
My new product table is like
ID,Name,IDCategory,Size,ExpirationDate,SellPrice    '(I remove qty and keep sell price to simplified and sell my item at 1 price only )

The problem with the design is it becomes more complex in database and programming design as well, I think I need to apply FIFO system, and it becomes more complex for me as I think about edit transaction/returning items, etc.
what I could imagine right now is to make the table similar like this :
tblProductQty = BuyInvoiceID,Date,IDProduct,Qty

but then I realize this information already in my tblBuyTransactionDetail (
*table that keeps my buying transaction (like invoiceNo,SupplierID,Date,Total) with the details table like (InvoiceNo,IDProduct,Qty,BuyPrice,ExpirationDate))
now I am really confused, do I really need stockTable ?? but if not, it's meant that I need to do sum and subtract between transaction query to get a quantity of one product.
How you guys actually do this? what is the common design of all the big supermarkets use out there?
note: I currently use access and vbnet

A: I know for most erp systems there are separate tables for each of the following;
Purchases (note a purchase is not necessarily a product)
Product transactions (you will need this to calculate fifo stock values)
Sales (usually but not always products)
Product details (description etc)
You mention expiry dates. These should be recorded against individual purchases ideally.
Also note that purchases and sales are usually broken down into a header table and a details table (invoices and invoice lines).

A: Both Ways are used to do this, Some use separate De normalized stock Table and Some Calculate it while reporting. Both are the correct way but below are the pros and cons of using separate Stock table, Please use as suitable to you.
Pros:

*

*Reporting will be fast.

*Reports Logic will be easy.

*If you provide Stock Closing Functionality after a time period, then same
stock table can be used by adding some additional columns in that table.

Cons:

*

*Separate Stock Tables Handling is more error prone as there each every transaction
related to stock up and down will also need to update this new stock
table as well.

*if there is very Frequent Stock up and Down in your
application, then it will effect the performance of
system as on each stock add or subtract this table will be locked in
transaction and updated.


text:
Q: What is not possible to do with Spring XML defined context? The options are: a)Autowire beans by their type
                 b)Inject values from property file
                 c)Use annotation in defined bean
                 d)Override beans defined in a parent application context
                 e)None of the above
Possible multiple options:

A: We can autowire beans by their type. But we cant inject the values from the properties file. And rest options seems correct
So b option may be. Am I right ?


text:
Q: Received Firebase Notification starts and closes android app When I'm sending Firebase Notification from the Firebase console, it starts my splash screen and notification icon is appearing to the top of display. I have no idea what can cause this kind of behaviour. Any ideas?
this is my MyFirebaseMessagingService.class
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

    import com.Novatech.paybox.Activities.MainActivity;
    import com.Novatech.paybox.Activities.NewsActivity;
    import com.Novatech.paybox.Classes.News;
    import com.Novatech.paybox.R;
    import com.Novatech.paybox.SQLite.DBHandler;
    import com.google.firebase.messaging.FirebaseMessagingService;
    import com.google.firebase.messaging.RemoteMessage;

    import java.util.List;

    public class MyFirebaseMessegingService extends FirebaseMessagingService {

        String Title;
        @Override
        public void onMessageReceived(RemoteMessage remoteMessage) {
            Intent intent  = new Intent(this, NewsActivity.class);
            if(remoteMessage.getData().size() > 0){
                String message = remoteMessage.getData().get("message");
                String title = remoteMessage.getData().get("title");
                Title = title;
                System.out.println("TitleFrom MEssageingService::"+title);
                Bundle bundle = new Bundle();
                bundle.putString("message",message);
                intent.putExtras(bundle);
            }
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_ONE_SHOT);
            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this).setContentIntent(pendingIntent);
            notificationBuilder.setContentTitle(Title);
            notificationBuilder.setContentText(remoteMessage.getNotification().getBody());
            notificationBuilder.setAutoCancel(true);
            notificationBuilder.setSmallIcon(getNotificationIcon());
            notificationBuilder.setContentIntent(pendingIntent);
            NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.notify(0, notificationBuilder.build());
        }
        private int getNotificationIcon(){
            boolean userWhiteIcon = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
            return userWhiteIcon ? R.drawable.paybox_logo_transparant : R.drawable.paybox_logo;
        }
    }

and this is MyFirebaseInstanceIdService
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;

public class MyFirebaseInstanceIdService extends FirebaseInstanceIdService {
    private static final String TAG = "REG_TOKEN";

    @Override
    public void onTokenRefresh() {
        // Get updated InstanceID token.
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        Log.d(TAG, "Refreshed token: " + refreshedToken);

       // Log.d(REG_TOKEN,recent_token);
       // System.out.println("REG_TOKEN::"+recent_token);
    } }

and this is my main activity where I redirect user to another activity if he/she taps on notification.
String notificationMessegaBody="a";

        if(getIntent().getExtras() != null){
            notificationMessegaBody = getIntent().getExtras().getString("id");
            System.out.println("MessageBody FromLoginChooserActivity::" + notificationMessegaBody);
            //insert news in SQLite Database
            if(notificationMessegaBody!="a"){
                if(!(notificationMessegaBody == null)){
                    Intent intent = new Intent(LoginChooserActivity.this, NewsActivity.class);
                    startActivity(intent);
                }
            }
        }else{
            System.out.println("extras are empty");
        }

service inside AndroidManifest.xml
 <service
            android:name=".Notification.MyFirebaseInstanceIdService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>

        <service
            android:name=".Notification.MyFirebaseMessegingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>-->

this is a logcat output
10-18 13:17:43.445 4691-4691/? I/art: Late-enabling -Xcheck:jni
10-18 13:17:43.525 4691-4691/com.Novatech.paybox I/MultiDex: VM with version 2.1.0 has multidex support
10-18 13:17:43.525 4691-4691/com.Novatech.paybox I/MultiDex: install
10-18 13:17:43.525 4691-4691/com.Novatech.paybox I/MultiDex: VM has multidex support, MultiDex support library is disabled.
10-18 13:17:43.564 4691-4691/com.Novatech.paybox D/FirebaseApp: Initialized class com.google.firebase.auth.FirebaseAuth.
10-18 13:17:43.571 4691-4691/com.Novatech.paybox D/FirebaseApp: Initialized class com.google.firebase.iid.FirebaseInstanceId.
10-18 13:17:43.579 4691-4753/com.Novatech.paybox E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/com.Novatech.paybox-2/base.apk"],nativeLibraryDirectories=[/data/app/com.Novatech.paybox-2/lib/arm, /data/app/com.Novatech.paybox-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
10-18 13:17:43.583 4691-4691/com.Novatech.paybox V/GoogleSignatureVerifier: com.google.android.gms signature not valid.  Found:
                                                                            MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
                                                                            EQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29n
                                                                            bGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEz
                                                                            MzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYw
                                                                            FAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5k
                                                                            cm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtW
                                                                            LgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKke
                                                                            dxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjA
                                                                            sb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/Cx
                                                                            URaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJE
                                                                            qO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/T
                                                                            gt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYD
                                                                            VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIG
                                                                            A1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC
                                                                            4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/y
                                                                            zKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCE
                                                                            yj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1S
                                                                            KMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifK
                                                                            Z0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3Wf
                                                                            MBEmh/9iFBDAaTCK
10-18 13:17:43.583 4691-4753/com.Novatech.paybox V/GoogleSignatureVerifier: com.google.android.gms signature not valid.  Found:
                                                                            MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
                                                                            EQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29n
                                                                            bGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEz
                                                                            MzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYw
                                                                            FAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5k
                                                                            cm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtW
                                                                            LgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKke
                                                                            dxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjA
                                                                            sb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/Cx
                                                                            URaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJE
                                                                            qO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/T
                                                                            gt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYD
                                                                            VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIG
                                                                            A1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC
                                                                            4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/y
                                                                            zKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCE
                                                                            yj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1S
                                                                            KMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifK
                                                                            Z0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3Wf
                                                                            MBEmh/9iFBDAaTCK
10-18 13:17:43.587 4691-4753/com.Novatech.paybox E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/com.Novatech.paybox-2/base.apk"],nativeLibraryDirectories=[/data/app/com.Novatech.paybox-2/lib/arm, /data/app/com.Novatech.paybox-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
10-18 13:17:43.631 4691-4691/com.Novatech.paybox W/DynamiteLoaderImpl: Failed to load module version: module com.google.android.gms.flags not found
10-18 13:17:43.631 4691-4691/com.Novatech.paybox I/DynamiteModule: Considering local module com.google.android.gms.flags:1 and remote module com.google.android.gms.flags:0
10-18 13:17:43.631 4691-4691/com.Novatech.paybox I/DynamiteModule: Selected local version of com.google.android.gms.flags
10-18 13:17:43.636 4691-4691/com.Novatech.paybox E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.android.gms.crash.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/com.Novatech.paybox-2/base.apk"],nativeLibraryDirectories=[/data/app/com.Novatech.paybox-2/lib/arm, /data/app/com.Novatech.paybox-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
10-18 13:17:43.637 4691-4691/com.Novatech.paybox I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:4
10-18 13:17:43.637 4691-4691/com.Novatech.paybox I/DynamiteModule: Selected remote version of com.google.android.gms.crash, version >= 4
10-18 13:17:43.647 4691-4691/com.Novatech.paybox W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/0000000a/n/armeabi-v7a
10-18 13:17:43.647 4691-4691/com.Novatech.paybox W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/0000000a/n/armeabi
10-18 13:17:43.657 4691-4691/com.Novatech.paybox I/FirebaseCrashApiImpl: FirebaseCrashApiImpl created by ClassLoader com.google.android.chimera.container.internal.DelegateLastPathClassLoader[DexPathList[[zip file "/data/data/com.google.android.gms/app_chimera/m/0000000a/DynamiteModulesC_GmsCore_prodmnc_xxhdpi_release.apk"],nativeLibraryDirectories=[/data/user/0/com.google.android.gms/app_chimera/m/0000000a/n/armeabi-v7a, /data/user/0/com.google.android.gms/app_chimera/m/0000000a/n/armeabi, /vendor/lib, /system/lib]]]
10-18 13:17:43.665 4691-4691/com.Novatech.paybox W/DynamiteLoaderImpl: Failed to load module version: module com.google.android.gms.flags not found
10-18 13:17:43.665 4691-4691/com.Novatech.paybox I/DynamiteModule: Considering local module com.google.android.gms.flags:1 and remote module com.google.android.gms.flags:0
10-18 13:17:43.665 4691-4691/com.Novatech.paybox I/DynamiteModule: Selected local version of com.google.android.gms.flags
10-18 13:17:43.671 4691-4691/com.Novatech.paybox W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
10-18 13:17:43.680 4691-4691/com.Novatech.paybox D/FirebaseCrashApiImpl: FirebaseCrash reporting API initialized
10-18 13:17:43.681 4691-4691/com.Novatech.paybox I/FirebaseCrash: FirebaseCrash reporting initialized com.google.firebase.crash.internal.zzg@f7ae0eb
10-18 13:17:43.681 4691-4691/com.Novatech.paybox D/FirebaseApp: Initialized class com.google.firebase.crash.FirebaseCrash.
10-18 13:17:43.690 4691-4691/com.Novatech.paybox I/FA: App measurement is starting up, version: 9080
10-18 13:17:43.690 4691-4691/com.Novatech.paybox I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
10-18 13:17:43.690 4691-4691/com.Novatech.paybox D/FA: Debug logging enabled
10-18 13:17:43.690 4691-4691/com.Novatech.paybox D/FA: AppMeasurement singleton hash: 144412232
10-18 13:17:43.702 4691-4691/com.Novatech.paybox V/FA: Collection enabled
10-18 13:17:43.702 4691-4691/com.Novatech.paybox V/FA: App package, google app id: com.Novatech.paybox, 1:851374531660:android:13f39d9d52fa1182
10-18 13:17:43.710 4691-4691/com.Novatech.paybox V/FA: Registered activity lifecycle callback
10-18 13:17:43.711 4691-4691/com.Novatech.paybox D/FirebaseApp: Initialized class com.google.android.gms.measurement.AppMeasurement.
10-18 13:17:43.711 4691-4691/com.Novatech.paybox I/FirebaseInitProvider: FirebaseApp initialization successful
10-18 13:17:43.714 4691-4774/com.Novatech.paybox V/FA: Using measurement service
10-18 13:17:43.715 4691-4774/com.Novatech.paybox V/FA: Connecting to remote service
10-18 13:17:43.722 4691-4691/com.Novatech.paybox I/GoogleConversionReporter: Already sent ping for conversion Cyh0CKfbimQQ8vyp2QM
10-18 13:17:43.783 4691-4691/com.Novatech.paybox V/FA: onActivityCreated
10-18 13:17:43.788 4691-4691/com.Novatech.paybox I/GAv4: Google Analytics 9.0.80 is starting up. To enable debug logging on a device run:
                                                           adb shell setprop log.tag.GAv4 DEBUG
                                                           adb logcat -s GAv4

A: The problem was in my application.java where I was starting SplashScreen activity which wasn't LAUNCHER activity. I made SplashScreen activity LAUNCHER and deleted it's starting method in application.java , that actually solved the issue.


text:
Q: Does probability independence have anything to do with functional independence (on general case)? On normal-linear case I know it holds for example if $cor(X_1,Y)=0$ then $g_{X_1Y}(X_1,Y)=g_{X_1}(X_1)g_{Y}(Y)$, where $g_{(.)}$ is the distribution of (.), and that imples to $\beta_1=0$ on:
$Y=\beta_1X_1$
, since $cor$ works as measure to evaluate how good a linear approximation between two variables is and those implications hold we have that there is no linear function such that $Y=f(X_1)$ (or there is with $\beta_1=0$ but it is not informative at all) when both $X_1$ and $Y$ are
stochastically independent and normal distribuited.
But I'm not sure if it holds for general case, that is if $g_{X_1Y}(X_1,Y)=g_{X_1}(X_1)g_{Y}(Y)$ so there is no function $f$ such that $Y=f(X_1)$ (I call this functional independence). Am able to go functional dependence as probability depencence or is it pretty wrong? and if I'm not is there any relation between they both?

A: For random normal data, the sample mean $\bar X$ and the sample variance $S^2$ are independent random variables. But they are not 'functionally' independent because $\bar X$ is used in the definition of $S^2.$
A formal proof of the independence of $\bar X$ and $S^2$ can be done
using a linear transformation in $n$-space or by moment generating functions. [This is a consequence of Basu's Thm; see example. Also, see this Q&A; "Related" page listed in the margin.]
I show a simulation in R below that illustrates the idea (in terms of correlation), using $m$ normal
samples of size $n.$ With $m = 100\,000$ iterations the correlation
should be accurate to one or two decimal places.
    set.seed(2021)
    n = 10;  m = 10^5
    x = rnorm(m*n, 50, 7)
    DTA = matrix(x, ncol=n)  # each row a sample
    a = apply(DTA, 1, mean)  # m sample means
    v = apply(DTA, 1, var)   # m sample variances
    cor(a, v)
    [1] -0.00202886          # consistent w/ 0 correlation

    s = sqrt(v)
    plot(a, s, pch=".")


text:
Q: How to handle service when Orientation is changed I am making a music player app for learning purposes but I am stuck at the point where the user decides to change the orientation of the device, my app always recreates which is bad, I have managed to have all other data saved and restored using onRestoreInstanceState but I cannot think of a good approach with the musicplayer service, below is part of my code, it is a lot of code so i will focus on the problem
public class ManagerActivty extends AppCompatActivity{

 //music player service object
 private MusicService musicService;

 //boolean to keep track of musicservice state
 private boolean musicBound = Boolean.FALSE;

  //Music service connection object
    private ServiceConnection musicServiceConnection = new ServiceConnection() {
    @Override
    public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        if(!instanceSaved) {
            MusicService.MusicBinder binder = (MusicService.MusicBinder) iBinder;
            musicService = binder.getService();
            musicService.setOnSongChangeListener(ManagerActivty.this);
            musicService.setOnPlayerStateChangedListener(ManagerActivty.this);
            new loadSongAsync().execute();
            musicBound = Boolean.TRUE;
            System.out.println("Music Service Connected");

        }

    }

    @Override
    public void onServiceDisconnected(ComponentName componentName) {
        musicBound = Boolean.FALSE;
    }
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_manager_activty);
 }

//method to bind music service with my activity
 private void bindMusicService()
{
    playMusicIntent = new Intent(this, MusicService.class);
    bindService(playMusicIntent, musicServiceConnection, Context.BIND_AUTO_CREATE);
    startService(playMusicIntent);
    System.out.println("Binder Called");

}

@Override
protected void onStart() {
    super.onStart();

    //launch binder
    bindMusicService();
}

  @Override
protected void onDestroy() {
 //stop service connection
    if (playMusicIntent != null) {
        stopGuiUpdates();
        unbindService(musicServiceConnection);
        stopService(playMusicIntent);
        musicService = null;
    }
    super.onDestroy();
}

}

 @Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    System.out.println("Saved Instances");
    outState.putBoolean(Constant.IS_MEDIA_PLAYING_PLAYING, musicService.isPlaying());
    outState.putInt(Constant.MEDIA_PLAYER_POSITION, musicService.getMediaPlayer().getCurrentPosition());
    outState.putBoolean(Constant.IS_MUSIC_REPLAY, musicService.isReplay());

}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    System.out.println("Retrieving Instances");

      //if null try to re-bind service
    if(musicService == null) {
        bindMusicService();

    }

}

this code gives me a nullpointerexception when I try to access the musicservice object after orientation changed, anyone who has dealt with this before please help.

A: On everytime the user rotates his phone the onCreate() method is called. I would suggest to add this line to your xml
android:configChanges="keyboardHidden|orientation"
Also, learn somethings about the Parcelable interface.

A: You can declare the config changes to the <activity> tag in the App Manifest.xml file

android:configChanges="orientation|keyboardHidden"

This is the complete list of the attributes that you can set in <activity> tag in Manifest.xml

<activity android:allowEmbedded=["true" | "false"]
          android:allowTaskReparenting=["true" | "false"]
          android:alwaysRetainTaskState=["true" | "false"]
          android:autoRemoveFromRecents=["true" | "false"]
          android:banner="drawable resource"
          android:clearTaskOnLaunch=["true" | "false"]
          android:configChanges=["mcc", "mnc", "locale",
                                 "touchscreen", "keyboard", "keyboardHidden",
                                 "navigation", "screenLayout", "fontScale",
                                 "uiMode", "orientation", "screenSize",
                                 "smallestScreenSize"]
          android:documentLaunchMode=["intoExisting" | "always" |
                                  "none" | "never"]
          android:enabled=["true" | "false"]
          android:excludeFromRecents=["true" | "false"]
          android:exported=["true" | "false"]
          android:finishOnTaskLaunch=["true" | "false"]
          android:hardwareAccelerated=["true" | "false"]
          android:icon="drawable resource"
          android:label="string resource"
          android:launchMode=["multiple" | "singleTop" |
                              "singleTask" | "singleInstance"]
          android:maxRecents="integer"
          android:multiprocess=["true" | "false"]
          android:name="string"
          android:noHistory=["true" | "false"]
          android:parentActivityName="string"
          android:permission="string"
          android:process="string"
          android:relinquishTaskIdentity=["true" | "false"]
          android:screenOrientation=["unspecified" | "behind" |
                                     "landscape" | "portrait" |
                                     "reverseLandscape" | "reversePortrait" |
                                     "sensorLandscape" | "sensorPortrait" |
                                     "userLandscape" | "userPortrait" |
                                     "sensor" | "fullSensor" | "nosensor" |
                                     "user" | "fullUser" | "locked"]
          android:stateNotNeeded=["true" | "false"]
          android:taskAffinity="string"
          android:theme="resource or theme"
          android:uiOptions=["none" | "splitActionBarWhenNarrow"]
          android:windowSoftInputMode=["stateUnspecified",
                                       "stateUnchanged", "stateHidden",
                                       "stateAlwaysHidden", "stateVisible",
                                       "stateAlwaysVisible", "adjustUnspecified",
                                       "adjustResize", "adjustPan"] >
    . . .
</activity>


text:
Q: Understanding TCP's slow start I feel a little embarrassed to admit that I have trouble understanding TCP's slow start, which is supposed to be a very simple algorithm. Consider this scenario:

*

*sender has CWND=4 and sends all 4 segments

*receiver sends an ack for each received segment (it's not using any kind of delayed ack strategy)

*4 acks quickly arrive at the sender side where they are queued in the sender's network buffer

*

*sender processes ack 1, increments cwnd to 5, and sends 5 segments

*sender processes ack 2, increments cwnd to 6, and sends 6 segments (total sent: 11)

*sender processes ack 3, increments cwnd to 7, and sends 7 segments (total sent: 18)

*sender processes ack 4, increments cwnd to 8, and sends 8 segments (total sent: 26)

Because the acks were queued in the sender's buffer the sender was able to send 26 segments while only having received an ack for 4 segments. This seems contrary to the intention of slow start of placing an upper bound on the sent traffic.
Where am I wrong in my reasoning?
Update
[RFC 2581](https://www.rfc-editor.org/rfc/rfc2581) defines CWND as follows:

At any given time, a TCP MUST NOT send data with a sequence number higher than the sum of the highest acknowledged sequence number and the minimum of cwnd and rwnd.

This confirms @jman's explanation.

A: cwnd represents unacknowledged segments. So when the first ACK is received, cwnd becomes 5 and the stack sends 2 more segments since there are 3 unacknowledged segments in flight already.
Your example should read:

*

*sender processes ack 1, increments cwnd to 5, and sends 2 more segments (total sent: 6)

*sender processes ack 2, increments cwnd to 6, and sends 2 more segments (total sent: 8)

*sender processes ack 3, increments cwnd to 7, and sends 2 more segments (total sent: 10)

*sender processes ack 4, increments cwnd to 8, and sends 2 more segments (total sent: 12)


text:
Q: Angular 8 FormControl disable not being sent to child component I have the following custom input in my code:
<nivel-servico-slider formControlName="fornecedor_a"></nivel-servico-slider>

which has all properties for a custom input as described in Angular's guide to creating a custom input, however when I set that FormControl to disabled:
this.form.get('fornecedor_a').disable();

the disabled attribute is not set to the custom component (<nivel-servico-slider>), which doesn't trigger the get/setter for disabled inside the component:
@Input()
get disabled(): boolean {
  return this.internalDisabled;
}
set disabled(value: boolean) {
  console.log(value);
  this.internalDisabled = coerceBooleanProperty(value);
  if (this.internalDisabled) {
    this.input.disable();
  } else {
    this.input.enable();
  };
  this.stateChanges.next();
}

What am I doing wrong?

A: if you are using formControlName on your custom component, there is most likely a custom value accessor implemented https://angular.io/api/forms/ControlValueAccessor
so, to catch "disabling", you should implement setDisabledState(isDisabled: boolean)?: void


text:
Q: Number theory divisibility problem For an integer $n > 1$, prove that
$2^n - 1$ does not divide $ 3^n - 1$.
I tried doing it for primes first, but got no where. I think we might get it if we assume $k$ to be the smallest integer such that the divisibility holds, and then try to get a contradiction.

A: As stated by Michael in the comments, if $n$ is even $2^n-1$ is a multiple of three, so we may assume $n=2m+1$ with $m\geq 1$. Assuming that a prime number $p>3$ divides both $2^{2m+1}-1$ and $3^{2m+1}-1$, then $p\equiv \pm 1\pmod{12}$ and $p\equiv \pm 1\pmod{8}$, since:
$$ 2\cdot 4^m \equiv 3\cdot 9^m \equiv 1\pmod{p} $$
imply that both $2$ and $3$ are quadratic residues $\pmod{p}$. However,
$$ 2^{2m+1}-1 \equiv 7\pmod{12}, $$
so it is not possible that every prime $p>3$ that divides $2^{2m+1}-1$ is $\equiv \pm 1\pmod{12}$, hence $2^{2m+1}-1$ cannot divide $3^{3m+1}-1$.

A: Consider two cases:
$1)$ $n$ is even, therefore we can write $n=2m$ (with $m$ integer) and the expression $\frac {3^n-1}{2^n-1}= k$ (with $k$ integer) becomes $$\frac {9^m-1}{4^m-1}= k$$  but we can write $$\frac {8(9^{m-1}+9^{m-2}+...+9+1)}{3(4^{m-1}+4^{m-2}+....+4+1)}=k$$
this equation hasn't solutions in integers. Indeed $8\equiv 2\pmod 3$ and $9^{m-1}+9^{m-2}+...+9+1\equiv 1\pmod 3$.
$2)$ $n$ is odd, therefore we can write $n=2m+1$ and the equation becomes $$\frac {3^{2m+1}-1}{2^{2m+1}-1}= k$$ and rewriting the quation: $$\frac {9^{m+\frac{1}{2}}-1}{4^{m+\frac{1}{2}}-1}=k$$ and then we can write $$\frac {3\cdot 9^m-1}{2\cdot 4^m-1}=k$$ and multiplying the numerator and denominator for $2$ we obtain:$$\frac {6\cdot 9^{m}-1}{4^{m+1}-1}=k$$ and  rewriting the equation we obtain: $$\frac {6\cdot(9^m-\frac{1}{6})}{3\cdot(4^{m}+4^{m-1}+....+1)}=k$$ and  rewriting $$\frac {53\cdot (9^{m-1}\cdot 6^{m-1}+9^{m-2}\cdot 6^{m-2}+...+9\cdot 6+1)}{3\cdot(4^{m}+4^{m-1}+....+1)\cdot 6^{m-1}}=k$$ but this equation hasn't solutions. Indeed $3$ isn't a divisor of $53$ and of $9^{m-1}\cdot 6^{m-1}+9^{m-2}\cdot 6^{m-2}+...+9\cdot 6+1$.
Little curiosity
Considering the equation$$\frac {9^{m+1}-1}{6\cdot (4^m-\frac {1}{6})}=k$$ therefore rewriting the equation:$$\frac {8(9^m+9^{m-1}+...9+1)}{23(4^{m-1}+4^{m-2}\frac {1}{6}+....+\frac {1}{6^{m-1}})}=k$$ but the only values that are multiple $23$ are multiple of $10$,$m=10q$ (with $q$ integer). Indeed $$9^2\equiv 12\pmod {23}, 9^3\equiv 16\pmod {23},9^4\equiv 6\pmod {23},9^5\equiv 8, 9^6\equiv 3, 9^7\equiv 4, 9^8\equiv 13, 9^9\equiv 2, 9^{10}\equiv 18$$ and $$1+9+9^2+9^3+9^4+9^5+9^6+9^7+9^8+9^9+9^{10}$$ is a multiple of $23$. Therefore the only values that are multiple of $23$ are $10q$ $m=10q$ but we had demonsrated that these values aren't acceptable.


text:
Q: Angular form element in separated component gives FormGroup error I have a form element made with Angular Material which is a autocompleted country selectbox:
<mat-form-field>
  <input type="text" placeholder="Country" aria-label="Number" matInput formControlName="country" [matAutocomplete]="auto">
  <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
    <mat-option *ngFor="let option of filteredOptions | async" [value]="option">
      {{ option.name }}
    </mat-option>
  </mat-autocomplete>
</mat-form-field>

In the ngOnInit I call an API and this populates the filteredOptions.
Since I am going to use this picker in many forms I want to make a component of it. As soon as I move the code to a component I got:

SelectCountryComponent.html:2 ERROR Error: formControlName must be
  used with a parent formGroup directive.  You'll want to add a
  formGroup
         directive and pass it an existing FormGroup instance (you can create one in your class).

Even though I use my component in a FormGroup it still gives this error. What would be the right approach to create a component which contains a formControl?
select-country.component.ts
@Component({
  selector: 'app-select-country',
  templateUrl: './select-country.component.html',
  styleUrls: ['./select-country.component.css']
})
export class SelectCountryComponent implements OnInit {

  countryFormGroup = new FormGroup({
    country: new FormControl('')
  });

  options: Country[];
  filteredOptions: Observable<Country[]>;

  constructor(public api: ApiService) {

  }

  ngOnInit() {

    this.api.get('country').subscribe(res => {
      console.log(res);
      this.options = res;
      this.filteredOptions = this.countryFormGroup.get('country').valueChanges.pipe(
        startWith<string | Country>(''),
        map(value => (typeof value === 'string' ? value : value['name'])),
        map(name => name ? this._filter(name) : this.options ? this.options.slice() : [])
      );
    });

  }

  displayFn(country?: Country): string | undefined {
    return country ? country.name : undefined;
  }

  private _filter(name: string): Country[] {
    const filterValue = name.toLowerCase();

    return this.options.filter(
      option => option.name.toLowerCase().indexOf(filterValue) === 0
    );
  }

}

select-country.component.html
<mat-form-field>
  <input type="text" placeholder="Country" aria-label="Number" matInput formControlName="country" [matAutocomplete]="auto">
  <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
    <mat-option *ngFor="let option of filteredOptions | async" [value]="option">
      {{ option.name }}
    </mat-option>
  </mat-autocomplete>
</mat-form-field>

A: Wrap your mat-form-field in a div or form with [formGroup]="countryFormGroup". You need to bind the instantiated formGroup to the template.
<div [formGroup]="countryFormGroup">
<mat-form-field>
  <input type="text" placeholder="Country" aria-label="Number" matInput formControlName="country" [matAutocomplete]="auto">
  <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
    <mat-option *ngFor="let option of filteredOptions | async" [value]="option">
      {{ option.name }}
    </mat-option>
  </mat-autocomplete>
</mat-form-field>
</div>

A: In your case:
<form [formGroup]="countryFormGroup" (ngSubmit)="onSubmit()">
  <mat-form-field>
    <input type="text" placeholder="Country" aria-label="Number" matInput formControlName="country" [matAutocomplete]="auto">
  </mat-form-field>
</form>

You need to bind countryFormGroup with form by [formGroup]="countryFormGroup" and use formControlName inside it.
To make your code cleaner, you can filter options using pipe in HTML


text:
Q: convert input stream to json to display i want the the data received as input stream from my page to be converted into json and not string as it is being converted.
can anyone please edit my code so that i can impress my PL. i really need to finish it.
The Code:

     // 8. Execute POST request to the given URL
        HttpResponse httpResponse = httpclient.execute(httpPost);

        // 9. receive response as inputStream
        inputStream = httpResponse.getEntity().getContent();

        // 10. convert inputstream to string
        if(inputStream != null)
            result = convertInputStreamToString(inputStream);
        else
            result = "Did not work!";

    } catch (Exception e) {
        Log.d("InputStream", e.getLocalizedMessage());
    }

    // 11. return result
    return result ;
}

 private static String convertInputStreamToString(InputStream inputStream)
        throws IOException{
    BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream));
    String line = "";
    String result = "";
    while((line = bufferedReader.readLine()) != null)
        result += line;

    inputStream.close();
    return result;

}

A: private static JSONObject convertInputStreamToJSONObject(InputStream inputStream)
        throws JSONException {
    BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream));
    String line = "";
    String result = "";
    while((line = bufferedReader.readLine()) != null)
        result += line;

    inputStream.close();
    return new JSONObject(result); }

That will do it.


text:
Q: What is the best way to declare a bunch of drawables (Kotlin)? I have a lot of vector icons as XML drawable resources (96 to be exact). I display them in 8 categories. Currently i declared them as follows:
private val categoryA = arrayListOf(R.drawable.a1, ... R.drawable.an)
private val categoryB = arrayListOf(R.drawable.b1, ... R.drawable.bn)
***
private val categoryH = arrayListOf(R.drawable.h1, ... R.drawable.hn)

Everything works fine and fast, but i am not sure if that is a good way for a real app. I also use Room DB for other purposes in the app, so should i add new table and prepopulate DB on first launch?
It is also easy, at least right now, to add/remove icons later on... But on the other hand the code does not look nice (to me) with so many R.drawable.id lines.

A: Write a function that can get your drawable Ints by reflection:
fun getDrawableIdByName(name: String) = try {
    R.drawable::class.java.getField(name).getInt(null)
} catch (e: NoSuchFieldException) {
    error("No drawable with name $name")
}

Then you can construct your lists with it:
val categoryLists = ('a'..'h')
    .map { category ->
        List(12) { index ->
            getDrawableIdByName("$category${index + 1}")
        }
    }

I suppose you could write this to your database after the first launch, but I think it's overkill for only 96 items.


text:
Q: APTANA Formatting Javascript code with PHP statement Aptana Studio formatter doesn't work properly when I mix PHP and JavaScript in my .js file.
My code is:
{
alert("<?php echo $LANG[$iPage]["DureeNotPage"] ?>");

The formatter puts a new line before and after the <?php ... ?> part:
{
alert("
<?php echo $LANG[$iPage]["DureeNotPage"] ?>
");

I tried default prodile, jQuery javascript style guide and Google javascript style guide but this keeps happening.
Is there a way to avoid this?


text:
Q: Obtener el valor de un select Estoy tratando de que todos los "input text" obtengan el valor de cada select, pero solo me funciona en uno(en el primero).

let combos = document.querySelector(".combos")
        let text_field = document.querySelector(".text_field")

        combos.addEventListener("change",function(){
            text_field.value = combos.value
        })

        <select class="combos">
            <option value="Vacio" selected>--Seleccione--</option>
            <option value="Alta">Alta</option>
            <option value="Media">Media</option>
            <option value="Baja">Baja</option>
        </select>

        <input type="text" class="text_field" name="text_field" value="Vacio">

        <select class="combos">
                <option value="Vacio" selected>--Seleccione--</option>
                <option value="Alta">Alta</option>
                <option value="Media">Media</option>
                <option value="Baja">Baja</option>
        </select>

        <input type="text" class="text_field" name="text_field" value="Vacio">

        <select class="combos">
                <option value="Vacio" selected>--Seleccione--</option>
                <option value="Alta">Alta</option>
                <option value="Media">Media</option>
                <option value="Baja">Baja</option>
        </select>

        <input type="text" class="text_field" name="text_field" value="Vacio">

        <select class="combos">
                <option value="Vacio" selected>--Seleccione--</option>
                <option value="Alta">Alta</option>
                <option value="Media">Media</option>
                <option value="Baja">Baja</option>
        </select>

        <input type="text" class="text_field" name="text_field" value="Vacio">

A: Aunque no es la mejor solución, cambiar tu JS por este hara que funcione:
const combos = document.querySelectorAll(".combos")
const text_field = document.querySelectorAll(".text_field")

for (let i = 0; i < combos.length; i++) {

  combos[i].addEventListener("change", (e) => {

    text_field[i].value = e.target.value

  })

}

No es la mejor solución, pero hará que funcione respetando la estructura que utilizas.


text:
Q: How can i apply CSS to print? I am trying to print a div in one of my pages but i can't apply css when printing. Writing media="print" inside of the style tags doesn't work. What should i do?

A: There is many ways for that:
First:

A: What you're doing in your original message will work fine.  It's just the old school way of doing things.
One thing to note is that the browser will not apply all of your styles in the print mode.  It picks and chooses which styles are print appropriate. I have also found that if you use a HTML 5 doctype it will give you slightly different results.
Here's a simple example similar to yours that you can try in the browser.
<!DOCTYPE html>

Print This?

Another Style

Here's a screenshot from the print preview of Chrome (v19.0.1077.3 canary), which you mentioned your using to test this.

A: I'm using the Jquery Print Element 1.2 plugin to print only the content of a div.
This way, you don't need to set css display:none for all those elements you don't want to print.
I know it's not a straight answer on your question, but see it as a kind suggestion.
Example:
$('SelectorToPrint').printElement();

Here's my implementation using the classNameToAdd option:
function printDiv(divToPrint) {

   $('#' + divToPrint).printElement(
        {
            printBodyOptions:
            {
                classNameToAdd: 'printarea'

            }
        }
   );

}

Once you've added the plugin to your page you can call the above function when the users clicks the print button/link.
Print part of the page

You can download this plugin and find more documentation here.


text:
Q: Android Allow App to set Brightness permission using command line I tried different things but I'm not able to find a solution yet. My App wants the user to change the birghtness of the screen. A system dialog pops up, that this needs a special permission and I than have allow the App in System Settings to allow that.
Because I want to run instrumented tests on my device, I'm looking for a solution using the command line to grant that permission automativally.
All other permission are finde if I use:
   "adb -s " +device+ " install -g " +version

But this does not allow the brightness settings.
I tried:
    adb shell settings put secure enabled_accessibility_services screen_brightness

and
    adb shell appops set +app+ SCREEN_BRIGHTNESS allow

but this does not help.
Any suggestions?

A: I used
    adb shell appops set <app> WRITE_SETTINGS allow

that fixed it for me


text:
Q: CSS Keyframe animation not removing display block I have a search bar hidden by default, when you click the button it will hide or remove it depending on the state. I thought it worked great as it appeared and disappeared perfectly until i realized that i could not click on a specific element since the search div was hidden but actually the display was block. I need it to go to display none.
Html:

<button id="pl-manage-search" style="background-color:#2f383f;font-size: 38px;" class="btn btn-default" type="button" title="Toggle Search" onclick="openSearch()"></button>

Css:
@keyframes fadinsearch {
    0% {
        display: none;
        opacity: 0;
    }
    1% {
        display: block;
    }
    100% {
        display: block;
        opacity: 1;
    }
}

.fadinsearch {
    animation: fadinsearch 500ms linear;
    animation-fill-mode: forwards;
}

@keyframes fadoutsearch {
    0% {
        display: block;
        opacity: 1;
    }
    99% {
        display: block;
    }
    100% {
        display: none;
        opacity: 0;
    }
}

.fadoutsearch {
    animation: fadoutsearch 500ms linear;
    animation-fill-mode: forwards;
}

JS:
var opens = false;
function openSearch()
{
    if (opens == false)
    {
        $("div[id='searchsection']").each( function()
        {
            //$(this).toggleClass('blank fadinsearch');
            $(this).removeClass( "blank" ).addClass( "fadinsearch" );
            $(this).removeClass( "fadoutsearch" ).addClass( "fadinsearch" );
        });
        document.getElementById("searchsection").style.display = "block";
        document.getElementById("playlist-entries").style.paddingTop = "79px";
        opens = true;
    }
    else
    {
        $("div[id='searchsection']").each( function()
        {
            $(this).removeClass( "fadinsearch" ).addClass( "fadoutsearch" );
        });
        document.getElementById("playlist-entries").style.paddingTop = "1px";
        //document.getElementById("searchsection").style.display = "none";
        opens = false;
    }
}

A: You should not try animate between non numerical values.
Instead you can use opacity and z-index or left: -100%; or things like that because you can't change display to none with keyframes.
You can read more about it here: Transitions and Animations in CSS- book


text:
Q: Trying to loop over and extract the names from the table This is the code I have and I am trying to crack it with jQuery to extract the names inside the td elements
In some cases the td is empty and I want to merge the 1 td on the left side with the 5 td of right side because the 5td on right side have the first td as empty and have record in the second td
I am only concerned with TD, not with TH
Here is the code [with help of somebody, I am able to reach till here]

table = doc.select("##warranty-information");
trs = table.select("tr");
for(i = 0; i < trs.size(); i++) {
  tds = trs.get(i).select("td");
  for(j = 0; j < tds.size(); j++) {
    trs.get(0).tds.get(j).text()
    trs.get(i).tds.get(1).text()
    WriteDump( tds.get(j).text() );
  }
  /*
  if( tds.size() ) {
    form[ tds.get(0).text() ] = tds.get(1).text();
  }
  */
}

    Warranty Information

    Warranty
    2 Years

    Hardware

    Adapter Style
    Cable Adapters

    Converter Type
    Cable Adapters

    Output Signal
    DisplayPort

    Included in Package
    1 - SATA hard drive docking station

    1 - USB Cable

    2 - eSATA Cable

    1 - Power Adapter

    1 - Instruction Manual

A: You are probably better off doing this manually as there isn't a good way to sort format the table data due to the irregular usage. but you could use something like this.

const data = [...document.querySelectorAll('td')].map(x => x.innerText)
const obj = { "Included in Package": [] }

for (let ii = 1, ll = data.length; ii < ll; ii+=2) {
  const key = data[ii - 1]
  const value = data[ii]
  if (key === "" || key === "Included in Package") {
    obj["Included in Package"].push(value)
  }
  else {
    obj[key] = value
  }
}

console.log(obj)
td {
  vertical-align: top;
}

    Warranty Information

    Warranty
    2 Years

    Hardware

    Adapter Style
    Cable Adapters

    Converter Type
    Cable Adapters

    Output Signal
    DisplayPort

    Included in Package
    1 - SATA hard drive docking station

    1 - USB Cable

    2 - eSATA Cable

    1 - Power Adapter

    1 - Instruction Manual

A: It's pretty easy using jQuery.

let names = $('#warranty-information')
  .find('td')
  .map((i, el) => $(el).text().trim()) // map jQuery array to text of each element
  .get() // convert to normal array
  .filter(text => !!text); // filter not empty text

console.log(names);

    Warranty Information

    Warranty
    2 Years

    Hardware

    Adapter Style
    Cable Adapters

    Converter Type
    Cable Adapters

    Output Signal
    DisplayPort

    Included in Package
    1 - SATA hard drive docking station

    1 - USB Cable

    2 - eSATA Cable

    1 - Power Adapter

    1 - Instruction Manual


text:
Q: How to search for "R" materials? "The Google" is very helpful... unless your language is called "R," in which case it spits out tons of irrelevant stuff.
Anyone have any search engine tricks for "R"? There are some specialized websites, like those below, but how can you tell Google you mean "R" the language? If I'm searching for something specific, I'll use an R-specific term, like "cbind." Are there other such tricks?

*

*rweb.stat.umn.edu

*www.rseek.org

*search.r-project.org

*www.dangoldstein.com/search_r.html

A: CRAN is the authoritative place to look for R material.

A: Search for "S-PLUS" instead.  R and S-PLUS are siblings, but the latter is easier to search for.

A: I typically use r-seek.org, but you can "search exactly as is" with Google by putting a + immediately before R.

By attaching a + immediately before a
  word (remember, don't add a space
  after the +), you are telling Google
  to match that word precisely as you
  typed it. Putting double quotes around
  a single word will do the same thing.

For example: +R cbind

A: http://rseek.org is a great search engine for R manuals, mailing lists, and various websites.  It's a Google syndicated search app with specialized UI.  I always use it.

A: google for "r language" (with the quotes) and then your search terms.

A: Typing .R into Google search box instead of just R helps.

A: Similar to @MikeKSmith's answer, type R+ into the search box

A: An update, several years later
All the links you need are right here:
https://stackoverflow.com/tags/r/info

This was discussed on the R-Help mailing list recently.
Some things mentioned there that haven't been covered here are:

*

*Using the RSiteSearch function, and the package of the same name.

*Using R-specific search engines.  You mentioned RSeek and RSearch.  You can also search the R mail archive, the help wiki, the task views, RForge, and Bioconductor among other places.

A: To find questions/answers on Stack Overflow, I always; go to Tags, type R, find the R tag and click on it.
Jeff mentioned a better way to search for the R
Tag on the podcast, but I've since deleted it.  :-(
Discussion aside, Stack Overflow (or one of the sister sites) would be a great resource for R users.  The very high volume R-help email list could be reduced by sending Noobies like myself to specific places here.  One confounding issue is that while the questions are mostly about the R language, they are often about the proper statistical test or algorithm for the problem.
RWFarley

A: You can use this site:
http://www.dangoldstein.com/search_r.html,
  "Search the R Statistical Language".
Has "R Multi-site search powered by Google" and "R Multi-
site search powered by Rollyo".
Note that it requires JavaScript to work (can be restricted
to www.dangoldstein.com and google.com if your browser setup
allows it - e.g. using NoScript in Firefox).

A: Most of the time I find googling for R plus my searching term works fine.  When it doesn't, I'll try using "R project", or adding CRAN, statistic or language to the search.
Is there a particular topic that you're having problems searching for?

A: A new CRAN package is extremely helpful for this: check out the "sos" package.

A: GitHub's advanced search with a language constraint can be useful. Try this: language:R lubridate for example.

A: I would just add, one great way to search for R script is to type your search term into google with "ext:r" at the end.  This will return all files that have the R extension.  For instance:

*

*If you wanted some high performance computing examples, this returns Russ Lenth's "R code used in Netflix analyses" from Luke Tierney and Kate Cowles "High Performance Computing in Statistics" course.

*If you wanted examples of bootstrapping, this returns many scripts, most of which look very relevant.

I usually do my basic R searches with "r-project" at the beginning, since most people who refer to R in any great detail will usually also reference the site.

A: Joining this discussion very late, but here is my preferred search string in Google: [R] followed by search string.
For example:
[R] lm  finds several links to linear modelling in R
The reason this works is that StackOverflow uses the [r] tag, and the R mailing lists also use [R].

A: You could always search for "R stats", considering R is a statistical program.
Edit:
http://www.google.com/search?source=ig&hl=en&rlz=&q=R+stats&btnG=Google+Search
The first page shows plenty of relevant results.

A: Adding "site:r-project.org" will help narrow down the results to only things on the official project web site.  YMMV.

A: How about "R statistical" or "R package"?
Also, restrict your search to the domain cran.r-project.org. For example, searching for how to use ifelse in R:
ifelse site:cran.r-project.org

A: for your original question, i.e. how to search in google: one of my previous colleagues suggested to use keyword "r-help" instead of "r" together with your question when searching in google. It searches in the mailing list for answers. That always works for me.

A: When googling, "in R" works well instead of just "R".

A: Just type what you want to do, e.g. "R merge data frame" in google that works great! I don't read any materials, just use google as I type R code. It's just great!!!


text:
Q: SML - Iterate through String I'm trying to find if sentences read from a file has some pattern.
So far, I've written the code that reads all the sentences from file line by line, and puts those sentences to an array.
val infile = "c:/input.txt" ;

fun readlist (infile : string) =
    let val ins = TextIO.openIn infile
        fun loop ins = case TextIO.inputLine ins of
                            SOME line => line :: loop ins
                          | NONE      => []
    in loop ins before TextIO.closeIn ins
    end;

val pureGraph =  readlist(infile);

A: Try to write a function that evaluates to true if the letter a is in a string. Use explode to get a list of Chars. Recurse or fold over that list until you find a or reach the end. When you have that function, generalize it to any character. This will probably lead you to an O(n^2) runtime complexity.
Another approach is to sort the character list, remove duplicates, zip it with the correct list of characters and compare each tuple with recursion/fold. This should run in O(n log n) time because of the sort.
A third approach is to fold over the character list with an array or a hash map. In the array or map you add in what the current character is. At the end you see if all characters were found. This approach should run in O(n) time if your hashmap is constant-time.

A: Divide and conquer your problem:

*

*Write a function isPanagram : string -> bool that determines this for a single line.
One strategy could be: Start with the set of all letters. Loop through the string, and for each character in the string, remove it from the set until the end of the string, or the set is empty. If the set is empty, it is a panagram. This requires that you represent sets in some way, e.g. with a list or a binary search tree.
Consider looping through the string by index, rather than exploding it:
val allLetters = ...
fun remove x ... = ...
fun isEmpty ... = ...

fun isPanagram s =
    let val len = size s
        fun loop i missingLetters =
            isEmpty missingLetters orelse
            i < len andalso loop (i+1) (remove (String.sub (s, i)) missingLetters)
    in loop 0 allLetters end

*Write a function readLines : string -> string list that reads the content of a file and separates the lines into elements of a list:
fun isLinebreak c = c = #"\r" orelse c = #"\n"
fun readLines filename =
    let val ins = TextIO.openIn filename
        val data = TextIO.inputAll ins
        val _ = TextIO.closeIn ins
    in String.tokens isLinebreak data end

(Yes, reading the file one line at a time will save memory.)

A: The SML/NJ library has a number of data structures which can be used for things like sets and hash tables. They are not exactly well-documented, but this explains a bit how to use them. Using their set library, you can write something like this:
structure CharSet = RedBlackSetFn(struct
    type ord_key = char
    val compare = Char.compare
    end)

val alphabet = CharSet.fromList (explode "ABCDEFGHIJKLMNOPQRSTUVWXYZ");

fun isPanagram s =
    let val chars = CharSet.fromList (map Char.toUpper (explode s))
        val letters = CharSet.intersection (chars,alphabet)
    in CharSet.numItems letters = 26
end;

used like this:
- isPanagram "We promptly judged antique ivory buckles for the next prize.";
val it = true : bool
- isPanagram "We promptly judged antique plastic buckles for the next prize.";
val it = false : bool


text:
Q: Angular 4 Bootstrap dropdown require Popper.js I have a fresh created Angular 4 CLI app. After running this:
npm install bootstrap@4.0.0-beta jquery popper.js --save

and editing .angular-cli.json like this:
"styles": [
  "styles.css",
  "../node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
  "../node_modules/jquery/dist/jquery.slim.min.js",
  "../node_modules/bootstrap/dist/js/bootstrap.min.js",
  "../node_modules/popper.js/dist/umd/popper.min.js"
],

I still have an issue in Chrome Console:
Uncaught Error: Bootstrap dropdown require Popper.js (https://popper.js.org)
    at eval (eval at webpackJsonp.../../../../script-loader/addScript.js.module.exports (addScript.js:9), <anonymous>:6:17548)
    at eval (eval at webpackJsonp.../../../../script-loader/addScript.js.module.exports (addScript.js:9), <anonymous>:6:23163)
    at eval (eval at webpackJsonp.../../../../script-loader/addScript.js.module.exports (addScript.js:9), <anonymous>:6:50902)
    at eval (<anonymous>)
    at webpackJsonp.../../../../script-loader/addScript.js.module.exports (addScript.js:9)
    at Object.../../../../script-loader/index.js!../../../../bootstrap/dist/js/bootstrap.min.js (bootstrap.min.js?f885:1)
    at __webpack_require__ (bootstrap a2f1d85ef068872b0530:54)
    at Object.2 (scripts.bundle.js:66)
    at __webpack_require__ (bootstrap a2f1d85ef068872b0530:54)
    at webpackJsonpCallback (bootstrap a2f1d85ef068872b0530:25)

How do I fix this?

A:
Form Angular 8 to 13

npm install bootstrap jquery popper.js --save
     "styles": [
      "src/styles.scss",
      "node_modules/bootstrap/dist/css/bootstrap.min.css"
    ],
    "scripts": [
      "node_modules/jquery/dist/jquery.slim.min.js",
      "node_modules/popper.js/dist/umd/popper.min.js",
      "node_modules/bootstrap/dist/js/bootstrap.min.js"
    ],

A:
For Angular 7

npm install bootstrap jquery popper.js --save
       "styles": [
          "src/styles.scss",
          "node_modules/bootstrap/dist/css/bootstrap.min.css"
        ],
        "scripts": [
          "node_modules/jquery/dist/jquery.slim.min.js",
          "node_modules/bootstrap/dist/js/bootstrap.min.js",
          "node_modules/popper.js/dist/umd/popper.min.js"
        ],

A: Was same issue, when I updated app to 8 version of Angular. As solution can use bootstrap bundle minified js file instead bootstrap.min.js. Bootstrap bundle included popper.js already. Need to fix angular.json (scripts array in build section), in final will be something like this:
"scripts": [
    "./node_modules/jquery/dist/jquery.min.js",
    "./node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",
],

For this solution popper.js is not needed in project. Can remove this module:
npm uninstall popper.js

just in case, jquery needed :)
Hope, help you

A: Include popper.js before bootstrap.js:
"scripts": [
  "node_modules/jquery/dist/jquery.slim.min.js",
  "node_modules/popper.js/dist/umd/popper.min.js",
  "node_modules/bootstrap/dist/js/bootstrap.min.js"
],

A: The new https://www.npmjs.com/package/@popperjs/core doesnt work with bootstrap 5.
it still requires the old https://www.npmjs.com/package/popper.js?ref=vanillalist deprecated package.
tried in angular 13, it doesnt work, so have to fall back.


text:
Q: Formatting issue on datatable printing to pdf I'm using C#, ASP.NET, iTextSharp for my application.
I have formatting issues when I print my datatable to PDF.
I have two datatables: dt and dt_child
    foreach (DataRow dr in dt.Rows)
        {
        foreach (DataColumn dc in dt.Columns)
            {
            stringWrite.Write(dr[dc]);
            }
            indentno=dr["REF"].ToString();
            dt_child = getDataTablebyProcedure("ChildProcedure",ref);
            stringWrite = getStringWriterbyDataTable(dt_child, stringWrite);
        }

Code is working fine. I have an issue with formatting.
The picture shows how it is currently displayed.
I want
1: The header row of dt to be displayed. It is currently not displayed.
2: The row of dt to be displayed in table form. Currently I'm iterating rows in each column.

A: You will need to set UI for PDF.
Try this if it helps
private void ExportDataToPDFTable()
    {
      Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
         try
          {
           string pdfFilePath = Server.MapPath(".") + "/pdf/myPdf.pdf";
           //Create Document class object and set its size to letter and give space left, right, Top, Bottom Margin
           PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(pdfFilePath, FileMode.Create));

           doc.Open();//Open Document to write

           Font font8 = FontFactory.GetFont("ARIAL", 7);

           //Write some content
            Paragraph paragraph = new Paragraph("Using ITextsharp I am going to show how to create simple table in PDF document ");

            DataTable dt = GetDataTable();

            if (dt != null)
                {
                 //Craete instance of the pdf table and set the number of column in that table
                 PdfPTable PdfTable = new PdfPTable(dt.Columns.Count);
                 PdfPCell PdfPCell = null;

                 //Add Header of the pdf table
                 PdfPCell = new PdfPCell(new Phrase(new Chunk("ID", font8)));
                 PdfTable.AddCell(PdfPCell);

                 PdfPCell = new PdfPCell(new Phrase(new Chunk("Name", font8)));
                 PdfTable.AddCell(PdfPCell);

                 //How add the data from datatable to pdf table
                 for (int rows = 0; rows < dt.Rows.Count; rows++)
                    {
                     for (int column = 0; column < dt.Columns.Count; column++)
                         {
                           PdfPCell = new PdfPCell(new Phrase(new Chunk(dt.Rows[rows][column].ToString(), font8)));
                            PdfTable.AddCell(PdfPCell);
                            }
                        }

                        PdfTable.SpacingBefore = 15f; // Give some space after the text or it may overlap the table

                        doc.Add(paragraph);// add paragraph to the document
                        doc.Add(PdfTable); // add pdf table to the document

                    }

                }
                catch (DocumentException docEx)
                {
                    //handle pdf document exception if any
                }
                catch (IOException ioEx)
                {
                    // handle IO exception
                }
                catch (Exception ex)
                {
                    // ahndle other exception if occurs
                }
                finally
                {
                    //Close document and writer
                    doc.Close();

       }
 }

Courtesy
Add table into existing PDF using iTExtsharp
For reference
http://www.codeproject.com/Tips/573907/Generating-PDF-using-ItextSharp-with-Footer-in-Csh


text:
Q: How to Automate Oracle SQL Developer to export a query to csv/xlsx once a day I'm fairly new to SQL and my team has been tasked with running a daily report which requires SQL data. Is there a way to use Oracle SQL Developer to automatically export a query to csv/excel on a daily basis?

A: The program Oracle SQL Developer itself won't automate it, but there are plenty of options to get it done.
Basically, some computer somewhere needs to have a scheduler that can wake it up and do the work. Some people use their own computers for this, using windows scheduled tasks, cron jobs, or 3rd party programs.
But what "tasks" will your computer run? The task is basically to connect to the database, authenticate, send the Query text, retrieve the results in memory, and then export them as a file. Lot's of people will use python for this, because it can handle all of those steps.
You'll notice that we're already at 2 external "things" that could fail.
(1) your computer,
(2) your python code.
A simpler option, is the oracle database itself. Is it on a remote server that's always running? If so, you might take advantage of that and have it do all the work.
You're looking at a few steps, but I think they are easier (you might have to get permissions from an admin, though).
Specify a file location - remember, this is on the server, not your computer
create or replace directory csv_dir as '/destination/for/results';

Create a stored procedure - acts like a container for your SQL logic.
create or replace procedure write_file is
  file_handle UTL_FILE.file_type;
begin
  file_handle := utl_file.fopen('CSV_DIR', 'csv_filename.csv', 'w', 32767);
  for rws in (
    select * from t -- your query here
  ) loop
    utl_file.put_line(file_handle,
      rws.c1 || ',' || rws.c2 || ',' || rws.c3 -- your columns here
    );
  end loop;
  utl_file.fclose(file_handle);
end write_file;

Create a scheduler job - runs the stored procedure. This is a feature of your Oracle server.
BEGIN
  DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'EXPORT_CSV_J',
    job_type => 'PLSQL_BLOCK',
    job_action => 'begin write_file; end;',
    number_of_arguments => 0,
    start_date => NULL,
    repeat_interval => 'FREQ=DAILY',
    end_date => NULL,
    enabled => FALSE,
    auto_drop => FALSE);

  DBMS_SCHEDULER.SET_ATTRIBUTE(
    name => 'EXPORT_CSV_J',
    attribute => 'logging_level',
    value => DBMS_SCHEDULER.LOGGING_RUNS);

  DBMS_SCHEDULER.enable(
    name => 'EXPORT_CSV_J');
END;

I borrowed this code from this website since it has been a while since I did this myself.
If for some reason your database isn't actually Oracle (I know some people use Oracle SQL Developer even though their actual database is something different) then the steps will be similar but the code will be different.


text:
Q: Size of near-zero set of polynomial Let $p(x)$ be a polynomial of degree $D$ in one variable.  I am interested in the set
$$
A_{\varepsilon} := \{x\in \mathbb{R} \,\mid\, |p(x)|\leq \varepsilon |p'(x)|\}.
$$
Here $p'(x)$ denotes the derivative of $p$.  I wonder if there is there is a nice bound for the size of $A_\varepsilon$.  In particular, my question is:

Does there exists a constant $C_D$ (which is allowed to depend on the
  degree $D$) such that  $$ \mu(A_\varepsilon) \leq C_D \varepsilon. $$

Some examples:
I think that the case that $p(x)=x^D$ is pretty interesting.  In this case, the polynomial has a root of order $k$ at the origin, and
$$
A_\varepsilon = [-\varepsilon D, \varepsilon D].
$$
This makes me think that perhaps one could take $C_D = 2D$.
This examples also suggests that perhaps $A_\varepsilon$ is actually contained near the roots of the polynomials.  This can't be quite true, at least over $\mathbb{R}$, because of the example $p(x)=x^2+\varepsilon^{4}$.  This polynomial has no real roots, but it behaves just like $x^2$ for the purposes of this problem.

A: I figured it out, albeit with a suboptimal constant $C_D = D^2$.
The first observation is that $x\in A_\varepsilon$ if and only if
$|p'(x)|/|p(x)| \geq \varepsilon^{-1}$.  This is a simple rearrangement, but the point is that there is a nice formula for $p'(x)/p(x)$.  To see this, factor $p$ over the complex numbers.  If $\{r_i\}_{i=1}^D$ is the set of complex roots, we can write $p(z) = c \prod_{i=1}^D (z-r_i)$.  Then
$$
\frac{p'}{p} = \frac{d}{dz} \log p = \sum_{i=1}^D \frac{1}{z-r_i}.
$$
Now if the magnitude of the sum is larger than $\varepsilon^{-1}$, it must be that at least one of the terms has magnitude at least $(D\varepsilon)^{-1}$.
Thus we observe
$$
A_\varepsilon \subset \bigcup_{i=1}^D B_{D\varepsilon}(r_i)
$$
where $B_{D\varepsilon}$ denotes a ball of radius $D\varepsilon$, and we think of both sets as being subsets of the complex plane.  From this we conclude
$$
|A_\varepsilon| \leq 2D^2\varepsilon.
$$
This is likely suboptimal, because we crudely estimated the sum of the reciprocals.  I would still be interested to learn what the best possible $C_D$ is.


text:
Q: Delimiter matching simple program won't work I have looked over this for hours it seems like. This program will compile, it just can't detect errors correctly. And for some reason it will work when I type in hey [) or hey {], etc. But it won't work for hey[) or hey{]. Obviously in all cases it should detect an error but for some reason the space after 'hey' makes a difference.
#include<iostream>
#include <stack>
using namespace std;

bool delimiterMatching(char *file){
  stack<char> x;
  int count = 0;
  char ch, onTop, check;
  while(ch != '\0'){
    ch = file[count];
    if (ch == '(' || ch == '[' || ch == '{')
      x.push(ch);
    else if (ch == ')' || ch ==  ']' || ch == '}') {
      onTop == x.top();
       x.pop();
      if((ch==')' && onTop!='(') || (ch==']' && onTop!='[') || (ch=='}' &&
                                onTop!= '{'))
    return false;
    }
  count++;
  }

  if (x.empty())
    return true;
  else
    return false;

}

int main()
{
  char *test = new char();
  cout << "enter sentence: ";
  cin >> test;

  if (delimiterMatching(test))
    cout << "success" << endl;
  else
    cout << "error" << endl;

  return 1;
}

A: With cin >> test you don't get a whole sentence, but only a string until cin encounters whitespace. So if you type (hey ), thest would be (hey and the closing brace would only be read by the next >>, whereas (hey) would work as expected.
You have a second issue with your test allocation, which might be too short for reasonable input.
Change main() as follows:
char *test = new char[256];   // enough space.  COnsider also string
cout << "enter sentence: ";
cin.getline(test, 256);       // full line input.
...

You have also two nasty bugs in delimiterMatching().

*

*First you use an uninitialized ch in your while condition. Either initialise ch to a non nul char, or use while (file[count]).

*And did you notice onTop == x.top();  ?  Shouldn't it be onTop = x.top();?


text:
Q: Format number with comma separator for thousands using C#
Possible Duplicate:
String.Format an integer to use 1000's separator without decimal places or leading 0 for small integers

The blog post
http://blog.stevex.net/string-formatting-in-csharp/
(in the Custom number formatting section) shows that using the format {0:0,0}, a number like 1500 will be formatted as 1,500 which is good.  But I don't understand why 0 is formatted as 00
Do I need to handle the case of 0 separately which doesn't seem to be necessary.

A: You can use "F0", which is "fixed number with 0 decimal places". It give you a thousands separator when you results go over 1,000.


text:
Q: Using C++ types in an ANTLR-generated C parser I'm trying to use an ANTLR v3.2-generated parser in a C++ project using C as the output language. The generated parser can, in theory, be compiled as C++, but I'm having trouble dealing with C++ types inside parser actions. Here's a C++ header file defining a few types I'd like to use in the parser:
/* expr.h */
enum Kind {
  PLUS,
  MINUS
};

class Expr { // stub
};

class ExprFactory {
public:
  Expr mkExpr(Kind kind, Expr op1, Expr op2);
  Expr mkInt(std::string n);
};

And here's a simple parser definition:
/* Expr.g */
grammar Expr;

options {
  language = 'C';
}

@parser::includes {
  #include "expr.h"
}

@members {
  ExprFactory *exprFactory;
}

start returns [Expr expr]
  : e = expression EOF { $expr = e; }
  ;

expression returns [Expr e]
  : TOK_LPAREN k=builtinOp op1=expression op2=expression TOK_RPAREN
    { e = exprFactory->mkExpr(k,op1,op2); }
  | INTEGER { e = exprFactory->mkInt((char*)$INTEGER.text->chars); }
  ;

builtinOp returns [Kind kind]
  : TOK_PLUS { kind = PLUS; }
  | TOK_MINUS { kind = MINUS; }
  ;

TOK_PLUS : '+';
TOK_MINUS : '-';
TOK_LPAREN : '(';
TOK_RPAREN : ')';
INTEGER : ('0'..'9')+;

The grammar runs through ANTLR just fine. When I try to compile ExprParser.c, I get errors like

*

*conversion from 'long int' to non-scalar type 'Expr' requested

*no match for 'operator=' in 'e = 0l'

*invalid conversion from 'long int' to 'Kind'
In each case, the statement is an initialization of an Expr or Kind value to NULL.
I can make the problem go away for the Expr's by changing everything to Expr*. This is workable, though hardly ideal. But passing around pointers for a simple enum like Kind seems ridiculous. One ugly workaround I've found is to create a second return value, which pushes the Kind value into a struct and suppresses the initialization to NULL. I.e, builtinOp becomes
builtinOp returns [Kind kind, bool dummy]
  : TOK_PLUS { $kind = PLUS; }
  | TOK_MINUS { $kind = MINUS; }
  ;

and the first expression alternative becomes
TOK_LPAREN k=builtinOp op1=expression op2=expression TOK_RPAREN
    { e = exprFactory->mkExpr(k.kind,*op1,*op2); }

There has to be a better way to do things? Am I missing a configuration option to the C language backend? Is there another way to arrange my grammar to avoid this awkwardness? Is there a pure C++ backend I can use?

A: Here are the solutions I have found to this problem. The crux of the issue is that ANTLR wants to initialize all return values and attributes. For non-primitive types, ANTLR just assumes it can initialize with NULL. So, for example, the expression rule above will be translated into something like
static Expr
expression(pExprParser ctx)
{
    Expr e = NULL; // Declare and init return value
    Kind k; // declare attributes
    Expr op1, op2;
    k = NULL; // init attributes
    op1 = NULL;
    op2 = NULL;
    ...
}

The choices, as I see them, are these:

*

*Give the values primitive types that can legally be initialized to NULL. E.g., use Expr* and Kind* instead of Expr and Kind.

*Use the "dummy" trick, as above, to push the value into a structure where it won't be initialized.

*Use reference parameters instead of return values. E.g.,
builtinOp[Kind& kind]
  : TOK_PLUS { kind = PLUS; }
  | TOK_MINUS { kind = MINUS; }
  ;

*Augment the classes used as value types with operations that make the above declarations and initializations legal. I.e., for a Expr return value, you need a constructor that can take NULL:
Expr(long int n);

For an Expr attribute, you need a no-arg constructor and an operator= that can take NULL:
Expr();
Expr operator=(long int n);

I know it is pretty hacky, but I'm going with #4 for the time being. It just so happens that my Expr class has a fairly natural definition of these operations.
P.S. On the ANTLR list, the maintainer of the C backend hints that this problem may be solved in future releases.


text:
Q: Trying to Upload Multiple Images to Facebook and Twitter with Buffer REST API I'm using the Buffer REST API to schedule several posts to Facebook and Twitter.
https://buffer.com/developers/api
It's going well, except for the fact that I can't figure out how to attach several images at once for a post, so that the post will showcase all of the images in an album-like format you often see on Facebook.
I've tried a couple of things, like listing the media[photo] attribute twice with different images:
 {
   'access_token': process.env.BUFFER_ACCESS_TOKEN,
   'text': 'Some text to post',
   'media[photo]': 'http://www.someimage.com/image.jpg',
   'media[photo]': 'http://www.someotherimage.com/image.jpg',
   'profile_ids[]': [12349, 123456]
 }

And I've also tried containing those images inside their own array, like this:
 {
   ...other items,
   'media[photo]': ['http://www.someimage.com/image.jpg', 'http://www.someotherimage.com/image.jpg'],
 }

Nevertheless, only ONE of those images is actually attached to the schedule post when I view it in the Buffer UI.
Has anyone had any success doing this, or should I look to a different tool to accomplish it? Maybe Hootsuite?
Thanks in advance!


text:
Q: polymer / page.js change route in javascript without causing page refresh I use Polymer starter kit to build my app. I removed the hashbang in the urls.
I am trying to build a login screen and after successful login, I want to change the page to default route. To do this, I have a listener in app.js for successful log in. On successful log in, I change the route which causes page refresh. I tried multiple options:

*

*location = 'entireUrl'

*location.pathname = '/route'

*location = 'route'

All the options causes page refresh. Is there any way to code this without causing page refresh. Shouldn't page.js catch this and do the routing without page refresh?

A: For those looking for an answer, I fixed it by calling page.redirect('/route').
note: page.redirect will replace the browser history. If you want to retain browser history you can use page.show('/route')