text:
Q: Delete Blank Rows in an Excel table I'm trying to delete all rows where cells in column S are blank as part of a table ("Table1").
I receive an error "400".
This macro works if I replace & LastRow with a number, "S2:S1000" for example.
Sub deleteBlankRows()

    Dim LastRow As Long
    LastRow = Range("B" & Rows.Count).End(xlUp).Row

    With Range("S2:S" & LastRow)
        .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End With

End Sub

A: Assuming the rows you want to delete are only in the table, you can also work directly with the table object itself.
With ListObjects("Table1")
     .ListColumns("myColumnName").DataBodyRange.SpecialCells(xlCellTypeBlanks).Rows.Delete
End With

A: The error occurs because you are deleting entire rows from a table. You can convert the table to range, or use Rows rather than EntireRow in the macro:
Sub deleteBlankRows()

Dim LastRow As Long

With ThisWorkbook.Worksheets("YourSheetName")

    LastRow = .Range("B" & .Rows.Count).End(xlUp).Row

    With .Range("S2:S" & LastRow)
        .SpecialCells(xlCellTypeBlanks).Rows.Delete
    End With

End With

End Sub


text:
Q: How can I install VMware Workstation 8 on Ubuntu 14.04? I installed VMware Workstation 8 on Ubuntu 14.04, but when I run it, it fails to compile/build the modules with an error saying "Unable to start services."
Here is the modconfig log:
2014-11-10T10:57:16.143-08:00| vthread-3| I120: Log for VMware Workstation pid=5268 version=8.0.6 build=build-1035888 option=Release
2014-11-10T10:57:16.143-08:00| vthread-3| I120: The process is 64-bit.
2014-11-10T10:57:16.143-08:00| vthread-3| I120: Host codepage=UTF-8 encoding=UTF-8
2014-11-10T10:57:16.143-08:00| vthread-3| I120: Host is Linux 3.13.0-39-generic Ubuntu 14.04.1 LTS
2014-11-10T10:57:16.143-08:00| vthread-3| I120: Msg_Reset:
2014-11-10T10:57:16.143-08:00| vthread-3| I120: [msg.dictionary.load.openFailed] Cannot open file "/usr/lib/vmware/settings": No such file or directory.
2014-11-10T10:57:16.143-08:00| vthread-3| I120: ----------------------------------------
2014-11-10T10:57:16.143-08:00| vthread-3| I120: PREF Optional preferences file not found at /usr/lib/vmware/settings. Using default values.
2014-11-10T10:57:16.143-08:00| vthread-3| I120: Msg_Reset:
2014-11-10T10:57:16.143-08:00| vthread-3| I120: [msg.dictionary.load.openFailed] Cannot open file "/root/.vmware/config": No such file or directory.
2014-11-10T10:57:16.143-08:00| vthread-3| I120: ----------------------------------------
2014-11-10T10:57:16.143-08:00| vthread-3| I120: PREF Optional preferences file not found at /root/.vmware/config. Using default values.
2014-11-10T10:57:16.143-08:00| vthread-3| I120: Msg_Reset:
2014-11-10T10:57:16.143-08:00| vthread-3| I120: [msg.dictionary.load.openFailed] Cannot open file "/root/.vmware/preferences": No such file or directory.
2014-11-10T10:57:16.143-08:00| vthread-3| I120: ----------------------------------------
2014-11-10T10:57:16.143-08:00| vthread-3| I120: PREF Failed to load user preferences.
2014-11-10T10:57:16.143-08:00| vthread-3| W110: Logging to /tmp/vmware-root/modconfig-5268.log
2014-11-10T10:57:16.262-08:00| vthread-3| I120: modconf query interface initialized
2014-11-10T10:57:16.262-08:00| vthread-3| I120: modconf library initialized
2014-11-10T10:57:16.306-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:57:16.310-08:00| vthread-3| I120: Validating path /lib/modules/preferred/build/include for kernel release 3.13.0-39-generic
2014-11-10T10:57:16.310-08:00| vthread-3| I120: Failed to find /lib/modules/preferred/build/include/linux/version.h
2014-11-10T10:57:16.310-08:00| vthread-3| I120: Failed version test: /lib/modules/preferred/build/include/linux/version.h not found.
2014-11-10T10:57:16.310-08:00| vthread-3| I120: Validating path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic
2014-11-10T10:57:16.312-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:57:16.323-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:57:16.337-08:00| vthread-3| I120: Header path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic is valid.
2014-11-10T10:57:16.337-08:00| vthread-3| I120: Validating path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic
2014-11-10T10:57:16.339-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:57:16.349-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:57:16.363-08:00| vthread-3| I120: Header path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic is valid.
2014-11-10T10:57:16.382-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.385-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.387-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.389-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.390-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.408-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.410-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.412-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.415-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.418-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.421-08:00| vthread-3| I120: Validating path /lib/modules/preferred/build/include for kernel release 3.13.0-39-generic
2014-11-10T10:57:16.421-08:00| vthread-3| I120: Failed to find /lib/modules/preferred/build/include/linux/version.h
2014-11-10T10:57:16.421-08:00| vthread-3| I120: Failed version test: /lib/modules/preferred/build/include/linux/version.h not found.
2014-11-10T10:57:16.421-08:00| vthread-3| I120: Validating path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic
2014-11-10T10:57:16.423-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:57:16.433-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:57:16.446-08:00| vthread-3| I120: Header path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic is valid.
2014-11-10T10:57:16.465-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.467-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.470-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.473-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.475-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.478-08:00| vthread-3| I120: Validating path /lib/modules/preferred/build/include for kernel release 3.13.0-39-generic
2014-11-10T10:57:16.478-08:00| vthread-3| I120: Failed to find /lib/modules/preferred/build/include/linux/version.h
2014-11-10T10:57:16.478-08:00| vthread-3| I120: Failed version test: /lib/modules/preferred/build/include/linux/version.h not found.
2014-11-10T10:57:16.478-08:00| vthread-3| I120: Validating path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic
2014-11-10T10:57:16.480-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:57:16.489-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:57:16.502-08:00| vthread-3| I120: Header path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic is valid.
2014-11-10T10:57:16.535-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.537-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.539-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.542-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.545-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.905-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:57:16.905-08:00| vthread-3| I120: Validating path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic
2014-11-10T10:57:16.908-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:57:16.918-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:57:16.931-08:00| vthread-3| I120: Header path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic is valid.
2014-11-10T10:57:16.931-08:00| vthread-3| I120: Building module vmmon.
2014-11-10T10:57:16.932-08:00| vthread-3| I120: Extracting the sources of the vmmon module.
2014-11-10T10:57:16.977-08:00| vthread-3| I120: Building module with command: /usr/bin/make -j -C /tmp/vmware-root/modules/vmmon-only auto-build SUPPORT_SMP=1 HEADER_DIR=/lib/modules/3.13.0-39-generic/build/include CC=/usr/bin/gcc GREP=/usr/bin/make IS_GCC_3=no VMCCVER=4.8
2014-11-10T10:58:51.945-08:00| vthread-3| I120: Installing module vmmon from /tmp/vmware-root/modules/vmmon.o to /lib/modules/3.13.0-39-generic/misc.
2014-11-10T10:58:51.964-08:00| vthread-3| I120: Registering file: /usr/lib/vmware-installer/2.0/vmware-installer --register-file vmware-vmx regular /lib/modules/3.13.0-39-generic/misc/vmmon.ko
2014-11-10T10:59:03.867-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:59:03.867-08:00| vthread-3| I120: Validating path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic
2014-11-10T10:59:03.870-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:59:03.880-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:59:03.892-08:00| vthread-3| I120: Header path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic is valid.
2014-11-10T10:59:03.892-08:00| vthread-3| I120: Building module vmnet.
2014-11-10T10:59:03.892-08:00| vthread-3| I120: Extracting the sources of the vmnet module.
2014-11-10T10:59:03.933-08:00| vthread-3| I120: Building module with command: /usr/bin/make -j -C /tmp/vmware-root/modules/vmnet-only auto-build SUPPORT_SMP=1 HEADER_DIR=/lib/modules/3.13.0-39-generic/build/include CC=/usr/bin/gcc GREP=/usr/bin/make IS_GCC_3=no VMCCVER=4.8
2014-11-10T10:59:24.963-08:00| vthread-3| I120: Failed to compile module vmnet!
2014-11-10T10:59:24.968-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:59:24.968-08:00| vthread-3| I120: Validating path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic
2014-11-10T10:59:24.971-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:59:24.981-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:59:24.993-08:00| vthread-3| I120: Header path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic is valid.
2014-11-10T10:59:24.994-08:00| vthread-3| I120: Building module vmblock.
2014-11-10T10:59:24.994-08:00| vthread-3| I120: Extracting the sources of the vmblock module.
2014-11-10T10:59:25.019-08:00| vthread-3| I120: Building module with command: /usr/bin/make -j -C /tmp/vmware-root/modules/vmblock-only auto-build SUPPORT_SMP=1 HEADER_DIR=/lib/modules/3.13.0-39-generic/build/include CC=/usr/bin/gcc GREP=/usr/bin/make IS_GCC_3=no VMCCVER=4.8
2014-11-10T10:59:37.173-08:00| vthread-3| I120: Failed to compile module vmblock!
2014-11-10T10:59:37.179-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T10:59:37.179-08:00| vthread-3| I120: Validating path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic
2014-11-10T10:59:37.182-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:59:37.193-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T10:59:37.206-08:00| vthread-3| I120: Header path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic is valid.
2014-11-10T10:59:37.206-08:00| vthread-3| I120: Building module vmci.
2014-11-10T10:59:37.206-08:00| vthread-3| I120: Extracting the sources of the vmci module.
2014-11-10T10:59:37.248-08:00| vthread-3| I120: Building module with command: /usr/bin/make -j -C /tmp/vmware-root/modules/vmci-only auto-build SUPPORT_SMP=1 HEADER_DIR=/lib/modules/3.13.0-39-generic/build/include CC=/usr/bin/gcc GREP=/usr/bin/make IS_GCC_3=no VMCCVER=4.8
2014-11-10T11:00:32.559-08:00| vthread-3| I120: Failed to compile module vmci!
2014-11-10T11:00:32.564-08:00| vthread-3| I120: Trying to find a suitable PBM set for kernel 3.13.0-39-generic.
2014-11-10T11:00:32.564-08:00| vthread-3| I120: Validating path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic
2014-11-10T11:00:32.567-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T11:00:32.577-08:00| vthread-3| I120: Your GCC version: 4.8
2014-11-10T11:00:32.590-08:00| vthread-3| I120: Header path /lib/modules/3.13.0-39-generic/build/include for kernel release 3.13.0-39-generic is valid.
2014-11-10T11:00:32.590-08:00| vthread-3| I120: Building module vmci.
2014-11-10T11:00:32.590-08:00| vthread-3| I120: Extracting the sources of the vmci module.
2014-11-10T11:00:32.606-08:00| vthread-3| I120: Building module with command: /usr/bin/make -j -C /tmp/vmware-root/modules/vmci-only auto-build SUPPORT_SMP=1 HEADER_DIR=/lib/modules/3.13.0-39-generic/build/include CC=/usr/bin/gcc GREP=/usr/bin/make IS_GCC_3=no VMCCVER=4.8
2014-11-10T11:00:43.496-08:00| vthread-3| I120: Failed to compile module vmci!

