text:
Q: sqlite query results in crash in iPhone app - Memory Issue I am using a sqlite query to get nutrient values for a specific food item from USDA database.
The query works fine, when tried in simulator, but results in crash on device sometimes.
I am including the USDA database in the app itself. Also the table on which the query is getting executed holds more than 5 lac records. I am getting 'Level 1 Memory Warning' at the launch of application. I cannot go for webservices, as the requirement is to give offline support.
Any suggestions how to handle this situation??
Edit :
In the log I get Signal 0 message
Program received signal:  "0".
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")

A: I guess the size of the database is causing the crash...
If you are using this database as read only then you can use the compressed and encrypted form ... you can get more details from here http://www.hwaci.com/sw/sqlite/cerod.html
this might help you get rid of the memory warnings..
here is another link which can help you reduce the size of the database....
How to reduce the size of an sqlite3 database for iphone?

A: You are exhausting your app's memory. I am not a DB expert but you will have to use some special techniques to access your huge data base. Perhaps execute multiple queries serially in different sections of the DB. Or divide the DB into segments. Following are some references related to the crash you are seeing-
Program received signal: "0". Data Formatters temporarily unavailable
Data Formatters temporarily unavailable
Data Formatters temporarily unavailable, will re-try after a 'continue'
There are more if you search for the error message.

A: Memory Related Crashes are quite common for ios apps I've noticed that more stable apps tend to manually manage memory alot over just letting the device manage it. I think if you split it up into sections instead of reading off one file and like akshay said index the tables it will be more stable. You could try reading files from compressed zips which would be more efficient over just plain old reading.


text:
Q: Can I "speak IMAP" and review my actual mail quota? I'm trying to troubleshoot a frustrating inbox quota issue. Thunderbird says my inbox is 80% full. My ISP says it isn't. We made some tweaks and I should have 2G available (it had been "unlimited"). Thunderbird, unfortunately, still reports that I'm using 206456 of my 256000 KB limit on Quota Root "ROOT."
Is there a command line method I can use to find out what my mail host is telling Thunderbird? Can Mutt tell me?

A: Perhaps the Python imaplib library could help.  Launch a python console from the terminal with python. Then, create an IMAP connection with the following commands:
>>> import imaplib
>>> conn = imaplib.IMAP4('hostname')
>>> conn.login('username', 'password')

If your IMAP server uses SSL, use the IMAP4_SSL constructor instead of IMAP4.  You can then use the getquotaroot or getquota methods on the connection.  For example:
>>> conn.getquotaroot('INBOX')
>>> conn.getquota('quota root') # using the root from the previous command

A: Using openssl :
openssl s_client -connect example.org:imap -starttls imap

then log in when you get a prompt :
a LOGIN user@example.org password

and finally :
a GETQUOTA ""

redpajama_set_name: RedPajamaStackExchange


text:
Q: PowerPoint automatically fill shapes My PowerPoint has a timeline which i created my self with "SmartArt" and Shapes. Now i want that all the shapes in this timeline will fill automatically with dates if i edit the first date.
In the picture you can see my timeline.
I am totally new to PowerPoint VBA so i do not even know how to call this macro.
I would write the makro like this:
Sub Fill_Shapes()
    Dim StartDate As Date
    Dim myShape As Object

    Set myShape = ActiveSlide.Shapes(1)
    StartDate = myShape.Text

    For i = 2 To 14
        Set myShape = ActiveSlide.Shapes(i)
        With Application.Presentations(1).Slides(3).Shapes(i).TextFrame.TextRange
            .Text = StartDate  + 15
        End With
        StartDate = myShape.Text
    Next
End If

So my two problems are, how can i call the macro if i fill a date to the shape 1 (left from the red arrow) and will my macro even work the way i write it?

A: I think you are confusing Shapes with the individual elements (nodes) of SmartArt.
Smart Art is a effectively a single shape with its own inbuilt elements.  Therefore, with i being your looper you should be looking at
With Application.Presentations(1).Slides(3).Shapes(99).SmartArt.AllNodes.Item(i).TextFrame2.TextRange

Where 99 is the number of your shape (although you are better to refer to it by name).


text:
Q: php multilanguage website error issue i am new to php and i was trying to create a simple multilanguage web site with php. am mentioned below my total code, and i am having the total four files, index.php, setlocal.php, and one folder locale within that en.php, fn.php files. am having the folder structure like this..
----
index.php
setlocal.php

locale
 en.php
 fn.php

the file codes are..
index.php
<?php
include_once "setlocal.php";
?>

<!doctype html>

<title><?php echo $GLOBALS['l']['title1']; ?></title>

English

French

<?php echo $GLOBALS['l']['homdes1']; ?>

setlocal.php
<?php

($language = @$_GET['lang']) or $language = 'en';

$allowed = array('en', 'te');

if(!in_array($language, $allowed)) {
$language = 'en';
}

include "locale/{$language}.php";

$GLOBALS['l'] = '$local';

?>

locale
     |
    en.php
<?php

$local = array (
'title1' => 'sample english content',
'homdes1' => 'sample english contentsample english contentsample english content');

?>

fn.php
<?php

$local = array (
'title1' => 'sample french content',
'homdes1' => 'sample french contentsample french contentsample french contentsample       french contentsample french content');

?>

when am running the code it was showing the error like this below, kindly help me to solve  this issue, thank you.
Warning: Illegal string offset 'homdes1' in  D:\madhu_new\korimerla\htdocs\korimerla\php\index.php on line 15
$

A: Try removing the quotes around $local from this line in file setlocal.php:
$GLOBALS['l'] = '$local';

so that it reads:
$GLOBALS['l'] = $local;

This will give you:
// you can use var_dmp() this to see what you have in $GLOBALS['l']
var_dump($GLOBALS['l']);

array(2) {
  ["title1"]=>
  string(22) "sample english content"
  ["homdes1"]=>
  string(66) "sample english contentsample english contentsample english content"
}

This can then be accessed using the array syntax:
echo $GLOBALS['l']['homdes1'];

// gives:
sample english contentsample english contentsample english content

A: Change your setlocal.php to this:
<?php

//Check if $_GET['lang'] is set, if not default to 'en'
$language = isset($_GET['lang']) ? $_GET['lang'] : 'en';

$allowed = array('en', 'te');

if(!in_array($language, $allowed)) {
  $language = 'en';
}

include "locale/$language.php";

//without single quotes. PHP will expand (convert) variable names inside double quotes to the value, but within single vars are printed as is.
$GLOBALS['l'] = $local;

?>


text:
Q: Eclipselink -Glassfish project Object is not a known entity type error In a JSF 2.1 - Spring 3.1  integrated project.I m trying to handle transaction by container i m using eclipselink 2.3.2 ,Glassfish 3.1.2 and Maven on my project and working on Netbeans IDE 7.2 .
At service layer i injected entity manager by the code below and on debug it seems ok .
 @Inject
