text:
Q: ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist I am getting the above error when trying to connect to a server database from a client using service name orcl. It is getting connected when I am using the other service name i.e. dms
Below is my listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = dms)
      (SERVICE_NAME = dms)
      (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1)
#      (PROGRAM = extproc)
    )
  (SID_DESC =
     (SID_NAME = orcl)
     (SERVICE_NAME = dms)
    # (GLOBAL_DBANME = orcl)
      (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1)
   #  (PROGRAM = extproc)
  )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.53)(PORT = 1521))

    )
  )

ADR_BASE_LISTENER = /home/oracle/app/oracle
and tnsnames.ora
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.53)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
     #(SERVICE_NAME = orcl.localdomain)
      (ORACLE_SID = dms)
      (SERVICE_NAME = orcl)
    )
  )

DMS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.53)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dms)
      (ORACLE_SID = dms)
    )
  )

Please tell me what to do?

A: SQL> sqlplus "/ as sysdba"
SQL> startup

      Oracle instance started
      ------
      Database mounted.
      Database opened.

SQL> Quit

[oracle@hcis ~]$ lsnrctl start

A: Make sure that your ORACLE_HOME and ORACLE_SID are correct
To see the current values in windows, at the command prompt type
echo %ORACLE_HOME%

Then
echo %ORACLE_SID%

If the values are not your current oracle home and SID you need to correct them. This can be done in Windows environment variables.
Check out  this page for more info

A: ORA-01034 and ORA-27101 normally indicate that the database instance you're attempting to connect to is shut down and that you're not connected as a user who has permission to start it up.  Log on to the server 192.168.1.53 and start up the orcl instance, or ask your DBA to do this for you.

A: Had the same issue on windows XP. Resolved.
The error was caused due to the system log being full.
Control Panel -> Administrative Tools -> Event viewer
Right click on application log, clear all events, optionaly save the log.
Same process for system log.
Restart and it should work.

A: This same error occurred to me even though the ORACLE_HOME and ORACLE_SID seemed to be correctly set up.
The problem was in ORACLE_HOME, which is not supposed to end with a slash character. When I removed the ending slash, it started to work properly.
# ❌ INCORRECT
export ORACLE_HOME=/usr/local/oracle/11gR2/

# ✔ CORRECT
export ORACLE_HOME=/usr/local/oracle/11gR2

So, even if it seems everything is configured fine, check your variables for this.

A: Sometimes, the database will not be mounted correctly, so we need to mount it manually. For that, shut it down and start it up then mount. Log in as oracle user, then run the following commands:
sqlplus / as sysdba;
shutdown immediate;
startup nomount;
alter database mount;
alter database open;

A: Run in cmd:
sqlplus / as sysdba;

Then:
SQL> create pfile='c:/init.ora' from spfile;

Remove sga_target line in init.ora file, then:
SQL> create spfile from pfile='c:/init.ora';
SQL> startup;