Thanks for the help!!

A: Open Terminal
sudo apt-get install open-vm-tools open-vm-tools-dev open-vm-dkms open-vm-toolbox open-vm-tools-dev

This should do the trick, let me know though!

redpajama_set_name: RedPajamaStackExchange


text:
Q: create a function with proper scope I need to create a script to authenticate to a remote PC and access to PS console. It actually works, but I need to execute a number of commands when I need to terminate this session.
So I create a function STOP to be called to terminate the session, but it can't be used.
Is this a problem of scope (because it's inside an if statement)? If I manually create the same function and then I try to call it... It works!
# get connection parameters
$credential = Get-Credential -Credential xxx
$remote_PC = Read-Host "Insert the server name or IP (Q to abort): "
# connect
if (someKindOfCheck) {
    Enter-PSSession -ComputerName $remote_PC -Credential $credential
    # some commands
    function STOP {
        Exit-PSSession;
        # some commands
    }
}

A: I've come across a similar issue before, and I resolved it by creating  a New-PSSession and assigning it to a varialbe, I then use the Invoke-Command with -Session option to execute the required commands.

A: Enter-PSSession is only for interactive use (once you've entered that session it only takes input from the console).
The only way I can think of that would make this work "automagically" would be to create a custom remoting session on the target machine that implements a proxy function for Exit-PSSession,  and put your commands in that function.


text:
Q: Convert Multiple CSVs into a Single XML with Python I'm able to write a single csv to an XML, but I want to take multiple csv files and put all of the data into a single xml.
The code I'm using to convert a single csv to a single xml is:
f = open('Final Mission Arvada Import\Import Files\Client_Final.csv')
csv_f = csv.reader(f)
next(csv_f, None)
data = []

for row in csv_f:
    data.append(row)
f.close()

def convert_row(row):
    return """
      <hmis:Client hmis:dateCreated="%s" hmis:dateUpdated="%s" hmis:userID="%s">
        <hmis:PersonalID>%s</hmis:PersonalID>
        <hmis:FirstName hmis:hashStatus="1">%s</hmis:FirstName>
        <hmis:MiddleName hmis:hashStatus="1">%s</hmis:MiddleName>
        <hmis:LastName hmis:hashStatus="1">%s</hmis:LastName>
      </hmis:Client>""" % (row[1],row[2],row[3],row[4],row[5],row[6],row[7])

with open('Client.xml', 'w') as f:
    f.write('\n'.join([convert_row(row) for row in data]))

how can I then add additional information to the same xml from another csv?


text:
Q: A CD players plays songs until a certain artist is selected.
Suppose you have a CD player with 10 CDs where 9 of those CDs belong to an artist A and 1 CD belongs to an artist B.  Suppose this CD player will pick a CD at random, and from that CD it will pick a song.  It will repeat this process until it picks a song from artist B.  At which point it will turn off.
Give the probability that the CD player turns off after:
(a)  The sixth song.
  (b)  At least five songs.
  (c)  Now suppose that the CD player will run until two songs have been played by artist B.

For this problem I believe we use the geometric distribution because we want this to run until it fails.  I'm still working on developing intuition for geometric vs binomial vs negative binomial.
(a) $\frac{1}{10}\left(\frac{9}{10}\right)^5$
(b)  $P(\text{At least five songs A})=1-P(\text{At most five songs by artist A})=1-\sum\limits_{n=1}^{5}\left(\frac{9}{10}\right)^{n-1}.$
(c)  $\binom{3}{1}\left(\frac{1}{10}\right)^2\left(\frac{9}{10}\right)^2$

A: a) is correct.
b) $$1-\sum_{n=1}^4P(\text{off after the }n\text{-th song})=1-\sum_{n=1}^4 \frac1{10}\left(\frac{9}{10}\right)^{n-1}$$
ci) There will be turned off after the $6$-th song if this song is from B and exactly one of the preceding $5$ songs is from B. These events have probabilities: $\frac{1}{10}$ and $\binom51\frac1{10}\left(\frac9{10}\right)^4$ respectively, and are independent. So we end up with a probability:$$\binom51\left(\frac1{10}\right)^2\left(\frac9{10}\right)^4$$
cii) There will be turned off after at least $5$ songs if among the first $4$ there is at most $1$ song from B. Can you handle it from here?


text:
Q: OpenAM custom realm for J2EE Agent I have an issue to force openAM to log in using my custom realm.
I have configured my J2EE tomcat agent to use my custom realm /stmdevrealm:
com.sun.identity.agents.config.organization.name =stmdevrealm

My login page is accessible on http://login.stmdev.comp:9150/openam/UI/Login and my protected app is available on http://app.stmdev.comp:9140/agentsample/
When I try to log in to realm using http://login.stmdev.comp:9150/openam/UI/Login?realm=stmdevrealm I am able to log in successfully. However, when I'm accessing my protected app it uses default / realm.
Realm/DNS Aliases for "/" is set as
login.stmdev.comp

for "app" it is set as:
 app.stmdev.comp

What did I miss? How to force my agent to use right realm?

A: The realm where the agent profile exists is not related to the realm where user's should authenticate against.
Either change login URL property in the agent profile as you mentioned or use a separate DNS alias /FQDN for your sub-realm and specify this one.
However you need to consider the other use-case as well, where users have already a valid SSO Session but are authenticated in a different realm.
If you do not want to allow those users access to the protected app you need a proper policy condition


text:
Q: zend: baseUrl view helper returns empty string On my site, when I call $this->baseUrl() in a view, it returns an empty string. I would expect it to return e.g. http://www.foobar.com/. Do I need to manually set base url?
In manual to Zend_Application_Resource_Frontcontroller - configuration keys, I have just found this:

baseUrl: explicit base URL to the application (normally auto-detected)

Any ideas why it is not autodetected for me?

A: The baseUrl() helper returns the path to your Zend Application.
Use the serverUrl() helper for the hostname.

A: Did you set the baseurl in your application.ini?
resources.frontController.baseUrl = "/subdir"

Manual


text:
Q: Ejabberd/XMPP Chat Server I am looking to build a chat server using EJABBERD and XMPP but don't know how to start. Can anyone share with me good docs/tutorials to follow as a beginner.
Also, does ejabberd include a database for storing chat messages, if so please provide some help as to where to begin.
I have tried using Nodejs and socket.io but I faced multiple problems such as ghost connections, duplicate messages on android client. So, I have decided to look at some alternatives.
Thanks.

A: Your start point is
1) For xmpp server : https://github.com/processone/ejabberd or https://prosody.im
2) Read Book: xmpp definitive guide
3) Read blog for android client: http://www.blikoontech.com/tutorials/android-smack-xmpp-introductionbuilding-a-simple-client
Yes, ejabberd provides MySQL support to store chat messages.


text:
Q: Does Connection Pooling makes Java Swing Application works faster for remote MySQL database I have Created an Java Swing Application with MySQL as the database, Now i am hosting my MySQL database online and Swing Application will be stored locally, Now in order to experiment i have hosted my database i.e MySQL database on https://www.freemysqlhosting.net/ account as it allows free hosting for certain period, Also Connection is successfull and works but the application works too slow suppose if i have to search any entry from the swing aplication from the oline hosted database it works too slow,it is happening like i have to press any key or button and has to wait for the processing of the transaction. Does connection pooling technique will solve the performance issues, If yes which is best one and if not what can i do to solve this. Please Help
Below is the code which i have written to make database transactions and i am doing this everytime i make a database access
public  ArrayList<ChargeSheet> readByAllCompanyInfo(String cityname)
{
ArrayList<ChargeSheet> list = new ArrayList<ChargeSheet>();
con=db.getConnection();
try{
    pst = con.prepareStatement("select * from tblcompanyinformation where companyname = ?");
    pst.setString(1,cityname);
    rs = pst.executeQuery();
    while(rs.next()){
        ChargeSheet clientInformation=new ChargeSheet();
        clientInformation.setRecieptno(rs.getInt(2));
        clientInformation.setPresentdate(rs.getString(3));
        clientInformation.setCompanyname(rs.getString(4));
        clientInformation.setPhone(rs.getString(5));
        list.add(clientInformation);
    }
}
catch(SQLException ex){
    setLastError(ex.getMessage());
}
finally{
    db.closeConnection();
}
return list;
}

A: With that code, it is likely that using a connection pool will improve performance.  Especially if you are using SSL-enabled connections.
(Of course, this assumes that you use the same pool for connecting.)

If yes which is best one ....

Recommendations are Off-Topic for StackOverflow, but I'm sure you could find a website that lists and compares some popular alternatives.


text:
Q: Where is "Well" needed in the Transfinite Recursion Theorem? The transfinite recursion theorem asserts
Let $R$ be a well-founded relation on $U$ and let $\digamma$ be a $R$-recursive rule on $U$. There is a unique function $f$ such that $\operatorname{dom}(f)=U$ and $f(x)=\digamma\left(x,f\restriction R^{-}[x]\right)$ for every $x\in U$.
I have a proof which is the standard one based on setting $f=\bigcup H$ where $h\in H$ iff $h$ is a function, and $\operatorname{dom}(h)$ is $R$-transitive in $U$, and $h(x)=\digamma\left(x,h\restriction R^{-}[x]\right)$ for every $x\in \operatorname{dom}(h)$.
I can't see where "wellness" comes into the proof, by which I mean I don't seem to need that $R^{-}[x]=\left\{ z\in U\mid z\mathbin Rx\right\}$ is a set for every $x$. I am using MK class theory not ZFC.
Can someone comment on the role of "wellness" in the proof in ZFC and whether it is still needed in the corresponding MK proof?

A: The condition for $R$ being well-founded is not that $R^-[x]$ is always a set (if that was all, every relation on a set would be well-founded), but that every non-empty subset of $U$ has an $R$-minimal element.
As an example of a relation that doesn't have this property, consider the usual ordering $<$ on the closed unit interval $[0,1]$. The recursion theorem would fail for this set -- for example, consider
$$ \digamma(x,h) = \begin{cases} 0 & \text{if }[0,1]\cap\operatorname{Rng}h=\varnothing \\
\sup ([0,1]\cap \operatorname{Rng} h) & \text{otherwise} \end{cases} $$
This ought to satisfy your concept of a "$<$-recursive rule" on $[0,1]$.
However, this rule does not give rise to a unique $f$ -- in fact, every continuous non-decreasing $f:[0,1]\to[0,1]$ with $f(0)=0$ will satisfy the condition
$$ f(x)=\digamma\left(x,f\restriction R^{-}[x]\right) $$
so the recursion rule did not succeed in picking out a particular one among them.

The proof goes wrong in this case because $\bigcup H$ is not necessarily a function. In order to prove that it is, one needs the "well-founded" condition on $R$.