public void setEntityManager() {
EntityManagerFactory emfactory =Persistence.createEntityManagerFactory
("E_DefterManagementPU");
    this.em = emfactory.createEntityManager();

But after i filled the entity named EfaFunctions and try to persist with
em.persist(EfaFunctions);

it gives this error
java.lang.IllegalArgumentException: Object: org.eclipse.persistence.internal.jpa.EntityManagerImpl@599ebbf6
 is not a known entity type.

But in **persistence.xml ** i have following nodes
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>EFA</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>

My entity project location is com.edefter.entity.EfaFunctions ;not the location specified in error .Actually there is an answer written by Pascal in this link
but  my generation strategy is none and my entites were generated  from Database by netbeans .I need some experts advice . Thanks in Advance
I deleted the
@Table(name="EFA_FUNCTIONS")

annotation from top of Entity ,but @Entity still stays.
The error is gone but then the query starts as
INSERT INTO EFAFUNCTIONS

without  underscore but i need
 INSERT INTO EFA_FUNCTIONS

,becouse of it the data did not inserted . Why eclipselink gives error for @Table annotation and despite there is no table like EFAFUNCTIONS why it doesnt give any error

A: I solved the problem , As i mentioned  in question i had generated Entities from Database via Netbeans,so that i didn't suspect the entity format.I had worked before hibernate as ORM and hibernate plus DB2 or MYSQL.These combinations didnt give an error with same usage.But with  the combination Eclipselink - Oracle DB @Entity annotation has to be parameter as written below
@Entity(name="entityName")
@Table(name="TableName")
Thanks for comment.

A: Why would you try to persist an EntityManager ? Much better to pass in (to em.persist) an Entity (one of those classes tagged as @Entity)

A: I had a similar problem, when trying to persist an object of an entity class by calling persist() on the entitymanager:

java.lang.IllegalArgumentException: Object: entities.Documents[ id=null ] is not a known entity type.

it turned out that the name of the persistence unit declared in the persistence.xml in the line
<persistence-unit name="my-pu" transaction-type="RESOURCE_LOCAL">

was diffrent from the name I used when declaring the Entity Manager Factory in the java code:
 EntityManagerFactory entityManagerFactory =  Persistence.createEntityManagerFactory("my-persistenceunit");

After correcting both names to the same name, calling persist() worked as expected.


text:
Q: Why does this algorithm have a O(n^2) time instead of O(n^3)? I've been studying Big-O for an upcoming interview and I wanted something explained.
So one way I've been determining the run-time of algorithms is by counting the number of for-loops. For example, if an algorithm uses 1 for-loop I'd count that as O(n)
and if it used two for-loops I'd say it was O(n^2). I find that this is generally an easy way to figure out time for simple algorithms. Although in a textbook I am reading they said this algorithm has an O(n^2) run-time.
 a=5
b=6
c=10
for i in range(n):
   for j in range(n):
      x = i * i
      y = j * j
      z = i * j
for k in range(n):
   w = a*k + 45
   v = b*b
d = 33

How would this have an O(n^2) run-time? If ()=3+32+2+1=32+2+4 then are we just discarding the last loop (2n) because it does not add to 3n^2?
Thanks for reading!

A: Let's look at what the curves look like:

You can see here what a curve for just N looks like, along with the curve for N^2 and their sum.  Notice anything?  The N^2+N curve looks a lot more like an N^2 curve than an N curve, adding the N didn't really change it a whole lot.  In fact, if we scale the sum curve by a constant (.93 in this case), we can make them look almost identical:

If we're analyzing algorithms, at least theoretically, we're generally worried about the factors that will dominate our processing time.  If adding a factor of N to the runtime doesn't change much, why bother thinking about it?  We should worry about the quadratic behavior.  This isn't necessarily true in real life, where we might really care if something is a constant 2x factor, but at least for theoretical analysis it is.
This is why big-O notation is an asymptotic measure of performance.  We only consider what happens as N gets very large.  If we think about the ratio N^2/N as N -> infinity, it's obvious that this will trend to zero.  So, the larger n gets, the less important the linear factor is, and thus we discard it.


text:
Q: Changing backlight brightness in Appwidget is not responding instantly I have created a simple Appwidget to control the brightness of the screen by this code:
android.provider.Settings.System.putInt(context.getContentResolver(),
                  android.provider.Settings.System.SCREEN_BRIGHTNESS, 50);

When i click the widget, there is no change in the brightness of the backlight immediately.
But when i lock and unlock the phone, it works. I read Changing screen brightness programmatically (as with the power widget) that using dummy activity will give the solution. So i created an activity like this
public class Bright extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.finish();

}
}

In my AppWidget class i used intent like this:
context.startActivity(new Intent(context, Bright.class));

But when i click the widget, it force closes. Is my implementation is correct for my AppWidget??

A: You should adjust the brightness in your dummy Activity too by using getWindow().getAttributes().screenBrightness if you want it to respond immediately.
As for the crashing, you might want to post the stack trace. But first check that you added it to your manifest.


text:
Q: Default value of delegates inside classes using System;

public delegate void Printer(string s);

class Program
{
    public static void Main(string[] args)
    {
        Printer p = new Printer(delegate {});
        p+= myPrint;
        p("Hello");
        Console.ReadKey(true);
    }

    public static void myPrint(string s)
    {
        System.Console.WriteLine(s);
    }
}

It seems as if I have to initialize a delegate with an empty anonymous function to be able to use += later on. When I omit the new clause, p gets to be null and += doesn't work, which makes sense.
Now, when I have a class with a delegate instance, I can do the following:
using System;

public delegate void Printer(string s);

class Program
{
    public static void Main(string[] args)
    {
        A a = new A();
        a.p += myPrint;
        a.p("Hello");
        Console.ReadKey(true);
    }

    public static void myPrint(string s)
    {
        System.Console.WriteLine(s);
    }
}

class A {
    public Printer p;
}

Why is this allowed? Is there a default value for the delegate instance p? It can't be null because then I would not be able to assign it a new callback using +=. I have tried to search for this problem with the keywords "default value for delegates" and found nothing. Also, sorry if the question if too basic.
Thanks for your help!

A: Delegates are reference types, so the default value is null.
However, variables (unlike fields) are not initialized by default:
Printer p;
p += myPrint; // doesn't work: uninitialized variable

You need to initialize the variable before you can use it:
Printer p = null;
p += myPrint;

or
Printer p;
p = null;
p += myPrint;

Note that for delegates (but not events!)
p += myPrint;

is shorthand for
p = (Printer)Delegate.Combine(p, new Printer(myPrint));


text:
Q: php-cs-fixer doesn't indent HTML inside PHP control structures I'm trying to use php-cs-fixer with a WordPress project, which means I (unfortunately) have files with a mix of PHP and HTML. I'm using the @PSR12 ruleset.
I'm having trouble with getting HTML within PHP control structures to indent correctly. Take this example snippet:
<?php if (!empty($related_posts)) : ?>

Related <?= esc_html($title) ?>

<?php endif ?>

php-cs-fixer reformats it to:
<?php if (!empty($related_posts)) : ?>

Related <?= esc_html($title) ?>

<?php endif ?>

Note the closing h3 tag has been moved to a new line, and the first-level indent within the if statement body has been removed.
The h3 issue I can live with, as this is resolved if I put the opening tag on its own line:

    Related <?= esc_html($title) ?>

...but the lack of indent within the if statement is going to do my head in. The same thing happens with for and while statements.
Is there a rule in php-cs-fixer that I've overlooked that will resolve this?

A: The Answer of keradus on the "PHP code does not align with html code" issue:

PHP CS Fixer was never written with supporting mixed html/php file.
Some fixers are supporting one php part and one html part inside single file, but not big mix of them, like in template files.
If we would like to support template files, we would need to not only detect and track concrete fixers, but also provide some big integration test (like we do for Sf ruleset) that it remains to work for most important rules.
Before that happen, I would not claim that we officially support html/php mixed-files.

And in another answer:

we do not aim to fix mixed file (PHP and HTML in single file)

A: Not really an answer but I ended up just switching to PHP_CodeSniffer to get around this.


text:
Q: setURLStreamHandlerFactory and "java.lang.Error: Factory already set" I've come across an unexpected error caused by calling URL.setURLStreamHandlerFactory(factory); in an Android application that is being updated.
public class ApplicationRoot extends Application {

    static {
        /* Add application support for custom URI protocols. */
        final URLStreamHandlerFactory factory = new URLStreamHandlerFactory() {
            @Override
            public URLStreamHandler createURLStreamHandler(final String protocol) {
                if (ExternalProtocol.PROTOCOL.equals(protocol)) {
                    return new ExternalProtocol();
                }
                if (ArchiveProtocol.PROTOCOL.equals(protocol)) {
                    return new ArchiveProtocol();
                }
                return null;
            }
        };
        URL.setURLStreamHandlerFactory(factory);
    }

}

Intro:
Here is my situation: I'm maintaining a non-market application used in an enterprise fashion.  My business sells tablets with pre-installed applications that are developed and maintained by the business.  These pre-installed applications are not part of the ROM; they are installed as typical Unknown Source applications.  We do not perform updates through the Play Store or any other market.  Rather, application updates are controlled by a custom Update Manager application, which communicates directly with our servers to perform OTA updates.
Problem:
This Update Manager application, which I am maintaining, occasionally needs to update itself.  Immediately after the application updates itself, it restarts by way of the android.intent.action.PACKAGE_REPLACED broadcast, which I register for in the AndroidManifest.  However, upon restart of the application immediately after the update, I occasionally receive this Error
java.lang.Error: Factory already set
    at java.net.URL.setURLStreamHandlerFactory(URL.java:112)
    at com.xxx.xxx.ApplicationRoot.<clinit>(ApplicationRoot.java:37)
    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1208)
    at android.app.Instrumentation.newApplication(Instrumentation.java:996)
    at android.app.Instrumentation.newApplication(Instrumentation.java:981)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2625)
    at android.app.ActivityThread.access$1800(ActivityThread.java:172)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1384)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5653)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
    at dalvik.system.NativeStart.main(Native Method)

