text:
Q: Query to Database MySQL iOS application I have a database mysql and it contains 1000 records of people (Name, Age, Adress, Country). I want to make an application that :

*

*Randomly displays ONE of the records in the database.

*Randomly displays ONE of the records according to a specific 'Country'.

My usual approach to this is : parse ALL data to the iphone using JSON, then manipulate the data. Because of the volume of data that the user needs to download (1000 records) and because i only need just ONE of the records to be displayed, it seems wasteful to download all 1000 records and then sort the data. What other approach can i use? (not sure but is it possible to query the database directly?)

A: It would be very unsafe to query the DB directly and the usual approach you mentioned would be a very bad idea. So, the general approach, safe and optimized, for this scenario is to write some web-service, can be in PHP or ASP.net or etc., end-points which can optionally take some parameters, like the specific country, as argument and return you data in JSON format and then you can display it. This is how I'd approach to such problem. Here's a tutorial on writing some basic web-services with PHP.
http://davidwalsh.name/web-service-php-mysql-xml-json
Hope that'd help.


text:
Q: R Warning in stemCompletion and error in TermDocumentMatrix I was followed the instruction from here
In slide no. 9 tolower has issue in package tm 0.6 and above I have used
myCorpus <- tm_map(myCorpus, content_transformer(tolower)

it was duplicate from this stackoverflow
but i still get error when run stemCompletion
myCorpus <- tm_map(myCorpus, stemCompletion, dictionary = myCorpusCopy)

And I follow this instruction for both variable myCorpus and myCorpusCopy to PlainTextDocument
corpus <- tm_map(corpus, PlainTextDocument)

I was able to execute
myCorpus <- tm_map(myCorpus, stemCompletion, dictionary = myCorpusCopy)

but I get 50 warnings

There were 50 or more warnings (use warnings() to see the first 50)
      warnings()

and I get all 50 warnings:

1: In grep(sprintf("^%s", w), dictionary, value = TRUE) : argument
  'pattern' has length > 1 and only the first element will be used 2: In
  grep(sprintf("^%s", w), dictionary, value = TRUE) : argument 'pattern'
  has length > 1 and only the first element will be used 3: In
  grep(sprintf("^%s", w), dictionary, value = TRUE) : argument 'pattern'
  has length > 1 and only the first element will be used 4: In
  grep(sprintf("^%s", w), dictionary, value = TRUE) : argument 'pattern'
  has length > 1 and only the first element will be used 5: In
  grep(sprintf("^%s", w), dictionary, value = TRUE) : argument 'pattern'
  has length > 1 and only the first element will be used 6: In
  grep(sprintf("^%s", w), dictionary, value = TRUE) : argument 'pattern'
  has length > 1 and only the first element will be used 7: In
  grep(sprintf("^%s", w), dictionary, value = TRUE) : argument 'pattern'
  has length > 1 and only the first element will be used 8: In
  grep(sprintf("^%s", w), dictionary, value = TRUE) : argument 'pattern'
  has length > 1 and only the first element will be used 9: In
  grep(sprintf("^%s", w), dictionary, value = TRUE) : argument 'pattern'
  has length > 1 and only the first element will be used 10: In
  grep(sprintf("^%s", w), dictionary, value = TRUE) : argument 'pattern'
  has length > 1 and only the first element will be used

I try to ignore the warnings and create TermDocumentMatrix()
tdm <- TermDocumentMatrix(myCorpus, control = list(wordLengths = c(1,
Inf)))

and I get error:
Error: inherits(doc, "TextDocument") is not TRUE

A: Here's how you can create a stemmed term-document-matrix and re-complete the stemmed tokens afterwards:
txt <- " was followed the instruction from here In slide no. 9 tolower has issue in package tm 0.6 and above I have used "
myCorpus <- Corpus(VectorSource(txt))
myCorpus <- tm_map(myCorpus, content_transformer(tolower))
tdm <- TermDocumentMatrix(myCorpus, control = list(stemming = TRUE))
cbind(stems = rownames(tdm), completed = stemCompletion(rownames(tdm), myCorpus))
#          stems      completed
# 0.6      "0.6"      "0.6"
# abov     "abov"     "above"
# and      "and"      "and"
# follow   "follow"   "followed"
# from     "from"     "from"
# has      "has"      "has"
# have     "have"     "have"
# here     "here"     "here"
# instruct "instruct" "instruction"
# issu     "issu"     "issue"
# no.      "no."      "no."
# packag   "packag"   "package"
# slide    "slide"    "slide"
# the      "the"      "the"
# tolow    "tolow"    "tolower"
# use      "use"      "used"
# was      "was"      "was"

redpajama_set_name: RedPajamaStackExchange


text:
Q: no POST while booting. monitor not displaying anything The monitor not displaying anything.
I don't hear the POST signal as well. ( the beep while booting )
Things that I have tried.

*

*Connected MONITOR to laptop ( which I am using currently ), displaying properly working fine. So, it is not the Monitor's fault.

*Connected keyboard USB to desktop while booting ( it is detecting keyboard, I can switch numlock off/on )

*Cleared CMOS by touching two pins ( reading the motherboard manual Gigabyte that I got from shipment )

*Switched RAM's, placing them in different slots and placing only one RAM instead of both. Purchased another ( better RAM ) Kingston DDR3 ( saw the mobo manual and checked if it supports ).

*Removed the RADEON HD 6870 Graphics card from its slot and put it back again to make sure it fit perfectly.

*Also, removed DVD drive, because I don't need it now.

*Also, removed all the USB drives ( no keyboard, no mouse ).

*I have also tried removing all the RAM(s), and booted the system. It is turned on for some time ( around 6 seconds ) and turn off automatically, and then turn on again. It happened 3 times, So, I turned it off. I made sure, the speakers are on all the time, no beep/weird noise heard. ( Recommendation attempt from Luke )

*replaced PSU with the one that I borrowed from my friend, it still doesn't give any beeps while booting. monitor still not displaying anything. Now, I am guessing the motherboard/processor is at fault.

Nothing helped.
I see that the fan-supply that is connected to the processor is spinning and the fan on the RADEON is also spinning.
I don't hear any weird beeps/noises while booting.
What do you guys think?

A: I agree, the power supply is next. If you don't have another one, and you're sure the speaker is connected (for the POST beeps), remove all the RAM and see if 3 beeps are sounded.
Just out of curiosity, is this a new build or a computer that suddenly stopped working?

A: did you try to use the on-board video, also try to remove the battery on the mobo (make sure the computer is not plugged in) then after a few minutes press the power button a couple of times just to make sure that no power is sitting in the mobo, then put battery back in and then plug in the computer


text:
Q: Find correct android version on device     if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD) {
        //--incompatible code--
    } else {
        //--compatible code--
    }

The condition runs into incompatible code on Gingerbread. Does Build.VERSION.SDK_INT represents actual device version ? or the SDK version the app has been compiled with ?

A: This is a static member, which was assigned value when the app first executes.
public static final int SDK_INT = SystemProperties.getInt("ro.build.version.sdk", 0);

The SystemProperties.getInt() member function runs on your target device and is not determined when you compile your application.
According to the official guide you should use >= instead of > when detect api version, i.e.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {

since there may be minor versions between major versions.

A: The issue was that there are 2 codes for GB:
Build.VERSION_CODES.GINGERBREAD -> API 9
and
Build.VERSION_CODES.GINGERBREAD_MR1 -> API 10
as minSdkVersion API in manifest = 10 then I should have used Build.VERSION_CODES.GINGERBREAD_MR1.


text:
Q: $_POST doesn't contain all data Since a few days ago, we've a problem in an online shop. (Gambio bases on xtC)
We have a formula with more than 3000 text fields. About the first third of them work correctly; the rest is null, empty.
It seems that $_POST is filled correctly, but on the server, the app gets a reduced array.
I tested it on different computers, with different browsers, with different content: => always the same.
Server: Linux infong 2.4 #1 SMP Mon Oct 10 09:34:36 UTC 2011 i686 GNU/Linux

PHP Version 5.2.17 (build 12-29-2011)
post_max_size is 8 MB.
The problems were recognized on 12-30-2011, so it might be connected with the new build on the server.
Has somebody ideas concerning this problem?

A:
The problems were recognized on 12-30-2011, so it might be connected with the new build on the server.

If you're using a PHP version provided by your linux distribution, it's very likely that they backported this patch to PHP 5.3 and 5.4, designed to mitigate a possible attack vector that impacts PHP and numerous other languages and libraries.
If this is the case, try dumping a phpinfo() and look for max_input_vars.  If it's there, you can set it in php.ini to a higher number, as you see fit.  If you don't see it, it's likely that you didn't receive that exact patch and the number has been hard-coded by your distribution.


text:
Q: Does Resharper tell me a css class is unknown because it's on a CDN? Resharper tells me, "Unknown css class 'container-fluid" for this line in my site's _SiteLayout.cshtml file:
<header class="container-fluid">"

I do have this in my <head> section:
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">

...and I believe "container-fluid' is there. Is this simply a matter of Resharper not being able to find the class because it's remote?

A: I was also having this issue using Resharper 8.2, tried Fizzix solution but I already had those options selected and it didn't seem to fix it :(
What did work, however, was a simple fix;

*

*I right-clicked on the css file that contained the class it was telling me was unknown in my SOlution Explorer.

*Selected 'Exclude from Project'

*Right-clicked on file again and 'Include in Project'

Error went away instantly and page now renders with the css class correctly! Weird!

A: ReSharper cannot access this file since it is not yet rendered into the project.
For example, when you have a CSS file within your project, ReSharper can simply search through it looking for class names. Although, when a CSS file is outside of your project (remote, or in a CDN), it does not have the capabilities to access it since it is not included yet.
Once your project is running within a browser and the file from the CDN is called, that is when it is included within your project.
Therefore, if you would like to know which class names exist or not when working with ReSharper, it is usually best to download them and include them within your project :)
EDIT:
After researching into this, I think I have found a way to allow ReSharper to search within external sources and uncompiled code.
Go to: ReSharper -> Options -> Tools -> External Sources

More information in the official documentation for ReSharper | Options | Tools | External Sources.


text:
Q: Windows Remote Viewing of Event Logs fails with "Access denied" I'm trying to connect to a remote windows server (2019) from a machine in the same domain and view its event logs. However, I'm getting "Access denied" in almost all ways I've triied. Below is a list of relevant details:

*

*Event viewer's "Connect to another machine" works correctly

*PowerShell Get-WinEvent fails with Access denied (with proper -Credential passed)

*PowerShell Get-WmiObject -Class Win32_NTEventLogFile -ComputerName ... -Credential ... fails with access denied

*after using winevt's EvtOpenSession, all subsequent calls fail with Access denied (which is epxected, as the check is lazily performed)

The following configuratons have been done:

*

*the user is a service account and has been added to the following groups: Distributed COM users, Event log readers, Performance Monitor Users, Remote Management users

*the firewall inbound rules to allow remote log management have been enabled

*in the WMI configuration management, the user has been added to the WMI root with "Remote enable" and all other permissions

So, the question being - what am I missing on order to get winevt EvtOpenSession to work, as well as (optionally) Get-WinEvent and Get-WMIObject


text:
Q: Start button on Windows 10 doesn't work and Microsoft Edge icon invisible My Windows 10 computer recently got a problem and I don't know how. The first thing I noticed when I turned it on about a month ago was that the Microsoft Edge button was invisible. Later I saw that I could not left-click on the start button.
What should I do to fix these problems?

A: I had this issue on my Laptop after the first major Windows 10 update.
I couldn't find any useful solution so I waited until the next windows update and it resolved the issue. Are there any more windows updates pending that you could run?