A: I am going to answer my own question. I had a lot of trouble finding
a simple proof of the recursion theorem online in the form I wanted, so will
post the one I eventually have put together. I am using MK class theory although that shouldn't be too relevant. Hopefully it is all correct, please let me know if there are errors.
Let $R$ be a relation on class $U$. Recall that $R$ is founded
on $U$ if every $X\subseteq U\setminus\left\{ \varnothing\right\} $
has an $m\in X$ such that $X\cap R^{-}\left[m\right]=\varnothing$,
we call any such $m$ an $R$-first member of $X$. We say $R$ is
well-founded on $U$ if it is founded on $U$ and $R^{-}\left[x\right]:=\left\{ z\mid zRx\right\} $
is a set for every $x\in U$.
Given any $X\subseteq U$ we say $X$ is $R$-inductive on $U$ iff
for any $x\subseteq U$, if $R^{-}\left[x\right]\subseteq X$ then
$x\in X$.
Transfinite Induction Theorem: Let $R$ be a founded relation on $U$
and $X\subseteq U$. If $X$ is $R$-inductive in $U$ then $X=U$.
Proof: Suppose for contradiction that $X\subset U$ then $U\setminus X\neq\varnothing$
and so there is an $m\in U\setminus X$ such that $x\notin R^{-}\left[m\right]$
for any $x\in U\setminus X$. If $x\in R^{-}\left[m\right]$ then
we must have $x\in X$, otherwise we would have $x\in U\setminus X$
contrary to the selection of $m$ using foundedness, so $R^{-}\left[m\right]\subseteq X$
but $X$ is $R$-inductive so $m\in X$ contrary to $m\in U\setminus X$,
absurd. Hence $X\subseteq U$ but $X\not\subset U$ so $X=U$.$\square$
We say $\digamma$ is a $R$-recursive rule on $U$ if it is a function
and $\left\langle x,f\right\rangle \in\text{dom}\digamma$ whenever
$x\in U$ and $f$ is a function with $R^{-}\left[x\right]\subseteq\text{dom}f$.
Hence being a rule is a constraint on the domain of $\digamma$. We
require $f$ to be set so that $\left\langle x,f\right\rangle \in\text{dom}\digamma$
makes sense.
Transfinite Recursion Theorem: Let $R$ be a well-founded relation
on $U$ and let $\digamma$ be a $R$-recursive rule on $U$, There
is a unique function $f$ such that $\text{dom}f=U$ and $f\left(x\right)=\digamma\left(x,f\restriction R^{-}\left[x\right]\right)$
for every $x\in U$.$\square$
We will prove the recursion theorem by a sequence
of definitions and lemmas.
We say $T$ is $R$-transitive in $U$ iff $T\subseteq U$ and $R^{-}\left[x\right]\subseteq T$
whenever $x\in T$. Clearly $U$ and $\varnothing$ are $R$-transitive
in $U$ and the $R$-transitive subclasses of $U$ are closed under
arbitrary intersections and unions.
Lemma: For every $A\subseteq U$ there is a smallest $R$-transitive
class $T$ such that $A\subseteq T$.
Proof: Set $T:=\bigcap\left\{ S\subseteq U\mid A\subseteq S\text{ and }S\text{ is }R\text{-transitive}\right\} $,
this definition works because $U$ is $R$-transitive by closure under
arbitrary intersections.$\square$
Next is the key lemma which is used several times in the following
proofs.
Lemma: Suppose $g,h$ are functions whose domains are $R$-transitive
in $U$ and are such that $g\left(x\right)=\digamma\left(x,g\restriction R^{-}\left[x\right]\right)$
and $h\left(x\right)=\digamma\left(x,h\restriction R^{-}\left[x\right]\right)$
for every $x$ in their respective domains, then $g=h$ on $\text{dom}g\cap\text{dom}h$.
Proof: First note that for any $x\in\text{dom}g\cap\text{dom}h$ we
have $R^{-}\left[x\right]\subseteq\text{dom}g\cap\text{dom}h$
 by $R$-transitivity, so $g\restriction R^{-}\left[x\right]$ and
$h\restriction R^{-}\left[x\right]$ are sets by well-foundedness
and so can participate in the domain of $\digamma$.
Let $S:=\left\{ x\in\text{dom}g\cap\text{dom}h\mid g\left(x\right)\neq h\left(x\right)\right\} $.
Suppose for contradiction that $S\neq\varnothing$ and let $m$ be
an $R$-first member of $S$. Since $m\in\text{dom}g\cap\text{dom}h$
we have $R^{-}\left[m\right]\subseteq\text{dom}g\cap\text{dom}h$
by $R$-transitivity, and for any $x\in R^{-}\left[m\right]$ we have
$g\left(x\right)=h\left(x\right)$, otherwise $x$ would contradict
$m$ being $R$-first in $S$, so we have $g\restriction R^{-}\left[m\right]=h\restriction R^{-}\left[m\right]$.
Hence we have $g\left(m\right)=\digamma\left(m,g\restriction R^{-}\left[m\right]\right)=\digamma\left(m,h\restriction R^{-}\left[m\right]\right)=h\left(m\right)$,
absurd, so $S=\varnothing$ and $g=h$ on $\text{dom}g\cap\text{dom}h$.
$\square$
Lemma: Define $f$ by $\left\langle x,y\right\rangle \in f$ iff there
is a function $h$ such that $\left\langle x,y\right\rangle \in h$,
$\text{dom}h$ is $R$-transitive in $U$, and $h\left(x\right)=\digamma\left(x,h\restriction R^{-}\left[x\right]\right)$
for every $x\in\text{dom}h$. Then $f$ is the unique function such
that $\text{dom}f=U$ and is $R$-transitive, and $f\left(x\right)=\digamma\left(x,f\restriction R^{-}\left[x\right]\right)$
for every $x\in\text{dom}f$.
Proof: For this proof call $h$ a recursor iff $h$ is a function
such that $\text{dom}h$ is $R$-transitive in $U$, and $h\left(x\right)=\digamma\left(x,h\restriction R^{-}\left[x\right]\right)$
for every $x\in\text{dom}h$. Note that if $\left\langle x,y\right\rangle \in f$
iff there is a recursor $h$ such that $x\in\text{dom}h$ and $h\left(x\right)=y$.
Consequently if $h$ is a recursor then $h\subseteq f$.
Since $f$ is a set of ordered pairs it is a relation.
Suppose for contradiction that $f$ is not a function and let $m$
be an $R$-first member of $\text{dom}f$ at which $f$ is not single-valued.
Let $z_{1},z_{2}$ be two distinct values of $f$ at $m$ so $mfz_{1}$,
$mfz_{2}$ and $z_{1}\neq z_{2}$, so by definition there are recursors
$h_{1},h_{2}$ such that $mh_{1}z_{1}$ and $mh_{2}z_{2}$. By the
lemma we have $h_{1}=h_{2}$ on $\text{dom}h_{1}\cap\text{dom}h_{2}$
and since $m\in\text{dom}h_{1}\cap\text{dom}h_{2}$ we have $R^{-}\left[m\right]\subseteq\text{dom}h_{1}\cap\text{dom}h_{2}$
by $R$-transitivity, so $h_{1}=h_{2}$ on $R^{-}\left[m\right]$
so $z_{1}=h_{1}\left(m\right)=\digamma\left(m,h_{1}\restriction R^{-}\left[m\right]\right)=\digamma\left(m,h_{2}\restriction R^{-}\left[m\right]\right)=h_{2}\left(m\right)=z_{2}$,
absurd. Hence $f$ is a function.
If $x\in\text{dom}f$ and $z\in R^{-}\left[x\right]$, then $\left\langle x,f\left(x\right)\right\rangle \in f$
so there is a recursor $h$ such that $x\in\text{dom}h$ and $h\left(x\right)=f\left(x\right)$,
but $\text{dom}h$ is $R$-transitive so $z\in\text{dom}h$ and $h\left(z\right)=\digamma\left(z,h\restriction R^{-}\left[z\right]\right)$,
so by definition $\left\langle z,h\left(z\right)\right\rangle \in f$
so $z\in\text{dom}f$. Hence $R^{-}\left[x\right]\subseteq\text{dom}f$
so $\text{dom}f$ is $R$-transitive.
Let $x\in\text{dom}f$ be arbitrary then $\left\langle x,f\left(x\right)\right\rangle \in f$
so for some recursor $h$ we have $x\in\text{dom}h$ and $h\left(x\right)=f\left(x\right)=\digamma\left(x,h\restriction R^{-}\left[x\right]\right)$.
Since $x\in\text{dom}h\cap\text{dom}f$ we have $R^{-}\left[x\right]\subseteq\text{dom}h\cap\text{dom}f$
by $R$-transitivity and since $h\subseteq f$ we have $h\restriction R^{-}\left[x\right]=f\restriction R^{-}\left[x\right]$
so $f\left(x\right)=h\left(x\right)=\digamma\left(x,h\restriction R^{-}\left[x\right]\right)=\digamma\left(x,f\restriction R^{-}\left[x\right]\right)$.
Suppose for contradiction that $\text{dom}f\subset U$ and let $m$
be an $R$-first member of $U\setminus\text{dom}f$. Let $f^{+}=f\cup\left\{ \left\langle m,\digamma\left(m,f\restriction R^{-}\left[m\right]\right)\right\rangle \right\} $
then since $m\notin\text{dom}f$ we have $f\subset f^{+}$. If $x\in\text{dom}f^{+}$
then either (1) $x\in\text{dom}f$ so $R^{-}\left[x\right]\subseteq\text{dom}f\subseteq\text{dom}f^{+}$
by $R$-transitivity, or (2) $x=m$ so any $z\in R^{-}\left[m\right]$
is in $\text{dom}f$ as $m$ is $R$-first, so $R^{-}\left[m\right]\subseteq\text{dom}f\subseteq\text{dom}f^{+}$,
hence in either case $R^{-}\left[x\right]\subseteq\text{dom}f^{+}$
so $\text{dom}f^{+}$ is $R$-transitive. Therefore $f^{+}$ is cleary
a recursor, $m\in\text{dom}f^{+}$ and $f^{+}\left(m\right)=\digamma\left(m,f\restriction R^{-}\left[m\right]\right)$
so $\left\langle m,\digamma\left(m,f\restriction R^{-}\left[m\right]\right)\right\rangle \in f$
so , absurd, so $\text{dom}f=U$.
Assume $g$ is also a function such that $\text{dom}g=U$ and $g\left(x\right)=\digamma\left(x,g\restriction R^{-}\left[x\right]\right)$
for every $x\in\text{dom}g$. Since $\text{dom}g=U$ it is $R$-transitive
so $g$ is a recursor so $g\subseteq f$. Suppose for contradiction
that $g\subset f$ then $\text{dom}g\subset\text{dom}f=U$, absurd.
Hence $g=f$.$\square$


text:
Q: How does $({{n/e})^n} / ({({n/{2e}})^n})$ simplify to $2^n$ (MIT OpenCourseware 6.006) As stated in the title, how is the following simplification performed?
$$\frac{\left(\frac{n}{e}\right)^n}{\left(\frac{n}{2e}\right)^n}=2^n$$
This was shown by a student in this Recitation video (29:05) from MIT OpenCourseware.

A: $$\frac{\left(\frac{n}{e}\right)^n}{\left(\frac{n}{2e}\right)^n} = \frac{n^n (2e)^n}{e^nn^n}$$
by $\frac{a/b}{c/d} = \frac{ad}{bc}$.
Clearly, the $n^n$ terms cancel, and $(2e)^n = 2^ne^n$. Then, the $e^n$ terms cancel.

A: Use the rules:
$$\dfrac{\frac{a}{b}}{\frac{c}{d}} = \frac{a d}{b c}$$
$$ \left(\frac{a}{b}\right)^n = \frac{a^n}{b^n}$$
$$ (ab)^n = a^n b^n$$
See if you can figure out how it simplifies.

A: $$\frac{\left(\frac{n}{e}\right)^n}{\left(\frac{n}{2e}\right)^n} =\frac{\left(\frac{n}{e}\right)^n}{\left(\frac{1}{2}\right)^n\left(\frac{n}{e}\right)^n} =\frac{1}{1/2^n}=2^n$$