Note that the majority of the time, the application restarts properly.  However, every once in a while, I get the above error.  I'm perplexed because the only place I call setURLStreamHandlerFactory is here, and it is done in a static block, which I presume - although correct me if I'm wrong - is only called once, when the ApplicationRoot class if first loaded.  However, it would seem that it is getting called twice, resulting in the above error.
Question:
What in the blazing sams is going on?  My only guess at this point is that the VM/process for the updated application is the same as the previously installed application that is being updated, so when the static block for the new ApplicationRoot gets called, the URLStreamHandlerFactory set by the old ApplicationRoot is still "active".  Is this possible?  How can I avoid this situation?  Seeing that it doesn't always happen, it seems to be a race condition of some sort; maybe within Android's APK installation routine? Thanks,
Edit:
Additional code as requested.  Here is the manifest portion dealing with the Broadcast
<receiver android:name=".OnSelfUpdate" >
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_REPLACED" />
        <data android:scheme="package" />
    </intent-filter>
</receiver>

And the BroadcastReceiver itself
public class OnSelfUpdate extends BroadcastReceiver {

    @Override
    public void onReceive(final Context context, final Intent intent) {
        /* Get the application(s) updated. */
        final int uid = intent.getIntExtra(Intent.EXTRA_UID, 0);
        final PackageManager packageManager = context.getPackageManager();
        final String[] packages = packageManager.getPackagesForUid(uid);

        if (packages != null) {
            final String thisPackage = context.getPackageName();
            for (final String pkg : packages) {
                /* Check to see if this application was updated. */
                if (pkg.equals(thisPackage)) {
                    final Intent intent = new Intent(context, MainActivity.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(intent);
                    break;
                }
            }
        }
    }

}

A: Static blocks are executed when the class is loaded - if the class is reloaded for some reason (for example when it has been updated) it will be executed again.
In your case it means that the URLStreamHandlerFactory you set the previous time it was loaded will remain.
This isn't really an issue unless you've updated the URLStreamHandlerFactory.
There are two ways of fixing this:

*

*Catch the Error and continue on your merry way, ignoring the fact that you're still using the old factory.

*Implement a very simple wrapper that delegates to another URLStreamHandlerFactory that you can replace and that you won't have to change. You'll run into the same issue here with the wrapper though so you need to catch the Error on that one or combine it with option 3.

*Keep track of whether or not you've already installed the handler using a system property.
Code:
public static void maybeInstall(URLStreamHandlerFactory factory) {
    if(System.getProperty("com.xxx.streamHandlerFactoryInstalled") == null) {
        URL.setURLStreamHandlerFactory(factory);
        System.setProperty("com.xxx.streamHandlerFactoryInstalled", "true");
    }
}

*Force replacement using reflection. I have absolutely no idea why you can only set the URLStreamHandlerFactory once - it makes little sense to me TBH.

Code:
public static void forcefullyInstall(URLStreamHandlerFactory factory) {
    try {
        // Try doing it the normal way
        URL.setURLStreamHandlerFactory(factory);
    } catch (final Error e) {
        // Force it via reflection
        try {
            final Field factoryField = URL.class.getDeclaredField("factory");
            factoryField.setAccessible(true);
            factoryField.set(null, factory);
        } catch (NoSuchFieldException | IllegalAccessException e1) {
            throw new Error("Could not access factory field on URL class: {}", e);
        }
    }
}

The field name is factory on Oracle's JRE, might be different on Android.

A: AFAIK you can/should not restart the JVM. Furthermore, as you've already found out, you can't set URLStreamHandlerFactory twice in a JVM for a single application.
Your application should try to set the factory only when it isn't:
try {
    URL.setURLStreamHandlerFactory(factory);
} catch (Error e) {
    e.printStackTrace();
}

If your application updates also include updating the factory, you could try killing the process your app resides in but I don't it's a good idea to do so, even worse - it might not even work.


text:
Q: preciso espremer meu layout quando abre o teclado Estou usando um TableLayout que contem EditText, e quando o foco está no EditText o teclado abre e fica na frente de informações importantes, gostaria de poder espremer o layout quando abrir o teclado. Para o meu layout inteiro (que antes ocupava a tela toda) fique inteiro visível com o teclado aberto. Isso é possível?
Alguém pode me dar umas dicas ou mostrar uma literatura/tutorial?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000"
    android:orientation="vertical"
    tools:context="com.example.app.MainActivity" >

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:weightSum="4" >

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:weightSum="1" >

            <EditText
                android:id="@+id/etdescricao"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />
        </TableRow>

        <TableRow
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#000000" >

            <EditText
                android:id="@+id/etl5"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:weightSum="5" >

            <EditText
                android:id="@+id/et1"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/etl1"
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et2"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/etl2"
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et3"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/etl3"
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et4"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/etl4"
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et5"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />
        </TableRow>

        <TableRow
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#000000" >

            <EditText
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:weightSum="5" >

            <EditText
                android:id="@+id/et6"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et7"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et8"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et9"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et10"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />
        </TableRow>

        <TableRow
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#000000" >

            <EditText
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:weightSum="5" >

            <EditText
                android:id="@+id/et11"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et12"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et13"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et14"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />

            <EditText
                android:id="@+id/et15"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#ffffff"
                android:maxLength="100"
                android:maxLines="2" />
        </TableRow>

        <TableRow
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#000000" >

            <EditText
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#000000"
                android:maxLength="100"
                android:maxLines="2" />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:weightSum="5" >

            <Button
                android:id="@+id/btSalvar"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@drawable/btn_selector"
                android:text="Salvar"
                android:textColor="#ffffff"
                android:textSize="30sp" />

            <Button
                android:id="@+id/BtPrevious2"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@drawable/btn_selector"
                android:text="@string/previous"
                android:textColor="#ffffff"
                android:textSize="30sp" />

            <Button
                android:id="@+id/tvp2"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#000000"
                android:singleLine="true"
                android:textColor="#ff0000"
                android:textSize="75sp" />

            <Button
                android:id="@+id/btNext2"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@drawable/btn_selector"
                android:text="@string/Next"
                android:textColor="#ffffff"
                android:textSize="30sp" />

            <ImageButton
                android:id="@+id/imageButton1"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="#000000"
                android:src="@drawable/logostar" />
            <!-- android:background="#000000" -->

        </TableRow>
    </TableLayout>
</LinearLayout>

A: O que você pode fazer é colocar seu layout dentro de um ScrollView e quando o teclado abrir, o usuário poderá rolar o layout para ver a informação que desejar.
Ficaria assim:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.app.MainActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#000000"
        android:orientation="vertical" >

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:weightSum="4" >

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:weightSum="1" >

                <EditText
                    android:id="@+id/etdescricao"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />
            </TableRow>

            <TableRow
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000" >

                <EditText
                    android:id="@+id/etl5"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />
            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:weightSum="5" >

                <EditText
                    android:id="@+id/et1"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/etl1"
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et2"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/etl2"
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et3"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/etl3"
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et4"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/etl4"
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et5"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />
            </TableRow>

            <TableRow
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000" >

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />
            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:weightSum="5" >

                <EditText
                    android:id="@+id/et6"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et7"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et8"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et9"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et10"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />
            </TableRow>

            <TableRow
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000" >

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />
            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:weightSum="5" >

                <EditText
                    android:id="@+id/et11"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et12"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et13"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et14"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />

                <EditText
                    android:id="@+id/et15"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#ffffff"
                    android:maxLength="100"
                    android:maxLines="2" />
            </TableRow>

            <TableRow
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#000000" >

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#000000"
                    android:maxLength="100"
                    android:maxLines="2" />
            </TableRow>

            <TableRow
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:weightSum="5" >