text:
Q: urllib2 works where request doesn't EDIT: Solved! See below.
I'm a recent convert to using the requests library for python. However, I'm encountering a situation where urllib2 works and requests doesn't.
import requests, urllib2
url = "http://thepiratebay.se/search/test/0/7/0"
print urllib2.urlopen(url).getcode() # 200 - OK!
print requests.get(url).status_code # 400 :(

I've also tried setting headers but it doesn't seem to fix the problem, so I've included my minimal example. Other thoughts: is urllib2 somehow handling the redirect to thepiratebay.sx correctly while requests doesn't?
Thanks in advance!

Thanks for the help all, I upgraded requests (1.0.4 => 1.2.2) and it solved the problem. Oops, should have considered that earlier!

A: The requests library does handle redirects by default, as seen here.
In fact, I cannot reproduce your issue:

Perhaps try it again?

A: Both of these should handle redirects by default
From http://docs.python.org/2/library/urllib2.html, urllib2 handles "basic and digest authentication, redirections, cookies and more."
From http://docs.python-requests.org/en/latest/user/quickstart.html#redirection-and-history "Requests will automatically perform location redirection while using the GET and OPTIONS verbs."
Both of these return a 200 response for me.


text:
Q: Return callback result in swift I have a function in swift to return a string from array, if the array has value return directly, if not I need load it from server and return the value from callback, I don't know how to do it, something like
func getValue(idx: Int)->string {
    if arrayValue.count <= 0 {
        callbackfunc() { arrayValue in
        return arrayValue[idx]
       }
    } else {
      return arrayValue[idx]
    }
}

but it is impossible to return from callback, any help? thank you very much

A: Add a completion handler:
func getValue(idx: Int, completion: @escaping (String) -> Void) {
    if arrayValue.count <= 0 {
       callbackfunc() { arrayValue in
          completion(arrayValue[idx])
       }
    } else {
      completion(arrayValue[idx])
    }
}

And call it:
getValue(idx: 2) { result in
    print(result)
}

A: As you have found out you cannot directly return a value from a closure.  Therefore you need to handle the returned data within the callback.  This can be as complex as needs be, but for a simple example you could just pass the data back to an underlying method.
Depending on what else the app might be doing during the time the callback is running, you may need to be careful how you update this data to make it thread-safe.   As a simple precaution it's probably worth performing the update on the main thread:
func getValue(idx: Int)->string {
    if arrayValue.count <= 0 {
        callbackfunc() { [weak self] arrayValue in
           DispatchQueue.main.async {
              self.processReturnedData(arrayValue[idx])
           }
       }
    } else {
      return arrayValue[idx]
    }
}

func processReturnedData(_ idx: IDXType) {
   //do something with the data
}


text:
Q: Why is my Joomla user plugin not called? I've written a small user plugin for Joomla! that should change the return url on logging in depending on the user's group. However, it's not even being called. What am I doing wrong?
class plgUserPluginName extends JPlugin
{
    /**
    * This method should handle any login logic and report back to the subject
    *
    * @param    array   $user       Holds the user data
    * @param    array   $options    Array holding options (remember, autoregister, group)
    *
    * @return   boolean True on success
    * @since    1.5
    */
    public function onUserLogin($user, $options = array())
    {
        $user = JFactory::getUser();
        $db = JFactory::getDBO();
        $db->setQuery(
            'SELECT link_id FROM '.$db->quoteName('#__mt_links') .
            ' WHERE '.$db->quoteName('user_id').' = '.$db->quote($user->id)
        );
        $link_id = $db->loadResult();
        if(!$link_id){
            $db->setQuery(
               'SELECT group_id FROM '.$db->quoteName('#__user_usergroup_map') .
               ' WHERE '.$db->quoteName('user_id').' = '.$db->quote($user->id)
            );
            $group_id = $db->loadResult();
            if($group_id == somegroupid) $options['return'] = 'abc';
            elseif($group_id == someothergroupid) $options['return'] = 'xyz';
        }
        return true;
    }
}

My xml is:
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="user">
    <name>plg_user_pluginname</name>
    <version>1.0.0</version>
    <description>PLG_USER_PLUGINNAME_XML_DESCRIPTION</description>
    <files>
        <filename plugin="pluginname">pluginname.php</filename>
        <filename>index.html</filename>
    </files>
    <languages>
        <language tag="en-GB">en-GB.plg_user_pluginname.ini</language>
        <language tag="en-GB">en-GB.plg_user_pluginname.sys.ini</language>
    </languages>
    <config>
    </config>
</extension>

A: I am not sure which of the following two solved it, but
a) I renamed my plugin to plgUserPluginname instead of plgUserPluginName (small n for name)
b) I changed accessibility from Registered to Public
and it's being called now!


text:
Q: "android.database.sqlite.SQLiteException: no such table" error in rare cases I have an app currently available in the app store, but there is one type of error report that I can't seem to figure out completely. My app uses an internal sqlite database, but on some devices (certainly not the majority) the following error sometimes occurs:

android.database.sqlite.SQLiteException: no such table: image_data
  (code 1): , while compiling: SELECT Min(stamp) FROM image_data WHERE
  category = 'Astronomy' AND stamp >= 1357426800 and coalesce(title_nl,
  '') = ''

I am sure this table exists and I'm sure this query is correct. I know that this error only occurs in the widgets of the app and in a BroadcastReceiver fired by the AlarmManager (the app once in a while tries to download new entries, as it's a picture of the day app).
I think it has something to do with the Context I am in when accessing the database. I have a class called AppContextHelper which extends Application and has a static member in which I store the context. That context is always used when accessing the database.
My question: could it be that THAT context is invalid in some cases when acquiring the database in a widget or the aforementioned BroadcastReceiver fired by the AlarmManager and that in that case I should use the provided Context in favor of the 'application' context? If so, why is that context invalid or better yet, which context is it that is provided?
Thanks in advance!
As requested the code leading to the problem, again, only on SOME devices and ONLY in the widgets or AlarmManager class. I will post the code leading to the error in the AlarmManager class (that is the code with the least lines)

*

*The code initializing the alarm:
    Intent myIntent = new Intent(AppContextHelper.getContext(), ApodDownloader.class);
    mPendingIntent = PendingIntent.getBroadcast(AppContextHelper.getContext(), 0, myIntent, 0);

    AlarmManager alarmManager = (AlarmManager)AppContextHelper.getContext().getSystemService(Context.ALARM_SERVICE);
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());

    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis() + 10000, AlarmManager.INTERVAL_HOUR, mPendingIntent);

*AppContextHelper.java
public class AppContextHelper extends Application {

    private static Context mContext;

    @Override
    public void onCreate() {
        super.onCreate();
        mContext = this;
    }

    public static Context getContext(){
        return mContext;
    }
}