text:
Q: DAX syntax sugar examples I just came accross article on  syntax sugar in DAX - https://exceleratorbi.com.au/simple-filters-and-syntax-sugar-in-dax/
1.
Total Sales Syntax Sugar = SUM(Sales[ExtendedAmount])
Total Sales Full Syntax = SUMX(Sales, Sales[ExtendedAmount])

*Total Sales Prior Year Syntax Sugar =
CALCULATE(
[Total Sales],
SAMEPERIODLASTYEAR('Calendar'[Date])
Total Sales Prior Year Full Syntax =
CALCULATE(
[Total Sales],
DATEADD('Calendar'[Date], -1, YEAR))

*Total Sales of Bikes Simple =
CALCULATE(
[Total Sales],
Product[Category] = "Bikes")
Total Sales of Bikes Full Version =
CALCULATE(
[Total Sales],
FILTER(
ALL(Product[Category]),
Product[Category] = "Bikes"))
Does anyone know other exampes of syntax sugar in DAX?
Robert


text:
Q: Android: user can still login without completing account creation My app new user can reg with phone auth only no Email, now app have a 3 activity for reg new user first one to enter phone number second is OTP to enter the sent code and then be sent to 3 activity where user can upload a profile image and name, the problem is with the last acitivty is that if user somehow closed the app without uploading a profile image or setting a name which means that the firebase doesn't reg him at all he would still be able to access the app as normal user.
OTP acitivty:
public class OTPActivity extends AppCompatActivity {
    ActivityOTPBinding binding;
    FirebaseAuth auth;

    String verificationId;
    ProgressDialog dialog;
    private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks;
    private PhoneAuthProvider.ForceResendingToken mResendToken;
    private static final String TAG = "PhoneAuthActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityOTPBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        auth = FirebaseAuth.getInstance();

        dialog = new ProgressDialog(this);
        dialog.setMessage("Checking...");

        // force prevent canceling the check
        dialog.setCancelable(false);
        dialog.show();

        String phoneNumber =  getIntent().getStringExtra("phoneNumber");

        binding.phoneLbl.setText(phoneNumber);

        binding.changePhone.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        PhoneAuthOptions options = PhoneAuthOptions.newBuilder(auth)
                .setPhoneNumber(phoneNumber)
                .setTimeout(60L, TimeUnit.SECONDS)
                .setActivity(OTPActivity.this)
                .setCallbacks(mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
                    @Override
                    public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential) {

                    }

                    @Override
                    public void onVerificationFailed(@NonNull FirebaseException e) {
                        dialog.dismiss();
                        Toast.makeText(OTPActivity.this, "Verification Failed, Check Phone Number.", Toast.LENGTH_SHORT).show();
                        Log.w(TAG, "onVerificationFailed", e);
                    }

                    @Override
                    public void onCodeSent(@NonNull String verifyId, @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken) {
                        super.onCodeSent(verifyId, forceResendingToken);
                        dialog.dismiss();
                        verificationId = verifyId;
                        mResendToken = forceResendingToken;

                        InputMethodManager imm = (InputMethodManager)   getSystemService(Context.INPUT_METHOD_SERVICE);
                        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
                        binding.otpView.requestFocus();
                        Log.d(TAG, "onCodeSent:" + verifyId);
                    }
                }).build();

        PhoneAuthProvider.verifyPhoneNumber(options);

        binding.otpView.setOtpCompletionListener(new OnOtpCompletionListener() {
            @Override
            public void onOtpCompleted(String otp) {
                PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, otp);
                auth.signInWithCredential(credential).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()){
                            Intent intent = new Intent(OTPActivity.this, SetupProfileActivity.class);
                            startActivity(intent);
                            finishAffinity();
                        } else {
                            Toast.makeText(OTPActivity.this, "Verification Failed, Please Try Again.", Toast.LENGTH_LONG).show();
                        }
                    }
                });
            }
        });

        binding.resendOTP.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(OTPActivity.this, getString(R.string.code_is_being_resent), Toast.LENGTH_SHORT).show();
                resendVerificationCode(phoneNumber, mResendToken);
            }
        });
    }

    // [START resend_verification]
    private void resendVerificationCode(String phoneNumber,
                                        PhoneAuthProvider.ForceResendingToken token) {
        PhoneAuthOptions options =
                PhoneAuthOptions.newBuilder(auth)
                        .setPhoneNumber(phoneNumber)       // Phone number to verify
                        .setTimeout(60L, TimeUnit.SECONDS) // Timeout and unit
                        .setActivity(this)                 // Activity (for callback binding)
                        .setCallbacks(mCallbacks)          // OnVerificationStateChangedCallbacks
                        .setForceResendingToken(token)     // ForceResendingToken from callbacks
                        .build();
        PhoneAuthProvider.verifyPhoneNumber(options);

    }
    // [END resend_verification]
}

Setup Profile:
public class SetupProfileActivity extends AppCompatActivity {

    ActivitySetupProfileBinding binding;
    FirebaseAuth auth;
    FirebaseDatabase database;
    FirebaseStorage storage;
    Uri selectedImage;
    ProgressDialog dialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivitySetupProfileBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        database = FirebaseDatabase.getInstance();
        storage = FirebaseStorage.getInstance();
        auth = FirebaseAuth.getInstance();

        dialog = new ProgressDialog(this);
        dialog.setMessage("Uploading Profile Setting...");
        dialog.setCancelable(false);

        binding.profileImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_GET_CONTENT);
                intent.setType("image/*");
                startActivityForResult(intent, 45);
            }
        });

        binding.finishBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String name = binding.nameBox.getText().toString();
                if (name.isEmpty()) {
                    binding.nameBox.setError(getString(R.string.cant_be_empty));
                }
                dialog.show();

                if (selectedImage !=null){
                    StorageReference reference = storage.getReference().child("Profiles").child(auth.getUid());
                    reference.putFile(selectedImage).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
                        @Override
                        public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
                            if (task.isSuccessful()) {
                                reference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                                    @Override
                                    public void onSuccess(Uri uri) {
                                        String imageUrl = uri.toString();

                                        String uid = auth.getUid();
                                        String phone = auth.getCurrentUser().getPhoneNumber();
                                        String name = binding.nameBox.getText().toString().trim();

                                        User user = new User(uid, name, phone, imageUrl);

                                        database.getReference()
                                                .child("Users")
                                                .child(phone)
                                                .setValue(user)
                                                .addOnSuccessListener(new OnSuccessListener<Void>() {
                                                    @Override
                                                    public void onSuccess(Void aVoid) {
                                                        dialog.dismiss();
                                                        Intent intent = new Intent(SetupProfileActivity.this, MainActivity.class);
                                                        SharedPreferences preferences = getSharedPreferences("DisplayUserInfo", MODE_PRIVATE);
                                                        SharedPreferences.Editor editor = preferences.edit();
                                                        editor.putString("DisplayName", name);
                                                        editor.putString("DisplayProfileImage", imageUrl);
                                                        editor.apply();
                                                        startActivity(intent);
                                                        finish();
                                                    }
                                                });
                                    }
                                });
                            }
                        }
                    });
                } else {
                    String uid = auth.getUid();
                    String phone = auth.getCurrentUser().getPhoneNumber();
                    User user = new User(uid, name, phone, "No Image");
                    database.getReference()
                            .child("Users")
                            .child(phone)
                            .setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
                        @Override
                        public void onComplete(@NonNull Task<Void> task) {
                            if (task.isSuccessful()) {
                                dialog.dismiss();
                                Intent intent = new Intent(SetupProfileActivity.this, MainActivity.class);
                                startActivity(intent);
                                finish();
                            } else {
                                Toast.makeText(SetupProfileActivity.this, "Failed To Reg Account", Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                }
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data !=null){
            if (data.getData() !=null){
                binding.profileImageView.setImageURI(data.getData());
                selectedImage = data.getData();
            }
        }
    }

    // check if want to exit
    boolean doubleBackToExitPressedOnce = false;
    @Override
    public void onBackPressed() {
        if (doubleBackToExitPressedOnce) {
            super.onBackPressed();
            return;
        }

        this.doubleBackToExitPressedOnce = true;
        Toast.makeText(this, getString(R.string.click_again_to_Exit), Toast.LENGTH_SHORT).show();

        new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {

            @Override
            public void run() {
                doubleBackToExitPressedOnce=false;
            }
        }, 2000);
    }
}

Code used to autologin :
//AutoLogin
if (auth.getCurrentUser() !=null){
    Intent intent = new Intent(PhoneLoginActivity.this, MainActivity.class);
    startActivity(intent);
    finish();
}

A: Simple way to handle your situation is to keep a boolean variable like "isProfileComplete" on User Profile. Set this to true once you receive all required info from the user on Setup Profile. Check this value on your Launcher Activity, if its false then redirect user to Setup Profile page else on your Landing page.
Edit
You need minor changes in your auto login code section
if (auth.getCurrentUser() !=null){
    Intent intent;
    if(isProfileComplete())
      intent = new Intent(PhoneLoginActivity.this, MainActivity.class);
    else
      intent = new Intent(PhoneLoginActivity.this, SetupProfileActivity.class);
    startActivity(intent);
    finish();
}

private boolean isProfileComplete(){
  //get User object for the logged in user using SharedPreferences or FirebaseDB
  return user.isProfileComplete
}


text:
Q: VB.Net : Create a Recordset with manual inputs and GetRows() methods failing First time writing on a forum but this one really left me no choice and it seems that nobody had the same problem as I have... not a good sign...
I have a project to use the COM Server of a software we use internally and need to use one of their built-in function which requires a recordset as an input and return another recordset with the results (important because I need to stick with the recordset).
Here's breifly what I tried. I create a recordset from scratch and fill it with some hardcoded data just for testing purposes. Once my recordset is filled, I want to look at the data just to be sure everything works well, but I'll have to do the same eventually with my results.
The problem I get is it seems that the GetRows() method return only 1 row every time depending on the last row I moved to. But once it's called, I cannot get the other records. I'm already using the GetRows() method with an actual query and still with an ADODB recordset and it works perfectly. Building a recodset from scratch seems less easy.
I need to put all my data in an object to work with it. But even if I want to use only a recordset, I cannot access to all data in it. Very fustrating... something I'm missing here...
Error I get: either bof or eof is true or the current record has been deleted
Thanks in advance,
Public Function GetFDBData() As Boolean

        Dim filtersView As New ADODB.Recordset
        Dim rsFields(1) As Object
        Dim fieldsAPT(3, 1) As Object
        Dim dataView As Object
        Dim i As Integer

        rsFields(0) = "Field Name"
        rsFields(1) = "Filter"

        fieldsAPT(0, 0) = "ISIN"
        fieldsAPT(0, 1) = "=CA89*"
        fieldsAPT(1, 0) = "Currency"
        fieldsAPT(1, 1) = "=CAD"
        fieldsAPT(2, 0) = "Line"
        fieldsAPT(2, 1) = "=Bond"
        fieldsAPT(3, 0) = "Redemption Date"
        fieldsAPT(3, 1) = "=20230*"

        Try
            'Build the recordset containing APT fields and filters (in the same variable fieldsAPT)
            filtersView.CursorLocation = ADODB.CursorLocationEnum.adUseClient
            filtersView.Fields.Append(rsFields(0), ADODB.DataTypeEnum.adVarChar, 30)
            filtersView.Fields.Append(rsFields(1), ADODB.DataTypeEnum.adVarChar, 30)
            filtersView.Open(, , ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)

            Dim fieldAPT(1)
            For i = 0 To UBound(fieldsAPT)
                fieldAPT(0) = fieldsAPT(i, 0)
                Console.WriteLine(fieldAPT(0))              'Works fine
                fieldAPT(1) = fieldsAPT(i, 1)
                Console.WriteLine(fieldAPT(1))              'Works fine
                filtersView.AddNew(rsFields, fieldAPT)
                filtersView.Update()
                Console.WriteLine(filtersView.RecordCount)  'I can see 1 2 3 4 no problem here
            Next i

            Dim xx As Integer = filtersView.RecordCount     'xx is 4 as expected
            Console.WriteLine("xx: " & xx)
            filtersView.MoveFirst()                         'Will move to the first record or whatever record
            'dataView = filtersView.GetRows()               'I expected this line to work, but same results

            For i = 0 To xx - 1
                dataView = filtersView.GetRows()
                Console.WriteLine(dataView(i, 0).ToString)      'ISIN, normal
                Console.WriteLine(filtersView.RecordCount)      'Still equals 4, normal
                Console.WriteLine(filtersView.BOF)              'False, normal
                Console.WriteLine(filtersView.EOF)              'True, which is NOT normal
                Console.WriteLine(filtersView.AbsolutePosition) 'Get -3 not sure why (position 1 related to 4???)
                Console.WriteLine(filtersView.MaxRecords)       'Get 0 not sure why
                filtersView.MoveNext()                          '!!!! Here is where it fails !!!! Cannot go more than i=0
            Next i

            GetFDBData = True
        Catch ex As Exception
            MsgBox(ex.Message)
            GetFDBData = False
        Finally
            'Clear memory
            filtersView.Close()
        End Try