                <Button
                    android:id="@+id/btSalvar"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/btn_selector"
                    android:text="Salvar"
                    android:textColor="#ffffff"
                    android:textSize="30sp" />

                <Button
                    android:id="@+id/BtPrevious2"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/btn_selector"
                    android:text="@string/previous"
                    android:textColor="#ffffff"
                    android:textSize="30sp" />

                <Button
                    android:id="@+id/tvp2"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#000000"
                    android:singleLine="true"
                    android:textColor="#ff0000"
                    android:textSize="75sp" />

                <Button
                    android:id="@+id/btNext2"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/btn_selector"
                    android:text="@string/Next"
                    android:textColor="#ffffff"
                    android:textSize="30sp" />

                <ImageButton
                    android:id="@+id/imageButton1"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="#000000"
                    android:src="@drawable/logostar" />
                <!-- android:background="#000000" -->

            </TableRow>
        </TableLayout>
    </LinearLayout>

</ScrollView>

A: Um atributo que funcionaria para o seu caso é android:layout_alignParentBottom="true", o que ele faz, é alinhar a view sempre a cima do teclado (quando o mesmo surgir).
Mas você precisa estar usando RelativeLayout.
Quer maiores informações e exemplos?
Link


text:
Q: Join a string with an array in Javascript I can't understand why this test fails:
it('should concat string and arr', function(done) {
    var str = "update userprofile set firstname = 'Barbara', lastname = 'Jensen', cellphone = '5638499', email = 'me@gmail.com', "
    var arr = ['computer', 'business']
    str += "interests = " + arr
    var expected = "update userprofile set firstname = 'Barbara', lastname = 'Jensen', cellphone = '5638499', email = 'me@gmail.com', interests = ['computer', 'business']"
    should(str).equal(expected)
    done()
})

Test result looks like this:

A: When you do
"interests = " + arr

the toString method in that array object will be invoked. Quoting the Array.prototype.toString documentation,

The Array object overrides the toString method of Object. For Array objects, the toString method joins the array and returns one string containing each array element separated by commas. For example, the following code creates an array and uses toString to convert the array to a string.
var monthNames = ['Jan', 'Feb', 'Mar', 'Apr'];
var myVar = monthNames.toString(); // assigns 'Jan,Feb,Mar,Apr' to myVar.

To fix your test case, you need to convert the Array manually, like this
str += "interests = [" + monthNames.map(function(currentString) {
    return "'" + currentString + "'";
}).join(", ") + "]";

A: When you join an array to a string, Javascript will automatically concatenate out the values inside of the array.
For example:
var str = 'my string'+[ 'my', 'arr' ];

Will produce:
"my stringmy,arr"

You must serialise the array using JSON.stringify (or similar). For example:
var str = 'my string';
str+= JSON.stringify( [ 'my', 'arr' ]);

Will produce:
"my string["my","arr"]"

A: The problem is that the outside square brackets of your array are not part of your string, but you expect them to be. It would work if you had:
 var arr = '[computer, business]';

another way to achieve this, is to do that yourself:
var stringOfArr = "[" + arr.join(", ") + "]";


text:
Q: Nativescript-vue GridLayout column losing column position when navigating tabview I am having issues with GridLayout losing their column sizing inside a TabView whenever I go to another tab below the current index
An example is below where I am navigating from the 'Freaks' tab to the 'Legends' tab before it and the items inside the GridLayout lose their column position. All of them seem to revert back to column 0'. Both of the tabs uses the same component with only the data being passed as props being different.
Original GridLayout column position in 'Freaks' tab
GridLayout in 'Legends' tab losing column specifications
Gridlayout code would be
<GridLayout columns="40, *, auto" class="w-100 py-7 border-bottom-light" @longPress="optionsOpened">
    <TImage :col="0" :src="image" class="w-40 h-40 round" />
    <StackLayout :col="1" class="px-20" verticalAlignment="center">
        <Label class="text-13" :text="`${data.attributes.first_name} ${data.attributes.last_name}`" textWrap="true" />
        <Label v-if="role" class="text-11 text-grey text-capitalize" :text="data.attributes.jersey_number ? `#${data.attributes.jersey_number} ${role}` : role" />
    </StackLayout>
    <template v-if="!hide_action">
        <StackLayout class="action-container" :col="2" orientation="horizontal">
            <ActionTile class="at" :text="0xf00c" :is_icon="true" v-if="data.attributes.available == true" @tap.native="markAvailability(!data.attributes.available)" />
            <ActionTile class="at" color="red" :text="0xf00d" :is_icon="true" v-if="data.attributes.available == false" @tap.native="markAvailability(!data.attributes.available)" />
        </StackLayout>
    </template>
</GridLayout>

Has anyone encountered a similar issue? If so, what was your fix? Any help would be much appreciated.


text:
Q: SQL Query is slow and not using indexes SELECT `productTitle`, `orderCnt`, `promPCPriceStr`,
  `productImgUrl`, `oriPriceStr`, `detailUrl`,
  (SELECT count(id) FROM orders t4
   WHERE t4.productId = t1.productId
     AND DATE( t4.`date`) > DATE_SUB(CURDATE(), INTERVAL 2 DAY)
  ) as ordertoday
FROM `products` t1
WHERE `orderCnt` > 0
 AND `orderCnt` < 2000
 AND `promPCPriceStr` > 0
 AND `promPCPriceStr` < 2000
HAVING ordertoday > 5 AND ordertoday < 2000
order by ordertoday desc limit 150

This query take 18 second to finish when i run explain command on it shows this

it does not use the index keys !
The tables used
Products Table
CREATE TABLE `products` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `productId` bigint(20) NOT NULL,
 `detailUrl` text CHARACTER SET utf32 NOT NULL,
 `belongToDSStore` int(11) NOT NULL,
 `promPCPriceStr` float NOT NULL DEFAULT '-1',
 `oriPriceStr` float NOT NULL DEFAULT '-1',
 `orderCnt` int(11) NOT NULL,
 `productTitle` text CHARACTER SET utf32 NOT NULL,
 `productImgUrl` text CHARACTER SET utf32 NOT NULL,
 `created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
 `cat` bigint(20) NOT NULL DEFAULT '-1',
 PRIMARY KEY (`id`),
 UNIQUE KEY `productId` (`productId`),
 KEY `orderCnt` (`orderCnt`),
 KEY `cat` (`cat`),
 KEY `promPCPriceStr` (`promPCPriceStr`)
) ENGINE=InnoDB AUTO_INCREMENT=37773 DEFAULT CHARSET=latin1

Orders Table
CREATE TABLE `orders` (
 `oid` int(11) NOT NULL AUTO_INCREMENT,
 `countryCode` varchar(10) NOT NULL,
 `date` datetime NOT NULL,
 `id` bigint(20) NOT NULL,
 `productId` bigint(20) NOT NULL,
 PRIMARY KEY (`oid`),
 UNIQUE KEY `id` (`id`),
 KEY `date` (`date`),
 KEY `productId` (`productId`)
) ENGINE=InnoDB AUTO_INCREMENT=9790205 DEFAULT CHARSET=latin1

A: MySQL won't use an index even if one exists on a column you search, if the values you search for appear on a large subset of the rows.
I did a test with MySQL 5.6. I created table with ~1,000,000 rows, with a column x with random values evenly distributed between 1 and 1000. There's an index on column x.
Depending on my search terms, I see the index is used if I search for a range of values matching a small enough subset of rows, otherwise it decides using the index is too much trouble, and just does a table-scan:
mysql> explain select * from foo where x < 50;
+----+-------------+-------+-------+---------------+------+---------+------+--------+-----------------------+
| id | select_type | table | type  | possible_keys | key  | key_len | ref  | rows   | Extra                 |
+----+-------------+-------+-------+---------------+------+---------+------+--------+-----------------------+
|  1 | SIMPLE      | foo   | range | x             | x    | 4       | NULL | 102356 | Using index condition |
+----+-------------+-------+-------+---------------+------+---------+------+--------+-----------------------+

mysql> explain select * from foo where x < 100;
+----+-------------+-------+------+---------------+------+---------+------+---------+-------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows    | Extra       |
+----+-------------+-------+------+---------------+------+---------+------+---------+-------------+
|  1 | SIMPLE      | foo   | ALL  | x             | NULL | NULL    | NULL | 1046904 | Using where |
+----+-------------+-------+------+---------------+------+---------+------+---------+-------------+

I would infer that your query's search conditions match a pretty large portion of the rows, and MySQL decides the indexes on these columns are not worth using.
WHERE `orderCnt` > 0
 AND `orderCnt` < 2000
 AND `promPCPriceStr` > 0
 AND `promPCPriceStr` < 2000

If you think MySQL is making the wrong choice, you can try to use an index hint to tell MySQL that a table-scan is prohibitively expensive. This will urge it to use the index (if the index is relevant to the search condition).
mysql> explain select * from foo force index (x) where x < 100;
+----+-------------+-------+-------+---------------+------+---------+------+--------+-----------------------+
| id | select_type | table | type  | possible_keys | key  | key_len | ref  | rows   | Extra                 |
+----+-------------+-------+-------+---------------+------+---------+------+--------+-----------------------+
|  1 | SIMPLE      | foo   | range | x             | x    | 4       | NULL | 216764 | Using index condition |
+----+-------------+-------+-------+---------------+------+---------+------+--------+-----------------------+

I would write the query this way, without any subquery:
SELECT t.productTitle, t.orderCnt, t.promPCPriceStr,
  t.productImgUrl, t.oriPriceStr, t.detailUrl,
  COUNT(o.id) AS orderToday
FROM products t
LEFT JOIN orders o ON t.productid = o.productid AND o.date > CURDATE() - INTERVAL 2 DAY
WHERE t.orderCnt > 0 AND t.orderCnt < 2000
 AND t.promPCPriceStr > 0 AND t.promPCPriceStr < 2000
GROUP BY t.productid
HAVING ordertoday > 5 AND ordertoday < 2000
ORDER BY ordertoday DESC LIMIT 150

When I EXPLAIN the query, I get this report:
+----+-------------+-------+------+-----------------------------------+-----------+---------+------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys                     | key       | key_len | ref              | rows | Extra                                        |
+----+-------------+-------+------+-----------------------------------+-----------+---------+------------------+------+----------------------------------------------+
|  1 | SIMPLE      | t     | ALL  | productId,orderCnt,promPCPriceStr | NULL      | NULL    | NULL             | 9993 | Using where; Using temporary; Using filesort |
|  1 | SIMPLE      | o     | ref  | date,productId                    | productId | 8       | test.t.productId |    1 | Using where                                  |
+----+-------------+-------+------+-----------------------------------+-----------+---------+------------------+------+----------------------------------------------+

It still does a table-scan for products but it joins the relevant matching rows in orders with an index lookup instead of a correlated subquery.
I filled my tables with random date, to make 98,846 product rows and 215,508 orders rows. When I run the query it takes about 0.18 seconds.
Although when I run your query with the correlated subquery, it takes 0.06 seconds. I don't know why your query is so slow. You could be running on an underpowered server.
I'm running my test on a Macbook Pro 2017 with an i7 CPU and 16GB of RAM.

A: In both tables, it is counterproductive to have both an AUTO_INCREMENT PRIMARY KEY and a BIGINT column that is UNIQUE.  Get rid of the AI column and promote the other to PK.  This may require changing some of your code, since the AI column is gone.
As for the subquery...
  (SELECT count(id) FROM orders t4
   WHERE t4.productId = t1.productId
     AND DATE( t4.`date`) > DATE_SUB(CURDATE(), INTERVAL 2 DAY)
  ) as ordertoday

Change COUNT(id) to COUNT(*) unless you need to check id for being NOT NULL (which I doubt).
The date column is hidden in a function call, so no index will be useful.  So, change the date test to
AND t4.`date` > CURDATE - INTERVAL 2 DAY

Then add this composite index.  (It will help with Karwin's reformulation, too).
INDEX(productId, date)


text:
Q: comparing two lists creates an error I'm trying to make the program print smaller numbers than it did previously this error doesnt make any sense as im comparing two lists not an int and a list?
    else:
        if len(tuple(guessstore)) == 3:
            if guessstore[1] > code[1]:
                randomnumber2 = random.randint(0,9 < guessstore[1])
            elif guessstore[1] < code[1]:
                randomnumber2 = random.randint(0,9 > guessstore[1])

Traceback (most recent call last):
  File "F:\Further Programming\Assignment3\number2.py", line 153, in <module>
    ch2()
  File "F:\Further Programming\Assignment3\number2.py", line 82, in ch2
    if guessstore[1] > code[1]:    #if code is larger than guess print that its larger
TypeError: unorderable types: list() > int()

Please help. I don't know why I'm getting this error

A: looks like guessstore[1] is a list and code[1] is a int, maybe the error is in how you handle guessstore that make it a list of list, by the code you show, looks like guessstore is a list, if that is the case perhaps you do something like this guessstore+=[[n]] or guessstore.append( [n] ) (where n in a number) that make you guard a list with n in it inside of guessstore, instead do guessstore.append( n ). Or equivalently in how you handle code that make it a list of int, with only that portion of the code that is all of what I can tell.


text:
Q: Problems with multiple SSL on same IP, but only in select clients I know there are tons of posts about multiple SSL on same IP, but I promise I'm not beating a dead horse.  My question is very clear.  First, a little background...
Our organization has several ecommerce sites.  All of these sites are running on the same IP, using SNI for name based virtual hosts.  In most cases, this is working great.  However, in some browsers (ie7 / ie8, but only on select machines for some reason), we got reports that users were seeing a domain mismatch with the SSL certificate.  It turned out that they were seeing the SSL certificate for the first SSL host in alphabetic order, since Apache resolves the IP address first, THEN grabs what it thinks is the right virtual host file.
I did some experimenting with the SSL protocol and found that if I set it thusly (ssl.conf):
SSLProtocol TLSv1
Then I'd simply get a not found for any of the https domains in IE.
If I set SSLStrictSNIVHostCheck on in ports.conf
SSLStrictSNIVHostCheck on
Then I'd get a permission denied in the problematic browsers.
The problem is obviously that IE is not supporting, or not using, the TLSv1 protocol, or SNI, both of which are needed.  So my question is...
Is there a configuration change I can make to support IE, perhaps under a different protocol, or is my only option using a separate IP for each virtual host which requires SSL?
Thanks in advance = )

A: SNI support is still, unfortunately, rather lacking. You don't specify, but I'd wager that your problematic IE browsers are on Windows XP machines, yes? There is no SNI support in any version of IE on Windows XP (or earlier); only Vista and later support it, and only in IE 7 and later.
See here for a list of browsers supporting SNI.
My advice: If you need to support clients that lack SNI support (and with the number of XP systems still out there, you quite likely do need to), then you'll have to implement solutions that do not depend on SNI.

A: If you want to reach a broad audience, then do not use SNI. It is not supported widely enough and you should avoid it for at least a couple of years from now.
You should have a look at UCC/SAN certificates instead. It's usually more pricey, but it's the right thing to do in this situation. Or you could have allocated an IP address for each site.
http://www.geotrust.com/ssl/ssl-certificates-san-uc/ gives a little more info on this type of certificate.

A: Today about 10% of the internet users lack support for Server Name Indication. At GlobalSign we recently created a solution to support users that have no support for Server Name Indication (SNI) by using two SSL Certificates (one is for the IP address and is free). You can read more about the problem and the solution we created to safely host multiple SSL Certificates on a single IP address in a blog article that we published today.
https://www.globalsign.com/blog/saving-ipv4-resources.html


text:
Q: Python Pillow input image less weight than final, how? So I'm trying to optimize some images with Pillow using Python, but the original image is actually more optimized than final image... How can this happen?
This is the simplest script I'm using, there are others, which crop the image, remove whitespace and some stuff that might reduce file size, but it gets bigger...
So I tried only the optimizing part, just opened the image then saved it to JPEG with 80 quality.
Original image is 29,7KB final image is 31,5KB. How is this possible?
output = StringIO.StringIO()

image = Image.open(StringIO.StringIO(imagen))

ImageFile.MAXBLOCK = max(image.size) ** 2
image.save(output, 'JPEG', quality=80, optimize=True, progressive=True)

contents = output.getvalue()
output.close()
return contents


text:
Q: creating angularjs + signalr service I am creating a generic angular service that will do native operations of signalr
angular.module('signalr', []).provider('signalrService', [function () {

var configuration;
this.config = function (config) {
    configuration = config;
};

this.$get = ['$log', '$timeout', '$q', '$rootScope', function ($log, $timeout, $q, $rootScope) {
    return new signalrService(configuration, $log, $timeout, $q);
  }];

}])

function signalrService(configuration, $log, $timeout, $q, $rootScope) {

if (!configuration) {
    $log.log('Invalid config');
    return;
}

var signalRhubs = $.hubConnection();

if (!signalRhubs) {
    $log.log('SignalR is not referenced.');
    return;
}

signalRhubs.logging = configuration.logging;

var warmMeUp = signalRhubs.createHubProxy('userHub');

warmMeUp.on('getOnlineUserList', function (data) {
  console.log(data)
 })

signalRhubs.connectionSlow(function () {
    $log.warn('We are currently experiencing difficulties with the connection.')
});

signalRhubs.error(function (error) {
    $log.error('SignalR error: ' + error)
});

$(signalRhubs).bind("onDisconnect", function (e, data) {
    $timeout(function () {
        $log.warn('Signalr Connection dead.')
    }, 10000);
});

this.invoke = function (hubName, serverFunction, paramObject) {

    var def = $q.defer();

    var hubProxy = signalRhubs.createHubProxy(hubName)

        signalRhubs.start().done(function () {

            if (paramObject) {

                 hubProxy.invoke(serverFunction, paramObject).done(function (data) {

                    def.resolve(data);
                }).fail(function (error) {
                    $log.error('SignalR error: ' + error)
                    def.reject();
                });
            }
            else {
                hubProxy.invoke(serverFunction).done(function (data) {
                    def.resolve(data);
                }).fail(function (error) {
                    $log.error('SignalR error: ' + error)
                    def.reject();
                });
            }
        }).fail(function () {
            $log.error('Failed to start signalR')
            def.reject();
        });

    return def.promise;
}

this.on = function (hubName,clientSubscribeFunction) {
    var def = $q.defer();
    var hubProxy = signalRhubs.createHubProxy(hubName)
        hubProxy.on(clientSubscribeFunction, function (object) {
            def.resolve(object);
        });

    return def.promise;

  }

}

and here is my controller
app.controller('homeController', ['$scope', 'signalrService', function ($scope, signalrService) {

signalrService.on('userHub', 'getOnlineUserList').then(function (userList) {
    console.log(userList);
});

signalrService.invoke('userHub', 'getOnlineUsers')

}]);

the problem here is when i uncomment my "warmUp.on" delegate in service, both generic "on" (this.on) and "warmUp.on" is executed but when i comment "warmUp.on" the generic on(this.on) delegate is also not executed .
   Please help me with the issue

A: UPDATE :hosted in github now https://github.com/pranaydutta89/angular-signalr-service
I dn't knw how but this worked for me ,i am first now warming up one function of each hub and then my delegate works for me
angular.module('signalr', []).provider('signalrService', [function () {

var configuration;
this.config = function (config) {
    configuration = config;
};

this.$get = ['$log', '$timeout', '$q', '$rootScope', function ($log, $timeout, $q, $rootScope) {
    return new signalrService(configuration, $log, $timeout, $q);
  }];

}])

function signalrService(configuration, $log, $timeout, $q, $rootScope) {

if (!configuration) {
    $log.log('Invalid config');
    return;
}

var signalRhubs = $.hubConnection();

if (!signalRhubs) {
    $log.log('SignalR is not referenced.');
    return;
}

signalRhubs.logging = configuration.logging;

angular.forEach(configuration.register, function (key,value) {

    var x = signalRhubs.createHubProxy(key.hub);

    x.on(key.method, function (data) {
        console.log(data)
    });
})

signalRhubs.connectionSlow(function () {
    $log.warn('We are currently experiencing difficulties with the connection.')
});

signalRhubs.error(function (error) {
    $log.error('SignalR error: ' + error)
});

$(signalRhubs).bind("onDisconnect", function (e, data) {
    $timeout(function () {
        $log.warn('Signalr Connection dead.')
    }, 10000);
});

    this.invoke = function (hubName, serverFunction, paramObject) {

    var def = $q.defer();

    var hubProxy = signalRhubs.createHubProxy(hubName)

        signalRhubs.start().done(function () {

            if (paramObject) {

                 hubProxy.invoke(serverFunction, paramObject).done(function (data) {

                    def.resolve(data);
                }).fail(function (error) {
                    $log.error('SignalR error: ' + error)
                    def.reject();
                });
            }
            else {
                hubProxy.invoke(serverFunction).done(function (data) {
                    def.resolve(data);
                }).fail(function (error) {
                    $log.error('SignalR error: ' + error)
                    def.reject();
                });
            }
        }).fail(function () {
            $log.error('Failed to start signalR')
            def.reject();
        });

    return def.promise;
}

this.on = function (hubName,clientSubscribeFunction) {
    var def = $q.defer();

       var hubProxy = signalRhubs.createHubProxy(hubName)
        hubProxy.on(clientSubscribeFunction, function (object) {
            def.resolve(object);
        });

       return def.promise;

  }

}

@angular config
.config(['signalrServiceProvider', function (signalrProvider) {
 //register single function of each hub to warm him up
signalrProvider.config({
    logging: true,
    register: [{
        hub: 'warmHub',
        method : 'hello'
    }, {
        hub: 'userHub',
        method: 'method2client'
    }],

    })

 }]);


text:
Q: Display multiple rows in codeigniter I have  query where I fetch the content of about 5 rows each with different content, but i dont now to display them individually in my views.
When I pass the the query->result() from my model back to my controller as $query, and then load a view with the $query data, I don't know how to echo out the e.g. content field of row 1.
I only know how to do this: foreach($query as $row) { echo $row->content; }
But this doesn't allow me to select what row content data (out of the 5 retrieved) I wanna echo out.
Could someone please explain how this is done?

A: The CodeIgniter documentation includes a section titled Generating Query Results which has some examples of what you are looking for.
Here's an (obviously contrived) example:
model:
class Model extends CI_Model
{
    public function get_data()
    {
        return $this->db->query('...');
    }
}

controller:
class Controller extends CI_Controller
{
    public function index()
    {
        $data['query_result'] = $this->model->get_data();
        $this->load->view('index', $data);
    }
}

view:
<?php foreach ($query_result->result() as $row): ?>
    <?php echo $row->field_1; ?>
    <?php echo $row->field_2; ?>
    <?php // and so on... ?>
<?php endforeach; ?>

A: function a(){
   $this->db->select('*');
   $this->db->from('table');
   $this->db->where(array('batch_id'=>$batchid,'class_id'=>$classid));
   $this->db->where(array('batch_id'=>$batchid,'class_id'=>$classid));
   $query=$this->db->get();
   for($i=1;$i<=$query->num_rows();++$i){
      $data[$i]['task'] = $query->row($i)->task;
      $data[$i]['subject_id'] = $query->row($i)->subject_id;
      $data[$i]['postdate'] = $query->row($i)->postdate;
      $data[$i]['cdate'] = $query->row($i)->cdate;
   }
}


text:
Q: ActiveRecord::RecordNotFound in CustomersController#new Couldn't find Business without an ID so I have looked at other instances of this error in other questions on SO and none seem to be helpful. So, my authentication system should allow a Business to sign up, and allow a user to sign up under their business. However, I'm getting a "couldn't find business without ID" error.
class CreateUsers < ActiveRecord::Migration
  def change

    create_table :users do |t|

      t.references :company, foreign_key: true

      t.timestamps
      t.string :first_name
      t.string :last_name

      t.string :email
      t.string :password_digest
      t.string :remember_digest
      t.string :role

    end

class CustomersController < ApplicationController

  def new

    set_business

    @customer = @business.customers.create(user_params)

  end

  def create

    @customer = Customer.new(customer_params)
    @customer.save!
    session[:customer_id] = @customer.id
    redirect_to '/'
  rescue ActiveRecord::RecordInvalid => ex
    render action: 'new', alert: ex.message
  end

  private
  def customer_params

    params.require(:customer).permit(:first_name, :last_name, :business_no, :email, :password_digest, :business_id)
  end

  def set_business

    @business = Business.find (params[:business_id])

  end

HTML snippet: Customer.new.html.erb

Sign Up

      <%= form_for(@customer) do |f| %>
          <%= f.label :first_name %>
          <%= f.text_field :first_name, :placeholder => "First name" %>
          <%= f.label :last_name %>
          <%= f.text_field :last_name, :placeholder => "Last name" %>
          <%= f.label :email %>
          <%= f.email_field :email, :placeholder => "Email" %>
          <%= f.label :company_id %>
          <%= f.collection_select :business_id, Business.all, :id, :name %>
          <%= f.password_field :password_digest, :placeholder => "Password" %>
          <%= f.submit "Create Account", class: "btn-submit" %>
      <% end %>

class Business < ActiveRecord::Base
  has_many :customers

end

class Customer < ActiveRecord::Base
  belongs_to :business
end

How am I supposed to define the @business variable without getting this error so that a user can sign up under their business? I want them to select from a list of available companies on the form, which will then link them in the database when the user signs up. What am I doing wrong? I am very new to Ruby and I may need some good explanation to why this is happening.
thank you for your time :)

A: You should take a look at the contents of the params[], since there's no plain :business_id key, it's nested in a :customers hash:
change your set_business to somethink like this:
  def set_business

    @business = Business.find (params[:customer][:business_id])

  end

EDIT: This will not work, since the first call to new method, the params is not supplied. You should only get a list of businesses to populate the form!
def new
  @customer = Customer.new
  @businesses = Business.all
end

EDIT2: In create method you don't need to set the business either, since it's already set by the form!
def create
  @customer = Customer.create(customer_params)
  @customer.save
end

A: Update the controller
customers_controller.rb
class CustomersController < ApplicationController
  before_action :set_business

  def new
    @customer = @business.customers.build
  end

  def create
    begin
      @customer = @business.customers.new(customer_params)
      @customer.save!
      session[:customer_id] = @customer.id
      redirect_to '/'
    rescue ActiveRecord::RecordInvalid => ex
      render action: 'new', alert: ex.message
    end
  end

  private
  def customer_params
    params.require(:customer).permit(:first_name, :last_name, :business_no, :email, :password_digest, :business_id)
  end

  def set_business
    @business = Business.find (params[:business_id])
  end
end


text:
Q: sphinx js:function directive doesn't recognise params I get the following error using the js:function directive. Why doesn't :param recognise multiple values between ::?
"
invalid option data: extension option field name may not contain multiple words.

.. js:function:: f(test,test2)
   :param test:
   :param test2:

"

A: You need to add a blank line between the directive and its options.


text:
Q: What is the definition and origin of "imba"? I often hear the phrase, "That is imba" in the video gaming community. It seems to refer to something powerful or unskillful:

Hunters are so imba.
Grenade launchers are imba!

But I have also noticed that it is often used tongue-in-cheek or sarcastically to mock people complaining about something being altered in the game:

"Waa... they nerfed my class! Now that other class is imba!" QQ more, please.

What does "imba" mean and where did the term come from? Is it used outside of gaming? My first encounters with it related to Starcraft which has a well known Korean professional gaming league. Is "imba" a loan?

A: It means unbalanced, and it comes from imbalance. The word is normally used as an adjective (this move is imba), not as a noun (*you should fix the imba of that move). I have no idea why it became imba rather than unba, which would have been more logical; but this is how I have seen it used with regard to games. I don't think I have ever seen it used elsewhere.
It is used to indicate that a certain move, feature, or property renders one choice far superior or inferior to another, in such a way as to force a player into the superior choice or out of the inferior choice, whereas normally a good game would give a player several equally valid paths to victory.

A: It comes via real-time strategy games, where one goal of the designers is to keep things balanced for all the various players; deviations from that goal are carefully scrutinized by the community that plays the game.  More precisely, it comes from the regular complaint from certain types of gamers QQing over their losses — usually due to their inferior skill at the game — that the game's mechanics are broken or imbalanced.
Using imba, then, as a shortening of imbalanced, is a facetious way of mocking that attitude, by declaring even acknowledged essential parts of the game — such as the Hunter class in World of Warcraft, or some of its top players (usually insanely good ones) — imbalanced because in a way, if you don't know how to handle uber classes or uber players, they "break" the mechanics, albeit in a legal way.

A: The term "Imba" actually originated from Brunei...well this is content directly from my science/math teacher and it isn't a lie...I'll just address him as Cloud, since he is a VERY BIG fan of Final Fantasy and I do not wanna expose his name and he owns a bubble milk tea shop in Malaysia.
The word originated from Brunei in a school...one of Cloud's student attended a class taught by an Indian teacher from India and he pronounced the word "unbalanced" as "imbalance"...therefore this student of Cloud's started to create the term "Imba" and credits to him, it became the term we know now.


text:
Q: Resolution of the dependency - Xamarin - Unity The project is a copy of Unity doc but it raise an error that I cant underestand
The error is:

Unhandled Exception:
Unity.Exceptions.ResolutionFailedException: Resolution of the
  dependency failed, type = 'System.Object', name = 'MainPage'.
  Exception occurred while: Calling constructor
  SecondPrims.Views.MainPage(). Exception is: ResolutionFailedException
  - Resolution of the dependency failed, type = 'SecondPrims.ViewModels.MainPageViewModel', name = '(none)'. Exception
  occurred while: while resolving. Exception is:
  InvalidOperationException - The current type, ITextToSpeech, is an
  interface and cannot be constructed. Are you missing a type mapping?
  ----------------------------------------------- At the time of the exception, the container was:    Resolving
  SecondPrims.ViewModels.MainPageViewModel,(none)   Resolving parameter
  'textToSpeech' of constructor
  SecondPrims.ViewModels.MainPageViewModel(ITextToSpeech textToSpeech)
      Resolving ITextToSpeech,(none)
----------------------------------------------- At the time of the exception, the container was:    Resolving
  SecondPrims.Views.MainPage,MainPage (mapped from System.Object,
  MainPage)
      Resolving SecondPrims.Views.MainPage,MainPage
      Calling constructor SecondPrims.Views.MainPage()  occurred

Project file:
http://www.mediafire.com/file/fs656jowkiy2bd9/SecondPrims.zip

A: The answer is because of registering the ITextToSpeech Interface in each platform.
https://stackoverflow.com/a/50493741/478162

Prism 7 changed this behavior as it is actually an anti-pattern to
  rely on a secondary container. You simply need to register your
  TextToSpeech service in the IPlatformInitializer like:

public class iOSInitializer : IPlatformInitializer
{
    public void RegisterTypes(IContainerRegistry containerRegistry)
    {
        containerRegistry.Register<ITextToSpeech, TextToSpeech_iOS>();
    }
}

A: Are you adding your dependencies correctly ?
containerRegistry.RegisterForNavigation<MainPage>();
containerRegistry.Register<ITextToSpeech, TextToSpeech>();


text:
Q: removing alphebatical reordering of key value pairs in nlohmann json     nlohmann::json payload = {{"type", "market"},
            {"side", "buy"},
            {"product_id",market},
            {"funds", size}};
std::cout << payload.dump() << std::endl;

out : {"funds":"10","product_id":"BTC-USD","side":"buy","type":"market"}

As you can see json is alphabetically reordered, which I dont want... How do I solve this ? thanks in advance!

A: You can use nlohmann::ordered_json instead of nlohmann::json to preserve the original insertion order:
    nlohmann::ordered_json payload = {{"type", "market"},
                {"side", "buy"},
                {"product_id","market"},
                {"funds", "size"}};
    std::cout << payload.dump() << std::endl;

Result:
{"type":"market","side":"buy","product_id":"market","funds":"size"}

I'd note, however, that in general, such mappings in json are inherently unordered, so if you really care about the order, this may not be the best choice for representing your data. You might be better off with (for example) an array of objects, each of which defines only a single mapping.


text:
Q: Differentiation of an integral with respect to time variable I have a little doubt about an integral that I try to differentiate according to time  $t$. I have tried to do it with Leibniz rule but it did not work.
Here it is ;
$$\int_{0}^{\infty}u\left(c\left(t\right)\right) \exp\left\{ -\int_{0}^{t}\theta\left(c\left(s\right)ds\right)\right\} dt$$
$u(c(s))$ is an utility function in terms of consumption $c(s)$


text:
Q: How to connect Wix Database to my Xcode project? hey few weeks backs I decided I wanted to learn to write code and understand the basics of it. The reason behind it is that I want to create an iOS app for my current online business. My business is all digital and I run my website through Wix. So as as I was dabbling with Xcode and learning the swift language, I though I found a way to create a super simple app, that would just display my mobile website using a simple WebKit View. It looked pretty good to me and it worked perfectly.
However when I sent the app for review to the App Store they rejected it because since I was selling digital content I was not allowed "to provide access to external payment mechanisms for purchases or subscriptions to be used in the app".
So as I continue to learn more and more I found out that you can use Google's Firebase databases to create a log in method within your app. However, since my business is all through wix, I was wondering if there is a way that you can connect Wix's data bases to Xcode the same way that you can connect Firebase to Xcode? or is there a way that I can connect the Wix's database to Firebase and then have them interact directly through my Xcode project?
I apologize in advance If I am using wrong terminology. I have been working on this for a few weeks but I am eager to learn more. I would really appreciate some guidance. thank you.


text:
Q: TypeError: scope.viewDate.clone is not a function I'm trying to build a date time picker using angular and momentjs.
I've built my directive to populate the days but 'm getting the error "TypeError: scope.viewDate.clone is not a function" I'm not quite sure where I'm going wrong and how I can fix it.
angular.module('myApp')
.directive('datepicker', function () {
    return{
        restrict: 'EA',
        scope: true,
        require: 'ngModel',
        link: function (scope, elm, attr, ngModel) {

            scope.viewDate = moment;
            var selectedDate = null;

            function generateDays() {
                scope.days = [];

                var startOfSelectedDate = moment.isMoment(selectedDate) ? selectedDate.clone().startOf('day') : null;
                var startDate = scope.viewDate.clone().startOf('month').startOf('week').startOf('day');
                var endDate = scope.viewDate.endOf('month').endOf('week').endOf('day');

                while (startDate < endDate){
                    scope.days.push({
                        label: startDate.date(),
                        inMonth: startDate.month() === scope.viewDate.month() && startDate.year() === scope.viewDate.year(),
                        date: startDate.valueOf(),
                        selected: startDate.isSame(selectedDate)
                    });
                    startDate.add(1, 'day');
                }
            }
            generateDays();
        }
    }
});

A: You have missed to execute the moment while defining viewDate. your code will be
scope.viewDate = moment();


text:
Q: concordance for a phrase using NLTK in Python Is it possible to get concordance for a phrase in NLTK?
import nltk
from nltk.corpus import PlaintextCorpusReader

corpus_loc = "c://temp//text//"
files = ".*\.txt"
read_corpus = PlaintextCorpusReader(corpus_loc, files)
corpus  = nltk.Text(read_corpus.words())
test = nltk.TextCollection(corpus_loc)

corpus.concordance("claim")

for example the above returns
on okay okay okay i can give you the claim number and my information and
 decide on the shop okay okay so the claim number is xxxx - xx - xxxx got

and now if I try corpus.concordance("claim number") it does not work... I do have the code to do this with just by using .partition() method and some further coding on the same... but I'm wondering if it's possible to do the same using concordance.

A: According to this issue it is not (yet) possible to search for multiple words with the concordance() function.

A: If you read the discussion under the very issue that @b3000 dug up, you'll see that strangely enough, multi-word concordance is in fact available-- but only in the graphical concordance tool, which you can start up like this:
>>> from nltk.app import concordance
>>> concordance()

A: I munged together this solution...
def n_concordance_tokenised(text,phrase,left_margin=5,right_margin=5):
    #concordance replication via https://simplypython.wordpress.com/2014/03/14/saving-output-of-nltk-text-concordance/

    phraseList=phrase.split(' ')

    c = nltk.ConcordanceIndex(text.tokens, key = lambda s: s.lower())

    #Find the offset for each token in the phrase
    offsets=[c.offsets(x) for x in phraseList]
    offsets_norm=[]
    #For each token in the phraselist, find the offsets and rebase them to the start of the phrase
    for i in range(len(phraseList)):
        offsets_norm.append([x-i for x in offsets[i]])
    #We have found the offset of a phrase if the rebased values intersect
    #--
    # http://stackoverflow.com/a/3852792/454773
    #the intersection method takes an arbitrary amount of arguments
    #result = set(d[0]).intersection(*d[1:])
    #--
    intersects=set(offsets_norm[0]).intersection(*offsets_norm[1:])

    concordance_txt = ([text.tokens[map(lambda x: x-left_margin if (x-left_margin)>0 else 0,[offset])[0]:offset+len(phraseList)+right_margin]
                    for offset in intersects])

    outputs=[''.join([x+' ' for x in con_sub]) for con_sub in concordance_txt]
    return outputs

def n_concordance(txt,phrase,left_margin=5,right_margin=5):
    tokens = nltk.word_tokenize(txt)
    text = nltk.Text(tokens)

    return

n_concordance_tokenised(text,phrase,left_margin=left_margin,right_margin=right_margin)

n_concordance_tokenised(text1,'monstrous size')
>> [u'one was of a most monstrous size . ... This came towards ',
    u'; for Whales of a monstrous size are oftentimes cast up dead ']


text: Q: how to copy files using TTY teminal from one pc to another connected through same home network In my academic lab my friend copied files from one computer to another that were serially connected using the tty4.  How could he have done this if there was no internet and he didn't install any new software?


text:
Q: Background image stays after removing tag I am learning about webdev by designing a webpage and want the landing page to have a background image but the subsequent page not to. My index.html page extends the base.html template. I used the body tag to apply a background image to cover the page. But I want this removed from the results.html view so in the results.html I extend a header only view using header.html. And in the header.html layout I eliminate the body tag, but the background image remains somehow.
Any help for a beginner is much appreciated.
base.html
{% load staticfiles %}

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>me</title>

    <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">

    <link href="{% static 'css/ie10-viewport-bug-workaround.css' %}" rel="stylesheet">

    <link href="{% static 'css/cover.css' %}" rel="stylesheet">

            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
              Toggle navigation

            </button>
            Logo

About Us (current)

Log In

Sign Up

    {% block main_content %}
    {% endblock %}

me, 2016 | @me

index.html
{% extends "search/base.html" %}

{% block main_content %}

Search
              <input type="text" class="form-control" placeholder="">

Location
              <input type="text" class="form-control" placeholder="City, State or Zipcode">

              Search

  {% endblock %}

header.html
{% load staticfiles %}

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>me</title>

    <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">

    <link href="{% static 'css/ie10-viewport-bug-workaround.css' %}" rel="stylesheet">

    <link href="{% static 'css/cover.css' %}" rel="stylesheet">

{% block main_content %}
{% endblock %}

A: All Webpages need a  element, so you can't leave it out. There are many approaches to fix this, but they all revolve around having css that loads last on the results page that tells it to have no background image.
for demonstration purposes right before your  tag in header.html add the code


text:
Q: Fancybox trouble: undefined is not a function i'm with a little trouble here. Trying to install fancybox i'm getting this javascript error:
'undefined' is not a function (evaluating '$("a.fancybox").fancybox()')

here is my HTML

and my javascript

Has anyone encountered this problem?
Thanks !

A: I've run into a similar problem when a page has two copies of jQuery. So, make sure you only have ONE copy of jQuery on your page.
What happens is that Fancybox is extending itself from the first copy of jQuery; but because of a second copy, the document ready is being called from that copy only. And of course Fancybox is not applied to it.

A: I am assuming that you are using fancybox v1.3.x because that version cannot display dynamically added elements in Fancybox (FYI Fancybox v2.x can handle existing and dynamically added elements).
If you don't want to upgrade to Fancybox v2.x then you have two options:

*

*Use the jQuery livequery plugin
or

*Rebuild you script and use jQuery delegate() to trigger fancybox with the new elements

Both options are explained here.
Please notice that using the jQuery delegate() solution won't work with Fancybox galleries, only with single elements.
If you don't want to use the livequery plugin and still want to use Fancybox galleries of dynamically added elements, alternatively you could upgrade to jQuery 1.7+ and use the new API jQuery on()
I have a demo page here that shows how to use jQuery on() to display Fancybox galleries with existing and dynamically added elements. Please feel free to look at the source code.