*(part of) ApodDownloader.java (this contains the line of the exception being thrown)
@Override
public void onReceive(Context arg0, Intent arg1) {
    (new AsyncTaskThreadPool<Integer, Void, Boolean>() {

        @Override
        protected Boolean doInBackground(Integer... params) {
            Helpers.logMessage("Checking new entries.");

            SQLiteDatabase db = FrescoDatabase.acquireReadableDatabase(AppContextHelper.getContext());
            try {
                >>> THIS LINE THROWS THE EXCEPTION <<<
                maxStamp = Helpers.executeScalarLong(db, "SELECT Min(stamp) FROM image_data WHERE category = 'Astronomy' AND stamp >= 1357426800 and coalesce(title_nl, '') = ''");

                [...]
            } finally {
                FrescoDatabase.releaseReadableDatabase();
            }

            [...] more code

        }
        [...] onPostExecute
    }).executeOnExecutor(AsyncTaskThreadPool.THREAD_POOL_EXECUTOR, 0);

*FrescoDatabase.java
The database is automatically generated by the app on startup, this code is working, also on the devices that fire the exception. I cannot emphasize enough that the database exists on the problematic devices, since app is running flawlessly with the exception of the widgets and BroadcastReceiver of the AlarmManager, so please don't tell me the db is not initialized correctly :)
public class FrescoDatabase extends SQLiteOpenHelper {

    public static final String[] OBSOLETE_DATABASE_FILE_NAMES = new String[] { "Fresco.v1.sqlite", "Fresco.v2.sqlite", "Fresco.v3.sqlite", "Fresco.v4.sqlite", "Fresco.v5.sqlite" };
    public static final String DATABASE_FILE_NAME = "Fresco.v6.sqlite";
    public  static final int DATABASE_FILE_SIZE = 15302656;
    private static final int DATABASE_VERSION = 7;

    private static final Lock writeLock = new ReentrantLock();
    private static SQLiteDatabase currentDB = null;

    public static final SQLiteDatabase acquireWritableDatabase(Context c) {
        writeLock.lock();
        currentDB = new FrescoDatabase(c).getWritableDatabase();
        return currentDB;
    }

    public static final void releaseWritableDatabase() {
        currentDB.close();
        currentDB = null;
        writeLock.unlock();
    }

    public static final SQLiteDatabase acquireReadableDatabase(Context c) {
        writeLock.lock();
        currentDB = new FrescoDatabase(c).getReadableDatabase();
        return currentDB;
    }

    public static final void releaseReadableDatabase() {
        currentDB.close();
        currentDB = null;
        writeLock.unlock();
    }

    private FrescoDatabase(Context context) {
        super(context, InitializeFrescoDatabaseTask.getDatabaseFileName(context), null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // database is automatically generated, this should not be called
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}

*(part of) Helpers.java
    public class Helpers {
        [...]
        public static long executeScalarLong(SQLiteDatabase db, String query) {
            return executeScalarLong(db, query, new String[] { });
        }
        public static long executeScalarLong(SQLiteDatabase db, String query, String... parameters) {
            (line 85, see stack trace down below) Cursor cursor = db.rawQuery(query, parameters);
            try {
                cursor.moveToNext();
                long val = cursor.getLong(0);
                return val;
            }
            catch (Exception e) {
                ;
            }
            finally {
                cursor.close();
            }
            return -1;
        }
    }

The exception log (as requested):
            java.lang.RuntimeException: An error occured while executing doInBackground()
                at nl.tagpulse.utils.AsyncTaskThreadPool$3.done(AsyncTaskThreadPool.java:329)
                at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
                at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
                at java.util.concurrent.FutureTask.run(FutureTask.java:137)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
                at java.lang.Thread.run(Thread.java:856)
                Caused by: android.database.sqlite.SQLiteException: no such table: image_data (code 1): , while compiling: SELECT Min(stamp) FROM image_data WHERE category = 'Astronomy' AND stamp >= 1357426800 and coalesce(title_nl, '') = ''
                at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1012)
                at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:623)
                at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
                at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
                at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
                at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
                at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
                at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
                at nl.tagpulse.fresco.other.Helpers.executeScalarLong(Helpers.java:85)
                at nl.tagpulse.fresco.other.Helpers.executeScalarLong(Helpers.java:82)
                at nl.tagpulse.fresco.business.FrescoDatabase.retrieveNewEntries(FrescoDatabase.java:64)
                at nl.tagpulse.fresco.business.ApodDownloader$1.doInBackground(ApodDownloader.java:192)
                at nl.tagpulse.fresco.business.ApodDownloader$1.doInBackground(ApodDownloader.java:1)
                at nl.tagpulse.utils.AsyncTaskThreadPool$2.call(AsyncTaskThreadPool.java:317)
                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
                ... 4 more

I added a line 85 marker at the Helpers.java block.
Hope this helps!

A: Here's what's happening:
ApodDownloader is a BroadcastReceiver and in its onReceive() you start an AsyncTask of some sort which is not allowed.
The documentation states:

A BroadcastReceiver object is only valid for the duration of the call
  to onReceive(Context, Intent). Once your code returns from this
  function, the system considers the object to be finished and no longer
  active.
This has important repercussions to what you can do in an
  onReceive(Context, Intent) implementation: anything that requires
  asynchronous operation is not available, because you will need to
  return from the function to handle the asynchronous operation, but at
  that point the BroadcastReceiver is no longer active and thus the
  system is free to kill its process before the asynchronous operation
  completes.
http://developer.android.com/reference/android/content/BroadcastReceiver.html#ReceiverLifecycle

When the process is killed the Application context isn't available any longer. You can still access the AppContextHelper.getContext() but that would be a newly loaded class because the old one was killed when eliminating the process. In other words the context returned would be null.
This happens only in the rare case when Android actually kills a process which isn't very often in my experience.
If the Context your AppContextHelper provides hasn't been initialized yet, then your InitializeFrescoDatabaseTask.getDatabaseFileName(context) call returns an empty string and it would naturally open the wrong database. Because you do nothing in onCreate() of your FrescoDatabase class, the database isn't initialized correctly and it won't find the tables. But even if you'd create the tables it would be the the wrong database and although the crashes were gone it wouldn't show any data.
To prevent this from happening you need to do all the work in the same thread the onReceive() is running in or if that takes too long start a service to do the heavy lifting.
One more thing I noticed when analyzing your code is that you're using the application context to create the intent when creating your alarm (new Intent(AppContextHelper.getContext(), ApodDownloader.class);). When doing this you NEED to set the FLAG_ACTIVITY_NEW_TASK or you might get a "android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?" which might or might not crash the app.


text:
Q: Random count generator by probability in python Create a function that prints a random number between 1 and 5 to stdout (or console).
1 - 50%
2 - 25%
3 - 15%
4 - 5%
5 - 5%

A: I don't think exact answers will help you, each step builds on the last. Here's a start:
def foo():
    choices = *[1]*10, *[2]*5, *[3]*3, *[4], *[5]
    return random.choice(choices)

Note the leading asterisk expands the lists so we don't have [[1,1,1,1,1],[2,2,2,2],...]. It's not strictly necessary for the last two items.


text:
Q: JSONObject cannot be converted to JSONArray - I cannot see the ListView When I try to convert the PHP result gotten from "http://www.rivedcreations.esy.es/mostrar_noticias_sqlhostinger.php", Android Studio informs me about the same JSON exception and I don't know how can I show the data in my listView. The connection between mySQL and PHP is right because I can see the data in my webbrowser. Any idea? Thanks in advance for your help!!
public class MainActivity extends Activity implements View.OnClickListener {

    ListView listaJson;
    Button BotonIntroducirNoticia;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // Todo sobre el listView
        listaJson = (ListView) findViewById(R.id.listaJson);
        Tarea1 tarea1 = new Tarea1();
        tarea1.cargarContenido(getApplicationContext());
        tarea1.execute(listaJson);
        // Todo sobre el Boton
        BotonIntroducirNoticia = (Button) findViewById(R.id.bt_nuevanoticia);
        BotonIntroducirNoticia.setOnClickListener(this);
    }
    class Tarea1 extends AsyncTask<ListView, Void, ArrayAdapter<Clase_tabla_noticias>> {
        Context contexto;
        ListView list;
        InputStream is;
        ArrayList<Clase_tabla_noticias> listaclientes = new ArrayList<Clase_tabla_noticias>();
        public void cargarContenido(Context contexto) {
            // En que actividad se va a crear el contexto
            this.contexto = contexto;
        }
        protected void onPreExecute() {
        }
        //Devuelve un ArrayAdapter y recibe un listView
        @Override
        protected ArrayAdapter<Clase_tabla_noticias> doInBackground(ListView... params) {
            list = params[0];
            String String_Resultado_de_JSON_Array = "fallo";
            Clase_tabla_noticias cli;
            //Crear la conexión HTTP
            HttpClient cliente = new DefaultHttpClient();
            HttpGet peticionGet = new HttpGet("http://www.rivedcreations.esy.es/mostrar_noticias_sqlhostinger.php");// Url del Servidor
            try {
                HttpResponse response = cliente.execute(peticionGet);
                HttpEntity contenido = response.getEntity();
                is = contenido.getContent();
            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            BufferedReader buferlector = new BufferedReader(new InputStreamReader(is));
            StringBuilder sb = new StringBuilder();
            String linea;
            try {
                while ((linea = buferlector.readLine()) != null) {
                    sb.append(linea);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                is.close();
            } catch (IOException e) {
                Log.e("AVISO", "Error al intentar capturar el String resultado del PHP "+e.toString());
            }
            //En la variable resultado tendremos lo que se saca directamente del PHP, un objeto JSON
            String_Resultado_de_JSON_Array = sb.toString();
            //Como lo que queremos es romperlo, le pasamos el String resultado mediante un Objeto JSON
            try {
                JSONArray JSON_Array = new JSONArray(String_Resultado_de_JSON_Array);
                for (int i = 0; i < JSON_Array.length(); i++) {
                    JSONObject JSON_Objeto = JSON_Array.getJSONObject(i);
                    int id = JSON_Objeto.getInt("id");
                    String autor = JSON_Objeto.getString("autor");
                    String titulo = JSON_Objeto.getString("titulo");
                    cli = new Clase_tabla_noticias(id, autor, titulo);
                    listaclientes.add(cli);
                    Log.i("AVISO","id: " + id + ", autor: " + autor);
                }
            } catch (JSONException e) {
                Log.e("AVISO", "Error al intentar el bucle de cambio de JSON_Array a JSON_Objeto "+e.toString());
            }
            ArrayAdapter<Clase_tabla_noticias> adaptador = new ArrayAdapter<Clase_tabla_noticias>(contexto, android.R.layout.simple_list_item_1, listaclientes);
            return adaptador;
        }
        @Override
        protected void onPostExecute(ArrayAdapter<Clase_tabla_noticias> result) {
            list.setAdapter(result);
        }
        protected void onProgressUpdate(Void... values) {
        }
    }
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {
            case R.id.bt_nuevanoticia:
                intent = new Intent("es.esy.rivedcreations.beingfaureciamagazine.NoticiaActivity_Introducir");
                startActivity(intent);
                break;
        }
    }

A: Thank you very much for your quick response. You're amazing. Attached you can see also the solution that I have found of my own problem. hahaha. Now I'm happy. ;)
try {
    JSONObject JSON_Objeto = new JSONObject(String_Resultado_de_JSON_Array);
    JSONArray JSON_Array = JSON_Objeto.getJSONArray("tabla_noticias");
    for (int i = 0; i < JSON_Array.length(); i++) {
        JSON_Objeto = JSON_Array.getJSONObject(i);
        int id = JSON_Objeto.getInt("id");
        String autor = JSON_Objeto.getString("autor");
        String titulo = JSON_Objeto.getString("titulo");
        cli = new Clase_tabla_noticias(id, autor, titulo);
        listanoticias.add(cli);
    }
} catch (JSONException e) {
    Log.e("AVISO", "Error al intentar el bucle de cambio de JSON_Array a JSON_Objeto " + e.toString());
}
ArrayAdapter < Clase_tabla_noticias > adaptador = new ArrayAdapter < Clase_tabla_noticias > (contexto, android.R.layout.simple_list_item_1, listanoticias);
return adaptador;

A: This code will help you. This code is using Simple JSON Parser
try {
     Object obj = parser.parse(data); // data = JSON response on calling API
     JSONObject jsonObject = (JSONObject) obj;
     JSONArray msg = (JSONArray) jsonObject.get("tabla_noticias");
     Iterator<String> iterator = msg.iterator();
     while (iterator.hasNext()) {
        output.add(iterator.next()); // output is String List
      }
     String[] stringArray = output.toArray(new String[0]);
     return stringArray;
   }
catch (Exception e)
   {
    //Exception
   }

A: You are using the json you are getting as a json array while it's not, you should get the inner jsonarray first.
try to change:
String_Resultado_de_JSON_Array = sb.toString();
//Como lo que queremos es romperlo, le pasamos el String resultado mediante un Objeto JSON
try {
    JSONArray JSON_Array = new JSONArray(String_Resultado_de_JSON_Array);
    for (int i = 0; i < JSON_Array.length(); i++) {
        JSONObject JSON_Objeto = JSON_Array.getJSONObject(i);

to
String_Resultado_de_JSON_Array = sb.toString();
//Como lo que queremos es romperlo, le pasamos el String resultado mediante un Objeto JSON
try {
    JSONObject json = new JSONObject(String_Resultado_de_JSON_Array);
    JSONArray JSON_Array = json.getJSONArray("tabla_noticias");
    for (int i = 0; i < JSON_Array.length(); i++) {
        JSONObject JSON_Objeto = JSON_Array.getJSONObject(i);


text:
Q: A multiplication of a binary 5 bit number by 2 in VHDL I am facing a problem regarding A multiplication of a binary 5 bit number by 2 in VHDL. The error is:
** Error: C:/altera/13.1/binary.vhd(29): No feasible entries for infix operator "*".
** Error: C:/altera/13.1/binary.vhd(29): Bad right hand side (infix expression) in variable assignment.
** Error: C:/altera/13.1/binary.vhd(34): VHDL Compiler exiting

Here is my program:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.numeric_std.all;

entity binary is
port( int: in integer;
b: out std_logic_vector(4 downto 0));
end binary;
Architecture Behavior1 of binary is
function binary1 (int1:integer) return std_logic_vector is
variable int2: integer;
variable a:std_logic_vector(4 downto 0);
variable i: integer;

begin
int2:=int1;
i:=0;
while (i<a'length) loop
int2:=int2/2;
if (int2 mod 2 = 0) then
a(i):='0';
else
a(i):='1';
end if;
i:=i+1;
end loop;
a:=a * "00010";
return a;
end binary1;
begin
b<=binary1(int);
end Behavior1;

Please, I really need to understand the concept behind this problem. This is because I always encounter to such error.

A: There is no multiplication operator defined in ieee.std_logic_1164, which defines std_(u)logic and std_(u)logic_vector. This is what the first message is trying to tell you.
The next statement tells you that it doesn't know what to do with the variable assignment, because the right hand side operator could not be resolved. Third line just tells you that the HDL compiler exited (finished) after that.
Now, you already use ieee.numeric_std. Therefore, you should make use of the numeric_std types unsigned and signed.
variable a : unsigned(4 downto 0);

Define your variable as unsigned, then multiply by an integer
a := a * 2; --Read on, this does not work!

However, operator "*" is defined like this:
-- Id: A.17
function "*" (L: UNSIGNED; R: NATURAL) return UNSIGNED;
-- Result subtype: UNSIGNED((L'LENGTH+L'LENGTH-1) downto 0).
-- Result: Multiplies an UNSIGNED vector, L, with a non-negative
--         INTEGER, R. R is converted to an UNSIGNED vector of
--         SIZE L'LENGTH before multiplication.

The result will be a result(5+5-1 downto 0) ==> vector'length == 10, not a'length (==5). Therefore, we need to resize the result, i.e. cut the high-order bits off:
a := resize(a * 2, a'length);

You could also multiply by another unsigned:
variable a : unsigned(4 downto 0);
variable b : unsigned(2 downto 0);

Here the result will be result(5 + 3 - 1 downto 0) ==> result'length == 8. So again, resize to the rescue:
a := resize(a * b, a'length);

The fundamental problem you seem to have is that VHDL is a strongly typed language. This means, you need to keep track of what types there are in an expression and whether or not your desired function is defined for those types. You just assumed that the multiplication operator "*" was defined for std_logic_vector -- this is not the case.
Just a word of warning: There is indeed a package that defines an operator "*" for std_logic_vector. However, it is deprecated and despite its name not part of ieee (see here).
You should avoid it, because it is old and not standardized or the same across vendors.

A: FRob covered the type issue you are having.  However, another answer to multiplying by constant 2 is: just shift the vector to the left one bit.  Also, the divide by 2, likewise, can be shifted to the right.
BTW: The function seems to convert an std_logic_vector to an integer.  So, you could just do this:
my_slv <= std_logic_vector(to_unsigned(my_integer, my_slv'length));

in your case, change:
b<=binary1(int);

to:
b <= std_logic_vector(to_unsigned(int, b'length));

No need to write your own function. But, if this is a learning exercise, you can try the shifting to learn another way of doing it.


text:
Q: Automatically assign each element from an array to a variable I have an array that I populate automatically after doing a database query.
So I have for example @array whose length will vary in size depending on the result from the database query. I want to assign each element of the array to a different variable.
For example:
my $length = @array;

If length equals 3 then 3 variables should be created automatically with the elements of the array assigned to them in this order.
$var1 = $array[0];
$var2 = $array[1];
$var3 = $array[2];

A:
If length equals 3 then 3 variables should be created automatically with the elements of the array assigned to them in this order.

No, variables should definitely not be created in this fashion.
Why it's stupid to "use a variable as a variable name"

On the off chance of a communication failure, perhaps you are looking for the following:
my ($id, $name, $address, $phone) = @$row;

Later variables will be undef if @$row contains too few fields.


text:
Q: PHP use defined globals within Smarty .conf text file I have set a global var (STORE_PHONE_PICKUP_TIMES) in my php based webshop. The issue is to use it as described below.
Tested several options to put the php global into the .html file via the .conf file. But not succeeded.
like:
define('STORE_PHONE_PICKUP_TIMES', '10:00-17:00');

file_name: shop_content.conf
[shop_content]
phone_pickup =  We are daily present at: {php} echo STORE_PHONE_PICKUP_TIMES{/php}

file_name: shop_content.html

{#phone_pickup#}

The result is: We are daily present at: {php} echo STORE_PHONE_PICKUP_TIMES{/php}
How can I get this GLOBAL into the .conf file using the setup as describe above.

A: It is not possible to use php in smarty config. And it is good because it force you to use better logic your app ;)
I suggest to use globals in templates:

{#phone_pickup#} {$smarty.const.STORE_PHONE_PICKUP_TIMES}

OR
store pickup hours only in config, it is good place for it (and separate from language string):
phone_pickup_hours = '10:00-17:00'
phone_pickup = 'We are daily present at:'
now, in tpl it's easy:
{#phone_pickup#} {#phone_pickup_hours#}

but I assumed that you use define because you use this constant in other places for example in Controller layer so.. in php you can use config variable like this:
$pickup_hours = $smarty->getConfigVars('phone_pickup_hours');


text:
Q: linear programming problem solving
I have written in lp solve and obtain the solution of 0.58 highqualitymeat and 0.41 lowqualitymeat
the thing that confuses is doing it through a graph as:
let x be high quality meat and y be low quality meat
we will have a standard constraint : x + y = 1 and the fat constraint of 0.2x + 0.32y <= 25
when we try to do x = 0 then y = 0.78 which doesn't make sense to me because 0.78 will still have 32% fat so x can not be 0 in the graph as the low quality(y) meat has to be mixed with high quality meat (x) to be lowered down
also is there a easy way of finding the ratio of the meats to obtain the 0.25% fat other than trial and error
thanks

A: So you want to:
Minimise cost = $80 x + 60 y$
such that
$x + y = 1$
$20 x + 32 y <= 25$
Let's consider to start with the more usual constraint $x + y <= 1$. In theory a burger could contain some other material as filler.
Then the  graph required should consist of the two lines $x+y=1$ and $20x+32y=25$. The feasible region is the region bounded by the lines and the x-axis and y-axis. This quadrilateral has the following vertices:
$(0, 0)$
$(1, 0)$
$(0, 0.78125)$
$(\frac 7 {12}, \frac 5 {12})$
This last vertex is found by solving simultaneously the equations $x + y = 1$ and $20 x + 32 y <= 25$, which I think answers your question about trial and error.
In Linear Programming, we have the fact that the objective function (in this case the cost) is a maximum or a minimum at one of the vertices of the feasible region.
You therefore have to work out $80x+60y$ at each of the four vertices above to find which is the minimum cost.
Of course this yields the useless answer $(0, 0)$, which achieves a minimum cost of 0 p by including no meat at all!
So here is where we return to the constraint $x+y=1$ rather than the inequality we had earlier. This changes the feasible region from a quadrilateral to a straight line segment from $(1, 0)$ to $(\frac 7 {12}, \frac 5 {12})$.
There are now just two vertices to consider.
At $(1,0)$ the cost is 80 p.
At $(\frac 7 {12}, \frac 5 {12})$ the cost is $\frac {560} {12} + \frac {300} {12} = \frac {860} {12} = 71.67$ p.


text:
Q: Cannot construct instance of X (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value I'm trying to test a method handleRequest() which is the handler code when an AWS lambda is triggered. The method is as follows:
@Override
public Response handleRequest(Object input, Context context) {
   final Request request =
      OBJECT_MAPPER.readValue(OBJECT_MAPPER.writeValueAsBytes(input),Request.class);

   // some code that uses request
   .
   .
}

Input to AWS lambda function that is working fine when tested from AWS console -
{"fieldA": "fieldAValue",
"fieldB": "fieldBValue",
"fieldC": "fieldCValue",
"fieldList": [
  {
    "subFieldA": "subFieldAValue",
    "subFieldB": "subFieldBValue",
    "subFieldC": "subFieldCValue",
    "subFieldD": "subFieldDValue",
    "subFieldE": "subFieldEValue"
  }
]
}

My test method -
@Test
public void test_handleRequest() {
   String testInput =
       "{\"fieldA\":\"fieldAValue\",\"fieldB\":\"fieldBValue\",+
       "\"fieldC\":\"fieldCValue\"," +
       "\"fieldList\":[" +
       "{\"subFieldA\":\"subFieldAValue\", " +
       "\"subFieldB\":\"subFieldBValue\", " +
       "\"subFieldC\":\"subFieldCValue\", " +
       "\"subFieldD\":\"subFieldDValue\", " +
       "\"subFieldE\":\"subFieldEValue\"}]}";

   handleRequest(testInput, null);

   // code to assert that the actual and expected values are equal.
   .
   .
   .
}

Error when the test method is executed -
Cannot construct instance of 'model.Request'
(although at least one Creator exists): no String-argument constructor/factory method to
deserialize from String value ('{"fieldA":"fieldAValue","fieldB":"fieldBValue",
"fieldC":"fieldCValue","fieldList":[{"subFieldA":"subFieldAValue",
"subFieldB":"subFieldBValue", "subFieldC":"subFieldCValue",
"subFieldD":"subFieldDValue", "subFieldE":"subFieldEValue"}]}') at [Source: (byte[])""

The test method is failing with the error that the given input string cannot be mapped to Request class. I got expected result when the AWS lambda is triggered with the same input via AWS console, so I'm pretty sure that the code is perfectly fine.
Is this the right way to build the testInput? Any other alternative way to build testInput so that it can be correctly mapped to Request class when testing?

A: Converting the json string to Object type using readValue() before passing it to the method under test resolved the error.
@Test
public void test_handleRequest() {
   String testInput =
       "{\"fieldA\":\"fieldAValue\",\"fieldB\":\"fieldBValue\",+
       "\"fieldC\":\"fieldCValue\"," +
       "\"fieldList\":[" +
       "{\"subFieldA\":\"subFieldAValue\", " +
       "\"subFieldB\":\"subFieldBValue\", " +
       "\"subFieldC\":\"subFieldCValue\", " +
       "\"subFieldD\":\"subFieldDValue\", " +
       "\"subFieldE\":\"subFieldEValue\"}]}";

   Object input = new ObjectMapper().readValue(testInput, Object.class);
   handleRequest(input, null);

   // code to assert that the actual and expected values are equal.
   .
   .
   .
}


text:
Q: Magento 2: add custom font to theme I'm using a custom theme on my Magento 2.3.2.
I would like to add a custom font that is on my folder.
Since the official guide that i found on magento's site wasn't working for me, I've tracked down where the font in .body was set.
I've found the file lib/web/css/source/lib/variables/_typography.less
This is the piece of code that decides the font
@font-family__sans-serif: 'Helvetica Neue', Helvetica, Arial, sans-serif;

Now, I've tried to change those names and I can see changes happening on the site, problem is I can't figure out how to set the path to my custom font. I've tried a few things but nothing worked.

A: Please Follow the Below steps
Step 1 Please Upload your fonts file woff and woff2 in this

app/design/frontend/Vendor/Theme/web/fonts/fontdirectory

File Path
Step 2
Please include font family in this

app/design/frontend/Vendor/Theme/web/css/source/_typography.less

file Path
For Example
& when (@media-common = true) {
    .lib-font-face(
        @family-name: @font-family__base,
        @font-path: '@{baseDir}fonts/fontdirectory/<<font_name>>',
        @font-weight: 300,
        @font-style: normal,
        @font-display: swap
    );
}

Step 3 Please add the Below code on the same file (_typography.less)
@font-family__base`: '<<font_name>>';

Please execute static content deploy command

A: There are 2 ways to add fonts.
First is you can use direct google fonts link. Below is the file path to add direct links in the xml file.

app/design/frontend/Vendor/theme/Magento_Theme/layout/default_head_blocks.xml

Below is the example.
<link rel="stylesheet" type="text/css" src="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,300;1,400;1,700;1,900" src_type="url" />

Below has the second way to add fonts.

*

*Please Upload your fonts woff and woff2 in below path.

app/design/frontend/Vendor/Theme/web/fonts/

*After adding fonts in respected folder you have to include that fonts in css file like below :

app/design/frontend/Vendor/Theme/web/css/style.css

@font-face {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    src: url('../fonts/proxima_nova_semibold-webfont.eot');
    src: url('../fonts/proxima_nova_semibold-webfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/proxima_nova_semibold-webfont.woff2') format('woff2'),
         url('../fonts/proxima_nova_semibold-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

Also you can use fonts like below after inlucding in css.
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif';

Let me know still you facing any issue.
Thanks


text:
Q: Android Admob Preference Initialize Before when I have to display ads I would put the xml part of adMob in a layout and in the Java part I used code like
AdView mAdview;
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
mAdview = findViewById(R.id.adView_id);
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
mAdview.loadAd(adRequest);

And it worked.
Now I am creating an app which display ads on its preference screen . I used the following method described in stackoverflow to display my ad
https://stackoverflow.com/a/5850299/10403812
https://stackoverflow.com/a/45341837/10403812
It is working fine and my ads are being displayed on the preference screen . But I just want to know
1 . Do we not need to initialize our ads here like MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713"); here
2 . The solution only uses the unit ID of the ad . So we do not need the admob app ID here
Is it ok to use admob without initialize and app ID .


text:
Q: Build the conclusion with confidence (if this question doesn't fit here, please point me to right direction. Thanks.)
We need to check a sales data S's accuracy to determine if it can be used in downstream calculations. Currently, it's simply checked against last year's data (if it's below/above certain %). I wanted to include history data(the data before last year) into the play. Below it's what I would like to consider(suppose we use True as accurate thus can be used):

*

*If it's first time S presented without history data, we say it's true 100%

*If S is within +/- 40% of last year's data, we say it's false with 80% chance the conclusion is right

*If S is within MIN to MAX range of all history data (excluding last year's), it's true with 85% chance of correctness

*If 2, and there are 2 too in history, then it's false with 35% chance of being correct

Assume all history data are accurate and no other facts than history data alone is available.
I'm confused, how can I form a True/False conclusion toward S along with confidence(/chance of correctness) %?
(this is probably the whole picture of the question. No other facts - region, brand,.. available for this data.)


text:
Q: General:munfl error problem I have the following function, that is the result of The integration between x and some upper limit of a positive function, thus should be positive
$f(x,vE) = \frac{e^{-1140.09 x} \left(e^{67945.5 \text{vE}^2} \theta (\text{1.859514170346336$\grave{ }$*${}^{\wedge}$-9}-x)
   \left(e^{1140.09 x} \left(-\text{3.3591048468065713$\grave{ }$*${}^{\wedge}$-37}
   \text{vE}^8+\text{1.2371349122599874$\grave{ }$*${}^{\wedge}$-16} x^8+\text{4.6259292692714846$\grave{
   }$*${}^{\wedge}$-18} x^7-\text{5.720218174055417$\grave{ }$*${}^{\wedge}$-21} x^6-\text{3.830505707541381$\grave{
   }$*${}^{\wedge}$-19} x^5-\text{6.875632678803749$\grave{ }$*${}^{\wedge}$-22} x^4-\text{2.592004365421134$\grave{
   }$*${}^{\wedge}$-25} x^3+\text{1.1383704954727588$\grave{ }$*${}^{\wedge}$-27} x^2-\text{1.0946897704176435$\grave{
   }$*${}^{\wedge}$-14} x+\text{2.0355911402247853$\grave{ }$*${}^{\wedge}$-23}\right)+\text{1.1896770509204967$\grave{
   }$*${}^{\wedge}$-8} x^5-\text{8.30796052725145$\grave{ }$*${}^{\wedge}$-9} x^4+\text{1.4721183020268512$\grave{
   }$*${}^{\wedge}$-9} x^3-\text{7.569314750088174$\grave{ }$*${}^{\wedge}$-12} x^2+\text{1.0946949062266079$\grave{
   }$*${}^{\wedge}$-14} x-\text{2.0355980730229598$\grave{ }$*${}^{\wedge}$-23}\right)+e^{67945.5 \text{vE}^2}
   \left(-\text{1.1896770509204967$\grave{ }$*${}^{\wedge}$-8} x^5+\text{8.30796052725145$\grave{ }$*${}^{\wedge}$-9}
   x^4-\text{1.4721183020268512$\grave{ }$*${}^{\wedge}$-9} x^3+\text{7.569314750088174$\grave{ }$*${}^{\wedge}$-12}
   x^2-\text{1.0946949062266079$\grave{ }$*${}^{\wedge}$-14} x+\text{2.0355980730229598$\grave{
   }$*${}^{\wedge}$-23}\right)+e^{67945.5 \text{vE}^2+1140.09 x} \left(\text{vE}^{16} (1.
   x-\text{1.8595141703463354$\grave{ }$*${}^{\wedge}$-9})+\text{vE}^{14} (\text{2.0083576467270298$\grave{
   }$*${}^{\wedge}$-14}-0.0000108004 x)+\text{vE}^{12} (\text{2.663670413232032$\grave{ }$*${}^{\wedge}$-6}
   x-\text{4.953132878537244$\grave{ }$*${}^{\wedge}$-15})+\text{vE}^{10} (\text{5.166994397269747$\grave{
   }$*${}^{\wedge}$-10} x-\text{9.608099299823222$\grave{ }$*${}^{\wedge}$-19})+\text{vE}^8
   (\text{2.571855800860126$\grave{ }$*${}^{\wedge}$-21}-\text{1.383079431108135$\grave{ }$*${}^{\wedge}$-12}
   x)+\text{vE}^6 (\text{1.7552515711539956$\grave{ }$*${}^{\wedge}$-25}-\text{9.439301937812491$\grave{
   }$*${}^{\wedge}$-17} x)+\text{vE}^4 (\text{1.4313862961095703$\grave{ }$*${}^{\wedge}$-21}
   x-\text{2.6616831008553027$\grave{ }$*${}^{\wedge}$-30})+\text{vE}^2 (\text{2.9153325110971034$\grave{
   }$*${}^{\wedge}$-34}-\text{1.5677925759254207$\grave{ }$*${}^{\wedge}$-25} x)-\text{1.2371349122599874$\grave{
   }$*${}^{\wedge}$-16} x^8-\text{4.6259292692714846$\grave{ }$*${}^{\wedge}$-18} x^7+\text{5.720218174055417$\grave{
   }$*${}^{\wedge}$-21} x^6+\text{3.830505707541381$\grave{ }$*${}^{\wedge}$-19} x^5+\text{6.875632678803749$\grave{
   }$*${}^{\wedge}$-22} x^4+\text{2.592004365421134$\grave{ }$*${}^{\wedge}$-25} x^3-\text{1.1383704954727588$\grave{
   }$*${}^{\wedge}$-27} x^2+\text{1.2253923290809874$\grave{ }$*${}^{\wedge}$-30} x-\text{1.6264357714319357$\grave{
   }$*${}^{\wedge}$-39}\right)+e^{33972.8 \text{vE}^2+1140.09 x} \left(\text{vE}^8 (0.00937982
   x-\text{1.744191593358305$\grave{ }$*${}^{\wedge}$-11})+\text{vE}^6 (\text{4.087595291558347$\grave{
   }$*${}^{\wedge}$-13}-0.000219821 x)+\text{vE}^4 (\text{1.3071488339510708$\grave{ }$*${}^{\wedge}$-6}
   x-\text{2.430661779483706$\grave{ }$*${}^{\wedge}$-15})+\text{vE}^2 (\text{4.1941725957388944$\grave{
   }$*${}^{\wedge}$-19}-\text{2.255520642231904$\grave{ }$*${}^{\wedge}$-10} x)-\text{6.639200573944934$\grave{
   }$*${}^{\wedge}$-15} x+\text{1.2345687547022132$\grave{ }$*${}^{\wedge}$-23}\right)+(\text{1.7586098278121368$\grave{
   }$*${}^{\wedge}$-14} x-\text{3.270159894926998$\grave{ }$*${}^{\wedge}$-23}) e^{33972.8 \text{vE}^2+1140.09 x}\right)
   \theta \left(29.7983 \text{vE}^2-x+\text{1.859514170346336$\grave{ }$*${}^{\wedge}$-9}\right)}{\left(e^{33972.8
   \text{vE}^2} \left(0.00937982 \text{vE}^8-0.000219821 \text{vE}^6+\text{1.3071488339510708$\grave{ }$*${}^{\wedge}$-6}
   \text{vE}^4-\text{2.2555206422319046$\grave{ }$*${}^{\wedge}$-10} \text{vE}^2-\text{6.639200573944936$\grave{
   }$*${}^{\wedge}$-15}\right)+\text{1.758609827812137$\grave{ }$*${}^{\wedge}$-14} e^{33972.8 \text{vE}^2}+e^{67945.5
   \text{vE}^2} \left(1. \text{vE}^{16}-0.0000108004 \text{vE}^{14}+\text{2.6636704132320325$\grave{ }$*${}^{\wedge}$-6}
   \text{vE}^{12}+\text{5.166994397269748$\grave{ }$*${}^{\wedge}$-10} \text{vE}^{10}-\text{1.3830794311081354$\grave{
   }$*${}^{\wedge}$-12} \text{vE}^8-\text{9.439301937812495$\grave{ }$*${}^{\wedge}$-17}
   \text{vE}^6+\text{1.4313862961095709$\grave{ }$*${}^{\wedge}$-21} \text{vE}^4-\text{1.567792575925421$\grave{
   }$*${}^{\wedge}$-25} \text{vE}^2-\text{1.0946897704176435$\grave{ }$*${}^{\wedge}$-14}\right)\right)
   (x-\text{1.859514170346336$\grave{ }$*${}^{\wedge}$-9})}$
I am trying to get values of this function for vE up to 0.141421, however I start getting problems at vE=0.10. This is probably due to underflow errors. I have tried wrapping the function inside a SetPrecision, as well as using
$f[SetPrecision[x,$MachienPrecision],SetPrecision[vE,$MachienPrecision]]$
with no luck. I am afraid that the problem is the precision of the numeric coefficients of the function, that need to be set to arbitrary precision to fix the underflow.
Any suggestion on how to fix this problem without having to rewrite the function (it`s generated automatically by my program, chaging the part that generates it would be cubersome)
EDIT: Inputform expression
((E^(33972.7745398073*vE^2 + 1140.0906489396789*x)*(1.2345687547022132*^-23 +
     vE^6*(4.087595291558347*^-13 - 0.00021982060458281043*x) +
     vE^2*(4.1941725957388944*^-19 - 2.255520642231904*^-10*x) +
     vE^4*(-2.430661779483706*^-15 + 1.3071488339510708*^-6*x) + vE^8*(-1.744191593358305*^-11 + 0.00937982415607754*x) -
     6.639200573944934*^-15*x) + E^(33972.774539807324*vE^2 + 1140.0906489396789*x)*
    (-3.270159894926998*^-23 + 1.7586098278121368*^-14*x) + E^(67945.54907961463*vE^2)*
    (2.0355980730229598*^-23 - 1.0946949062266079*^-14*x + 7.569314750088174*^-12*x^2 - 1.4721183020268512*^-9*x^3 +
     8.30796052725145*^-9*x^4 - 1.1896770509204967*^-8*x^5) + E^(67945.54907961463*vE^2 + 1140.0906489396789*x)*
    (-1.6264357714319357*^-39 + vE^14*(2.0083576467270298*^-14 - 0.000010800442818636717*x) +
     vE^8*(2.571855800860126*^-21 - 1.383079431108135*^-12*x) +
     vE^6*(1.7552515711539956*^-25 - 9.439301937812491*^-17*x) +
     vE^2*(2.9153325110971034*^-34 - 1.5677925759254207*^-25*x) +
     vE^4*(-2.6616831008553027*^-30 + 1.4313862961095703*^-21*x) +
     vE^10*(-9.608099299823222*^-19 + 5.166994397269747*^-10*x) +
     vE^12*(-4.953132878537244*^-15 + 2.663670413232032*^-6*x) + vE^16*(-1.8595141703463354*^-9 + 0.9999999999999998*x) +
     1.2253923290809874*^-30*x - 1.1383704954727588*^-27*x^2 + 2.592004365421134*^-25*x^3 + 6.875632678803749*^-22*x^4 +
     3.830505707541381*^-19*x^5 + 5.720218174055417*^-21*x^6 - 4.6259292692714846*^-18*x^7 -
     1.2371349122599874*^-16*x^8) + E^(67945.54907961463*vE^2)*(-2.0355980730229598*^-23 + 1.0946949062266079*^-14*x -
     7.569314750088174*^-12*x^2 + 1.4721183020268512*^-9*x^3 - 8.30796052725145*^-9*x^4 + 1.1896770509204967*^-8*x^5 +
     E^(1140.0906489396789*x)*(2.0355911402247853*^-23 - 3.3591048468065713*^-37*vE^8 - 1.0946897704176435*^-14*x +
       1.1383704954727588*^-27*x^2 - 2.592004365421134*^-25*x^3 - 6.875632678803749*^-22*x^4 -
       3.830505707541381*^-19*x^5 - 5.720218174055417*^-21*x^6 + 4.6259292692714846*^-18*x^7 +
       1.2371349122599874*^-16*x^8))*HeavisideTheta[1.859514170346336*^-9 - x])*
  HeavisideTheta[1.859514170346336*^-9 + 29.79830996018*vE^2 - x])/
 (E^(1140.0906489396789*x)*(1.758609827812137*^-14*E^(33972.774539807324*vE^2) +
   E^(33972.7745398073*vE^2)*(-6.639200573944936*^-15 - 2.2555206422319046*^-10*vE^2 + 1.3071488339510708*^-6*vE^4 -
     0.00021982060458281048*vE^6 + 0.009379824156077542*vE^8) + E^(67945.54907961463*vE^2)*
    (-1.0946897704176435*^-14 - 1.567792575925421*^-25*vE^2 + 1.4313862961095709*^-21*vE^4 -
     9.439301937812495*^-17*vE^6 - 1.3830794311081354*^-12*vE^8 + 5.166994397269748*^-10*vE^10 +
     2.6636704132320325*^-6*vE^12 - 0.000010800442818636719*vE^14 + 1.*vE^16))*(-1.859514170346336*^-9 + x))

Sidenote: the function should indicate a probability, and is the integral of a probability density defined in [0,x_max], therefore it should hold $f(0,vE)=1$ for any $vE$

A: You might try to use exact numbers like
x = 1/100; Table[
Rationalize[((E^(33972.7745398073*vE^2 + 1140.0906489396789*x)*
            (1.2345687547022132*^-23 +
      vE^6*(4.087595291558347*^-13 - 0.00021982060458281043*
                      x) +
      vE^2*(4.1941725957388944*^-19 -
         2.255520642231904*^-10*x) +

      vE^4*(-2.430661779483706*^-15 +
         1.3071488339510708*^-6*x) +

      vE^8*(-1.744191593358305*^-11 + 0.00937982415607754*x) -
               6.639200573944934*^-15*x) +
   E^(33972.774539807324*vE^2 + 1140.0906489396789*x)*
            (-3.270159894926998*^-23 +
      1.7586098278121368*^-14*x) +

   E^(67945.54907961463*vE^2)*(2.0355980730229598*^-23 -
      1.0946949062266079*^-14*x +
               7.569314750088174*^-12*x^2 -
      1.4721183020268512*^-9*x^3 +
               8.30796052725145*^-9*x^4 -
      1.1896770509204967*^-8*x^5) +

   E^(67945.54907961463*vE^2 +
       1140.0906489396789*x)*(-1.6264357714319357*^-39 +

      vE^14*(2.0083576467270298*^-14 -
         0.000010800442818636717*x) +

      vE^8*(2.571855800860126*^-21 - 1.383079431108135*^-12*x) +

      vE^6*(1.7552515711539956*^-25 -
         9.439301937812491*^-17*x) +

      vE^2*(2.9153325110971034*^-34 - 1.5677925759254207*^-25*x) +

      vE^4*(-2.6616831008553027*^-30 +
         1.4313862961095703*^-21*x) +

      vE^10*(-9.608099299823222*^-19 + 5.166994397269747*^-10*x) +

      vE^12*(-4.953132878537244*^-15 +
         2.663670413232032*^-6*x) +

      vE^16*(-1.8595141703463354*^-9 + 0.9999999999999998*x) +
               1.2253923290809874*^-30*x -
      1.1383704954727588*^-27*x^2 +
               2.592004365421134*^-25*x^3 +
      6.875632678803749*^-22*x^4 +
               3.830505707541381*^-19*x^5 +
      5.720218174055417*^-21*x^6 -
               4.6259292692714846*^-18*x^7 -
      1.2371349122599874*^-16*x^8) +

   E^(67945.54907961463*vE^2)*(-2.0355980730229598*^-23 +
      1.0946949062266079*^-14*
                 x - 7.569314750088174*^-12*x^2 +
      1.4721183020268512*^-9*x^3 -
               8.30796052725145*^-9*x^4 +
      1.1896770509204967*^-8*x^5 +

      E^(1140.0906489396789*x)*(2.0355911402247853*^-23 -
         3.3591048468065713*^-37*
                      vE^8 - 1.0946897704176435*^-14*x +
         1.1383704954727588*^-27*x^2 -
                    2.592004365421134*^-25*x^3 -
         6.875632678803749*^-22*x^4 -
                    3.830505707541381*^-19*x^5 -
         5.720218174055417*^-21*x^6 +
                    4.6259292692714846*^-18*x^7 +
         1.2371349122599874*^-16*x^8))*
            HeavisideTheta[1.859514170346336*^-9 - x])*
 HeavisideTheta[

  1.859514170346336*^-9 + 29.79830996018*vE^2 -
   x])/(E^(1140.0906489396789*x)*
       (1.758609827812137*^-14*E^(33972.774539807324*vE^2) +
   E^(33972.7745398073*vE^2)*
            (-6.639200573944936*^-15 -
      2.2555206422319046*^-10*vE^2 +
               1.3071488339510708*^-6*vE^4 -
      0.00021982060458281048*vE^6 +
               0.009379824156077542*vE^8) +
   E^(67945.54907961463*vE^2)*
            (-1.0946897704176435*^-14 -
      1.567792575925421*^-25*vE^2 +
               1.4313862961095709*^-21*vE^4 -
      9.439301937812495*^-17*vE^6 -
               1.3830794311081354*^-12*vE^8 +
      5.166994397269748*^-10*vE^10 +
               2.6636704132320325*^-6*vE^12 -
      0.000010800442818636719*vE^14 + 1.*vE^16))*
       (-1.859514170346336*^-9 + x)), 10^(-100)], {vE, 1/100,
14/100, 1/100}]
(* {0, 430648/6879181385, 698481/9203324930, 1805038/23785891251,
3126065/41297181986,
1576001/21651692414,
313326/7428814151, -(450748/2278033113), -(4060782/2406568931),
-(1242769/132435345), -(99750955/2239724446), -(49680141/
241024459),
-(50095271/31604284), 66016483/33048707} *)

Then your expression seems to evaluate .
Edit: If you change the parameter of Rationalize to 10^-500 then
your sidenote appears to hold.


text:
Q: UPI Implicit Intent chooser not working on redmi device This is my code for upi implicit intent which gives user of option to choose multiple upi supported application and the code is working fine on all the devices i have tested and all the version except Redmi Devices.
My code is not working on any Redmi Note 5 Pro
Here is my code :
String UPI = "upi://pay?pa=abcupi@xxxxbank&pn=:ABC%20COMPANY%20LTD&tr="+dateTime+"&am="+amount+"&tn=XXXXXX UPI Payment";
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(UPI));
        Intent chooser = Intent.createChooser(intent, "UPI Transfer With");
        startActivityForResult(chooser, UPI_CHOOSER, null);

The chooser is not opening upi supported apps only on Redmi devices. I have tested on 3 different Redmi note 5 pro but it didn't work. Its not opening the chooser to show upi supported apps.

A: Here is how I solved it for Redmi Note 5 Pro:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(UPI));
if (intent.resolveActivity(getPackageManager()) != null) {
    startActivity(intent);
} else {
    Toast.makeText(this, "No application available to handle this request!", Toast.LENGTH_SHORT).show();
}


text:
Q: Unexpected tag names in WCF Service Response I have a wcf service and I have class like below:
public class Message
{
    [XmlElement(ElementName = "message")]
    [DataMember(Name = "message")]
    public string message { get; set; }

    [XmlElement(ElementName = "MsgID")]
    [DataMember(Name = "MsgID")]
    public string MsgID{ get; set; }
}

Then i browsed my service in a browser the XML i am getting like below:
<MessageResponse>
    <Status>SUCCESS</Status>
    <Messages>
       <a:Message>
         <a:message>msg1</a:message>
         <a:MsgID>1</a:MsgID>
       </a:Message>
    </Messages>
</MessageResponse>

My Service Contract is Like below: and one more important thing is:
MessageDco class is a copy of Message Class
[ServiceContract(Namespace="")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class UserLoginProfileService
    {
        [WebGet(UriTemplate = "/GetMessages?MsgID={MsgID}")]
        public MessageResponse GetMessage(Guid MsgID)
        {
            MessageResponse objMessageResponse = new MessageResponse();
            try
            {

                Message[] objMessage = new MessageFacade().GetMessage(MsgIDs);
                if (objUserLoginProfile != null)
                {
                    MessageResponse.Status = Status.Success;
                    MessageResponse.Messages =Mapper.ToDataContractObjects(objMessage);
                }
                else
                {
                    objMessageResponse.Status = Status.Success;
                }
            }
            catch (Exception ex)
            {

                objMessageResponse.Status = Status.Failure;

            }
            return objMessageResponse;
        }
    }

public class MessageResponse
    {
        [XmlElement(ElementName = "Messages")]
          [DataMember(Name = "Messages")]
        public MessageDco[] Messages { get; set; }

          [XmlElement(ElementName = "Status")]
          [DataMember(Name = "Status")]
          public string Status { get; set; }
}

My mapper class is like below:
public sealed class Mapper
    {
     public static MessageDco[] ToDataContractObjects(IEnumerable<MessageDco> objMessageDco)
    {
        if (objMessageDco != null)
        {
            return objMessageDco.Select(a => ToDataContractObjects(a)).ToArray();
        }
        else
        {
            return null;
        }
    }
}

if we see "a:" is added to the tags. why it is added? i am unable remove that "a:" from the tags. Please help me how to remove "a:" from Tags. And also if you see MessageResponse class (Status tag) is coming correct But array list(i.e: Message[]) in MessageResponse is Coming wrong.
Thanks in advance.

A: The a is a generated namespace for your elements.
For the DataContractSerializer you can remove the namespace for your types in your service definition using the ServiceContractAttribute like so:
[ServiceContract(Namespace="")]


text:
Q: An integer value in xml resource file depending on DPI on Android I got a good answer on my previous question about resizing my vector splash screen image, but I wonder to know is it possible without using Java/Kotlin code for two reasons: 1) I am new to Android and I am not sure where to add the code, 2) I am not sure if the code does not slow down splash screen loading.
My idea is that I probably add an integer value as described here, but make it different depending on DPI (or screen size), it is possible?
And then I probably refer it from my splash screen as @myval:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle" >
            <!-- <solid android:color="#FF07862c"/> -->
            <gradient
                android:type="radial"
                android:startColor="#086824"
                android:endColor="#098a2f"
                android:gradientRadius="@myval"
                android:centerX="0.5"
                android:centerY="0.5"/>
        </shape>
    </item>
    <!-- <item android:drawable="@drawable/background0" android:gravity="center"/> -->
    <item android:drawable="@drawable/logo"
        android:width="@myval"
        android:height="@myval"
        android:gravity="center"/>
</layer-list>

A: For such purpose, you can use dimen and alternative resources.
File structure:
res/
    values/
        dimens.xml
    values-sw600dp/
        dimens.xml

In each dimens.xml (XX or YY may be varied between in values/dimens and in values-sw600dp/dimens):
<resources>
    <dimen name="logoWidth">XXdp</dimen>
    <dimen name="logoHeight">YYdp</dimen>
</resources>

Usage in layout.xml:
<item android:drawable="@drawable/logo"
        android:width="@dimen/logoWidth"
        android:height="@dimen/logoHeight"
        android:gravity="center"/>


text:
Q: Setting up relationships on a gaming schema with multiple locales I've devised the following schema:

Where BotLocale holds locales like en-US, es-AR, etc. GameArtifact has a primary key which is artifact_id and GameClass with locale, identifier being the primary key.
How can I properly set up a relationship between the exclusive column of GameArtifact and identifier from GameClass taking into account that identifier will be repeated multiple times per row due to many locales?
This is how GameClass table looks like:
 id | locale | identifier  |      class
----+--------+-------------+------------------
    | en-US  | knight      | Knight
    | es-AR  | knight      | Caballero

One approach I thought for doing this is to separate GameClass into two tables, one which holds the identifier alone which would be referenced from GameArtifact and another table which holds the actual translations for a GameClass.

The issue in this approach would be that there's an extra table I'd need to JOIN when querying.
Is this the best way to achieve this or there's a better approach when handling this type of cases?

A: Your approach is the correct one if the typical workload consists of small transactions that access only a few rows at a time (OLTP).
The extra join won't hurt, because it will be a nested loop join. Databases are optimized for stuff like that.
Any small performance loss will be outweighed by the advantage of having foreign keys to guarantee data integrity.


text:
Q: awk checking for spaces in columns Using a fixed record length file and trying to check for spaces for a column from position 134 and length of 160 for all spaces
Here is what I have:
 awk file.test |awk '{ teststr=substr($0,134,160); if (teststr ~ /^[[:space:]]*$/) {print "ALLSPACES"teststr"end"} else {print "NOTALLSPACES"teststr"end"} } '

It always return the else part eventhough there are values on the teststr
NOTALLSPACESTHIS IS A TESTend
NOTALLSPACES              end
NOTALLSPACES              end

What is wrong with the awk statement /regex

A: The typo was causing the issue.. updated the awk statement above with the correct answer
 awk file.test |awk '{ teststr=substr($0,134,160); if (teststr ~ /^[[:space:]]*$/) {print "ALLSPACES"teststr"end"} else {print "NOTALLSPACES"teststr"end"} } '

TYPE: the *$ in after the space


text:
Q: Why isn't the innerHTML changing? Its supposed to count up when clicked Why doesn't this work? I'm sure I have the class name correct.
document.querySelector(".up").addEventListener("click", function () {
    let status = document.querySelector(".counter").innerHTML;
    status++;
});

A:
document.querySelector(".up").addEventListener("click", function () {
    let value = document.querySelector(".counter").innerHTML
    document.querySelector(".counter").innerHTML = value++
});

That's what you should do instead, but you must be sure you innerHTML is a number.
Edit:
So something like parseInt() should be used to parse the value of the innerHTML since it returns a string.
E.g
document.querySelector(".up").addEventListener("click", function () {
    let value = parseInt(document.querySelector(".counter").innerHTML)
    document.querySelector(".counter").innerHTML = value++
});

But make sure the value of the innerHTML is a number


text:
Q: Mail address validation check I'm trying to parse email address to display name, address.
This is the example. user<test@nomail.com> => user, test@nomail.com
I've implemented this using MailAddress class,
But my problem is that if string is not valid email address, MailAddress throws an exception - and I do not want the exception.
I've searched many email validation method using regex but they check email only (test@nomail.com) but not the full address (user<test@nomail.com>).
How can I solve this problem?

A: It's very, very hard and complicated to write a regular expression that will conform exactly to mail address RFC standards - and also, keep in mind the standards keeps updating.
Microsoft's official recommendation used to be to use a long, unreadable, unmaintainable regular expression - however they did change that recommendation to use a simple, short regular expression that will only validate that there's a @ and a . separated by at least one non-space char between them and between the start and end of the string - so an email address like a@b.c can pass this test.
If you're working with large amounts of strings and fear a performance penalty, go ahead and verity that the string will likely pass the EmailAddress constructor using the regular expression suggested in the docs, which is simple enough to read and understand - ^[^@\s]+@[^@\s]+\.[^@\s]+$
(note that a@b is still a valid mail address....)
Then, simply attempt to create an instance of MailAddress in a try...catch block.
This will also help you parse the mail address, because this class has properties that does a lot of the work for you - you can get the Host, the User, and even the Display name (if provided, of course).
Here's a simple demo (check it live on Rextester):
public static void Main(string[] args)
{
    var strings = new [] {
        "user<test@nomail.com>", // valid.
        "test@nomail.com", // valid.
        "Invalid<testnomail.com>", // Invalid.
        "Invalid<test@com>", // Invalid. Note: This will return a "false positive" if only tested using MailAddress's constructor - but it's not really false.
    };
    foreach(var a in strings)
    {
        ParseMailAddress(a);
    }
}

static void ParseMailAddress(string address)
{
     Console.WriteLine("--------------------------------------------");
     Console.WriteLine("Input: {0}", address);

    if(! Regex.IsMatch(address, @"^[^@\s]+@[^@\s]+\.[^@\s]+$") )
    {
        Console.WriteLine("Failed regex validation");
        return;
    }

    try
    {
        var mailAddress = new MailAddress(address);

        Console.WriteLine("Address: {0}", mailAddress.Address);
        Console.WriteLine("DisplayName: {0}", mailAddress.DisplayName);
        Console.WriteLine("Host: {0}", mailAddress.Host);
        Console.WriteLine("User: {0}", mailAddress.User);
    }
    catch (FormatException ex)
    {
        Console.WriteLine("Error: {0}", ex);
    }
}

And the results:
--------------------------------------------
Input: user<test@nomail.com>
Address: test@nomail.com
DisplayName: user
Host: nomail.com
User: test
--------------------------------------------
Input: test@nomail.com
Address: test@nomail.com
DisplayName:
Host: nomail.com
User: test
--------------------------------------------
Input: Invalid<testnomail.com>
Failed regex validation
--------------------------------------------
Input: Invalid<test@com>
Failed regex validation


text:
Q: Highlight specific words with CSS/JavaScript Is it possible to highlight (or do something to) specific words, or regular expressions?
I'm going for a no-javascript solution here, but it might not be possible.

A: You will need JavaScript to do this. I recommend using a strong tag rather than span but either will work. This will replace all first words. You can replace the ^\w with whatever is meaningful.
$('a').each(function() {
    var me = $(this);
    me.html( me.text().replace(/(^\w+)/,'<strong>$1</strong>') );
});

A: No it's not, you would have to use spans.

A: Best you can hope for is encapsulating the words in a span with a class to do some sort of highlighting. You could do this server side based on search results by using a simple regex compare to replace the searched for string with that string again wrapped with a span. It is not possible, so far as I know, to do this solely with CSS.


text:
Q: Understanding creation and annihilation operators I have a conceptual question about creation/annihilation operators as I read a textbook. According to the book, suppose we have eigenstates and eigenvalues of the form:
$$
H\phi_\lambda=\epsilon_\lambda\phi_\lambda
$$
The wave function $\Psi(r)$ could be expanded as:
$$
\Psi(r)=\Sigma_\lambda a_\lambda(t)\phi_\lambda(r)
$$
and
$$
\Psi^\dagger(r)=\Sigma_\lambda a^\dagger_\lambda(t)\phi^*_\lambda(r)
$$
Where $a$ and $a^\dagger$ are creation and annihilation operator, which follow the usual commutation rules.
It seems like the creation and annihilation operators are the coefficients of the expansion, which is usually complex numbers, rather than some operators that add/remove a particle from a state to me. So I am a little confused. How should I understand them in this case?
One reason I could think of is by calculating $|\Psi|^2$, it does act like the wave function in first quantization. If that's true, is the wave function normalized in this expansion, given that the basis set is already normalized?
And for the reference, the book I was reading is "Many-particle Physics" 3rd by Gerald D. Mahan.


text:
Q: Workaround for "Firefox: Event pages are not currently supported." I'm trying to make a temporary extension preform cleanup upon being disabled or uninstalled.
heres the manifest.json:
{
  "name": "nothing",
  "version": "0.9",
  "description": "empty",
  "background": {
      "scripts": ["background.js"]
  },
  "manifest_version": 2
}

and this is background.js:
function messageContentScript() {
    console.log("Suspending Extension");
}

browser.runtime.onSuspend.addListener(messageContentScript);

After running it I get the following error on the last line of the script:
TypeError: browser.runtime.onSuspend is undefined
after trying to find a solution to the issue, I found a suggestion somewhere to change the manifest.json by adding a line "persistent": false in the background object, after doing this however, I get an error after simply reloading the extension in about:debugging. The error is as follows:
Reading manifest: Error processing background.persistent: Event pages are not currently supported. This will run as a persistent background page.
And browser.runtime.onSuspend is still undefined. Is my browser version (Firefox-ESR 68) simply unable to perform an onSuspend catch? Is there a workaround or not?


text:
Q: How to implement interactive sorting in Report Viewer in VS 2010? I have created a report with report viewer in visual studio 2010. Please help me out on how to implement interactive sorting(end users must be able to sort. Sort icons must be displayed on the column) for a column in the report?

A: I believe you go to the report in the designer, rightclick the column you wish to add interactive sorting, then go to table/tablix properties, there should be an "Interactive Sorting" tab or "Sorting" tab with a check box to enable Interactive Sorting. (Sorry for uncertainty, going from memory atm)
(More Information Here: http://msdn.microsoft.com/en-us/library/cc627509.aspx and http://www.perpetuumsoft.com/ForumTopic.aspx?lang=en&topic_id=2444&forum_id=56)


text:
Q: "Let me know it" or "Let me know" Do you need to add "it" after "Let me know" so it becomes "Let me know it"? Or is this not really necessary?
Thanks!

A: In the vast majority of common examples, when used in isolation, "let me know" is probably the phrase that you want.
You would only include the word "it" if you are making specific reference to an antecedent recently mentioned, and if that antecedent is a singular third person noun that could reasonably be replaced with the word it.
For example:

I'll be available later if you want to see a movie. Let me know [i.e. if you do].
When you go grocery shopping, let me know [i.e. that you are going].
If you know the answer, let me know it [i.e. the answer], too.
If you know the answers, let me know them [i.e. the answers], too.

It's worth noting that, even in the last two examples, you could just say "let me know" and the sentences would still be grammatically correct.

If you know the answer, let me know, too.
If you know the answers, let me know, too.

A: The use of "it" in that phrase is abnormal (at least in the Western hemisphere it is).
"Let me know" isn't too abnormal, but the phrase "What is it?" (while being somewhat intrusive, although that mostly relies on your tone) would probably suit you better.


text: Q: Problema con arreglo de personas necesito ayuda, estoy empezando con java y estoy realizando una tarea donde tengo que hacer un programa para una compañia de vuelos que registre los datos de los pasajero. La cuestion es que los pasajeros los estoy metiendo en dos arreglos que los tengo definidos en una ventana que es la principal y el arreglo de persona en otra clase donde valido algunos datos pero el problema es que cuando cierro la ventana principal para ocultarla se pierden los datos del arreglo y no se como pasar el arreglo a otra clase o como hacer para que no se me pierdan los datos. Ayuda porfavor.


text:
Q: Laravel 5.1 Session::flash stopped working While developing my webapp I found that my flash messages stopped working and I can't find what is causing this.
In my template I have this markup:
@if (Session::has('alert'))

                @foreach (['danger', 'warning', 'success', 'info'] as $msg)
                    @if(Session::has('alert-' . $msg))

{{ Session::get('alert-' . $msg) }}

                    @endif
                @endforeach

 @endif

And in the controllers I use Session::flash like this:
Session::flash('alert-warning', trans('messages.succesful_verified'));

What can cause this? The messages stopped working suddenly without modify nothing.
I also have in the template a markup to show errors and it is working perfectly but flash messages don't.


text:
Q: why do bindAll in backbone.js views? In backbone's todo demo the code has a few spots where _.bindAll(this,...) is used. Specifically it's used in the initialize function of both views. As far as I can tell it's necessary to do the following:
this.$('.todo-content').text(content);

But why would one want to do the above, when one can do:
$('.todo-content').text(content);

?

A: _.bindAll( this, ... ) is necessary not only for this.$( selector ).doSomething() but generally to be sure that this in your view's method is always pointing to the view itself.
For example, if we want to refresh our view when the model changes, we bind the view's render method to the model's change event:
initialize: function() {
    this.model.bind( 'change', this.render );
},

Without _.bindAll( this, 'render' ), when the model changes this in render will be pointing to the model, not to the view, so we won't have neither this.el nor this.$ or any other view's properties available.

A: As of Backbone 0.5.2, it's no longer necessary to use _.bindAll(this...) in your views to set the context of the "bind" callback functions, as you can now pass a 3rd argument to bind() that will set the context (i.e. "this") of the callback.
For example:
var MyView = Backbone.View.extend({
  initialize: function(){
    this.model.bind('change', this.render, this);
  },
  render: function(){
    // "this" is correctly set to the instance of MyView
  }
});

A: this.$ limits jQuery's context to the view's element, so operations are quicker.
Additionaly, this.$('.todo-item')  won't find your elements with todo-item class outside your view's element.


text:
Q: Java MVC and Ajax weird cookie behaviour I have a Java Website using Spring's MVC pattern.
The frontend views are JSP files which use Java-Script and jQuery in numerous cases to allow for some smooth design, I guess.
Now, I realised a very specific bug that i wanted to get rid off the last few days but I cannot seem to understand how the given factors are causing it. It is really weird.
What causes the bug

*

*On any JSP that contains ajax-Javascript idle until Session-Timeout is reached

*Trigger the timeout by calling one of the ajax-Scripts (doesnt matter which, only matters that is is ajax)

*An automatic redirect to the login-page happens, as the server realises that the session was timed out by the time the request was done

*I logg back into the site and go back to where i previously had called the ajax-script

*I try to run that ajax-Script again and now am returned a wrong view. I basically have my mainpage returned instead of the usual desired view

I found where in my code this is caused. Each ajax-Script basically makes a POST or GET request to the server using a specific URL. And then i have a typcial Controller on the server that catches this request and procceses it (retrieving necessary data and then return the view supplied with Model-Data).
In all of those Controllers it is first checked whether or not a user is currently logged in. This is because basically all of the ajax-actions retrieve user-specific data and it wouldnt make sense to do so if there is no user logged in anymore.
Apparently this check fails, as the result of this check failing explains why i get my mainpage returned.
Instead of returning the right view with the right data i am returned a RedirectView onto "/login.html".
The reason i am now shown the Login-Page but my mainPage instead is most likely explained by the fact that the Controller listning to "/login.html" actually realises that a user IS infact logged in and thus returns my mainPage instead of the loginPage.
Note that each and every other controller other than the controller that is responsible for the ajax-Request that triggered the session-timeout continues working as expected!
No bugs or weird behaviour with any other ajax or non-ajax Request!
Meaning that only the ajax-Script that had caused the session-timeout is not working. Every other ajax-Script is still working perfectly fine!
Logging back in and out has no effect, the ajax-Script continues to be bugged. In most cases i have to restart the browser in order to make it work again.
Weird stuff that i have found out using FF/IE network-tools

*

*Every ajax-call and ONLY the ajax-calls are sent by the browser using 2 different Cookies!

*Each of those Cookies contains a different JSESSIONID

*When observing working ajax-Calls the SECOND Cookie sent in the Request-Header equals the Set-Cookie property returned by the Response-Header and the first doesnt!

*In non-working calls the FIRST cookie matches and the second doesnt!

*IE(9) doesnt have any problem at all. I found out that he sends every single request using 2 Cookies, not only the ajax ones! The bug described above never appears with IE.

To 1.): I found a Filter in my Sourecode. It implements Java's Filter-Class and is apparently ran through by every request sent to the server.
It basically only does one thing, which is called rewriteCookieToHeader.
This function checks if (response.containsHeader("SET-COOKIE") ) and if that is true it rewrites that property using the current SessionID and also adding the two flags HttpOnly and Secure
This is what apparently causes the appearance of a second cookie. If i comment this out the bug described does not appear anymore! As well as if i change the if(cond) to if(!cond).
However, i feel like this function has a security-purpose. Its used against some Session-Hijacking apparently, as well as i guess that those two flags are a necessary security measurement.
But it makes no sense at ALL that this function causes the appearance of a second cookie!
From the HttpServletResponse documentation it says that : " setting SET-COOKIE when it is already set will cause the old value to be replaced with the new one ".
This and the fact that the new cookie that randomly appears in the requests never equals any of the SET-COOKIE values!
It just magically appears and it is mentioned nowhere by the server or the function that apparently causes it in any way!
So on the one side i can remove the bug by removing rewriteCookieToHeader() but on the other side i just dont understand how this function could possibly cause what is causes!
I realise that this is a very specific bug and it goes deep into my implementation.
I just hope that someone might get a hint by what i have described and could suggest some further things that i could test out!
Edit: Here are request and response header-example for working (first two) and non-working (last two) ajax-call.
Working call
REQUEST
Host: localhost:9002
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101     Firefox/35.0
Accept: */ *
Accept-Language: de,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: https://localhost:9002/history.html
Content-Length: 22
Cookie: JSESSIONID=EAB07711A78F1086E0FE55963AD973D3;     JSESSIONID=EAB07711A78F1086E0FE55963AD973D3
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
RESPONSE
Content-Encoding: gzip
Content-Language: de
Content-Length: 611
Content-Type: text/html;charset=UTF-8
Date: Mon, 02 Mar 2015 10:05:35 GMT
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=EAB07711A78F1086E0FE55963AD973D3

Non-working call
REQUEST
Host: localhost:9002
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101     Firefox/35.0
Accept: */ *
Accept-Language: de,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: https://localhost:9002/history.html
Content-Length: 22
Cookie: JSESSIONID=705C77CBBE678624BAD25DD97E7D0DF8;     JSESSIONID=E67B1E2486D5410CC1A73B30D4E78206
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

RESPONSE
Content-Language: de
Content-Length: 0
Date: Mon, 02 Mar 2015 10:17:14 GMT
Location: https://localhost:9002/login.html
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=705C77CBBE678624BAD25DD97E7D0DF8


text:
Q: ScrollintoView on Hidded Listbox does not work I just want to use a ListBox and scroll to the last row. Thats no problem as long as the Listbox is visible. But the listbox is on a TabPage and when I use another PageIndex and come back to my ListBox, the old item is still selected and scrolled to instead of the last item and the view of the last item.
Dim st As New StackPanel
'''some code for stackpanel
Me.List1.Items.Add(st)
Me.List1.ScrollIntoView(st)

Any ideas?

A: My guess is that you're using a TabControl, which disposes it's TabItems when they're not visible. This means that items are re-created when you switch tabs, so unless values are bound to something in the DataContext, they lose their values and revert to the default.
Easiest solution would be to bind the SelectedItem to something in the DataContext, and be sure new items are getting set as the SelectedItem when they're added.
An alternative solution would be to extend the TabControl to stop it from destorying it's children when switching tabs


text:
Q: Delphi 10.2 Tokyo - Casting object provided by interface I'm trying to convert my aplliction from Delphi XE8 to 10.2 Tokyo. I'm getting strange runtime exeptions with casting objects provided by interfafce acrocss packages ( bpl's). when I try to cast objects with "as" keyword I'm getting
this exception during runtime:

Project Project1.exe raised exception class EInvalidCast with message
  'Invalid class typecast'

Here is the code :
Interface in a separte package Plugin_interface.bpl :
unit MainIntf;

interface
  Type IMainInft = interface
  ['{FE08C4A2-069C-4B8C-BB1B-445348CAB6A0}']
    function GetForm : TObject;
  end;

implementation

end.

Interface implamentation provided in Project1.exe :
unit MainImpl;

interface
uses MainIntf;

  Type TMain = class(TInterfacedObject,IInterface,IMainInft)
    function GetForm : TObject;
end;

implementation
uses unit1;

function TMain.GetForm: TObject ;
begin
  result:=Form1; // interafce is implemented on the main form so Form1 is rechable form here
end;

end.

And finally in another package "plugin.bpl" I'm  trying to obtain object from interface :
unit Plugin_main;

interface
uses Mainintf, Vcl.Forms;

type TPlugin = class (Tobject)
  IIMyRefernceToMianIntf: IMainInft;
end;

function RegisterPlugin(AMainIntf: IMainInft): TForm ; export;
procedure UnRegisterPlugin; export;

exports
  RegisterPlugin,
  UnRegisterPlugin;

var
 Plugin_obj:  TPlugin;

implementation
uses vcl.Dialogs,System.Classes ;

function RegisterPlugin(AMainIntf: IMainInft): TForm ;
var
 MyForm : TForm ;
begin
  Plugin_obj:=TPlugin.Create;
  Plugin_obj.IIMyRefernceToMianIntf:=AMainIntf;

  if AMainIntf.GetForm is TForm then
    Showmessage ('Great it is a Tform') // will not happen
  else
    Showmessage ('Sorry  it is not Tform'); // will happen
  if TComponent (AMainIntf.GetForm).Classname='TForm1' then
    Showmessage ('What ?? It is TForm1 decsendant from TForm  so is it TForm after all ?!');  // will happen
// result:=  AMainIntf.GetForm as TForm  -- This will rise na exception
  result:= TForm( AMainIntf.GetForm)  ; // this will work

end;

procedure UnRegisterPlugin;
begin
  Plugin_obj.Free;
end;
end.

Why cant I use "as" and "is" keyword .
Only hard catsing will do, but i hate to do it .
on XE8 compiler everything worked as expected - problem exists on XE 10.2 tokyo compiler

A: The "is" keyword checks the actual objects to see it is of the type you are asking. So, checking for this:
if AMainIntf.GetForm is TForm then
Showmessage ('Great it is a Tform') // will not happen

does not happen because GetForm returns TObject and not TForm. Checking with "is" means, also, that you are checking for castability, i.e. the ability to use the "as" keyword. Since, the "is" check fails, that command fails as well:
result:=  AMainIntf.GetForm as TForm;

Your next option here is to hard-cast GetForm the way you do it:
TForm(AMainIntf.GetForm);

which works because this casting does not check whether GetForm is of TForm type. Since you return a form in TMain, this hard-casting is safe bet for you.
Having said that, however, why don't you return TForm directly rather than TObject? Do you use IMainInft in other classes that return other types than TForm?


text:
Q: Report Type Issue We have few reports based on one report type (e;g Accounts with Assets and Transaction Header) but weird part is when I try to edit this custom report type; it is not showing up...
but I am able to create reports of this custom report type (Accounts with Assets and Transaction Header)
Has anyone come across this issue before and what is the fix for it so that we can edit this custom report type.

A: Please make sure your SFDC Account profile having the system permission "Manage Custom Report Types" which will help to edit custom report types.

"Manage Custom Report Types" - Create, edit, and delete custom report
types.

System Permission "Manage Custom Report Types" will require following permission,

"View Setup and Configuration" - View the App Setup and Administrative
Settings pages.

and permission"View Setup and Configuration" will require below system permission,

"View Roles and Role Hierarchy" - View the App Setup and
Administrative Settings pages.

Please let me know if it helps.