End Function

Also, if I do this,
Dim xx As Integer = filtersView.RecordCount     'xx is 4 as expected
            Console.WriteLine("xx: " & xx)
            filtersView.MoveLast()

Instead of
 Dim xx As Integer = filtersView.RecordCount     'xx is 4 as expected
                Console.WriteLine("xx: " & xx)
                filtersView.MoveFirst()

It will return "Redemption date" in the for loop after. Which makes sense because it is the last record. But puting movefirst even after does'nt solve the issue... still one row only. So the data is there, but I really can't extract one line and one line only...

A: Try changing your cursor type to adOpenDynamic
EDIT: OK,your line
    dataView = filtersView.GetRows()
is causing your cursor to travel to the end of the recordset, try moving it outside your loop and following it with a new MoveFirst like so
     filtersView.MoveFirst()                         'Will move to the first record or whatever record
     'dataView = filtersView.GetRows()               'I expected this line to work, but same results

     dataView = filtersView.GetRows()
     filtersView.MoveFirst()

     Dim sTemp As String = ""
     For i = 0 To xx - 1
        'Console.WriteLine(dataView(i, 0).ToString)      'ISIN, normal
        Console.WriteLine(filtersView.RecordCount)      'Still equals 4, normal
        Console.WriteLine(filtersView.BOF)              'False, normal
        Console.WriteLine(filtersView.EOF)              'True, which is NOT normal
        Console.WriteLine(filtersView.AbsolutePosition) 'Get -3 not sure why (position 1 related to 4???)
        Console.WriteLine(filtersView.MaxRecords)       'Get 0 not sure why
        sTemp = sTemp & "(" & dataView(0, i).ToString & ", " & dataView(1, i).ToString & ")"
        filtersView.MoveNext()                          '!!!! Here is where it fails !!!! Cannot go more than i=0
     Next i
     Console.WriteLine(sTemp)

You can verify that by checking the value of filtersView.AbsolutePosition immediately before and after your call to GetRows
Also, you are reversing rows and columns in dataView, move i to the second subscript position. I put it in a temporary string to make it easier to view in the debugger.


text:
Q: Failure to install Sybase package on Windows 10 / Python 3.6 I'm looking to connect to a Sybase db in PyCharm. I'm getting the following errors when installing from available packages and the terminal:
(venv64) C:\Users\xxxx\Documents\PyCharm\EOM_ML_201901>pip install sybase
ERROR: Could not find a version that satisfies the requirement sybase (from versions: none)
ERROR: No matching distribution found for sybase

(venv64) C:\Users\xxxx\Documents\PyCharm\EOM_ML_201901>pip install python-sybase
ERROR: Could not find a version that satisfies the requirement python-sybase (from versions: none)
ERROR: No matching distribution found for python-sybase

Has anyone succesfully installed on Win10?
Peter

A: I had the same challenge. I resolved it by using a trial version of the Devart ODBC Driver for ASE available here https://www.devart.com/odbc/ase/download.html
After the driver is installed, it can be configured. For this, in the Control Panel open Administrative Tools and find the Data Sources (ODBC) tool. Add the Devart ODBC Driver for ASE and set up your ASE credentials.
Then from your PyCharm, connect to your ASE using the following command:
import pyodbc
cnxn = pyodbc.connect('DRIVER={Devart ODBC Driver for ASE}; Server=myserver; Port=myport; Database=mydatabase; User ID=myuserid; Password=mypassword; String Types=Unicode')


text:
Q: Swift, Cocoa - how to update view properties when using an NSGraphicsContext? If I call self.layer? in a draw() method to control the content of an NSView, the view's properties can be updated by the view controller. However, if I create a graphics context for drawing into, this relationship breaks and the view controller no longer updates the view's properties. Why?
In the simple example I provide, if you comment out the guard statement in TestView and call drawBackgroundWithoutContext(), the view is given a background colour when viewDidLoad() is called, and the colour is updated when the mouseDown event occurs.
As soon as a context is declared this breaks, even if you are still calling drawBackgroundWithoutContext().
import Cocoa

class ViewController: NSViewController {

    var newR: CGFloat?
    var newG: CGFloat?
    var newB: CGFloat?

    var tview = TestView(frame: NSRect(x: 20, y: 30, width: 100, height: 100))

    override func viewDidLoad() {
        super.viewDidLoad()
        tview.r = 1.0
        tview.g = 0.5
        tview.b = 0.8
        self.view.addSubview(tview)
    }

    override func mouseDown(with event: NSEvent) {
        newR = 0.1
        newG = 0.9
        newB = 0.0
        tview.r = newR
        tview.g = newG
        tview.b = newB
        tview.draw(NSRect(x: 20, y: 30, width: 100, height: 100))
//      tview.setNeedsDisplay(NSRect(x: 20, y: 30, width: 100, height: 100))
    }
}

    class TestView: NSView {

        var r: CGFloat?
        var g: CGFloat?
        var b: CGFloat?

        override func draw(_ dirtyRect: NSRect) {
            super.draw(dirtyRect)

            guard  let context = NSGraphicsContext.current?.cgContext else {
                return
            }

    //      drawBackgroundWithoutContext(red: r, green: g, blue: b)

            drawBackgroundWithContext(context: context, red: r, green: g, blue: b)

        }

        func drawBackgroundWithoutContext(red: CGFloat?, green: CGFloat?, blue: CGFloat?) {
            self.layer?.backgroundColor = CGColor(red: red ?? 0.0, green: green ?? 0.0, blue: blue ?? 0.0, alpha: 1.0)
        }

        func drawBackgroundWithContext(context: CGContext, red: CGFloat?, green: CGFloat?, blue: CGFloat?) {
            context.setFillColor(CGColor(red: red ?? 0.0, green: green ?? 0.0, blue: blue ?? 0.0, alpha: 1.0))
            context.fill(CGRect(x: 20, y: 30, width: 100, height: 100))
        }

    }

I read that you should not actually call .draw() in the view controller and the correct method is setNeedsDisplay(), however this had no affect. I have left this call as a comment in the code so you can see what I tried.


text:
Q: Web Request do catch not working I want to create a little App which calls a Server and gets JSON Information. The thing the server returns is this:
{"temperature":23.60,"humidity":18.40}

My code is like this:
    let requestURL: NSURL = NSURL(string: "http://esp_0b48a1:1337/")!
    let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: requestURL as URL)
    let session = URLSession.shared
    let task = session.dataTask(with: urlRequest as URLRequest) {
        (data, response, error) -> Void in

        let httpResponse = response as! HTTPURLResponse
        let statusCode = httpResponse.statusCode

        if (statusCode == 200) {
            print("Everyone is fine, file downloaded successfully.")
            do{
                let json = try JSONSerialization.jsonObject(with: data!, options:.allowFragments) as! [String:AnyObject]

                if let temp = json["temperature"] as? String {
                    self.degrees.text = temp + "°C";
                    print(temp);
                }
                if let hum = json["humidity"] as? String {
                    self.hum.text = hum + "%";
                    print(hum);
                }
            }catch{
                print("error");
                self.degrees.text = "no Temperature";
                self.fill.text = "with";
                self.degrees.text = "some errors like " + String(statusCode);
            }
        }
    }

    task.resume()

And I am executing it in the viewDidLoad function of my MainViewController.
I get the output "Everyone ist fine, file dl successfully" but no more output. Not that one in the the do block nor that output in the catch and its not changing the UILabels.
But on my WebServer I can see that it gots a request!
Any ideas why?
I am connecting via http and set the Allow Arbitrary Loads in App Transport Security Settings to yes (info.plist)
dunklesToast

A: Casting as a float should get you going.  I'd suggest adding an else to handle a casting failure.
 if let temp = json["temperature"] as? Float {
                self.degrees.text = temp + "\(temp)°C";
                print(temp);
 }else{
 //handle this outcome
 }

 if let hum = json["humidity"] as? Float {
           self.hum.text = hum + "\(hum)°C";
           print(hum);
 }
 else{
 //handle this outcome
 }