A: I faced the same issue while creating the connection on SQLDeveloper "ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist"
Solution:
1.Update the listene.ora file to include the SID.
  SID_LIST_LISTENER =
    (SID_LIST =
      (SID_DESC =
        (SID_NAME = PLSExtProc)
        (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
        (PROGRAM = extproc)
      )
      (SID_DESC =
        (SID_NAME = CLRExtProc)
        (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
        (PROGRAM = extproc)
      )
      (SID_DESC =
        ((GLOBAL_DBNAME = XE.DB)
        ((ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
        ((SID_NAME = XE)
      )
    )

  LISTENER =
    (DESCRIPTION_LIST =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
        (ADDRESS = (PROTOCOL = TCP)(HOST = USMUMTBALAKDAS2.us.deloitte.com)(PORT = 1521))
      )
    )

  DEFAULT_SERVICE_LISTENER = (XE)

The Oraclexe directory may have the permission set to "ReadOnly", Change the directory/sub-directory permission to read/write and restart the listener services.
Problem is solved.

A: Open command prompt and execute the below commands:
set oracle_sid=DATABASE NAME
sqlplus /nolog
conn sys/sys as sysdba
shutdown abort
startup

A: I hit the same shared memory realm does not exist symptom (on Windows) but for a different reason. I had just installed Oracle (XE) and after some troubleshooting, established that my installation was corrupt due to the presence of an ORACLE_HOME environment property at the time I installed it.
If this is TLDR, skip to 'So to resolve:'!
My initial symptom was:
Message 850 not found; No message file for product=NETWORK, facility=NL

Apparently the Windows install reads the ORACLE_HOME from the registry and doesn't need (and certainly in my case shouldn't have...) an environment property.
Remove it, as follows:

*

*Edit the system environment settings (Windows key and start
typing 'env' and you should see this option come up.

*Delete any User and System Environment Variables called ORACLE_HOME, if
present. (make a note of their values, mainly out of interest, but may be of
use if you want to put them back for some reason!)

*Restart your machine. Don't muck around with just a log off - restart your
machine. The Windows Oracle install uses Windows services by default
and your installation is currently very bad - it needs a restart.

Following the restart I was then able to get error messages other than 'No message file...' and could start looking at what the issue was.
Setting the ORACLE_SID to XE and connecting @XE I got as far as the errors in this page, namely the following symptoms:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist

Another symptom was:
When launching the 'Get started' page it failed to connect, giving a not found error (if I recall correctly), despite the Windows listener & XE services being started. As noted in another answer, this could be due to the windows services not being started. In my case those services were started, so something else was misconfigured.
At this point, I figured maybe my install had just gone so badly wrong due to the presence of my bad ORACLE_HOME environment property that I should reinstall. (Previous reinstalls hadn't helped, but those had all been before I noticed the ORACLE_HOME system environment property (probably set up by me a year ago!).
So to resolve:

*

*Close any app looking at the Oraclexe install directory (editors/explorer/cmd prompts)

*A quick trip to Add/Remove programs and uninstall OracleXe

*Double-check you have no ORACLE_HOME environment property set anywhere, remember - Windows will use registry entries to get it.

*Restart (take no chances - we're in this for the long term!)

*Did you make sure there was no ORACLE_HOME property?

*Run the Oracle installer again (as local admin account if applicable)

*You should be able to rejoice in a working install. I did, at least!

A: After wasting so much time i got to know that there was mistake in my syntax to connect with DB. I was using colon ":"  instead of slash "/".
(1) if you use sid below is the syntax to get connection:
**"jdbc:oracle:thin:@{hostname}:{port}:{SID}"**

(2) if you use service name, below is the syntax to get connection:
"**jdbc:oracle:thin:@//{hostname}:{port}/{servicename}**"

A: Your listener.ora is misconfigured. There is no orcl service.

A: I hope you have resolved your issue. If you still got issue then double check again if you install this Oracle under a domain account. I found a thread that says Oracle XE giving same error when installing under domain account. Please use a local account instead.
Source:
https://community.oracle.com/thread/2141735?start=0&tstart=0

A: In my case here, I just had to resurrect a server that was 9 years old, and Oracle was giving me this error.
For some reason, the server had been renamed, but the app/oracle/product/10.2.0/server/network/admin/listener.ora file was still declaring a LISTENER with the old HOST.
I had to put the same name that I had in /etc/hostname in the /etc/hosts, and also fix the name used in the listener.ora.

A: Also try directly startup:
sqlplus /nolog
conn / as sysdba
startup

A: I have seen this issue come up when attempting to start a sqlplus session like this:
sqlplus /nolog
connect user/password

The fix was to remove /nolog and to escape the user/password:
sqlplus 'user/password'

A: SQL> sqlplus "/ as sysdba"
SQL> startup
  Oracle instance started
  ------
  Database mounted.
  Database opened.

SQL> Quit
I also got same problem.I tried above mentioned steps and
then it worked for me.You can try.


text:
Q: Yield Syntax apparent inconsistency in Scala for Expresisons? I am trying to learn scala and I am trying to understand why the following is legal:
for (idx <- 1 to 10) yield idx

but the following is not legal.
for (idx <- 1 to 10) { yield idx }

They seem syntactically the same. What am I missing?
Thanks in advance.

A: Because that's the way the parser works, here is the part from Scala specification:
Expr1 ::= 'for' ('(' Enumerators ')' | '{' Enumerators '}')
  {nl} ['yield'] Expr

It says we can have for with one or many so named enumerators, {nl} says we can nest multiple fors like
for(...)
  for(...)
    ...

We can add optional yield keyword followed by expression, but there is no place for braces. Expression (body) on it's own can be (idx), {idx}, just idx or something else so this is legal:
for (idx <- 1 to 10) yield { idx }

A: This comes down to how the for-expression is de-sugared (and the parser rules associated with it).
In the first case, the compiler will de-sugar the comprehension to be the following:
(1 to 10).map(idx => idx)

The second case is a shorthand that allows people to use for-loops (which is potentially troublesome). The second form of the for is essentially performing a foreach where the result is always Unit and therefore yield is not possible because the return type is already defined.

A: yield It seems it can be replaced with map.
Therefore making this possible
for (idx <- 1 to 10) yield {val square = idx * idx; square}

You can find more on this from scala-yield-syntax and alot more detail here can-someone-explain-scalas-yield

redpajama_set_name: RedPajamaStackExchange


text:
Q: PHP memory_limit can't get it to update If I run php -ini I get:
Configuration File (php.ini) Path => /usr/local/etc/php/7.4
Loaded Configuration File => /usr/local/etc/php/7.4/php.ini

If I run phpinfo() (I use Laravel Valet to serve my app locally) I get:
Configuration File (php.ini) Path: /usr/local/etc/php/7.4
Loaded Configuration File: /usr/local/etc/php/7.4/php.ini

So they're the same. I then run sudo nano /usr/local/etc/php/7.4/php.ini and update memory_limit to 2048M.
Then I run: php -ini: the new memory_limit is updated to the new value. But if I run phpinfo() it still says 128M. Even after brew services restart php@7.4 and valet restart.
This is driving me crazy, what am I missing?

A: So it turns out that valet runs php, not brew... When I ran brew services stop php@7.4 everything still worked. Then I came across this article, followed the steps there and it worked. I'm still slightly puzzled as to why phpinfo() displays that ini file path though.


text:
Q: including Qclasses in the classpath I generate My Qclasses in target/generated-sources/java and the Qclasses are generating good but when i want to use them in my src code /YY/src/controller/XXX.java for example like that
QLot lot = QLot.lot;

I get QLot cannot be resolved to a variable . It seems that the generated Qclasses are not in the classpath !!
<plugin>
      <groupId>com.mysema.maven</groupId>
      <artifactId>apt-maven-plugin</artifactId>
      <version>1.0.6</version>
      <executions>
        <execution>
          <goals>
            <goal>process</goal>
          </goals>
          <configuration>
            <outputDirectory>target/generated-sources/java</outputDirectory>
            <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
          </configuration>
        </execution>
      </executions>
</plugin>

A: You may try this (I assume you use Eclipse).
in pom.xml
- Set the target path of the generated classes as /src/main/generated (target is not a good place, because everytime you execute mvn clean the target folder will be cleaned and this may confuse IDEs)
- Optionally: Add generate-sources in  block, to ensure code generation executed at expected phase and before compilation.
in Eclipse or in console:
- Build the project with mvn clean package
in Eclipse Project Explorer view
- Find generated folder in src/main and right click on it and select Build Path > Use as Source Folder.

This should fix "cannot be resolved to a variable" problems if you already enabled "Build Automatically" option.


text:
Q: python zipflie extractall : password is right but there is a bad password error This is  the code :
"""
To decrypt a zipfile which has a password.
"""
import os
import zipfile
file_zip = zipfile.ZipFile('dict.zip')
file_zip.extractall(pwd="456789")
file_zip.close()

'456789' is the right password but I got a 'Bad password for file' error.
I have tried many different passwords and files but every time I'm faced with this error. I can't seem to figure out the reason.


text:
Q: Combinatorial Problem, 30 balls, 3 unique colors, 10 of each color. We pick 20, probability of getting 3 unique colors?
There are $10$ balls each of $3$ colors ($30$ balls total). We pick $20$ balls. What is the probability that $20$ balls represent $3$ unique colors?

My answer: $\dfrac{27\choose{17}}{30\choose{20}} = 0.2808$
This is obviously wrong, because this number should be greater than $0.5$ (intuitively), as the probability of picking balls with $2$ unique colors will obviously be less than $0.5$, and the probability of picking balls with $1$ unique color is obviously $0$.
Explanation: I pick $3$ balls, $1$ each of $3$ unique colors and then pick the remaining $20 - 3 = 17$ balls out of $30 - 3 = 27$ balls.
Why is the answer wrong? What will be the correct answer?

A: For this type of questions, I often find myself looking at the opposite event: what is the probability that the twenty balls contain less than three colors? Obviously, since there are ten balls of each color, at least two colors will be represented. There are only three ways to select twenty balls containing two colors only (namely, by choosing one of the three colors not to appear in the selection of twenty balls). We thus find that the probability of selecting two colors equals:
$$\frac{{3 \choose 1}{20 \choose 20}}{30 \choose 20} = \frac{3}{30045015}$$
As such, the probability of all three colors being represented equals:
$$1 - \frac{3}{30045015} \approx 0.99999990015$$


text:
Q: Azure Functions - SQL DB Extract to Output Blob I make reference to the below solution that I found on Stack. It's pretty close to what I am attempting to do but after a week of trying various options I am no closer.
I am attempting to write an Azure Function that will extract all the data from Azure Database and output the results to Blob Storage..
Below is my attempt. After exhausting all others, admittedly I'm not great at C# so it's probably my shortcoming. Any help will be greatly appreciated.
Here is the Azure Function:
#r "System.Configuration"
#r "System.Data"

using System.Configuration;
using System.Data.SqlClient;
using System.Threading.Tasks;
using System.Text;
using System.IO;

public static void Run(
    [TimerTrigger("0 */30 * * * *")] TimerInfo myTimer,
    [Blob("mycontainer/myblob.txt", FileAccess.Write)] out string OutputBlob,
    TraceWriter log)
{

   SqlDataReader rdr = null;

   var str = ConfigurationManager.ConnectionStrings["sqldb_connection"].ConnectionString;

   using (var conn = new SqlConnection(str))
   {
        conn.Open();

        // Query Text
        var text = "SELECT FirstName, LastName FROM Kpi";

        using (var cmd = new SqlCommand(text, conn))
        {
            // Execute the command
            rdr = cmd.ExecuteReader();

            var csv = new StringBuilder();

            while (rdr.Read())
            {
                // get the results of each column
                string FirstName = (string)rdr["FirstName"];
                string LastName = (string)rdr["LastName"];

                // create a string
                var newLine = string.Format("{0},{1}", FirstName, LastName);
                csv.AppendLine(newLine);
            }

            // How do I get the results to the outputBlob ??
            File.WriteAllText(outputBlob, csv.ToString());
        }
    }
}

Here is the error:

Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception
  while executing function: Functions.TimerTriggerCSharp1 --->
  Microsoft.CodeAnalysis.Scripting.CompilationErrorException : Script
  compilation failed. at async
  Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.CreateFunctionTarget(CancellationToken
  cancellationToken) at
  C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 340 at async

Error Message screenshot
Solution Found on Stack Overflow

A: You are using binding attributes in C# script, which is wrong... The referenced solution is using precompiled .NET project, not script.
When using script, make sure that your function.json file looks like this:
{
  "bindings": [
    {
      "schedule": "0 */30 * * * *",
      "name": "myTimer",
      "type": "timerTrigger",
      "direction": "in"
    },
    {
      "name": "OutputBlob",
      "type": "blob",
      "path": "mycontainer/myblob.txt",
      "direction": "out"
    }
  ],
  "disabled": false
}

then remove attributes from Function definition:
public static void Run(
    TimerInfo myTimer,
    out string OutputBlob,
    TraceWriter log)

and finally assign the blob content directly in the end of the call
// ...
            OutputBlob = csv.ToString();
        }
    }
}

Overall, my advice is to move to precompiled C# project (as the one in the question you referenced). That takes some setup (in Visual Studio or VS Code) but it will help you avoid the issues and find the errors faster and more exactly.

A: I think you can just assign it. Output blob is a string:
           OutputBlob= csv.ToString();


text:
Q: Show that one-sided limits always exist for a monotone function (on an interval) Show that one-sided limits always exist for a monotone function on an interval $[a,b]$.
Me attempt:
1) If a function is monotone on an interval $[a,b]$, then $f(a)\le f(x) \le f(b)$ for $x\in[a,b]$. Therefore if there exists left-hand (right-hand) limit of this function at a given point, then it must be finite. Now we must show that a both left-hand and right=hand limits exist. We use the fact that if we take a sequence $(x_n)\rightarrow c^{+} \in [a,b]$ then $f(x_n)$ is bounded and monotone and therefore it is convergent.

A: Outline: The general idea is right, but probably a lot more detail is expected. Note that there are two (very similar) cases, monotone non-decreasing and monotone non-increasing. In what follows, we deal with monotone non-decreasing.
It is useful to treat limits from the left and limits from the right separately. We look at the limit from the left. Let $c\in(a,b]$. We want to show that $\lim_{x\to c^{-}} f(x)$ exists. Let $U$ be the set of all $x$ in our interval such that $x\lt c$. Let $V$ be the set of all $f(x)$, where $x$ ranges over $U$. Show that $V$ is non-empty and bounded above. Then $V$ has a supremum $v$. Show that $\lim_{x\to c^{-}} f(x)=v$.
Alternately, one can use sequences.


text:
Q: Updating Silverlight with data. JSON or WCF? We will be using custom Silverlight 4.0 controls on our ASP.NET MVC web page to display data from our database and was wondering what the most efficient method was? We will be having returned values of up to 100k records (of 2 properties per record).
We have a test that uses the HTML Bridge from Javascript to Silverlight. First we perform a post request to a controller action in the MVC web app and return JSON. This JSON is then passed to the Silverlight where it is parsed and the UI updated. This seems to be rather slow, with the stored procedure (the select) taking about 3 seconds and the entire update in the browser about 10-15sec.
Having a brief look on the net, it seems that WCF is another option, but not having used it, I wasn't sure of it's capability or suitability.
Does anyone have any experiences or recommendations?

A: You should definitely consider a change in your approach. This just shouldn't have to be so complicated. WCF is a possible solution. I am sure you are gonna get better performance out of it.

*

*It is designed to transfer data across the wire. Web services in general are thought to be the "right way" to provide data to your silverlight app. WCF services are definitely more configurable.

*Another point in favour of  web services is that this approach is more straightforward than the one you apply. You don't have to serialize in JSON then to parse in JavaScript objects and then to pass them to Silverlight.

*It is really easy to port and continue developing with wcf.

*Last but not least your code will be much more readable and maintainable.

It seems that performance is critical in your case so you can take a look here for compraison.
In conclusion my advice is to consider a change in your approach. WCF services looks like possible solution.
Hope this helps.


text:
Q: Getting Variable name in CMD from other variables So I'm writing a short CMD script to use with CURL and encountered a problem I can't seem to solve with Google.
What I want is to get a variable depending on the names of the other variables for example:
    @echo off
    SET Example1 = Test1
    SET Example2 = Test2
    SET Example3 = Test3 (The variable data isn't this similar ofc)
    ...
    FOR %%G in (1,2,3) DO (
    ...
    *This is where I want to Echo out Something like Example%%G*
    )

Just using
    Echo Example%%G

Doesn't work and I can't seem to find anything online.

A: Batch is sensitive to spaces in a SET statement. SET FLAG = N sets a variable named "FLAGSpace" to a value of "SpaceN"
Once you've fixed that, to output it, unless you use delayedexpansion (far too many SO examples...), try
FOR %%x IN (1,2,3) DO CALL ECHO %%example%%x%%

where echo could be set "extra%%x=%%example%%x%%"
beyond that, need more info on what you are actually doing...

A: Try this:
@echo off
setlocal enabledelayedexpansion
SET Example1=Test1
SET Example2=Test2
SET Example3=Test3
FOR %%G in (1,2,3) DO (
  echo. !Example%%G!
 )

As pointed out by Magoo, there should be no space between variable and value in SET command.


text:
Q: Is there a control for Java Swing that is similar to listview in .NET? I am looking for a control in Java Swing that is similar to this one in .NET.

A: Also consider Outline, discussed here.

A: in Swing use JTree along with JCheckBox for what you are looking for.
Use the JTree along with the JTable. See http://java.sun.com/products/jfc/tsc/articles/treetable1/index.html for reference


text:
Q: AJAX Question - Newbie I have a HTML TEXT BOX in one of my webpage, there is not submit button.
<form>
<label>Website URL: </label>
<input name="" type="text" class="textfield" />
</form>

The text box is used to enter url, i need to do validation  of this textbox using AJAX.So for example if someone enters url and hit enter the URL will appear below the text box and the text box will be emptied again. It will only do this if it is a validly formed url, for example if someone writes ttjkl.145 this will not do anything as it is not a valid url. It will however accept any variations that are valid such as http://www.url.com or www.url.co.uk and url.com.au. And it will remove anything after the end of the country code for example if the person types www.abc.net/dlkjfk then only www.abc.net will be accepted

A: What you need has nothing to do with Ajax. JavaScript alone can do what you need.
The answer you seek already exists:
URL regex validation
Help me validate url which should even accept .me domains
how can i validate a url in javascript using regular expression


text:
Q: Error Installing FastAI on Windows: bdist_wheel did not run successfully I have been trying to install fastai in a virtual environment on my windows computer, and continue getting the error below.
I used conda to create a virtual environment, and am attempting to pip install fastai with Python 3.11.
Haven't had any issues installing other packages in this environment, so any thoughts would be appreciated.
Building wheel for bcolz (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [46 lines of output]
      C:\Users\username\miniconda3\envs\Ron\Lib\site-packages\setuptools\installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.

I have been on a number of forums, have tried pip install wheel and a pip3 install to no avail.
My system info is:
OS Name Microsoft Windows 11 Home
Version 10.0.22621 Build 22621


text:
Q: Logback for different log levels Used Slf4j. Need to a set scheme where log.info() send only to console, log.debug() console and file. I try to do with logback.xml, but all data write to file, how to write to file only debug level?
<configuration>
    <property name="HOME_LOG" value="logs/app.log"/>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>${HOME_LOG}</file>
        <append>true</append>
        <immediateFlush>true</immediateFlush>
        <encoder>
            <pattern>%d %p %c{1.} [%t] %m%n</pattern>
        </encoder>
    </appender>
    <root level="info">
        <appender-ref ref="STDOUT"/>
    </root>
    <logger name="pro.tradeshare" level="debug" additivity="false">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="FILE"/>
    </logger>
</configuration>


text:
Q: Excel Linear Interpolation VBA this function interpolates/extrapolates a table of known x,y
For example,
x y
1 10
2 15
3 20

Linterp(A1:B3, -1) = 0
However, this code can only do two adjacent arrays.
I would like to modify this code so that I can
select two separate arrays, for example N106:N109,P106:P109.
How can I make this adjustment in this code?
Function Linterp(r As Range, x As Double) As Double
     ' linear interpolator / extrapolator
     ' R is a two-column range containing known x, known y
    Dim lR As Long, l1 As Long, l2 As Long
    Dim nR As Long
     'If x = 1.5 Then Stop

    nR = r.Rows.Count
    If nR < 2 Then Exit Function

    If x < r(1, 1) Then ' x < xmin, extrapolate
        l1 = 1: l2 = 2: GoTo Interp

    ElseIf x > r(nR, 1) Then ' x > xmax, extrapolate
        l1 = nR - 1: l2 = nR: GoTo Interp

    Else
         ' a binary search would be better here
        For lR = 1 To nR
            If r(lR, 1) = x Then ' x is exact from table
                Linterp = r(lR, 2)
                Exit Function

            ElseIf r(lR, 1) > x Then ' x is between tabulated values, interpolate
                l1 = lR: l2 = lR - 1: GoTo Interp

            End If
        Next
    End If

Interp:
    Linterp = r(l1, 2) _
    + (r(l2, 2) - r(l1, 2)) _
    * (x - r(l1, 1)) _
    / (r(l2, 1) - r(l1, 1))

End Function

A: one very simple way is having the function accepting two ranges in input, one for X values (say rX) and one for Y ones (say rY), and then changing every occurrence of r(foo,1) to rX(foo) and r(foo,2) to rY(foo)
like follows
Option Explicit

Function Linterp2(rX As Range, rY As Range, x As Double) As Double
     ' linear interpolator / extrapolator
     ' R is a two-column range containing known x, known y
    Dim lR As Long, l1 As Long, l2 As Long
    Dim nR As Long
     'If x = 1.5 Then Stop

    nR = rX.Rows.Count
    If nR < 2 Then Exit Function

    If x < rX(1) Then ' x < xmin, extrapolate
        l1 = 1: l2 = 2: GoTo Interp

    ElseIf x > rX(nR) Then ' x > xmax, extrapolate
        l1 = nR - 1: l2 = nR: GoTo Interp

    Else
         ' a binary search would be better here
        For lR = 1 To nR
            If rX(lR) = x Then ' x is exact from table
                Linterp2 = rY(lR)
                Exit Function

            ElseIf rX(lR) > x Then ' x is between tabulated values, interpolate
                l1 = lR: l2 = lR - 1: GoTo Interp

            End If
        Next
    End If

Interp:
    Linterp2 = rY(l1) _
    + (rY(l2) - rY(l1)) _
    * (x - rX(l1)) _
    / (rX(l2) - rX(l1))

End Function

but you must implement code to check for consistency of the two ranges, like being both of one column each and with the same number of rows

A: use this function  :
Public Function lineare_iterpolation(x As Variant, x1 As Variant, x2 As Variant, y1 As Variant, y2 As Variant) As Variant
    If x = x1 Then
        lineare_iterpolation = y1
        Exit Function
    End If
    If x = x2 Then
        lineare_iterpolation = y2
        Exit Function
    End If
    lineare_iterpolation = y1 + (x - x1) * (y2 - y1) / (x2 - x1)
    Exit Function
End Function


text:
Q: SharePoint throttling We have a lot of users that use SharePoint and also we use only application token to manage the data. So we send lots of requests and we are facing throttling. So the questions are:

*

*Are there any possibilities to increase the requests limit?

*How can I see my current quota/resource usage?

A: You can not request a limit increase, and Microsoft does not provide any specific information regarding the algorithm they use to decide when or why to begin throttling.
The best option you have is to apply incremental back-off logic to account for throttled calls:
https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/handle-sharepoint-online-throttling-by-using-exponential-back-off
You have to contact Microsoft support and open a ticket in order to get information regarding which service principals and users are being throttled. An engineer will have to pull the info from their database.
They can not give you specific quota/resource information. The will only tell you how many calls were throttled for a given principal.


text:
Q: Android data transfer between apps and website I have build a website which provide a lot of data and based on some rules of company, I can't directly get the data from database for my app version. The only way to do it is to use a webview to show the previous website, but I want to get some data reference to the website for my app processing.
I would like to get an values call productID from the website and use it to save as a record into the mobile local database. This saving move will run in the Android app. Is there a way to do this?
It there a way to get data from the website? Is JavaScript possible for this case?

A: Just a few words to Google for you. Just look out for a REST API for you Server (you can write it in PHP) to give the data in JSON to your app.
Use GSON in your app to get the JSON object to a Java object. And keep in mind to do all network calls in a thread/async task. You can have a look at the Volley library provided by Google.
Have fun with your Project ;) Step by step, and you will get it!
Tutorial


text:
Q: Can't resolve all parameters for Component:(?) Ionic2 RC4 Dears,
I know that question is repeated but really i tried all available solutions but still can't solve my problem.
I have multiple components and a service I imported the service to components like signin,signup,..etc.
but i have one component that make the problem and if i removed the service injection from it application will run perfect.
the Invalid component is :
Activation.ts
import {Component,Injectable,Inject} from '@angular/core';
import {CloudAuth} from '../../shared/auth_service';
@Component({
  selector: 'page-activation',
  templateUrl: 'activation.html'
})
export class Activation   {
  constructor( @Inject(CloudAuth) public _CloudAuth:CloudAuth ){

  }
}

one of worked components login.ts
import {Component} from '@angular/core';
import {NavController, NavParams, LoadingController, AlertController, AlertOptions, Platform} from 'ionic-angular';
 import {FormBuilder, Validators, FormGroup} from '@angular/forms';
import {TranslateService} from "ng2-translate";

import {Facebook} from 'ionic-native';
 import {CloudAuth} from '../../shared/auth_service';

@Component({
  selector:'page-login',
  templateUrl: 'login.html',
})
export class login {

  constructor(public loading: LoadingController, public navCtrl: NavController, public params: NavParams,
              public _userService: UserService, public _FormBuilder: FormBuilder, public translate: TranslateService,
              public alertCtrl: AlertController , public _CloudAuth:CloudAuth) {
 ...........
  }
 ...........

}

My service code is auth_service.ts:
import {Injectable , Inject} from "@angular/core";
import { Platform } from 'ionic-angular';
import "rxjs/add/operator/map";
import { JwtHelper } from 'angular2-jwt';
import {TranslateService} from 'ng2-translate/ng2-translate';

import {Activation} from '../user/activation/activation';
import {welcomePage} from '../welcome/welcome';
import {userLogin} from '../user/user';
import {CompleteRegistration} from '../user/completeRegistration/completeRegistration';
import {HomePage} from '../home/home';

@Injectable()
export class CloudAuth {

  jwtHelper: JwtHelper = new JwtHelper();
  token=null;
  constructor(
    @Inject(TranslateService) public translate: TranslateService ,
    @Inject(Platform)  public platform: Platform
  ){
          this.token = localStorage.getItem('user_token');
  }

      getToken(){
        return this.token;
      }
      updateToken(newtoken){
        localStorage.setItem('user_token', newtoken.toString());
        this.token = newtoken;
        return true;
      }
      isTokenExpired(){
          // Check if token expired
          return this.jwtHelper.isTokenExpired(this.token)
      }
      tokenData(){
         // Return data stored in token
          if(this.token=='' || this.token == null) return false;
          else return this.jwtHelper.decodeToken(this.token);
       }

       checkCode(code){
          let userData =  this.tokenData();
          if( userData == false) return false;
          else {
              if(userData.activation_code == code) return true;
              else return false;
          }
       }

      // Check if user login or not and loading the default app Language.
      checkLogin():any{
        console.log(this.token);
        let lang = localStorage.getItem('Language');
        if(!lang || lang==''|| lang === undefined ) return welcomePage;
        else {
          if(lang=='ar'){
                this.platform.setLang('ar',true);
                this.platform.setDir('rtl',true);
          }
          this.translate.use(lang);
          let userData =  this.tokenData();
          if( this.token==null ||  this.token== '' || userData == false) return userLogin;
          else {
              if(userData.active == 1) {
                  if(!localStorage.getItem('firstRun') ){
                    return CompleteRegistration;
                  }else{
                    return HomePage;
                  }
              }else {
                  return Activation;
              }
          }
        }
      }
}

I removed @Inject decorator but also not working.
My package.json is :
{
  "name": "ionic-hello-world",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/storage": "1.1.6",
    "angular2-jwt": "^0.1.25",
    "ionic-angular": "2.0.0-rc.4",
    "ionic-native": "2.2.11",
     "ionicons": "3.0.0",
    "ng2-translate": "^4.0.1",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "0.0.47",
    "typescript": "2.0.9"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [
    "ios",
    {
      "platform": "ios",
      "version": "",
      "locator": "ios"
    }
  ],
  "description": "pecardPlayground: An Ionic project"
}

My node and ionic information is :
Ionic Framework: 2.0.0-rc.4
Ionic Native: 2.2.11
Ionic App Scripts: 0.0.47
Angular Core: 2.2.1
Angular Compiler CLI: 2.2.1
Node: 6.7.0
OS Platform: macOS Sierra

this error dose't appear before it happened since upgrade to Ionic RC4
hope to find a solution.
Thanks

A: You seem to have a case of Circular Dependency.
You have imported Activation component in auth_service and have imported
auth_service in Activation which is your starting page.
use forwardRef
constructor(@Inject(forwardRef(() => CloudAuth)) _CloudAuth)

in your constructor in Activation.
 Another tutorial link here
Edit:
Also could rethink design if possible.


text:
Q: Prove that for all prime numbers $n$ larger than 3 that $(9n+1)^2-(n+9)^2$ is divisible by 1920 Prove that for all prime numbers $n$ larger than $3$ that $(9n+1)^2-(n+9)^2$ is divisible by $1920$.
Hi there, I've tried this problem for the past two days on and off but I'm getting increasingly frustrated as I think it's a really simple problem with a simple solution, but I'm having trouble connecting the dots. I've tried looking at congruencies and sub-cases to no avail, I've researched similiar problems and they usually look into proving divisibility with $128$ and $15$ ($3,5$). Any help's appreacited, thanks.

A: Any prime number $n\ge 5$ is of the form $6k-1$ or $6k+1$, hence $24\mid n^2-1\iff n^2-1=24k$ For any prime $n$. Now, $$(9n+1)^2-(n+9)^2=(8n-8)(10n+10)=80(n-1)(n+1)=80(n^2-1)=1920k$$

A: Use the formula $a^2-b^2 = (a-b)(a+b)$ to get $$N = (9n+1)^2 - (n+9)^2 = (8n-8)(10n+10) = 80 \cdot (n-1)(n+1) = 80 \cdot (n^2-1)$$
$\textbf{1.}$ Clearly $5 \mid N$
$\textbf{2.}$ Since $3 \nmid n$, it follows that $n^2 \equiv 1 \pmod 3$, so $3 \mid N$
$\textbf{3.}$ Since $n$ is odd $n^2 \equiv 1 \pmod 8$, so $128 \mid N$


text:
Q: Python - Selenium Web Driver - can't find xpath for "edit images" button on craigslist I am trying to use the following code to click on the "Edit Images" button on craigslist
driver.find_element_by_xpath("/form/input[@value='Edit Images']").click()

I am getting the following error:
NoSuchElementException: Message: Unable to locate element: //form/input[@value='Edit Images']

The following is the source code for the craigslist page that I am working with. I am not sure what I am doing wrong:

A: try xpath
//button[@value = 'Edit Images']
but you have to make sure that this element is visible.


text:
Q: Cannot read property 'push' of undefined When pushing an array's contents i get

here is my code

A: This is because the context of this has changed within your each. Try this:
const self = this;

$.each(res, function(index, value) {
    self.qtyOptions.push(value);
}


text:
Q: Upstart ReactPHP Script - AWS EC2 ElasticbeanStalk I have a php script that runs in a never ending loop using ReactPHP Loop and HTTPServer
Now, I am using an AWS Elastic Beanstalk Worker which reads an SQS queue for which HTTPServer on port 80 is required. Here is my PHP Script:
<?php

/* loading the base configuration files and defines */
require_once 'base/bootstrap.php';

$loop   = React\EventLoop\Factory::create();
$socket = new React\Socket\Server($loop);
$http   = new React\Http\Server($socket);

$i = 0;
$j = 0;

$api = BaseClass::initiate(); // the initially loaded class setting up the environment

/**
 * The $loop React Event Loop will make sure that $api BaseClass required to be alive
 * is up-to-date managing the Environment
 */
$loop->addPeriodicTimer(3, function ($timer) use (&$i, &$j, $loop, &$api) {
    try {

        if ($i >= rand(300, 400)) {
            /* Refresh the Environment if any DB changes happen, like new clients added, etc. */
            $api = BaseClass::initiate();
        }

        /**
         * I Do my Work Here
         */

    } catch (Exception $e) {
        /**
         * Error Handling
         */
    }
    $i++;
    $j++;
});

/**
 * The $http React HTTP Server will listen to the SQS Queue and perform actions accordingly
 */
$http->on('request', function (React\Http\Request $request, React\Http\Response $response) use (&$api) {
    $request->on('data', function ($data) use (&$api, $request, $response) {
        try {
            $postData = json_decode($data, TRUE);

            /**
             * I process the Post Data here using $api loaded Class
             */

        } Catch (Exception $e) {
            /* Send an Error Message to the Queue */
            /**
             * Error Handling
             */
        }
    });
});

$socket->listen(80);
$loop->run();

The reason i am looking at this structure is that $api opens a socket connection and needs to be alive for the $http Server to process.
nohup php /var/app/current/server.php & just works fine, however, i am looking at creating an upstart service
My UpStart script is as follow within /etc/init/myscript.conf
#Info
start on startup
stop on shutdown
respawn
php /var/app/current/server.php

which does not work. Not sure, where i am going wrong.
Any Suggestions?

A: Replace your /etc/init/myscript.conf with this one
# Info
description "myscript name"
author      "Yourself"

# Events
start on startup
stop on shutdown

# Automatically respawn
respawn
respawn limit 20 5

# Run the script!
# Note, in this example, if your PHP script returns
# the string "ERROR", the daemon will stop itself.
script
    [ $(exec /usr/bin/php -f /var/app/current/server.php) = 'ERROR' ] && ( stop; exit 1; )
end script

then start it with
sudo service myscript start


text:
Q: Absolute difference between the first and second half of a random vector Suppose I have a zero vector of length $2n$, and I randomly choose $k$ of the entries of this vector to be $1$. The choice is taken uniformly from all $\binom{2n}{k}$ possibilities. Now let $S_1$ denote the sum of the first half of the vector, and $S_2$ denote the sum of the second half. I want to know the percentage of vectors such that the difference between $S_1$ and $S_2$ is nontrivial. More precisely, I want to compute the probability that $P(\frac{|S_1-S_2|}{n} > \epsilon)$ as $n$ and $k$ become large.

I'm almost sure that there is an established result somewhere, but since I'm not familiar with combinatorics, I don't know how to search for it.

A: TL;DR: I will show in this answer that
$$
\mathbb{P}\left(\frac{|S_1 - S_2|}{n} > \epsilon\right)
\le \frac{1}{\varepsilon^2 (2n-1)},
$$
independent of $k$ (better bounds can be given if $k$ is close to $1$ or $2n$).
In other words, the probability you ask for is bounded above by roughly $1 / (2 \varepsilon^2 n).$ In particular, it tends to $0$ as $n \to \infty$.

Markov's inequality is useful here. We consider the random variable $S_1 - S_2$ which is the sum of the first $n$ entries of the vector, minus the last $n$; that is, if the vector is $v$,
$$
S_1 - S_2 = (v_1 + v_2 + \cdots + v_n) - (v_{n+1} + v_{n+2} + \cdots + v_{2n}).
$$
We are interested in $\mathbb{P}\left(|S_1 - S_2| > n \epsilon\right)$.
But it will be more convenient to work with $(S_1 - S_2)^2$, so we note
$$
\mathbb{P}\left(|S_1 - S_2| > n \epsilon\right)
= \mathbb{P}\left((S_1 - S_2)^2 > n^2 \epsilon^2\right).
$$
We can then apply Markov's inequality as follows:
$$
\mathbb{P}\left((S_1 - S_2)^2 > n^2 \epsilon^2\right)
\le \frac{\mathbb{E}((S_1 - S_2)^2)}{n^2 \epsilon^2}.
$$
Now, observe that $S_1 + S_2 = k$, so $S_2 = k - S_1$. So we get
$$
= \frac{\mathbb{E}((2 S_1 - k)^2)}{n^2 \epsilon^2}.
$$
Now the expected value of $S_1$ is $\frac{k}{2}$, so the denominator is related to the variance. We get
$$
\mathbb{P}\left(|S_1 - S_2| > n \epsilon\right) \le \frac{4 \cdot \text{Var}(S_1)}{n^2 \varepsilon^2}. \tag{1}
$$
So the question becomes, what is the variance of $S_1$?
We can use this formula:
$$
\text{Var}(S_1)
= \text{Var}(v_1 + v_2 + \cdots + v_n)
= \sum_{i=1}^n \text{Var}(v_i) + \sum_{i \ne j} \text{Cov}(v_i, v_j).
$$
An individual $v_i$ is Bernoulli where the probability of being $1$ is $\frac{k}{2n}$, so the variance is $\frac{k}{2n} \left(1 - \frac{k}{2n}\right)$.
As for the covariance between $v_i$ and $v_j$, there are four possibilities for the pair of variables, and the covariance is calculated as
\begin{align*}
\text{Cov}(v_i, v_j)
= &\frac{k}{2n} \cdot \frac{k-1}{2n-1} \cdot \left(\frac{2n - k}{2n}\right)^2 \\
&+ 2 \cdot \frac{k}{2n} \cdot \frac{2n - k}{2n-1} \cdot \left( -\frac{k}{2n} \right) \left( \frac{2n - k}{2n} \right) \\
&+ \frac{2n - k}{2n} \cdot \frac{2n - k - 1}{2n-1} \cdot \left( -\frac{k}{2n} \right)^2 \\
&= \frac{k(2n-k)}{(2n)^3 (2n - 1)}
\left[ (k-1)(2n-k) - 2k(2n-k) + k(2n-k-1) \right] \\
&= \frac{k(2n-k)}{(2n)^3 (2n - 1)} \left[ -(2n- k) - k\right] \\
&= \frac{k(2n-k)}{(2n)^3 (2n - 1)} \cdot (-2n) \\
&= -\frac{k(2n-k)}{(2n)^2 (2n-1)}.
\end{align*}
Therefore,
\begin{align*}
\text{Var}(S_1)
&= n \cdot \frac{k}{2n} \left(1 - \frac{k}{2n}\right) + n(n-1) \cdot -\frac{k(2n-k)}{(2n)^2 (2n-1)} \\
&= \frac{n k (2n - k)}{(2n)^2} \left[ 1 - \frac{(n-1)}{2n-1}\right] \\
&= \frac{n^2 k (2n - k) }{(2n)^2 (2n-1)} \\
&= \frac{k(2n-k)}{4 (2n-1)}.
\end{align*}
Finally, we can return to (1). We get that
\begin{align*}
\mathbb{P}\left(|S_1 - S_2| > n \epsilon\right)
&\le \frac{4}{n^2 \varepsilon^2} \cdot \frac{k(2n-k)}{4 (2n-1)} \\
&= \frac{1}{\varepsilon^2} \cdot k (2n - k) \cdot \frac{1}{n^2 (2n-1)} \\
&\le \frac{1}{\varepsilon^2} \cdot n^2 \cdot \frac{1}{n^2 (2n-1)} \\
&= \frac{1}{\varepsilon^2} \cdot \frac{1}{2n-1}.
\end{align*}
Here, we used the fact that $k (2n - k)$ is maximized when $k = n$; better bounds can be given if $k$ is small (close to $1$) or large (close to $2n$).
In summary,
$$
\boxed{\mathbb{P}\left(|S_1 - S_2| > n \epsilon\right)
\le \frac{1}{\varepsilon^2 (2n-1)}.}
$$
We can make some concrete observations:

*

*This bound is independent of $k$.

*If $\varepsilon$ is fixed, the probability goes to $0$ as $n \to \infty$ (regardless of whether $k$ is held constant or also increasing).

A: We can use the normal approximation.  The expected number in the first half is $\frac k2$ with a standard deviation of $\frac 12\sqrt k$.  You are asking for the deviation to be greater than $\frac 12\epsilon n$, which grows faster than $\sqrt k$.  The probability tends to zero.
You can use this approximation to look up the probability in a z-score table.


text:
Q: how to make blank textbox equal 0 I have a textbox below which is created through this code:
$('#txtWeight').each( function() {

     var $this = $(this);
     var $weightText = $("<input type='text' class='txtWeightRow' maxlength='5' onkeypress='return isNumberKey(event)'/>").attr('name',$this.attr('name'))
                     .attr('value',$this.val())

    $weight.append($weightText);

    });

What I want to know is that how is it suppose to be written that if the textbox is blank, then it should have a hidden value of 0?
Below is code which does the calculation between 100 and the number entered in the textbox:
function calculateTotal()
{
   var totalweight = totalmarks;
   $("#qandatbl td.weight input").each(function (i, elm){
        totalweight = totalweight - parseInt($(elm).val(), 10);
    });

    $("#total-weight").text(totalweight);
}

td.weight input is the textbox.
totalmarks = 100.
Thanks

A: In the code that does the subtraction, you can treat an empty value as 0 by using the Number() constructor (a typecast). Like this:
var $result = 100 - Number($('#txtWeight').val());

Then it doesn't matter what is in the textbox, the subtraction will work. If the value in the textbox is not a number (e.g. an empty string) it will be treated as the number zero, and the result of the subtraction will be 100 (not NaN).
In your code, just use Number() instead of parseInt():
function calculateTotal()
{
    var totalweight = totalmarks;
    $("#qandatbl td.weight input").each(function (i, elm){
        totalweight = totalweight - Number($(elm).val());
    });

    $("#total-weight").text(totalweight);
}

If you want just to avoid decimal numbers, you can even do parseInt after the Number (i.e. totalweight = totalweight - parseInt(Number($(elm).val()), 10);).

A: On your form submit, you could just check to see if it has a value...
var myVal = $('#txtWeight').val();
myVal = myVal == '' ? 0 : myVal;

A: Conveniently, the result of coercing an empty string to a number is 0.  So, wherever you need to use the value of the textbox, just coerce it to a number first (by using the + operator):
var weight = +$("#txtWeight").val();

This will give you 0 for empty strings, or whatever number is entered for other numbers.  Since you are preventing non-number keys from being pressed, the only thing you need to worry about is alternative input methods such as copy/paste or drag/drop.
Edit: Looking at your calculateTotal() function, all you really need to do is to get rid of your call to parseInt().  The substraction operator (-) in your expression is already implicitly coercing the value to a number.  It's getting messed up because parseInt is returning NaN.
function calculateTotal() {
    var totalweight = totalmarks;
    $("#qandatbl td.weight input").each(function (i, elm) {
        totalweight -= elm.value;
    });

    $("#total-weight").text(totalweight);
}

Note, I also shortened your expression from x = x - n to x -= n, and skipped creating a jQuery object just to read the value property.


text:
Q: I am trying to login with my Apps. I dont understand the mistake. I prove my code for a example more easy and this had work it. thanks when i click login button after enter email and password i got the error as "unfortunately,myapp has beeen stopped" and i got error message as FATAL EXCEPTION: AsyncTask #1 and An error occurred while executing doInBackground().
for ref i have attached code. thanks for help
public class LoginActivity extends Activity implements OnClickListener {

    Button submitBtn,registerBtn,forgotpassBtn;
    EditText emailEt,passwordEt;
    //SessionManager session;

    //Driver Login Fields
    EditText drloginEmail;
    EditText drloginPassword;
    TextView drloginResult;
    Button loginSubmitBtn;

    //Registration Fields
    EditText registrationName,registrationEmail,registrationPhone,registrationPassword,registrationConfirmPassword;
    TextView registrationResult;

    //LostPass Fields
    EditText lostPassEmail;
    TextView lostPassResltText;

    SharedPreferences sh;

    JSONParser jparser=new JSONParser();

    private static final String regiURL = "http://10.0.2.2/appslider/registration.php";
    public static final String loginURL = "http://10.0.2.2/appslider/login.php";
    public static final String getDataURL = null;
    public static final String recoverPasswordURL = "http://10.0.2.2/sendmail.php";

    Context con;

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

        con=LoginActivity.this;

        sh=getSharedPreferences("CRUZER_PREF", MODE_PRIVATE);

        init();

        String email=sh.getString("loginemail", null);
        String pass=sh.getString("loginpass", null);
        boolean driver=sh.getBoolean("type", false);

        if(email!=null && pass!=null && !driver){
            emailEt.setText(email);
            passwordEt.setText(pass);
            submitBtn.performClick();
        }else if(email!=null && pass!=null && driver){
            showDriverLoginDialog();
            drloginEmail.setText(email);
            drloginPassword.setText(pass);
            loginSubmitBtn.performClick();
        }

    }

    private void init() {

        submitBtn=(Button) findViewById(R.id.loginSubmitBtn);
        registerBtn=(Button) findViewById(R.id.loginRegisterBtn);
        forgotpassBtn=(Button) findViewById(R.id.loginForgotPassBtn);

        submitBtn.setOnClickListener(this);
        registerBtn.setOnClickListener(this);
        forgotpassBtn.setOnClickListener(this);

        emailEt=(EditText) findViewById(R.id.loginEmailEt);
        passwordEt=(EditText) findViewById(R.id.loginPassEt);

    }

    @Override
    public void onClick(View v) {
        if(!Util.isConnectingToInternet(this)){
            Util.showNoInternetDialog(this);
            return;
        }

        switch (v.getId()) {
            case R.id.loginSubmitBtn:
                if(!TextUtils.isEmpty(emailEt.getText().toString())){
                    if(!TextUtils.isEmpty(passwordEt.getText().toString())){
                        new Login().execute("client");
                    }else Toast.makeText(this, "Please enter your password", Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(this, "Please enter your email address", Toast.LENGTH_SHORT).show();
                }
                break;
            case R.id.loginRegisterBtn:
                showRegisterDialog();
                break;
            case R.id.loginForgotPassBtn:
                showLostPasswordDialog();
                break;
        }
    }

    class Login extends AsyncTask<String, String, String>{
        ProgressDialog pDialog;
        String s="";
        int success=-1;
        int error=0;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog=new ProgressDialog(con);
            pDialog.setMessage("Login is processing......");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();
        }

        boolean driver=false;
        String email="";
        String password="";
        String drloginEmail;
        String drloginPassword;
        String emailEt;
        String passwordEt;

        @Override
        protected String doInBackground(String... st) {

            if(st!=null && st[0].equals("driver")){
                //email=drloginEmail.getText().toString();
                email=this.drloginEmail.toString();
                //password=drloginPassword.getText().toString();
                password=this.drloginPassword.toString();
                driver=true;
            }else{
                //email=emailEt.getText().toString();
                email=this.emailEt.toString();
                //password=passwordEt.getText().toString();
                password=this.passwordEt.toString();
            }

            List<NameValuePair> params=new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("email", email));
            params.add(new BasicNameValuePair("password", password));

            if(driver)params.add(new BasicNameValuePair("category", "driver"));
            else params.add(new BasicNameValuePair("category", "client"));

            UserInfo.setEmail(email);
            UserInfo.setPassword(password);

            try {
                JSONObject jobj=jparser.makeHttpRequest(loginURL, "POST", params);
                success=jobj.getInt("success");
                s=jobj.getString("message");

                if(success==1){
                    JSONObject job=jobj.getJSONArray("info").getJSONObject(0);
                    UserInfo.setName(job.getString("name"));
                    UserInfo.setPhonenumber(job.getString("number"));
                    UserInfo.setId(job.getString("id"));
                }

            } catch (JSONException e) {
                //  e.printStackTrace();
                error=1;
            }catch(Exception e){
                error=1;
            }

            return null;
        }

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);
            pDialog.dismiss();

            if(error==1){
                if(Util.isConnectingToInternet(con)){
                    Toast.makeText(con, "Server is down, Please try again later", Toast.LENGTH_SHORT).show();
                }else
                    Util.showNoInternetDialog(con);
                return;
            }

            if(success==0){
                Toast.makeText(con, s, Toast.LENGTH_LONG).show();
            }else if(success==1){
                /*GetUserData data=new GetUserData();
                data.execute();*/

                SharedPreferences.Editor edit=sh.edit();
                edit.putString("loginemail", email);
                edit.putString("loginpass", password);
                edit.putBoolean("type", driver);
                edit.commit();

                Intent i=new Intent(con, DriverPositionActivity.class);
                if(driver)
                    i=new Intent(con, DriverActivity.class);

                startActivity(i);
                Toast.makeText(con, s, Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    }
}

A: This is what you have done inside doInBackground
        if(st!=null && st[0].equals("driver")){
            //email=drloginEmail.getText().toString();
            email=this.drloginEmail.toString();
            //password=drloginPassword.getText().toString();
            password=this.drloginPassword.toString();
            driver=true;
        }else{
            //email=emailEt.getText().toString();
            email=this.emailEt.toString();
            //password=passwordEt.getText().toString();
            password=this.passwordEt.toString();
        }

here inside login async class you have not initilize variables named as drloginEmail,passwordEt and you are fetching data from that may be this is a issue. Please initilize these variables with the values getting from corresponding  EditText's.


text:
Q: How to access the downloads folder directory path A component of an extension that I've been developing requires the extension to save files and then (at a later time) open those files again.  As far as I know, this can be done as long as the downloads directory is known.  Saving is easy, you just use:
chrome.downloads.download({
    url: fileData,
    filename: "/AppGeneratedSubFolder/"+fileName,
    conflictAction:'overwrite',
    saveAs:false
}

And I can perform the opening process if I have included the correct permission in the manifest and have the "Allow access to file URLs" box checked by the user.
I can then access the file by using the following:
var missing = "userInputRightNow"
var open= "file:///"+missing+"/AppGeneratedSubFolder/"+fileName;
chrome.windows.create({
    url:open,
    type:'popup',
    state: 'maximized',
    focused:true,
});

However, this requires me to somehow get the content for the variable labeled missing.  I have done this by directing users to the following page (i.e., opening it in a new window) and telling them to copy the directory into an input box within my application--I then save the value for future use by the application:
chrome://settings/?search=Ask%20where%20to%20save%20each%20file%20before%20downloading

However, I'm wondering if there is any better approach.  I broadly understand the design decision to not expose a user's file system to extension APIs.  However, I'm wondering if I'm missing some work around:

*

*Is there another permission that might enable this that I haven't considered?

*I don't actually have any reason to "know" the missing information.  I would be satisfied with a way to reference the relative path without knowing it.

*Or some superior method to obtaining that missing information as trying to walk users through the process of copying and pasting it (no matter how clear) seems to be a major bottle neck in my installation process.


text:
Q: the characteristic function of $S_N=\sum_\limits{i=1}^{n}X_i$
Let $N,X_1,X_2,...$ independent random variables, $N\in\{1,2,...\}$ almost certainly and let $S_n=\sum_\limits{i=1}^{n}X_i$.
  Suppose $P(N=n)=p_n$,$n\geqslant 1$ and let $\phi_i$ characteristic function of $X_i$ for $i\geqslant 1$. Determine the characteristic function of $S_N$ and comment the result.

$\phi(S_N)=\int_{-\infty}^{\infty}e^{it S_N}dP=\int_{-\infty}^{\infty}e^{it\sum_\limits{i=1}^{N}X_i }dP=?$
Is $\int_{-\infty}^{\infty}e^{it\sum_\limits{i=1}^{N}X_i }dP=\prod_\limits{i=1}^{N}{e}^{itX_i}P_i$?
Questions:
What is meant on this exercise? How should I solve it?
Thanks in advance!

A: Note that
$$
\begin{align}
Ee^{itS_N}
&=E\left[\sum_{n=1}^\infty e^{itS_n} I(N=n)\right]\\
&=\sum_{n=1}^\infty E\left[ e^{itS_n} I(N=n)\right]\tag{0}\\
&=\sum_{n=1}^\infty Ee^{it S_n} P(N=n)\tag{1}\\
&=\sum_{n=1}^\infty\prod_{k=1}^n \varphi_{X_k}(t) P(N=n)\tag{2}
\end{align}
$$
where in (1) we used the independence of the $X_i$ from $N$, in (2) we used the independence once more and in (0), the swapping of $E$ and the sums can be justified by noting that $\sum_{n=1}^\infty E|e^{itS_n} I(N=n)|\leq 1<\infty$.


text:
Q: How to set Apache-accessible SELinux policy for EFS mounted user directories? When I mount my EFS to a user directory, the directory policy becomes system_u:object_r:nfs_t:s0, which is too restrictive - I need it to behave more like a typical user directory, which is unconfined_u:object_r:user_home_dir_t:s0.
How do I change this?

A: I was able to fix this by defining the context while mounting the directories. I also had to define it in my fstab configuration to ensure the definition persisted after reboot. Additionally, I needed to set domain policy to httpd_sys_content_t, which allowed apache to access the content.


text:
Q: jQuery: select checkbox when upload field is clicked I'm working on a CMS. When a user wants to replace an existing thumbnail image, they can upload a replacement, and check a checkbox to certify that they are indeed replacing the image. The checkbox seems necessary because otherwise the form submits a blank value (due to the blank default value of the upload field, a security default for all browsers) and wipes out the existing image without a replacement image being specified.
The problem is that I keep forgetting to manually activate the checkbox and the uploaded image does not actually replace the existing one because without the checkbox being checked, the receiving PHP file does not (by design) process the uploaded filename. I suspect that users will have the same problem and I want to keep this from happening by reducing the number of steps required. One solution would be to check the checkbox with jQuery whenever the upload field is clicked. So why doesn't this work:
$('#image_req').click(function () {
    if ($('#checkbox_req').attr('checked',true)) {
        $('#checkbox_req').removeAttr('checked');
        alert('Unchecked');
    } else if ($('#checkbox_req').attr('checked',false)) {
        $('#checkbox_req').attr('checked','checked');
        alert('Checked');
    }
});

The HTML in question looks like this:
<input id="image_req" name="local_filename" type="file" />
<input id="checkbox_req" name="replace_image" value="yes" type="checkbox" />

A: it could be that the $ is conflicting with an existing javascript library in your CMS. I had to do something similar with select boxes and found out about jQuery.noConflict:
jQuery.noConflict();

jQuery(document).ready(function() {
    //preselect sectionid
    jQuery('select[name="sectionid"] option[value="29"]').attr("selected", true);
    jQuery('select[name="sectionid"] option[value="29"]').trigger("change");
    jQuery('select[name="access"] option[value="1"]').attr("selected", true);
});

after "jQuery.noConflict();" you can use "jQuery" instead of "$"
also in my case I had to trigger the change event because the 'access' selectbox's content is dependent on whatever is selected in 'sectionid' selectbox

A: Can't you include the default value in a hidden input (type="hidden")? That way when you submit the form you know what the default value is. If nothing changes, use the default value or do nothing, and if a file gets uploaded (check $_FILES), use the new file.

A: @Arne
I tried running your code quickly but for some reason it just unchecks it everytime.. I modified it quickly so that it checks the checkbox each time.. as I understand it there is no need to uncheck the box, right?
$('#image_req').mouseup(function () {
    if ($('#checkbox_req').attr('checked',false)) {
        $("input[name='replace_image']").attr('checked', true);
    }
});

@Doug: thanks for the tip

A: Your if conditions do not work properly because you are actually assigning values instead of getting them.
Try this:
$('#image_req').click(function () {
    var checkbox = $('#checkbox_req');
    if (checkbox.is(':checked')) {
        checkbox.removeAttr('checked');
        alert('Unchecked');
    } else {
        checkbox.attr('checked', 'checked');
        alert('Checked');
    }
});

But does this make any sense? When the user first checks the box manually and then hits upload, it gets unchecked again.
I would check it by default by setting the checked attribute in your HTML. If the user then not wants to have the image replaced, he can uncheck it manually.
PS: What about simply turning the checkbox into a hidden field, if you actually need this checkbox to be checked always?
<input id="checkbox_req" name="replace_image" value="yes" type="hidden" />

If this is not possible for any reason, here's another idea with the same effect: Check the box with javascript and hide it via CSS.

A: I ended up using a hidden input, which was the obvious solution, and one that I've implemented before, but somehow overlooked this time. But I appreciate all the varied and helpful responses. Stack Overflow rocks.


text:
Q: c# Register Global Hotkeys without hook library (Keyboard Hooks) I try to configure some global Hotkeys in a C# WinForm Application that should work with and without focus. For this I played a little bit with some Hooking Librarys like: Link
But these Libraries are not working really reliable so that I decided to look for a different way. And I found one but there is one problem: With the new method posted below I can catch a keypress, but I like to catch also the keydown (WM_KEYDOWN/0x100) and keyup event... But this is not working. Any ideas?
Code:
public Form1()
        {
            InitializeComponent();
        }

            [DllImport("user32.dll")]
            private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);

            [DllImport("user32.dll")]
            private static extern bool UnregisterHotKey(IntPtr hWnd, int id);

            const int MOD_CONTROL = 0x0002;
            const int MOD_SHIFT = 0x0004;
            const int WM_HOTKEY = 0x0312;
            const int WM_KEYDOWN = 0x0100;

private void Form1_Load(object sender, EventArgs e)
        {

            // Hook Keys
            RegisterHotKey(this.Handle, 1, MOD_CONTROL, (int)0);
            RegisterHotKey(this.Handle, 2, MOD_CONTROL, (int)Keys.X);

        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            UnregisterHotKey(this.Handle, 1);
        }

        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_HOTKEY && (int)m.WParam == 1)
            {
                MessageBox.Show("here");
            }
            if (m.Msg == WM_KEYDOWN && (int)m.WParam == 2)
                this.Opacity = 100;
            base.WndProc(ref m);
        }


text:
Q: If a div has "clear:right", nothing should float to the right of it, should it? I seem to have gotten confused as to what the css "clear" keyword means.
I have a number of div elements, all with "float:left". The second last div element also has "clear:right". I thought that would cause the subsequent element to go to the next line. But for me, it doesn't.
Here's my example:

0

ShopTVC Wallace and Gromit WOA 6Apr11

00:00:32

Looks like this:

I am trying to make the duration ("00:00:32"), appear on the next line, to the right of the thumbnail (the blue rectangle).
I know that I could put the last three divs into another container div, but the purpose of this question is to understand why "clear:right" doesn't stop the duration from floating on the right of the title.
Here's the CSS:
div.Section
{
    overflow:auto;
    background:cornsilk;
    border:2px solid navy;
    padding:12px;
}

div.Section div.Thumbnail
{
    width:64px;
    height:42px;
    background:SteelBlue;
    foreground:Navy;
}

div.Number
{
    width:16px;
    margin-left:6px;
}

div.Duration
{
    margin-left:22px;
}

div.Section div
{
    float:left;
}

div.Section div.Title
{
    color:DarkGreen;
    clear:right;
}

And, of course, the jsfiddle link: http://jsfiddle.net/8J7V6/3/

A: ahruss's answer is the correct one, but I also noticed no one really answered your question. Basically clear:left refers to left floating elements. clear:right refers to right floating elements.
Since your element is floating left, not right, clear:right won't affect it.
The other thing you could do is wrap the two text elements in a separate div from the blue box, float that container div in and the blue div, then when you float the two text elements, your clear:left code will put the date under the text still within your container div and not under the blue image to it's left.
Like this:

0

ShopTVC Wallace and Gromit WOA 6Apr11

00:00:32

and add this to your css:
div.TextContainer {
   float:left;
}

Add in whatever other visual styles you need.

A: The clear property doesn't prevent elements from being placed in that space after the cleared element. It prevents the element from being placed where there are already elements floated to the that direction before it. Adding a clear:left to div.Duration would make it be placed below the navy box. Adding a
 before the duration might solve your problem, or, as you already said in your question, you could use another container div for the last three divs.

A: I have used padding and margin. If it is not possible to use in your case then the following solution will not be appropriate.
http://jsfiddle.net/8J7V6/5/

A: There isn't anything floating to the right of it. The Problem you're facing is that you already sent all your content prior to the time, and then you're telling the time to float to the left. It's still floating to the left, it's just stacking on top of the content that's already there to the left.
But yes, clearing to the right makes that element break down past all elements which are floated to the right before it. Clear does not affect elements after it.
Have you tried using a simple
 after your title?

A: .Duration { clear: left; } should work


text:
Q: @selector - How to reference a class method? I am adding a menu item programmatically:
refreshItem = [[NSMenuItem alloc] initWithTitle:@"Refresh" action:@selector(refreshMenu) keyEquivalent:@""];
The refreshMenu method is called fine if it's an instance method, but I want to turn it into a class method:
 +(void)refreshMenu {}
How would I reference it then?

A: You'd still use @selector(refreshMenu), but you'd set the -target of the NSMenuItem to be the Class (ie, [self class]) instead of the instance (self).

A: Note that classes are objects themselves: they're instances of their metaclass.
[menuItem setTarget:[MyClass class]];


text:
Q: Reading Yahoo Finance: Extract a smaller table from a bigger table Python (historical low price) I have a table from yahoo finance with one year of data
The table is like the figure below

I want to join two columns of this table to make a new one. I want the column date and price
Does anyone can give me a tip?

A: I got the first part of your question, where you only want to see a table (pandas dataframe) with columns date and low.
Column selection in pandas is very easy. You put the list of columns you like to see in a python list, and then pass it to dataframe in way you subset.
mycolumns = ["date", "low"]
newdf = bvsp2[mycolumns]
print(newdf)

Output
          date      low
0   2017-02-16  67661.0
1   2017-02-17  67158.0
2   2017-02-20  67756.0
3   2017-02-21  68536.0
4   2017-02-22  68282.0
..         ...      ...


text:
Q: Dirac delta function composition rule after reviewing the properties of the Dirac delta function, I have a hard time figuring out one property: the composition rule.
Composition rule
I understand the integral form comes from a change of variable and by partitioning the domain around the roots of a function g, but I don't understand the first form.

A: Assume that $f \in C^\infty(\mathbb{R})$ satisfies $f(x_i) = 0$ with $f'(x_i) > 0.$ Then there is some interval $(x_i-\epsilon, x_i+\epsilon)$ on which $f'>0$ and $f$ is invertible. Then, using the substituion $y = f(x),\ dy = f'(x) \, dx,$
$$\begin{align}
\int_{x_i-\epsilon}^{x_i+\epsilon} \delta(f(x)) \, \varphi(x) \, dx
= \int_{f(x_i-\epsilon)}^{f(x_i+\epsilon)} \delta(y) \, \varphi(f^{-1}(y)) \, \frac{dy}{f'(f^{-1}(y))} \\
= \varphi(f^{-1}(0)) \, \frac{1}{f'(f^{-1}(0))}
= \varphi(x_i) \, \frac{1}{f'(x_i)} \\
= \frac{1}{f'(x_i)} \int_{x_i-\epsilon}^{x_i+\epsilon} \delta(x-x_i)\,\varphi(x)\,dx\\
= \int_{x_i-\epsilon}^{x_i+\epsilon} \frac{\delta(x-x_i)}{f'(x_i)} \,\varphi(x)\,dx
\end{align}$$
If instead $f'(x_i) < 0,$ then $f(x_i-\epsilon) > f(x_i+\epsilon)$ and we get
$$\begin{align}
\int_{x_i-\epsilon}^{x_i+\epsilon} \delta(f(x)) \, \varphi(x) \, dx
= \int_{f(x_i-\epsilon)}^{f(x_i+\epsilon)} \delta(y) \, \varphi(f^{-1}(y)) \, \frac{dy}{f'(f^{-1}(y))} \\
= \{ \text{ swapping integration limits } \} \\
= - \int^{f(x_i-\epsilon)}_{f(x_i+\epsilon)} \delta(y) \, \varphi(f^{-1}(y)) \, \frac{dy}{f'(f^{-1}(y))} \\
= - \varphi(f^{-1}(0)) \, \frac{1}{f'(f^{-1}(0))}
= - \varphi(x_i) \, \frac{1}{f'(x_i)} \\
= - \frac{1}{f'(x_i)} \int_{x_i-\epsilon}^{x_i+\epsilon} \delta(x-x_i)\,\varphi(x)\,dx\\
= - \int_{x_i-\epsilon}^{x_i+\epsilon} \frac{\delta(x-x_i)}{f'(x_i)} \,\varphi(x)\,dx
\end{align}$$
The two cases can be combined into
$$
\int_{x_i-\epsilon}^{x_i+\epsilon} \delta(f(x)) \, \varphi(x) \, dx
= \int_{x_i-\epsilon}^{x_i+\epsilon} \frac{\delta(x-x_i)}{|f'(x_i)|} \,\varphi(x)\,dx
$$
Taking all zeroes into account we get
$$
\int_{-\infty}^{\infty} \delta(f(x)) \, \varphi(x) \, dx
= \int_{-\infty}^{\infty} \sum_i \frac{\delta(x-x_i)}{|f'(x_i)|} \,\varphi(x)\,dx
,
$$
i.e.
$$
\delta(f(x))
= \sum_i \frac{\delta(x-x_i)}{|f'(x_i)|}
.
$$


text:
Q: Selenium search by tag name option I'm trying to get all data from a website called Correios. On this website, I need to handle some dropdowns which I'm having some issues with, like:
It's returning a list with a bunch of empty strings.
chrome_path = r"C:\\Users\\Gustavo\\Desktop\\geckodriver\\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
lista_x = []
driver.get("http://www2.correios.com.br/sistemas/agencias/")
driver.maximize_window()

dropdownEstados = driver.find_elements_by_xpath("""//*[@id="estadoAgencia"]""")

optEstados = driver.find_elements_by_tag_name("option")

for valores in optEstados:
    print(valores.text.encode())

And what I get from that is:
b''
b'ACRE'
b'ALAGOAS'
b'AMAP\xc3\x81'
b'AMAZONAS'
b'BAHIA'
b'CEAR\xc3\x81'
b'DISTRITO FEDERAL'
b'ESP\xc3\x8dRITO SANTO'
b'GOI\xc3\x81S'
b'MARANH\xc3\x83O'
b'MINAS GERAIS'
b'MATO GROSSO DO SUL'
b'MATO GROSSO'
b'PAR\xc3\x81'
b'PARA\xc3\x8dBA'
b'PERNAMBUCO'
b'PIAU\xc3\x8d'
b'PARAN\xc3\x81'
b'RIO DE JANEIRO'
b'RIO GRANDE DO NORTE'
b'ROND\xc3\x94NIA'
b'RORAIMA'
b'RIO GRANDE DO SUL'
b'SANTA CATARINA'
b'SERGIPE'
b'S\xc3\x83O PAULO'
b'TOCANTINS'
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''
b''

How can I remove the empty b" "?

A: If I understand it right, you want to locate all these options:

Try this XPath expression to locate the dropdown elements:
//*[@id="estadoAgencia"]/option

The code sample:
chrome_path = r"C:\\Users\\Gustavo\\Desktop\\geckodriver\\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
lista_x = []
driver.get("http://www2.correios.com.br/sistemas/agencias/")
driver.maximize_window()

dropdownEstados = driver.find_elements_by_xpath("//*[@id='estadoAgencia']")

# Find elements in dropdown
optEstados = driver.find_elements_by_xpath("//*[@id='estadoAgencia']/option")

for valores in optEstados:
    print(valores.text.encode())

Via this XPath expression you will get all dropdown elements, without empty strings except one, which is in this dropdown. Output:
b''
b'ACRE'
b'ALAGOAS'
b'AMAP\xc3\x81'
b'AMAZONAS'
b'BAHIA'
b'CEAR\xc3\x81'
b'DISTRITO FEDERAL'
b'ESP\xc3\x8dRITO SANTO'
b'GOI\xc3\x81S'
b'MARANH\xc3\x83O'
b'MINAS GERAIS'
b'MATO GROSSO DO SUL'
b'MATO GROSSO'
b'PAR\xc3\x81'
b'PARA\xc3\x8dBA'
b'PERNAMBUCO'
b'PIAU\xc3\x8d'
b'PARAN\xc3\x81'
b'RIO DE JANEIRO'
b'RIO GRANDE DO NORTE'
b'ROND\xc3\x94NIA'
b'RORAIMA'
b'RIO GRANDE DO SUL'
b'SANTA CATARINA'
b'SERGIPE'
b'S\xc3\x83O PAULO'
b'TOCANTINS'

Note: the first element is an empty string because of this:

A: There is a small change required in your code:
 dropdownEstados = driver.find_element_by_xpath("""//*[@id="estadoAgencia"]""")
 optEstados = dropdownEstados.find_elements_by_tag_name("option")

  for valores in optEstados:
     print(valores.text.encode())

A: To retrieve the text from all the <options> of the DropDown with id as estadoAgencia, as it is a <select> tag it would be much easier and efficient to use the methods associated with <select> tag and you can use the following solution:

*

*Code Block:
estado_select = Select(driver.find_element_by_id('estadoAgencia'))
for opt in estado_select.options:
    print(opt.get_attribute('innerHTML'))

*Console Output:
ACRE
ALAGOAS
AMAPÁ
AMAZONAS
BAHIA
CEARÁ
DISTRITO FEDERAL
ESPÍRITO SANTO
GOIÁS
MARANHÃO
MINAS GERAIS
MATO GROSSO DO SUL
MATO GROSSO
PARÁ
PARAÍBA
PERNAMBUCO
PIAUÍ
PARANÁ
RIO DE JANEIRO
RIO GRANDE DO NORTE
RONDÔNIA
RORAIMA
RIO GRANDE DO SUL
SANTA CATARINA
SERGIPE
SÃO PAULO
TOCANTINS


text:
Q: Ionic 1 FCM Push Notifications With Images I am working on ionic1 project. I need to display the push notifications with images in it for the Android platform. I am able to display the notifications with the text but images are not appearing somehow. I need some working solution for displaying image after the text in ionic1 in the notification bar.
I am using https://github.com/fechanique/cordova-plugin-fcm


text:
Q: Determining type of MFC object from HWND Further to this question I have decided to overwrite the PreTranslateMessage function of my main window CMainFrame to check if a WM_MOUSEWHEEL message has been sent, and if it has and the target of the message is a combo box then prevent the message from being dispatched.
However, I am having an issue determining if the target of the message is a combo box, here is what I am currently trying:
BOOL CMainFrame::PreTranslateMessage( MSG* pMsg )
{
      CWnd* pWnd = CWnd::FromHandle( pMsg->hwnd );
      if( pWnd )
      {
            if( pMsg->message == WM_MOUSEWHEEL )
            {
                    CRuntimeClass* pRuntimeClass = pWnd->GetRuntimeClass();
                    bool bIsCombo = pRuntimeClass->IsDerivedFrom( RUNTIME_CLASS(CComboBox) ) || pWnd->IsKindOf( RUNTIME_CLASS(CComboBox) );

                    if( bIsCombo && !reinterpret_cast<CComboBox*>(pWnd)->GetDroppedState() )
                         return TRUE;
            }
       }

       return CFrameWndEx::PreTranslateMessage( pMsg );

}

However, this doesn't work because the runtime class always seems to be CWnd, so I'm curious to know if there's a way to get this to work? Using a dynamic_cast from CWnd* to CComboBox* also didn't appear to work.
Thanks in advance!

A: GetClassName, which is what Captain Obvlious shows above is workable solution and will do what you want.
Of course, the sane solution (which I show in the question you link to) is to simply create a class derived from CComboBox and handle the WM_MOUSEWHEEL there in whichever way you feel is appropriate for your application. Then you can use the derived class instead of CComboBox simply by changing CComboBox to CNoScrollComboBox or whatever you name your class.
It's really quite simple and saves you a whole lot of trouble.

A: If the parent window does not subclass the combo box with CComboBox (or other suitable CWnd derived class) MFC will return a pointer to a temporary CWnd object. You have two options here. Subclass the combobox window when the parent is created  (in OnCreate on OnInitDialog) -OR- call GetClassName() and check the type of the target window when you handle the mouse wheel message.


text: Q: how to generate DTMF tones in j2me I was wondering if anyone has come across a way to generate DTMF tones in J2ME. I am trying to generate DTMF tones in J2ME, and can't seem to find anything substantial out there.  If anyone has any idea on where I would look for something like this, I would be very appreciative.


text:
Q: convergence rate of Pearson correlation I am looking to find the finest bound possible for $$\mathbb{P}\left( | \hat{\rho}(X,Y) - \rho(X,Y) | \geq t\right) \leq ?$$
where $\rho$ is the Pearson correlation defined as
$$\rho(X,Y) = \frac{\mathbb{E}[XY] - \mathbb{E}[X] \mathbb{E}[Y]}{\sqrt{\mathbb{E}[X^2] - \mathbb{E}[X]^2}\sqrt{\mathbb{E}[Y^2] - \mathbb{E}[Y]^2}} $$
and its statistical estimate
$$\hat{\rho}(X,Y) = \frac{\sum_{t=1}^T (X^t - \overline{X})(Y^t - \overline{Y})}{\sqrt{\sum_{t=1}^T \left(X^t - \overline{X}\right)^2}\sqrt{\sum_{t=1}^T \left(Y^t - \overline{Y}\right)^2}}$$
I think Fisher may have worked on it, but I did not find any relevant paper.

A: I derived the following bound, not sure if it's very sharp.
Here is the baseline: $X_i \sim \mathcal{N}(0,1)$, their correlation is $\rho$.
I transform the squared sum of Gaussian differences into squared sum of independent Gaussians ($\Delta_ij \sim 2(1-\rho)\mathcal{N}(0,1)$) which follow a $\chi^2(T)$. I then apply a $\chi^2$ tail inequality to obtain the result.
Hope it is correct.
\begin{eqnarray}
\mathbb{P}\left( \left|\hat{\rho}(X_i,X_j) - \rho(X_i,X_j) \right| \geq t \right) & = & \mathbb{P}\left( \left|\hat{\rho}(X_i,X_j) - \mathbb{E}\left[\hat{\rho}(X_i,X_j)\right] \right| \geq t \right) \\
& = & \mathbb{P}\left( \left| 1 - \frac{1}{2T}\sum_{t=1}^T \left(X_i^t - X_j^t \right)^2 - 1 + \frac{1}{2T}\mathbb{E}\left[ \sum_{t=1}^T \left(X_i^t - X_j^t \right)^2 \right] \right| \geq t \right) \\
& = & \mathbb{P}\left( \left| \sum_{t=1}^T \left(X_i^t - X_j^t \right)^2 - \mathbb{E}\left[ \sum_{t=1}^T \left(X_i^t - X_j^t \right)^2 \right] \right| \geq 2Tt \right) \\
& = & \mathbb{P}\left( 2(1-\rho) \left| \sum_{t=1}^T {\Delta_{ij}^t}^2 - \mathbb{E}\left[ \sum_{t=1}^T {\Delta_{ij}^t}^2 \right] \right| \geq 2Tt \right) \\
& = & \mathbb{P}\left( \left| \sum_{t=1}^T {\Delta_{ij}^t}^2 - \mathbb{E}\left[ \sum_{t=1}^T {\Delta_{ij}^t}^2 \right] \right| \geq \frac{Tt}{1-\rho} \right)
\end{eqnarray}
To conclude we use the following lemma and its corolary
Generalized exponential inequality for chi-square distributions (p. 1365)
Let $(Y_1,\ldots,Y_D)$ be i.i.d. Gaussian variables, with mean 0 and variance 1. Let $a_1,\ldots,a_D$ be nonnegative. We set $|a|_\infty = \sup_i |a_i|$ and $|a|_2^2 = \sum_{i=1}^D a_i^2$. Let $Z = \sum_{i=1}^D a_i(Y_i^2 - 1)$.
Then, the following inequalities hold for any positive $x$:
$$\mathbb{P}(Z \geq 2|a|_2 \sqrt{x} + 2|a|_\infty x) \leq \exp(-x)$$
$$\mathbb{P}(Z \leq -2|a|_2 \sqrt{x}) \leq \exp(-x)$$
As an immediate corrolary we obtain
Exponential inequality for chi-square distributions
Let $U$ be a $\chi^2$ with $D$ degrees of freedom.
For any positive $x$,
$$\mathbb{P}(U-D \geq 2 \sqrt{Tx} + 2x) \leq \exp(-x)$$
$$\mathbb{P}(D-U \geq 2 \sqrt{Tx}) \leq \exp(-x)$$
We obtain
$$\mathbb{P}\left(  \sum_{t=1}^T {\Delta_{ij}^t}^2 - \mathbb{E}\left[ \sum_{t=1}^T {\Delta_{ij}^t}^2 \right]  \geq \frac{Tt}{1-\rho} \right) \leq \exp\left\{ -\frac{1}{2}T \left(\sqrt{1 + \frac{2t}{1-\rho}} + 1 + \frac{t}{1-\rho} \right) \right\}$$
and
$$\mathbb{P}\left( \mathbb{E}\left[ \sum_{t=1}^T {\Delta_{ij}^t}^2 \right] - \sum_{t=1}^T {\Delta_{ij}^t}^2  \geq \frac{Tt}{1-\rho} \right) \leq \exp\left\{ -\frac{1}{4}T \frac{t^2}{(1-\rho)^2} \right\}$$
Therefore
$$\mathbb{P}\left( \left|  \sum_{t=1}^T {\Delta_{ij}^t}^2 - \mathbb{E}\left[ \sum_{t=1}^T {\Delta_{ij}^t}^2 \right] \right| \geq \frac{Tt}{1-\rho} \right) \leq \exp\left\{ -\frac{1}{4}T \frac{t^2}{(1-\rho)^2} \right\} + \exp\left\{ -\frac{1}{2}T \left(\sqrt{1 + \frac{2t}{1-\rho}} + 1 + \frac{t}{1-\rho} \right) \right\}$$
Finally,
$$\mathbb{P}\left( \left|\hat{\rho}(X_i,X_j) - \rho(X_i,X_j) \right| \geq t \right) \leq \exp\left\{ -\frac{1}{4}T \frac{t^2}{(1-\rho)^2} \right\} + \exp\left\{ -\frac{1}{2}T \left(\sqrt{1 + \frac{2t}{1-\rho}} + 1 + \frac{t}{1-\rho} \right) \right\}$$


text:
Q: iMacros Proxy Authentication - Not able to write login credentials I am not able to authenticate proxy address using iMacros.
The ONLOGIN doesn't work out.
Messed around it as well.
I need it to work.
If any other workaround, like using javascript or some EVAL command.
Look forward to answers,
I am using Firefox browser version 51, iMacros addon Version - 8.9.7


text:
Q: Как правильно подойти к верстке динамического шаблона? Наверно все знают про студии которые занимаются продажей шаблонов под разные движки. В админке есть настройки к шаблону, например в фотогалереи можно поставить разное количество колонок в определенном блоке, причем в другом месте сайта будет другое кол-во колонок. Как сие верстается и какими инструментами пользоваться? Хочу попробовать реализовать такое у себя в самописке, естественно не полностью. До селе верстал и как-то не думал об этом-:), а вот сегодня понял что куча страниц к каждому блоку (ведь может быть несколько вариантов отображения и не все они подойдут под общий html каркас) не есть хорошо. Проблема также и с выводом из БД сего если будет куча HTML макетов. Конечно подозреваю что частично JavaScript (который я мало знаю впрочем) решит мои проблемы, но боюсь опять упереться в стену. Может у кого-то есть опыт по реализации подобного?

A: Возможно, вы ищете muuri, sortable, isotope или packery.
Это даст повод для размышлений.


text:
Q: How to include angular syntax in Razor Can Angular syntax be included in Razor:
In the code below I am trying to say if "p.name" is not equal to "Select All"  display an image but I dont think I can include {{p.name}} in the if statement

        <input type="checkbox" ng-model="p.selected" />

        @if ("p.name" != "Select All") {

        }

        {{p.name}}

A: in Razor you are comparing two strings that will never be equal.  "p.name" != "Select All" will always be true.
This all takes place before angular.
In angular you can use ng-show

        <input type="checkbox" ng-model="p.selected" />

        {{p.name}}

A: You can't do that since Razor has no idea about what the value of p.name evaluates.
However you can achieve it with AngularJS


text:
Q: detecting disconnection from a WiFi access point I am trying to use a BroadcastReceiver to detect when the phone has disconnected from a WiFi access point. To do this, I registered my BroadcastReceiver in the manifest:
<receiver android:name="com.eshayne.android.WiFiBroadcastReceiver">
    <intent-filter>
        <action android:name="android.net.wifi.STATE_CHANGE" />
    </intent-filter>
</receiver>

In my WiFiBroadcastReceiver class, I am checking for a NETWORK_STATE_CHANGED_ACTION action and looking at the NetworkInfo's detailed state:
if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
    NetworkInfo info = (NetworkInfo)intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
    android.util.Log.d("com.eshayne.android.WiFiBroadcastReceiver", "network state change - detailedState=" + info.getDetailedState() + ": " + info.toString());
    if (info.getDetailedState() == DetailedState.DISCONNECTED) {
        ...
    }
    else if (info.getDetailedState() == DetailedState.CONNECTED) {
        ...
    }

The problem I'm seeing is that when the phone leaves the WiFi access point's range, my "disconnected" callback gets called 6 times - pretty regularly at about once every 15 seconds - before it stops. So far I haven't been able to find any distinguishing characteristics between each callback's NetworkInfo. Each NetworkInfo object being written to the log looks like this:
02-18 10:16:51.918 D/com.eshayne.android.WiFiBroadcastReceiver( 1511): network state change - detailedState=DISCONNECTED: NetworkInfo: type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true

It's also not an issue of the phone wandering in and out of WiFi range, as my "connected" callback is not called in between "disconnected" callbacks. Nor are any other states being triggered in between. Just a rapid series of 6 callbacks each with a detailedState of DISCONNECTED.
Is there a better way for me to detect when the phone has lost its WiFi connection, so that my callback only gets called once per disconnect? Or any way to detect which of the 6 callbacks I'm seeing is the "final" one?

A: You say it's a "rapid series of 6 disconnected callbacks", but your if/else-if only checks for DISCONNECTED and CONNECTED, with what looks like no default block to handle all other cases.  From the NetworkInfo.DetailedState api page, there's 10 possible states that could be returned by NetworkInfo.getDetailedState(), including "connecting", "scanning", "disconnecting", all of which would be plausible behavior for a phone that just got disconnected from a network.
Throw down a default case that alerts you to any change in wifi state, not just "CONNECTED" and "DISCONNECTED".  You might find that the phone is rotating between several different states, and not just shotgunning the same one at you six times. Hopefully from there, how to proceed in your code will be a little clearer.

A: One workaround you could use is to maintain your last callback action somewhere (global state, shared preferences, etc.) and only run your callbacks if the action has changed.
enum NetworkCallbackAction { None, Disconnected, Connected };
NetworkCallbackAction lastHandledAction = NetworkCallbackAction.None;

// ...

if (info.getDetailedState() == DetailedState.DISCONNECTED) {
  if (lastHandledAction != NetworkCallbackAction.Disconnected) {
    lastHandledAction = NetworkCallbackAction.Disconnected;
    // ...
  }
}
else if (info.getDetailedState() == DetailedState.CONNECTED) {
  if (lastHandledAction != NetworkCallbackAction.Connected) {
    lastHandledAction = NetworkCallbackAction.Connected;
    // ...
  }
}

A nicer abstraction of this logic would be to write a broadcast receiver who's only job is to normalize the network state changes into consistent events and smooth out the real-world quirks, and then re-broadcast its own actions. This allows you to simplify the raw updates into something that makes sense for your application. It could, for example, remember it's last broadcasts and only broadcast changes (similar to what the code above does). In case of bursts of network change intents it could wait a few seconds before broadcasting the last state it received.


text:
Q: FM signal strength of Android I want to know the FM Radio signal strength in Android. For this I have to interact with hardware or not? Or is there any API which can directly give me the value of signal strength?

A: FM radio is available in some phones. Anyways you must have an FM tuner (radio) built-in.

For this I have to interact with
  hardware or not?

Yes, of course you will have to as it has not been brought into the stack.

is there any API which can directly give me the value of signal strength?

I think, NO.
Maybe you will have to write your own jni, and java source and add it to the stack, if you need one.


text:
Q: What is the connection map? In my symplectic geometry homework I have this exercise: Let $Q$ be a manifold, $\pi:T^*Q\to Q$ be the projection map, and $\kappa:T(T^*Q)\to T^*Q$ be the connection map. Prove that the standard symplectic form $\omega_0$ on $T^*Q$ for $\xi,\eta\in T(T^*Q)$ has the form $\omega_0(\xi,\omega)=\kappa(\xi)[d\pi(\eta)]-\kappa(\eta)[d\pi(\xi)]$.
Due to my lacklustre differential geometric background I do not know what the connection map is, despite having tried searching online. Is someone able to explain or define it in a self-contained manner, or provide a link where this is done? My background is a course on smooth manifolds, and riemannian geometry 'as taught in physics'.

A: Here is an attempt to reverse engineer what $\kappa$ should be, by using Darboux coordinates $(x^i, p_i)$ for $T^*Q$. Write $$\xi = \xi^i \partial_{x^i}+\xi_i\partial_{p_i} \quad\mbox{and}\quad \eta = \eta^i\partial_{x^i} + \eta_i \partial_{p_i}, $$and here I'm using Einstein's convention. We know that $$  \omega_0 = {\rm d}x^i\wedge {\rm d}p_i $$implies that $$\omega_0(\xi,\eta) = \xi^i\eta_i -\eta^i\xi_i. $$Noting that $${\rm d}\pi(\xi) = \xi^i\partial_{x^i} \quad \mbox{and}\quad {\rm d}\pi(\eta) = \eta^i\partial_{x^i},$$one guess would be that $\kappa(\xi)({\rm d}\pi(\eta))$ is $\xi^i\eta_i$, but the index balance required by Einstein's convention hints that this is not the case, as we'll need $\kappa(\xi)\colon TQ \to \Bbb R$ and here we have $\eta_i$ instead of $\eta^i$. So the only other choice is to say that $\kappa(\eta)({\rm d}\pi(\xi)) = -\eta_i\xi^i$. This would lead us to $\kappa(\eta)(v) = -\eta_iv^i = -\eta_i\,{\rm d}x^i(v)$.
That said, the challenge is writing this in a coordinate-free way. But $TT^*Q$ has natural horizontal and vertical distributions (namely, spanned by the $\partial_{x^i}$ and the $\partial_{p_i}$ -- and this does not depend on the choice of coordinates), and $\eta_i\,{\rm d}x^i$ is the covector corresponding to the vertical projection of $\eta$ under the isomorphism $\eta_i\,{\rm d}x^i \cong \eta_i\partial_{p_i}$: any vertical tangent vector in $T_{(x,p)}(T^*Q)$ is identified with an element of $T^*_xQ$, since the tangent space to a vector space at any point is itself (note that the index balance required by Einstein's convention is still respected, as the $i$ in $\partial_{p_i}$ counts as an upper index).
This means we get our conclusion: $\kappa(\xi)$ should be minus the covector corresponding to the vertical projection of $\xi$.


text:
Q: Appcelerator Titanium external libraries I am using appcelerator titanium and i am trying to build a mobile app that allows you to change an imageview brightness and contrast by using touch events.
It is not possible by using Titanium standard features, so i am guessing if i can import some external libraries like pixastic that can help me do so.
is it possible? how can i do that?
Thanks

A: sure. pixastic is a javascript library so just include it with
Ti.include("path/to/pixastic");

if you intent to write a native code for your algorithms you can enrich your project with a objective-c module (or java module).


text:
Q: Android Studio: How to add new Components to Palette? How do I add new components (like SpinEdits etc.) and categories to my palette? Other sites points to the SDK Manager, but I installed all the SDK Tools and it did not work. I could not find any other option there for adding new components.

A: You can add them as dependencies to your project structure.
Go to File -> Project Structure.
However, you should first consider what feature you want to add. You can add any feature by typing the artifact it belongs to. Of course, you can find its artifact in its documentation page. For example, if you are trying to add CardView,
then you should go to this page:
https://developer.android.com/reference/android/support/v7/widget/CardView
and you should find its artifact as:
com.android.support  cardview-v7:28.0.0-alpha1


text:
Q: maximization of harmonic mean Suppose x is a vector of size N with positive real elements  sorted in decreasing order. Is it possible to find the analytical solution (no iterative solution) to the optimum value of M (1<= M <= N) whether $$M \log \left(1+\frac{M}{\sum_{i=1}^M \frac{1}{x_i}}\right)$$ is maximized?

A: The naive method of just evaluating
$$f(M) = M\log\left(1+\frac{M}{\sum_{i=1}^M\frac{1}{x_i}}\right)$$
is an $O(N)$ algortithm.  Since one can, by choosing
$$x_N = 1 \\
x_{N-k} = 1+(k-1)\epsilon \text{ when } n-k > m_0 \\
x_{N-k} = k+1 \text{ when } n-k \geq m_0 \\
$$ with $\epsilon$ sufficiently small always adjust the $\{x_i\}$ such that to the optimum value of $M$ is at the arbitrarily chosen $m_0$, there can be no algorithm that is better than $O(N)$ (that is, no "not-iterative" solution).