text:
Q: Change of order of filters speeds up the query in Entity Framework I use Entity Framework to fetch data from my database. For that purpose, I use
return await _context.vw_Attribute_Entities
     .Where(x => x.ProjectID == id && x.EntityID == entityId)
     .Select(dt => new DataTypesDetails() { ... }

This thing was fast and good but out of nowhere (didn't make any changes on backend side nor data base) it became slowly and needs more than 30 seconds to return result. However, if I reorder the filter like
return await _context.vw_Attribute_Entities
     .Where(x => x.EntityID == entityId && x.ProjectID == id)
     .Select(dt => new DataTypesDetails() { ... }

it speeds up again. This query returns 90 rows at max and the time it needs is ~1 second. I had a problem like this multiple times and the solution was to wrap this as a stored procedure in my database and execute that stored procedure on .NET side, but I'm curious about why does this happen?
p.s I have a SQL Server as a database.


text:
Q: Novacode DocX Different page orientations within the same document Using the following code, I'm trying to create a document in which pages 2 and 3 are landscape while the others are portrait. All should be 8.5" x 11".
using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
   using (DocX document = DocX.Create(ms))
   {
      document.PageLayout.Orientation = Novacode.Orientation.Portrait;
      document.PageWidth = 816F;
      document.PageHeight = 1056F;

      document.MarginTop = 50F;
      document.MarginRight = 50F;
      document.MarginBottom = 75F;
      document.MarginLeft = 50F;

      document.AddHeaders();
      document.AddFooters();
      document.DifferentFirstPage = true;
      document.DifferentOddAndEvenPages = false;

      Header header_first = document.Headers.first;
      Header header_main = document.Headers.odd;
      Footer footer_main = document.Footers.odd;

      Novacode.Table tHeaderFirst = header_first.InsertTable(2, 1);
      tHeaderFirst.Design = TableDesign.None;
      tHeaderFirst.AutoFit = AutoFit.Window;

      Paragraph pHeaderFirst = header_first.Tables[0].Rows[0].Cells[0].Paragraphs[0];
      Novacode.Image imgHeaderFirst = document.AddImage(ctx.Server.MapPath("~/proposal-assets/header-front.jpg"));
      pHeaderFirst.InsertPicture(imgHeaderFirst.CreatePicture());

      Novacode.Table tHeaderMain = header_main.InsertTable(2, 1);
      tHeaderMain.Design = TableDesign.None;
      tHeaderMain.AutoFit = AutoFit.Window;

      Paragraph pHeader = header_main.Tables[0].Rows[0].Cells[0].Paragraphs[0];
      Novacode.Image imgHeader = document.AddImage(ctx.Server.MapPath("~/proposal-assets/header-internal-portrait.jpg"));
      pHeader.InsertPicture(imgHeader.CreatePicture());

      Paragraph pFooter = footer_main.Paragraphs.First();
      pFooter.Alignment = Alignment.center;
      pFooter.Append("Page ");
      pFooter.AppendPageNumber(PageNumberFormat.normal);
      pFooter.Append("/");
      pFooter.AppendPageCount(PageNumberFormat.normal);

      Paragraph p1 = document.InsertParagraph("test");
      p1.InsertPageBreakAfterSelf();
      document.InsertSection(true);
      document.PageLayout.Orientation = Novacode.Orientation.Landscape;
      //document.PageWidth = 1056F;
      //document.PageHeight = 816F;

      Paragraph p2 = document.InsertParagraph("test");
      p2.InsertPageBreakAfterSelf();

      Paragraph p3 = document.InsertParagraph("test");
      p3.InsertPageBreakAfterSelf();

      document.InsertSection(true);
      document.PageLayout.Orientation = Novacode.Orientation.Portrait;
      //document.PageWidth = 816F;
      //document.PageHeight = 1056F;

      Paragraph p4 = document.InsertParagraph("test");
      p4.InsertPageBreakAfterSelf();

      Paragraph p5 = document.InsertParagraph("test");
      p5.InsertPageBreakAfterSelf();

      Paragraph p6 = document.InsertParagraph("test");
      p6.InsertPageBreakAfterSelf();

      document.Save();
   }
}

I'm having several issues with this.
First, if I set the orientation once at the beginning, all the pages come out the correct size, but once I add the 2nd and 3rd changes to PageLayout.Orientation, suddenly ALL my pages are the wrong size.
Second, inserting the sections does weird things with my headers and footers. The first page of the 3rd section acts like it's the first page of the document and takes the first page header and footer.
Finally, adding the 2nd and 3rd changes to PageLayout.Orientation doesn't actually change the page orientations. As you can see in the commented out code, I've also tried setting new page heights and widths after changing the layout. Doing so makes my pages go back to the correct size, but in no way affects the orientation.
What am I missing? Any help would be greatly appreciated.

A: Finally! I've worked out a usable solution which I'll place here in hopes it'll help someone else.
document.PageLayout.Orientation = Novacode.Orientation.Portrait;
document.PageWidth = 816F;
document.PageHeight = 1056F;
document.MarginTop = 50F;
document.MarginRight = 50F;
document.MarginBottom = 75F;
document.MarginLeft = 50F;

document.AddHeaders();
document.AddFooters();
document.DifferentFirstPage = true;
document.DifferentOddAndEvenPages = false;

Header header_first = document.Headers.first;
Header header_main = document.Headers.odd;
Footer footer_main = document.Footers.odd;

Paragraph pHeaderFirst = header_first.Paragraphs.First();
Novacode.Image imgHeaderFirst = document.AddImage(ctx.Server.MapPath("~/proposal-assets/header-front.jpg"));
pHeaderFirst.Alignment = Alignment.center;
pHeaderFirst.SpacingAfter(25);
pHeaderFirst.AppendPicture(imgHeaderFirst.CreatePicture());

Paragraph pHeader = header_main.Paragraphs.First();
Novacode.Image imgHeader = document.AddImage(ctx.Server.MapPath("~/proposal-assets/header-internal-portrait.jpg"));
pHeader.Alignment = Alignment.center;
pHeader.SpacingAfter(25);
pHeader.AppendPicture(imgHeader.CreatePicture());

Paragraph pFooter = footer_main.Paragraphs.First();
pFooter.Alignment = Alignment.center;
pFooter.Append("Page ");
pFooter.AppendPageNumber(PageNumberFormat.normal);
pFooter.Append("/");
pFooter.AppendPageCount(PageNumberFormat.normal);

Paragraph p1 = document.InsertParagraph("test");

System.IO.MemoryStream ms2 = new System.IO.MemoryStream();
DocX document2 = DocX.Create(ms2);
document2.PageLayout.Orientation = Novacode.Orientation.Landscape;
document2.PageWidth = 1056F;
document2.PageHeight = 816F;
document2.MarginTop = 50F;
document2.MarginRight = 50F;
document2.MarginBottom = 75F;
document2.MarginLeft = 50F;
Paragraph p2 = document2.InsertParagraph("test --- doc 2");
p2.InsertPageBreakAfterSelf();
Paragraph p3 = document2.InsertParagraph("test --- doc 2");
document2.Save();

document.InsertSection();
document.InsertDocument(document2);

System.IO.MemoryStream ms3 = new System.IO.MemoryStream();
DocX document3 = DocX.Create(ms3);
document3.PageLayout.Orientation = Novacode.Orientation.Portrait;
document3.PageWidth = 816F;
document3.PageHeight = 1056F;
document3.MarginTop = 50F;
document3.MarginRight = 50F;
document3.MarginBottom = 75F;
document3.MarginLeft = 50F;
Paragraph p4 = document3.InsertParagraph("test");
p4.InsertPageBreakAfterSelf();
Paragraph p5 = document3.InsertParagraph("test");
p5.InsertPageBreakAfterSelf();
Paragraph p6 = document3.InsertParagraph("test");
document3.Save();

document.InsertSection();
document.InsertDocument(document3);

document.Save();

Creating the different sections as separate documents and inserting them into the main document worked well and solved all my problems.


text:
Q: How can I input data into a webpage to scrape the resulting output using Python? I am familiar with BeautifulSoup and urllib2 to scrape data from a webpage.  However, what if a parameter needs to be entered into the page before the result that I want to scrape is returned?
I'm trying to obtain the geographic distance between two addresses using this website:  http://www.freemaptools.com/how-far-is-it-between.htm
I want to be able to go to the page, enter two addresses, click "Show", and then extract the "Distance as the Crow Flies" and "Distance by Land Transport" values and save them to a dictionary.
Is there any way to input data into a webpage using Python?

A: Take a look at tools like mechanize or scrape:

*

*http://pypi.python.org/pypi/mechanize

*http://stockrt.github.com/p/emulating-a-browser-in-python-with-mechanize/

*http://www.ibm.com/developerworks/linux/library/l-python-mechanize-beautiful-soup/

*http://zesty.ca/scrape/
Packt Publishing has an article on that matter, too:

*

*http://www.packtpub.com/article/web-scraping-with-python

A: Yes! Try mechanize for this kind of Web screen-scraping task.

A: I think you can also use PySide/PyQt, because they have a browser core of qtwebkit, you can control the browser to open pages, simulate human actions(fill, click...), then scrape data from pages. FMiner is work on this way, it's a web scraping software I developed with PySide.
Or you can try phantomjs, it's an easy library to control browser, but not it's javascript not python lanuage.

A: In addition with the answers already given, you could simply do a request on that page. Using your browser you could always inspect the Network (under Tools/Web Developer tools) behaviors and actions when you interact with the page. E.g. http://www.freemaptools.com/ajax/getaandb.php?a=Florida_Usa&b=New%20York_Usa&c=6052 -> request query for getting the results page you are expecting. Request that page and scrape the field you wanted to. IMHO, page requests are way faster than screen scraping (case-to-case basis).
But of course, you could always do screen scraping/browser simulation also (Mechanize, Splinter) and use headless browsers (PhantomJS, etc.) or the browser driver of the browser you want to use.

A: The query may have been resolved.
You can use Selenium WebDriver for this purpose. A web page can be interacted using programming language. All the operations can be performed as if a human user is accessing the web page.


text:
Q: jquery autocomplete source not work I copy the source code from jQuery autocomplete demo and replace relative url as absolute url, but when I test the page in localhost, the autocomplete widget doesn't work. Can anyone help me?

        <meta charset="utf-8" />
        <title>jQuery UI Autocomplete - Remote with caching</title>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />

        <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" />

            Birds:
            <input id="birds" />

A: You can't make requests to other hosts. localhost is not the same as jqueryui.com so you are being blocked by the same origin policy


text:
Q: I needed to do Bulk insert with dapper rainbow I am using the dapper rainbow database.cs extensions,
private void insertList(IEnumerable<myObject> list)
    {
          using (SqlConnection conn = new SqlConnection(connectionString))
        {
            var db = myDB.Init(conn, commandTimeout: 100);
            db.myTable.tableName = "ds.myTable";
            Parallel.ForEach(dsList, a => db.myTableInsert(a)
                        );
            db.Dispose();
        }
    }

This won't work, i think i need to open and close the connection inside the Parallel.ForEach. Is that the write way to do it?
I wanted to use this extension, its very helpful and hand, but having this problem of inserting a list. I could not find anything online about using this extension and using a list as well.

A: Generally database connections are NOT thread safe, so doing inserts in parallel on the same connection like that is bound to cause trouble.
So I would say that yes, you would need to open and close the connection inside the Parallel.ForEach().  You might want to benchmark that as well.  I'm not entirely convinced that doing inserts in parallel like that with multiple database connections would be any faster than doing them in a regular loop on a single connection.


text:
Q: In d3, how do I apply a style to my line chart for both the line and the area under the line? I"m using d3 v4.  I want to create a line chart in which I would like to have the area beneath the line filled but I would also like to apply a style to the line itself.  I have these classes
.line {
  fill: none;
  stroke: red;
  stroke-width: 1.5px;
}

.area {
    fill: url(#area-gradient);
    stroke-width: 0px;
}

but I can't figure out how to apply them to my element.  I tried
  svg.append("path")
    .datum(data)
    .attr("d", line)
    .attr("class", "line area")
    .attr("d", area);

but as you can see from this Fiddle -- https://jsfiddle.net/yw46ycse/6/ , the line style doesn't appear (at least I can't see it on Mac Chrome or Firefox).

A: You are treating your single path like it's two separate elements.  It's just one element and your area call (and style) is overriding your line call (and style).  If you want to style them different, plot a line and an area.
svg.append("path")
 .datum(data)
 .attr("class", "area")
 .attr("d", area);

svg.append("path")
 .datum(data)
 .attr("class", "line")
 .attr("d", line);

Updated fiddle.


text:
Q: How to find $\lim_{x \to 7} \frac{x-7}{\sqrt{x+2}-3}$? I'm totally at a loss for this... someone please help!
$$\lim_{x \to 7} \frac{x-7}{\sqrt{x+2}-3}$$
I've tried multiplying by the conjugate, but after doing that I couldn't find a way to cancel out the $x-7$ still (the only thing making the limit not work).
Edit: Thank you all so much! I made a simple math error when I multiplied by the conjugate...

A: Hint:- Rationalize.
Solution:-

$\displaystyle\lim_{x\to 7}\dfrac{x-7}{\sqrt{x+2}-3}=\displaystyle\lim_{x\to 7}\dfrac{(x-7)(\sqrt{x+2}+3)}{x+2-9}=\displaystyle\lim_{x\to 7}\dfrac{(x-7)(\sqrt{x+2}+3)}{x-7}=\displaystyle\lim_{x\to 7}(\sqrt{x+2}+3)=?$

A: Note that
$$\lim_{x \to 7}\frac{x-7}{\sqrt{x+2}-3} = \lim_{h \to 0}\frac{h}{\sqrt{9+h}-3};$$
but
$$
\frac{h}{\sqrt{9+h}-3} = \frac{h(\sqrt{9+h})+3h}{h} = \sqrt{9+h}+3 \to 6
$$
as $h \to 0$.

A: Let $f(x) = \sqrt {x+2}.$ The expression equals
$$\frac{1}{(f(x) - f(7))/(x-7)} \to 1/f'(7)$$
by the definition of the derivative.

A: $$\lim_{x -> 7} \frac{x-7}{\sqrt{x+2}-3} = \lim_{x -> 7} \frac{(x-7)(\sqrt{x+2}+3)}{x+2-9} = 6$$

A: Multiply by (conjugate/conjugate) as you suggested:
$$\lim\limits_{x \to 7} (\frac{x-7}{\sqrt{x+2}-3}\times \frac {\sqrt{x+2}+3}{\sqrt{x+2}+3})=\lim\limits_{x \to 7} \frac{(x-7)(\sqrt{x+2}+3)}{{x+2}-9}=\lim\limits_{x \to 7} \frac{(x-7)(\sqrt{x+2}+3)}{x-7}
  =\lim\limits_{x \to 7} \sqrt{x+2}+3=6$$
Do you see how $x-7$ cancelled out?


text:
Q: Simplify the code  private const string CurrentPageCssClass = "important";
        private void HidhLightCurrentPageIndex() {

            switch (tpMain.ActiveTabIndex) {
                case 0:
                    elblFirst.AddClass(CurrentPageCssClass);
                    elblSecond.RemoveClass(CurrentPageCssClass);
                    elblThird.RemoveClass(CurrentPageCssClass);
                    elblFouth.RemoveClass(CurrentPageCssClass);
                    elblFirth.RemoveClass(CurrentPageCssClass);
                    break;
                case 1:
                    elblFirst.RemoveClass(CurrentPageCssClass);
                    elblSecond.AddClass(CurrentPageCssClass);
                    elblThird.RemoveClass(CurrentPageCssClass);
                    elblFouth.RemoveClass(CurrentPageCssClass);
                    elblFirth.RemoveClass(CurrentPageCssClass);

                    break;
                case 2:
                    elblFirst.RemoveClass(CurrentPageCssClass);
                    elblSecond.RemoveClass(CurrentPageCssClass);
                    elblThird.AddClass(CurrentPageCssClass);
                    elblFouth.RemoveClass(CurrentPageCssClass);
                    elblFirth.RemoveClass(CurrentPageCssClass);

                    break;
                case 3:
                    elblFirst.RemoveClass(CurrentPageCssClass);
                    elblSecond.RemoveClass(CurrentPageCssClass);
                    elblThird.RemoveClass(CurrentPageCssClass);
                    elblFouth.AddClass(CurrentPageCssClass);
                    elblFirth.RemoveClass(CurrentPageCssClass);
                    break;
                case 4:
                    elblFirst.RemoveClass(CurrentPageCssClass);
                    elblSecond.RemoveClass(CurrentPageCssClass);
                    elblThird.RemoveClass(CurrentPageCssClass);
                    elblFouth.RemoveClass(CurrentPageCssClass);
                    elblFirth.AddClass(CurrentPageCssClass);
                    break;

            }
        }

Does anybody have any suggestions for how to simplify this code?

A:  private const string CurrentPageCssClass = "important";
        private void HidhLightCurrentPageIndex() {

            elblFirst.RemoveClass(CurrentPageCssClass);
            elblSecond.RemoveClass(CurrentPageCssClass);
            elblThird.RemoveClass(CurrentPageCssClass);
            elblFouth.RemoveClass(CurrentPageCssClass);
            elblFirth.RemoveClass(CurrentPageCssClass);
            switch (tpMain.ActiveTabIndex) {
                case 0:
                    elblFirst.AddClass(CurrentPageCssClass);
                    break;
                case 1:
                    elblSecond.AddClass(CurrentPageCssClass);
                    break;
                case 2:
                    elblThird.AddClass(CurrentPageCssClass);
                    break;
                case 3:
                    elblFouth.AddClass(CurrentPageCssClass);
                    break;
                case 4:
                    elblFirth.AddClass(CurrentPageCssClass);
                    break;
            }
        }

A: Put the controls in an array, then call RemoveClass on all the elements, and then AddClass on the active element.'
Edit: Code
var controls = new[] { elblFirst, elblSecond, elblThird, elblFourth, elblFifth };
foreach (var control in controls)
{
    control.RemoveClass(CurrentPageCssClass);
}

controls[tpMain.ActiveTabIndex].AddClass(CurrentPageCssClass);

Of course this is assuming that an additional call to RemoveClass has a negligible cost, otherwise use a regular for loop and skip the active index.

A: Here's another option that reduces code repetition and adhere more to the DRY principle:
private const string CurrentPageCssClass = "important";

private void toggleClass(object elbl, bool addClass) {
    if (addClass) {
        elbl.AddClass(CurrentPageCssClass);
    } else {
        elbl.RemoveClass(CurrentPageCssClass);
    }
}

private void HidhLightCurrentPageIndex() {
    int index = tpMain.ActiveTabIndex;
    toggleClass(elblFirst, index == 0);
    toggleClass(elblSecond, index == 1);
    toggleClass(elblThird, index == 2);
    toggleClass(elblFouth, index == 3);
    toggleClass(elblFirth, index == 4);
}

Other posts suggest calling "RemoveClass" on all items, then calling "AddClass" on the one you want. However, depending on what the "RemoveClass" method does there could be performance consequences of doing it that way. The solution I have posted will only call the appropriate method without requiring any additional, unnecessary method calls, and it's much shorter.


text:
Q: Cubemap texture with bitmap in OpenGL ES 2.0/3.0 When I create a cubemap texture with simple colors, this works well:
@JvmStatic
fun createSimpleTextureCubemap() {
    val textureId = IntArray(1)
    val cubeFace0 = byteArrayOf(127, 127, 127)
    val cubeFace1 = byteArrayOf(0, 127, 0)
    ... // create other cube faces with simple color

    val cubeFaces = ByteBuffer.allocateDirect(3)
    glGenTextures(1, textureId, 0)
    glBindTexture(GL_TEXTURE_CUBE_MAP, textureId[0])

    cubeFaces.put(cubeFace0).position(0)
    glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB,
        1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, cubeFaces)

    cubeFaces.put(cubeFace1).position(0)
    glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB,
        1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, cubeFaces)
    ...
    return textureId[0]
}

But when I try to create a cubemap texture with bitmap:
@JvmStatic
fun createTextureCubemap(context: Context, rowID: Int) {
    val input = context.resources.openRawResource(rowID)
    val bitmap = BitmapFactory.decodeStream(input)

    val textureId = IntArray(1)
    glGenTextures(1, textureId, 0)
    glBindTexture(GL_TEXTURE_CUBE_MAP, textureId[0])

    GLUtils.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, bitmap, 0)
    GLUtils.texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, bitmap, 0)
    GLUtils.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, bitmap, 0)
    GLUtils.texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, bitmap, 0)
    GLUtils.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, bitmap, 0)
    GLUtils.texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, bitmap, 0)

    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
    return textureId[0]
}

Then the object turns black. Someone may suggest why the cubemap with the bitmap does not work (black color)?
Thanks for any comment/answer.

A: Textures for Cubemaps need to be square. As mentioned in the comments, the bitmap used was not square.
From glTexImage2D reference (GLUtils.texImage2D is a convenience wrapper around glTexImage2D)

GL_INVALID_VALUE is generated if target is one of the six cube map 2D image targets and the width and height parameters are not equal.


text:
Q: How to prevent a dialog from closing when hitting enter or escape? I have a dialog that I would like to stay open except if the [x] or exit buttons are clicked. Dialogs seem to always close if you hit escape or if you hit enter when most objects are selected (e.g. string boxes), whether you use pose() or display(). Is there a way to prevent this?
Some public examples of when this occurs are DM Mitchell's "Example: Thread and Dialog Interaction" and "Example: Single Button Dialog" but it seems to apply to any dialog.
The exception seems to be a docked palette, but this functionality seems to be rather limited in GMS2.3/GMS3.
Example code to test:
class myUItest:UIframe
{
    object Init( object self )
    {
        TagGroup dlgTGitems
        TagGroup dlgTG = DLGCreateDialog("Modal",dlgTGitems)
        TagGroup dlgField = DLGCreateIntegerField(12,20)
        dlgTGitems.DLGAddElement(dlgField)
        return self.super.init(dlgTG)
    }
}

{
    object DLG = ALLOC(myUItest).Init()
    DLG.Pose()
    DLG.display("Modeless")
}

A: There seems to be no way to prevent termination of modal dialogs (those presented via the Pose method of UIFrame) via the keystrokes you mention.  However, would a modeless dialog work for your application?  Such a dialog is created by invoking the Display method on your UIFrame object and it is not closed via esc or enter.


text:
Q: Automating PDF download with Python Selenium Chromedriver I am using Chrome/Chromedriver version: 93.0.4577 and Selenium version: 3.141.0 on Win 10. I'm trying to get Selenium to download PDF's without opening the file prompt.
I'm working with a work site unfortunately so I'm unable to share it but I've tried the libraries: urllib, request, as well as adjusting the chrome Options (which I'd like to use):
chrome_profile = webdriver.ChromeOptions()
profile = {"plugins.plugins_list": [{"enabled": False,
                                     "name": "Chrome PDF Viewer"}],
           "download.default_directory": "C:\\PDFDownload\\PDFs",
           "download.prompt_for_download": False,
           "download.directory_upgrade": True}

chrome_profile.add_experimental_option("prefs", profile)

driver = webdriver.Chrome(executable_path="C:\\Selenium\\chromedriver.exe",
                                       chrome_options=chrome_profile)

I've also tried switching the chrome PDF site settings from 'Open PDFs in Chrome' to 'Download PDFs' when visiting them. However, everything still prompts me to save the file manually.
I feel like the chrome Options should be the winning ticket but it doesn't seem to have worked for me. Is there something I need to change/add in order to get past the pop up prompt?
I appreciate any advice, thank you!

A: You can try the following:

*

*First get the 'href' or download link of the PDF you're looking for. There must be some button or link which you might want to catch.

*use self.driver.get(the_link_you_extracted_in_step_1) and the PDF should be automatically downloaded


text:
Q: Unexpected behavior of binary conversions (COALESCE vs. ISNULL) Can you comment on what approach shown below is preferable? I hope the question will not be blocked as "opinionated". I would like to believe there is an explanation that makes that clear.
Context: I have a code for mirroring 3rd party table contents to my own table (optimization). It worked some time flawlessly until the size/modification of the database reached some threshold.
The optimization is based on row version values of more tables, and remembering the maximum of the values from the source tables. This way I am able to update my local table incrementally, much faster than rebuilding it from time to time from scratch.
The problem started to appear when the row-version value exceeded the 4byte value. After some effort, I have spotted that the upper 4 bytes of the binary(8) value were set to 0. Later, the suspect was found to have a form COALESCE(MAX(row_version), 1).
The COALESCE was used to cover the case when the local table is fresh, containing now data -- for comparing the MAX(row_version) of source tables with something meaningful.
The examples to show the bug: To simulate the last mentioned situation, I want to convert the NULL value of the binary(8) column to 1. I am adding also the ISNULL usage that was added later. The original code contained the COALESCE only.
DECLARE @bin8null binary(8) = NULL

SELECT 'bin NULL' AS the_variable, @bin8null AS value
SELECT 'coalesce 1' AS op, COALESCE(@bin8null, 1) AS good_value
SELECT 'coalesce 1 + convert' AS op, CONVERT(binary(8), COALESCE(@bin8null, 1)) AS good_value
SELECT 'isnull 1' AS op, ISNULL(@bin8null, 1) AS good_value
SELECT 'isnull 0x1' AS op, ISNULL(@bin8null, 0x1) AS bad_value

(There is a bug in the image coalesce 0x1 + convert fixed later in the code to coalesce 1 + convert, but not fixed in the image.)
The application bug appeared when the binary value was bigger than the part that could be stored in 4 bytes. Here the 0xAAAAAAAA was used. (Actually, the 0x00000001 was the case, and it was difficult to spot that the single 1 was changed to 0.)
DECLARE @bin8 binary(8) = 0xAAAAAAAA01BB3A35

SELECT 'bin' AS the_variable, @bin8 AS value
SELECT 'coalesce 1' AS op, COALESCE(@bin8, 1) AS bad_value
SELECT 'coalesce 1 + convert' AS op, CONVERT(binary(8), COALESCE(@bin8, 1)) AS bad_value
SELECT 'coalesce 0x1 + convert ' AS op, CONVERT(binary(8), COALESCE(@bin8, 0x1)) AS good_value
SELECT 'isnull 1' AS op, ISNULL(@bin8, 1) AS good_value
SELECT 'isnull 0x1' AS op, ISNULL(@bin8, 0x1) AS good_value

When executed in Microsoft SQL Server Management Studio on MS-SQL Server 2014, the result looks like this:

Description -- my understanding: The COALESCE() seems to derive the type of the result from the type of the last processed argument. This way, the non-NULL binary(8) was converted to int, and that lead to the loss of upper 4 bytes. (See the 2nd and 3rd red bad_value on the picture. The difference between the two cases is only in decimal/hexadecimal form of display.)
On the other hand, the ISNULL() seems to preserve the type of the first argument, and converts the second value to that type. One should be careful to understand that binary(8) is more like a series of bytes. The interpretation as one large integer is only the interpretation. Hence, the 0x1 as the default value does not expand as 8bytes integer and produces bad value.
My solution: So, I have fixed the bug using ISNULL(MAX(row_version), 1). Is that correct?

A: Let me start of by saying:
This is not a "bug".
ISNULL and COALESCE are not the same function, and operate quite differently.
ISNULL takes 2 parameters, and returns the second parameter if the first has a value NULL. If the 2 parameters are different datatypes, then the dataype of the first datatype is returned (implicitly casting the second value).
COALESCE takes 2+ parameters, and returns the first non-NULL parameter. COALESCE is a short hand CASE expression, and uses Data Type Precendence to determine the returned data type.
As a result, this is why ISNULL returns what you expect, there is no implicit conversion in your query for the non-NULL variable.
For the COALESCE there is implicit conversion. binary has the lowest precedence of all the data types, with a rank of 30 (at time of writing). The value 1 is an int, and has a precedence of 16; far higher than 30.
As a result COALESCE(@bin8, 1) will implicitly convert the value 0xAAAAAAAA01BB3A35 to an int and then return that value. You see this as SELECT CONVERT(int,0xAAAAAAAA01BB3A35) returns 29047349, which your first "bad" value; it's not "bad", it's correct for what you wrote.
Then for the latter "bad" value, we can convert that int value (29047349) back to a binary, which results in 0x0000000001BB3A35, which is, again the result you get.
TL;DR: checking return types of functions is important. ISNULL returns the data type of first parameter and will implicitly convert the second if needed. For COALESCE it uses Data Type Precedence, and will implicitly convert the returned value to the data type of with the highest precedence of all the possible return values.

A: This is not a bug. They're documented to handle data type precedence differently. COALESCE determines the data type of the output based on examining all of the arguments, while ISNULL has a more simplistic approach of inspecting only the first argument. (Both still need to contain values which are all compatible, meaning they are all possible to convert to the determined output type.)
From the COALESCE topic:

Returns the data type of expression with the highest data type precedence.

The ISNULL topic does not make this distinction in the same way, but implicitly states that the first expression determines the type:

replacement_value must be of a type that is implicitly convertible to the type of check_expression.

I have a similar example (and describe several other differences between COALESCE and ISNULL) here. Basically:
DECLARE @int int, @datetime datetime;
SELECT COALESCE(@int, CURRENT_TIMESTAMP);

-- works because datetime has a higher precedence than the chosen output type, int
 2020-08-20 09:39:41.763

GO
DECLARE @int int, @datetime datetime;
SELECT ISNULL(@int, CURRENT_TIMESTAMP);

-- fails because int, the first (and chosen) output type, has a lower precedence than datetimeMsg 257, Level 16, State 3Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query.


text:
Q: Display NotifyOSD Notifcations in Conky? I want to display the latest NotifyOSD notification in conky, I can display the entire file with
${execi 30 cat ~/.cache/notify-osd.log}
But is it possible to show only the last line of the file? and get it to periodically check the log for changes to the last line?

A: As you pointed out:

I sorted the problem by using this
${execi 30 cat
  ~/.cache/notify-osd.log| tail -4}
which works perfectly
(source)


text:
Q: Grouping and Summarize SQL My table looks like the following:

income
date
productid
invoiceid
customerid

300
2015-01-01
A
1234551
1

300
2016-01-02
A
1234552
1

300
2016-01-03
B
1234553
2

300
2016-01-03
A
1234553
2

300
2016-01-04
C
1234554
3

300
2016-01-04
C
1234554
3

300
2016-01-08
A
1234556
3

300
2016-01-08
B
1234556
3

300
2016-01-11
C
1234557
3

I need to know : Number of invoices per customer, how many customers in total (for example one invoice = several customers, two invoices = two customers, three invoices = three customers, and so..).
What is the syntax for this query?
In my sample data above, customer 1 has two invoices, customer 2 one invoice and customer 3 three invoices. So there is one customer each with a count of 1, 2, and 3 invoices in my example.
Expected result:

invoice_count
customers_with_this_invoice_count

1
1

2
1

3
1

I tried this syntax and I'm still stuck:
select * from
(
  select CustomerID,count(distinct InvoiceID) as 'Total Invoices'
  from exam
  GROUP BY CustomerID
) a

A: Select Count(customerID),CustomerID From a
Group By customerID
Having Count(customerID) > 1


text:
Q: CSS/JS: mimic background-image cover using image element with known width and height I am trying to create letterboxes for video thumbnails in css. Thumbnails can be any size but I want them to fit within a box with a fixed aspect ratio of 16:9. This is easy to accomplish if I use the background-image properties. See the example below:

.container {
   background-color: gray;
   position: relative;
   width: 100%;
   padding-top: 56.25%;
   background-size: contain;
   background-repeat: no-repeat;
   background-position: center;
}

.container1 {
   background-image: url("https://bulma.io/images/placeholders/640x480.png");
}

.container2 {
   background-image: url("https://bulma.io/images/placeholders/720x240.png");
}

However, using background-image introduces a few problems. I only want the background of .container to be gray while the thumbnail is loading, once it has loaded I want it to be black. I also want to replace the thumbnail url with a default thumbnail url if for some reason the thumbnail fails to load. I cannot think of a way to do this without being able to use the onload and onerror events of an actual image element.
Fortunately, since in my actual code I am fetching the thumbnail urls dynamically I can also return the width and height of a thumbnail so I know it before I try to load it. However, I cannot figure out how to convert the width and height of the thumbnail into the correct percent it needs to be to cover the center of the box the same way the first example does using background-image. See the example below:

let c1ThumbnailWidth = 640;
let c1ThumbnailHeight = 480;
let c2ThumbnailWidth = 720;
let c2ThumbnailHeight = 240;

$( document ).ready(function() {
  $('.container1 img').css('left', 100 * (1 - (9 / 16) * (c1ThumbnailWidth / c1ThumbnailHeight)) / 2 + '%');
  $('.container2 img').css('left', 100 * (1 - (9 / 16) * (c2ThumbnailWidth / c2ThumbnailHeight)) / 2 + '%');

  $('.container img').one('load', function() {
    $(this).parent().css('background-color', '#000');
  });

  $('.container img').on('error', function () {
    $(this).attr('src', 'default.jpg');
  });
});
.container {
   background-color: gray;
   position: relative;
   width: 100%;
   padding-top: 56.25%;
}

.container img {
    position: absolute;
    top: 0;
    height: 100%;
}

How can I make the image element mimic the behavior of a background-image set to cover or alternatively how can I tell when a background-image has loaded or failed to load and adjust it accordingly?

A: Have you tried using CSS object-fit on the image element?
https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit


text:
Q: two php objects, use function from the other? object variable scope? Maybe I've lost it, but what am I doing wrong here? I get undefined variable 'database' when I call the route method...
class database {
    function connect() {
        echo("connecting database");
    }
}

class router {
    function route() {
        $database->connect();
        echo("then do some routing");
    }
}

$database = new database;
$router = new router;

$router->route();

*

*Shouldn't the reference to the $database object in the $router object fall back to the global one??

*Do I really have to pass the database object when I call the route method?

*What if the database object ends up having heaps of methods, will I be passing all of them whenever I call the route method?

A: The class router can not see variable $database, you could pass it by parameter when calling the function
    class router {
        function route($database) {
            $database->connect();
            echo("then do some routing");
        }
    }

    $database = new database;
    $router = new router;

$router->route($database);

or maybe you could define $database as a global variable
class router {
    function route() {
        global $database;
        $database->connect();
        echo("then do some routing");
    }
}

$database   = new database;
$router = new router;

$router->route();


text:
Q: PHP cookie doesn't delete with class I would like to know why I can't delete a cookie with a class but I can without any class.
cookies.php
static public function Delete($name, $expiry){
    unset($_COOKIE[$name]);
    setcookie($name, false, $expiry, '/');
}

index.php
if(Cookie::Exists('country')){
    Cookie::Delete($_COOKIE['country'], time() - 3600);
}

This doesn't work. The code below works.
if(Cookie::Exists('country')){
    setcookie('country', false, time() - 3600, '/');
}

I get no errors. I've made an echo of the content with both two options, the first one the echo always retrieve content..the second one it only retrieves content 1 time (after that is deleted..which is correct).

A: Cookie::Delete($_COOKIE['country'], time() - 3600);
You are passing in the COOKIE's value as the name for your cookie. So if country was "UK" in the cookie, your DELETE method will set a cookie named "UK" to expire.
Change it too
Cookie::Delete('country', time() - 3600);