text:
Q: Scrapy timeout on certain sites On my own machine I tried
> scrapy fetch http://google.com/

or
> scrapy fetch http://stackoverflow.com/

worked perfectly, somehow www.flyertalk.com does not play well with scrapy. I keep getting timeout error (180s):
> scrapy fetch http://www.flyertalk.com/

however curl works fine without a hiccup
> curl -s http://www.flyertalk.com/

Very strange. here is the full dump:
2015-11-20 17:35:07 [scrapy] INFO: Enabled extensions: CloseSpider, TelnetConsole, LogStats, CoreStats, SpiderState
2015-11-20 17:35:07 [scrapy] INFO: Enabled downloader middlewares: HttpAuthMiddleware, DownloadTimeoutMiddleware, UserAgentMiddleware, RetryMiddleware, DefaultHeadersMiddleware, MetaRefreshMiddleware, HttpCompressionMiddleware, RedirectMiddleware, CookiesMiddleware, ChunkedTransferMiddleware, DownloaderStats
2015-11-20 17:35:07 [scrapy] INFO: Enabled spider middlewares: HttpErrorMiddleware, OffsiteMiddleware, RefererMiddleware, UrlLengthMiddleware, DepthMiddleware
2015-11-20 17:35:07 [scrapy] INFO: Enabled item pipelines:
2015-11-20 17:35:07 [scrapy] INFO: Spider opened
2015-11-20 17:35:07 [scrapy] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2015-11-20 17:35:07 [scrapy] DEBUG: Telnet console listening on 127.0.0.1:6037
2015-11-20 17:36:07 [scrapy] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2015-11-20 17:37:07 [scrapy] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2015-11-20 17:38:07 [scrapy] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2015-11-20 17:38:07 [scrapy] DEBUG: Retrying <GET http://www.flyertalk.com> (failed 1 times): User timeout caused connection failure: Getting http://www.flyertalk.com took longer than 180.0 seconds..
2015-11-20 17:39:07 [scrapy] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2015-11-20 17:40:07 [scrapy] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2015-11-20 17:41:07 [scrapy] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2015-11-20 17:41:07 [scrapy] DEBUG: Retrying <GET http://www.flyertalk.com> (failed 2 times): User timeout caused connection failure: Getting http://www.flyertalk.com took longer than 180.0 seconds..

A: I've experimented a little bit. The USER-AGENT header makes all the difference:
$ scrapy shell http://www.flyertalk.com/ -s USER_AGENT='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36'
In [1]: response.xpath("//title/text()").extract_first().strip()
Out[1]: u"FlyerTalk - The world's most popular frequent flyer community - FlyerTalk is a living, growing community where frequent travelers around the world come to exchange knowledge and experiences about everything miles and points related."

Without specifying the header I'm seeing it hanging forever.


text:
Q: Oracle context index: doesn't work over dblink There are two db's, table test_table on db1 with context index by field a. Query:
select *
  from test_table t
 where contains(t.a, 'str') > 0

It works fine on db1. But when I try execute same query over dblink from other database:
select *
  from test_table@db1 t
 where contains(t.a, 'str') > 0

I get this error:
ora-20000: Oracle Text Error:
 DRG-10599: column is not indexed

A: You have to add dblink to function.
https://docs.oracle.com/cd/E11882_01/text.112/e24436/csql.htm#CCREF0104

The CONTAINS operator also supports database links. You can identify a
  remote table or materialized view by appending @dblink to the end of
  its name. The dblink must be a complete or partial name for a database
  link to the database containing the remote table or materialized view.
  (Querying of remote views is not supported.)

select *
  from test_table@db1 t
 where contains(t.a, 'str')@db1 > 0.

redpajama_set_name: RedPajamaStackExchange


text:
Q: request focus not working properly I simply have a form inside a layout.I just want to display the top left part(i.e starting field of the form when the form is clicked .I used request focus .However its not working.When i open the form the middle part of the form gets into view and only on scrolling to top I can get the first field.How can I fix this so I can get to the starting part of the form when form is open.This is my form layout.
<?xml version="1.0" encoding="utf-8"?>
<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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    tools:context="com.example.user.educationhunt.UniversityRegistration">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    </android.support.design.widget.AppBarLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:paddingBottom="22dp"
            android:paddingLeft="22dp"
            android:paddingRight="22dp"
            android:paddingTop="22dp"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="18dp"
                android:layout_marginBottom="4dp"
                android:text="Name:">
            </TextView>

            <EditText
                android:id="@+id/register_school_name"
                android:layout_width="match_parent"
                android:background="@drawable/rounded_edittext"
                android:padding="11dp"
                android:textSize="12dp"
                android:hint="School Name*"
                android:layout_marginBottom="10dp"
                android:layout_height="wrap_content">
            </EditText>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="18dp"
                android:layout_marginBottom="4dp"
                android:text="Address:"/>

            <EditText
                android:id="@+id/register_school_address"
                android:layout_width="match_parent"
                android:background="@drawable/rounded_edittext"
                android:padding="11dp"
                android:textSize="12dp"
                android:hint="School Address*"
                android:layout_marginBottom="10dp"
                android:layout_height="wrap_content" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:orientation="horizontal">

                <Spinner
                    android:id="@+id/register_school_district"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_marginRight="10dp"
                    android:layout_height="wrap_content" />
                <Spinner
                    android:id="@+id/register_school_country"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_marginBottom="10dp"
                    android:layout_height="wrap_content" />

            </LinearLayout>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="18dp"
                android:layout_marginBottom="4dp"
                android:text="Phone:"/>

            <EditText
                android:id="@+id/register_school_phone"
                android:layout_width="match_parent"
                android:background="@drawable/rounded_edittext"
                android:padding="11dp"
                android:textSize="12dp"
                android:inputType="numberDecimal"
                android:hint="School Phone no*"
                android:layout_marginBottom="10dp"
                android:layout_height="wrap_content" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="18dp"
                android:layout_marginBottom="4dp"
                android:text="Email:"/>

            <EditText
                android:id="@+id/register_school_email"
                android:layout_width="match_parent"
                android:background="@drawable/rounded_edittext"
                android:padding="11dp"
                android:textSize="12dp"
                android:inputType="textEmailAddress"
                android:hint="Valid email address*"
                android:layout_marginBottom="10dp"
                android:layout_height="wrap_content" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="18dp"
                android:layout_marginBottom="4dp"
                android:text="Website:"/>

            <EditText
                android:id="@+id/register_school_website"
                android:layout_width="match_parent"
                android:background="@drawable/rounded_edittext"
                android:padding="11dp"
                android:textSize="12dp"
                android:hint="School Website*"
                android:layout_marginBottom="10dp"
                android:layout_height="wrap_content" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:orientation="vertical">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="18dp"
                    android:layout_marginBottom="4dp"
                    android:text="Institution Type:"/>
                <Spinner
                    android:id="@+id/register_school_institution"
                    android:layout_width="match_parent"
                    android:layout_marginBottom="10dp"
                    android:layout_height="wrap_content" />

            </LinearLayout>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="4dp"
                android:textSize="18dp"
                android:text="Establishment Date:"/>

            <EditText
                android:id="@+id/register_school_estdate"
                android:layout_width="match_parent"
                android:background="@drawable/rounded_edittext"
                android:padding="11dp"
                android:textSize="12dp"
                android:hint="School establishment date*"
                android:layout_marginBottom="10dp"
                android:layout_height="wrap_content" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="4dp"
                android:textSize="18dp"
                android:text="Fee Structure:"/>

            <LinearLayout
                android:id="@+id/addSchoolProgram"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">

                    <Spinner
                        android:id="@+id/register_school_level"
                        android:layout_width="match_parent"
                        android:layout_marginBottom="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_height="wrap_content" />

                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">

                    <EditText
                        android:id="@+id/register_school_annualFee"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/rounded_edittext"
                        android:padding="11dp"
                        android:inputType="numberDecimal"
                        android:textSize="12dp"
                        android:hint="Total Annual fee(NRs)*"/>

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/addSchoolProgram1"
                android:visibility="gone"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>
                    <Spinner
                        android:id="@+id/register_school_level1"
                        android:layout_width="match_parent"
                        android:layout_marginBottom="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_height="wrap_content" />

                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>
                    <EditText
                        android:id="@+id/register_school_annualFee1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/rounded_edittext"
                        android:padding="11dp"
                        android:inputType="numberDecimal"
                        android:textSize="12dp"
                        android:hint="1Total Annual fee(NRs)*"/>

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:visibility="gone"
                android:id="@+id/addSchoolProgram2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>
                    <Spinner
                        android:id="@+id/register_school_level2"
                        android:layout_width="match_parent"
                        android:layout_marginBottom="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_height="wrap_content" />

                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>

                    <EditText
                        android:id="@+id/register_school_annualFee2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/rounded_edittext"
                        android:padding="11dp"
                        android:inputType="numberDecimal"
                        android:textSize="12dp"
                        android:hint="2Total Annual fee(NRs)*"/>

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:visibility="gone"
                android:id="@+id/addSchoolProgram3"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>
                    <Spinner
                        android:id="@+id/register_school_level3"
                        android:layout_width="match_parent"
                        android:layout_marginBottom="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_height="wrap_content" />

                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>

                    <EditText
                        android:id="@+id/register_school_annualFee3"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/rounded_edittext"
                        android:padding="11dp"
                        android:textSize="12dp"
                        android:inputType="numberDecimal"
                        android:hint="3Total Annual fee(NRs)*"/>

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:visibility="gone"
                android:id="@+id/addSchoolProgram4"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>
                    <Spinner
                        android:id="@+id/register_school_level4"
                        android:layout_width="match_parent"
                        android:layout_marginBottom="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_height="wrap_content" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>

                    <EditText
                        android:id="@+id/register_school_annualFee4"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/rounded_edittext"
                        android:padding="11dp"
                        android:inputType="numberDecimal"
                        android:textSize="12dp"
                        android:hint="4Total Annual fee(NRs)*"/>

                </LinearLayout>
             </LinearLayout>
               <LinearLayout
                android:visibility="gone"
                android:id="@+id/addSchoolProgram5"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>
                    <Spinner
                        android:id="@+id/register_school_level5"
                        android:layout_width="match_parent"
                        android:layout_marginBottom="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_height="wrap_content" />

                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>

                    <EditText
                        android:id="@+id/register_school_annualFee5"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/rounded_edittext"
                        android:padding="11dp"
                        android:inputType="numberDecimal"
                        android:textSize="12dp"
                        android:hint="5Total Annual fee(NRs)*"/>

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:visibility="gone"
                android:id="@+id/addSchoolProgram6"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>
                    <Spinner
                        android:id="@+id/register_school_level6"
                        android:layout_width="match_parent"
                        android:layout_marginBottom="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_height="wrap_content" />

                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>

                    <EditText
                        android:id="@+id/register_school_annualFee6"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/rounded_edittext"
                        android:padding="11dp"
                        android:inputType="numberDecimal"
                        android:textSize="12dp"
                        android:hint="6Total Annual fee(NRs)*"/>

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:visibility="gone"
                android:id="@+id/addSchoolProgram7"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="vertical">
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginBottom="7dp"
                        android:background="#6c8487"/>

                    <Spinner
                        android:id="@+id/register_school_level7"
                        android:layout_width="match_parent"
                        android:layout_marginBottom="8dp"
                        android:layout_marginRight="8dp"
                        android:layout_height="wrap_content" />

                </LinearLayout>
        </LinearLayout>
    </ScrollView>
  </LinearLayout>

A: Try this:
     Activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
             //focus the view
             edittext.requestFocus();
        });


text:
Q: USB HDD Enclosure works with Ubuntu, but not Raspbian SOLVED:
Even though the enclosure came with its own power supply, it required a powered USB hub, probably for some internal components that don't draw power from the main supply.
I have this dual HDD enclosure.
http://www.raidsonic.de/data/products/icybox/IB-3620/E_IB-3620_Series_manual_v1.1.pdf
Basic model IB-3620U3.
The enclosure implements JBOD(single) so the installed drives are seen separately by the OS.
I have no problems when I plug the device into my Ubuntu 14.04 laptop, I can see both HDDs and the "usb" LED(that shows it is connected by USB) lights up on the device.
However, when I plug the device into my Raspberry Pi, running Raspbian, the HDDs are not seen and even the "usb" LED on the front of the device does not light.
Outputs (pastebin urls)
Raspbian:
lsusb
dmesg
uname -a
fdisk -l (just SD card)
Ubuntu(laptop):
lsusb
dmesg
uname -a
fdisk -l
Note: If I power up the device, while already plugged into my raspberry pi, the device's "usb" LED lights up, but there is no difference.
Note2: I know the device doesn't officially support Linux, but hardly anything does on the box. I have 2 of these USB HDD docks which work perfectly with Raspbian.
http://www.amazon.co.uk/Optimized-Inateck-Including-Comaptible-Tool-Free/dp/B00GIDNLI6/ref=sr_1_1?s=computers&ie=UTF8&qid=1403606340&sr=1-1&keywords=inateck+dock
Note3: One drive is ext4, and the other is NTFS.
Thank you for any help getting this thing working in Raspbian
Edit:
As requested, here is
lsmod(unplugged)
lsmod(plugged-in)
on the Ubuntu laptop.
And, lsmod(unplugged), for raspbian. Doesn't change after plugging the device in.
At a glance, it looks like the top modules usb-storage, ccm, and ctr, are the only ones to change on the laptop when plugging the device in.
Where do I got from here ?


text:
Q: How to pass the button ids of an array of buttons to php file? I want to create new buttons using a single button, and after creating those new buttons, I want to click on them and have their id number sent to the php file.
my code:

The problem is that I'm not able to make more than one button clickable.
Also I'm not able to set the id of the button to the value they have on them.

A: use this code ...


text:
Q: Merge 2 Rows selected by union query Okay, I am having a really strange issue.
I am trying to load some sensor data from a mysql database. The table structure looks like this:
+-----------------+---------------------+--------------+
+ PK [bigint(20)] +  timed [bigint(20)] + NO2 [double] +
+-----------------+---------------------+--------------+

*

*PK is the primary key

*timed is the timestamp stored as miliseconds from 01.01.1970 (linux timestamp)

*NO2 the measured concentration of NO2 (in ppb, parts per billion)

Now comes the hard part. There are two identical tables that have the exact same schema as described above. One for raw data and one for validated data.
Until the data gets validated it usually takes around 1 month. So when I display live data from the sensor I am merging those two tables using UNION. The validated value should always have priority over the raw value.
Also I only load daily average values.
This is the SQL query I created so far:
SELECT
    mergedData.rawValue,
    mergedData.validatedValue,
    CAST(IF(mergedData.validatedValue IS NULL, mergedData.rawValue, mergedData.validatedValue) AS DECIMAL(65, 2)) as sensorValue,
    timeValue,
    IsValid
FROM
(SELECT
    Month(FROM_UNIXTIME(timed / 1000)) as months,
    Year(FROM_UNIXTIME(timed / 1000)) as years,
    DAYOFMONTH(FROM_UNIXTIME(timed / 1000)) as days,
    HOUR(FROM_UNIXTIME(timed / 1000)) as hours,
    MINUTE(FROM_UNIXTIME(timed / 1000)) as minutes,
    avg(NO2) as rawValue,
    FROM_UNIXTIME(timed / 1000) as timeValue,
    IF(NO2 IS NOT NULL, 1, 0) as IsValid,
    NULL as validatedValue
FROM
    nabelnrt_pay
WHERE
    timed > 1360236120000
    AND timed < 1391772120000
GROUP BY years, months, days
UNION
SELECT
    Month(FROM_UNIXTIME(timed / 1000)) as months,
    Year(FROM_UNIXTIME(timed / 1000)) as years,
    DAYOFMONTH(FROM_UNIXTIME(timed / 1000)) as days,
    HOUR(FROM_UNIXTIME(timed / 1000)) as hours,
    MINUTE(FROM_UNIXTIME(timed / 1000)) as minutes,
    avg(NO2) as validatedValue,
    FROM_UNIXTIME(timed / 1000) as timeValue,
    IF(NO2 IS NOT NULL, 1, 0) as IsValid,
    NULL as rawValue
FROM
    nabelvalidated_pay
WHERE
    timed > 1360236120000
    AND timed < 1391772120000
GROUP BY years, months, days) as mergedData ORDER BY timeValue

This results in following result:

The problem I know have is, that when both table contain an entry I get two rows out of the query. I want to merge them to one row, so I got only 1 row per timestamp in the result. Also for some reason the data of mergedData.validatedValue gets displayed in rawValue instead of validatedValue.
Can someone tell me how I cam merge those two rows to 1 single resulting row and why the validatedData gets displayed in the wrong column?

A: The problem is that you are getting both rows in the final data.  You need to aggregate again.  In addition, because you want both values in the final result, you should use union all rather than union.  union removes duplicates, which is unnecessary because the rows are not going to be the same between the two subqueries:
SELECT max(mergedData.rawValue),
       max(mergedData.validatedValue),
       CAST(IF(mergedData.validatedValue IS NULL, mergedData.rawValue, mergedData.validatedValue) AS DECIMAL(65, 2)) as sensorValue,
       timeValue,
       IsValid
FROM ((SELECT Month(FROM_UNIXTIME(timed / 1000)) as months,
              Year(FROM_UNIXTIME(timed / 1000)) as years,
              DAYOFMONTH(FROM_UNIXTIME(timed / 1000)) as days,
              HOUR(FROM_UNIXTIME(timed / 1000)) as hours,
              MINUTE(FROM_UNIXTIME(timed / 1000)) as minutes,
              avg(NO2) as rawValue,
              FROM_UNIXTIME(timed / 1000) as timeValue,
              IF(NO2 IS NOT NULL, 1, 0) as IsValid,
              NULL as validatedValue
      FROM nabelnrt_pay
      WHERE timed > 1360236120000 AND timed < 1391772120000
      GROUP BY years, months, days
     )
     UNION ALL
     (SELECT Month(FROM_UNIXTIME(timed / 1000)) as months,
             Year(FROM_UNIXTIME(timed / 1000)) as years,
             DAYOFMONTH(FROM_UNIXTIME(timed / 1000)) as days,
             HOUR(FROM_UNIXTIME(timed / 1000)) as hours,
             MINUTE(FROM_UNIXTIME(timed / 1000)) as minutes,
             avg(NO2) as validatedValue,
             FROM_UNIXTIME(timed / 1000) as timeValue,
             IF(NO2 IS NOT NULL, 1, 0) as IsValid,
             NULL as rawValue
      FROM nabelvalidated_pay
      WHERE timed > 1360236120000 AND timed < 1391772120000
      GROUP BY years, months, days
     )
    ) as mergedData
GROUP BY years, months, days
ORDER BY timeValue

A: The order of columns must be same in queries used with union. Your query should be something similar to:
SELECT max(mergedData.rawValue),
       max(mergedData.validatedValue),
       CAST(IF(max(mergedData.validatedValue) IS NULL, max(mergedData.rawValue),
       max(mergedData.validatedValue)) AS DECIMAL(65, 2)) as sensorValue,
       max(timeValue),
       max(IsValid)
FROM ((SELECT Month(FROM_UNIXTIME(timed / 1000)) as months,
          Year(FROM_UNIXTIME(timed / 1000)) as years,
          DAYOFMONTH(FROM_UNIXTIME(timed / 1000)) as days,
          HOUR(FROM_UNIXTIME(timed / 1000)) as hours,
          MINUTE(FROM_UNIXTIME(timed / 1000)) as minutes,
          avg(NO2) as rawValue,
          FROM_UNIXTIME(timed / 1000) as timeValue,
          0 IsValid,
          NULL as validatedValue
  FROM nabelnrt_pay
  WHERE timed > 1360236120000 AND timed < 1391772120000
  GROUP BY years, months, days
 )
 UNION ALL
 (SELECT Month(FROM_UNIXTIME(timed / 1000)) as months,
         Year(FROM_UNIXTIME(timed / 1000)) as years,
         DAYOFMONTH(FROM_UNIXTIME(timed / 1000)) as days,
         HOUR(FROM_UNIXTIME(timed / 1000)) as hours,
         MINUTE(FROM_UNIXTIME(timed / 1000)) as minutes,
         NULL as rawValue,
         FROM_UNIXTIME(timed / 1000) as timeValue,
         1 AS IsValid,
         avg(NO2) as validatedValue
  FROM nabelvalidated_pay
  WHERE timed > 1360236120000 AND timed < 1391772120000
  GROUP BY years, months, days
 )
) as mergedData
GROUP BY years, months, days
ORDER BY timeValue

After this change, you will get two rows for validated readings and one row for the non-validated ones. The last group by you used will group these 2 rows for validated readings. Because you use aggregate functions in the select like max(mergedData.rawValue), you will get desired results.


text:
Q: how to join relations in-sequence in hadoop pig? I have one line data like this:
a\tb1,b2,..,bn\tc1,c2,..,cn

in which n is uncertain. And now, I want transform it to some lines like this:
a\tb1\tc1
a\tb2\tc2
...
a\tbn\tcn

Is it possible by pig latin, or has to use UDF?
If using the script:
A = LOAD 'file' AS (a, b, c);
B = FOREACH A GENERATE a, FLATTEN(TOKENIZE(b)), FLATTEN(TOKENIZE(c));
dump B;

I will get the resulr as following:
a\tb1\tc1
a\tb1\tc2
..
a\tb1\tcn
a\tb2\tc1
a\tb2\tc2
..
a\tb2\tcn
..

It isn't the data I wanted. Does anyone have ideas?

A: IMO too many people who use Pig are resistant to write UDFs. In your case, the UDF you'd need to do this is fairly simple. Here's sample code (untested)
public class InSequenceJoin extends EvalFunc<DataBag>
{
    public DataBag exec(Tuple input) throws IOException {
        String b = (String) input.get(0);
        String c = (String) input.get(1);
        String[] bArray = b.split(",");
        String[] cArray = c.split(",");
        DataBag bag = BagFactory.getInstance().newDefaultBag();
        for (int i = 0; i < bArray.length && i < cArray.length; i++) {
            Tuple tuple = TupleFactory.getInstance.newTuple(2);
            tuple.set(0, bArray[i]);
            tuple.set(1, cArray[i]);
            bag.add(tuple);
        }
        return bag;
    }
}

define InSequenceJoin mysourcepath.InSequenceJoin();
A = LOAD 'file' AS (a, b, c);
B = FOREACH A GENERATE a, FLATTEN(InSequenceJoin(b,c));
dump B;

You could add validation on if the sizes of the arrays match if you need to in the UDF. You could replace the String split I used in example with whatever you truly require.

A: I'd try to use datafu's bag UDFs.
Load the data as you've done, then use Enumerate to enumerate the bag elements, then flatten (which gives you the cross join between the bag elements as you've seen) and then you can filter on the indexes added to the bag elements.
See here: https://github.com/linkedin/datafu


text:
Q: Formatting XAxis labels when rendering chart on server using phantomjs and JSON I'm using phantomjs to render png images of a highchart using a json file from a commandline script.
As it's JSON obviously I can't using the xAxis.labels.formatter as I would in a web client version, but as these are for automated reports we don't want to have to generate them through a browser.
Is there anyway of formatting the xAxis labels to be something like the result of:

Highcharts.dateFormat('%d/%m/%y %H:%M',this.value)

Currently they are showing up as what I assume is the default. e.g. 10 Feb
This doesn't even tell us what year it is.
I'm using the default "highcharts-convert.js" file as the first parameter to phantomjs
Second paramater is my highcharts configuration as a json object
Third is the name of the output file
Is it possible to do it in the callback script if so how would I pass a function to the formatter?
I've tried iterating over the collection of labels but this didn't work:
function(chart) {
    $.each( chart.xAxis.labels, function( index, value ){
        chart.xAxis.labels[index] = Highcharts.dateFormat('%d/%m/%y %H:%M',value);
    });
}

Or are there any other alternatives that are open to me?

A: You can simple use xAxis.labels.format, see more info.
And demo from docs.


text:
Q: Error: Found input variables with inconsistent numbers of samples: [49400, 1] Here is my code
from pandas import read_csv
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
import pandas as pd

#Load dataset
df = pd.read_csv(r"C:\Users\dhava\OneDrive\Documents\Folder to run environment for Anaconda\Poseidon\Pump_Dataset.csv")
print(df.columns)

output  file contains the fllowing columns
Index(['id', 'target_status', 'amount_tsh', 'date_recorded', 'funder',
       'gps_height', 'installer', 'longitude', 'latitude', 'wpt_name',
       'num_private', 'basin', 'subvillage', 'region', 'region_code',
       'district_code', 'lga', 'ward', 'population', 'public_meeting',
       'recorded_by', 'scheme_management', 'scheme_name', 'permit',
       'construction_year', 'extraction_type', 'extraction_type_group',
       'extraction_type_class', 'management', 'management_group', 'payment',
       'payment_type', 'water_quality', 'quality_group', 'quantity',
       'quantity_group', 'source', 'source_type', 'source_class',
       'waterpoint_type', 'waterpoint_type_group'],
      dtype='object')

When I try to run the following code I encounter the above mentioned error
inputs= df[['id', 'amount_tsh', 'date_recorded', 'funder',
       'gps_height', 'installer', 'longitude', 'latitude', 'wpt_name',
       'num_private', 'basin', 'subvillage', 'region', 'region_code',
       'district_code', 'lga', 'ward', 'population', 'public_meeting',
       'recorded_by', 'scheme_management', 'scheme_name', 'permit',
       'construction_year', 'extraction_type', 'extraction_type_group',
       'extraction_type_class', 'management', 'management_group', 'payment',
       'payment_type', 'water_quality', 'quality_group', 'quantity',
       'quantity_group', 'source', 'source_type', 'source_class',
       'waterpoint_type', 'waterpoint_type_group']]

outputs = [['target_status']]

X_train, X_test, Y_train, Y_test = train_test_split(inputs, outputs, test_size=0.20, random_state=1)

I see that both inputs and outputs have same dimensions


text:
Q: NSDate Math? Now and Fire timer in the future I have been racking my brains on this one looking for a quick solution.
I need to fire off a NSTime at a specific time based on the current time in a specific time zone.
For example, I get the current time in PST:
NSDate *now = [NSDate date];

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"HH:mm:ss";

NSCalendar * cal = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
[cal setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"PST"]];

NSDateComponents * comps = [cal components:NSHourCalendarUnit fromDate:now];

I see that the time is 2 (14) getting [comps hour] and I need to fire a timer at 2:30PM (14:30) on that day. I need help converting it back and doing the math to say how long it is before the timer fires. I will be setting up several different timers based on the current time. While I am looking at the time in PST I know that the timers and setting of the time is done in GMT. That's another twist...
Thanks in advance...

A: I solved the problem myself.. But thanks for the tips...
if ([date earlierDate:newDate] == date) // it is before 7AM... fire at 7AM

and so on....


text:
Q: Displaying desired files only in asp.net   DirectoryInfo Dir = new DirectoryInfo(Server.MapPath(strheadlinesid));
  FileInfo[] FileList = Dir.GetFiles("*.txt", SearchOption.AllDirectories);

In the Place of *.txt ,I want to mention some more file extensions how can I do that.
I used another type of approach but I have a small problem in it when I use the FI as hyperlink it's giving total path.but I want to print only the file name not fullpath.
   string supportedExtensions = "*.jpg,*.gif,*.png,*.bmp,*.jpe,*.jpeg,*.wmf,*.emf,*.xbm,*.ico,*.eps,*.tif,*.tiff,*.g01,*.g02,*.g03,*.g04,*.g05,*.g06,*.g07,*.g08";

   foreach (string FI in Directory.GetFiles(Server.MapPath(strheadlinesid), "*.*", SearchOption.AllDirectories).Where(s => supportedExtensions.Contains(Path.GetExtension(s).ToLower())))
   {

       Response.Write(" " +
           FI + "	");

   }

A: Try
string fileFilter = "*.wma,*.jpeg,*.txt";
            string[] fileExt = fileFilter.Split(',');
            FileInfo[] fileInfo = null;
            DirectoryInfo dir = new DirectoryInfo("D:\\Test");
            List<FileInfo[]> listFileInfo = new List<FileInfo[]>();

            foreach (string strVar in fileExt)
            {
                fileInfo = dir.GetFiles(strVar, SearchOption.AllDirectories);
                listFileInfo.Add(fileInfo);
            }


text:
Q: Cloning a Hash in Ruby2 Im trying to clone a hash, to make a new copy of the original hash but it seems that when I set a value in the new hash, I have the same effect on the original hash.
rr = Hash.new
command = "/usr/local/bin/aws route53 list-resource-record-sets --hosted-zone-id EXAMPLEID --max-items 1"

rr=JSON.parse(%x{#{command}})

puts rr

if rr["ResourceRecordSets"][0]["TTL"] != 60
  new_rr = rr.clone
  new_rr["ResourceRecordSets"][0]["TTL"] = 60
  puts rr
  puts new_rr
end

Output:
{"NextRecordType"=>"MX", "NextRecordName"=>"example.com.", "ResourceRecordSets"=>[{"ResourceRecords"=>[{"Value"=>"1.2.3.4"}], "Type"=>"A", "Name"=>"example.com.", "TTL"=>1800}], "MaxItems"=>"1", "IsTruncated"=>true}
{"NextRecordType"=>"MX", "NextRecordName"=>"example.com.", "ResourceRecordSets"=>[{"ResourceRecords"=>[{"Value"=>"1.2.3.4"}], "Type"=>"A", "Name"=>"example.com.", "TTL"=>60}], "MaxItems"=>"1", "IsTruncated"=>true}
{"NextRecordType"=>"MX", "NextRecordName"=>"example.com.", "ResourceRecordSets"=>[{"ResourceRecords"=>[{"Value"=>"1.2.3.4"}], "Type"=>"A", "Name"=>"example.com.", "TTL"=>60}], "MaxItems"=>"1", "IsTruncated"=>true}

I dont see Hash.clone documented in Ruby 2.0, should I be using another method to create a Hash copy now?
Thanks in advance.

A: Hash is a collection of keys and values, where values are references to objects. When duplicating a hash, new hash is being created, but all object references are being copied, so as result you get new hash containing the same values. That is why this will work:
hash = {1 => 'Some string'} #Strings are mutable
hash2 = hash.clone

hash2[1] #=> 'Some string'
hash2[1].upcase!            # modifying mutual object
hash[1] #=> 'SOME STRING;   # so it appears modified on both hashes
hash2[1] = 'Other string'   # changing reference on second hash to another object
hash[1] #=> 'SOME STRING'   # original obejct has not been changed

hash2[2] = 'new value'      # adding obejct to original hash
hash[2] #=> nil

If you want duplicate the referenced objects, you need to perform deep duplication. It is added in rails (activesupport gem) as deep_dup method. If you are not using rails and don;t want to install the gem, you can write it like:
class Hash
  def deep_dup
    Hash[map {|key, value| [key, value.respond_to?(:deep_dup) ? value.deep_dup : begin
        value.dup
      rescue
        value
      end]}]
  end
end

hash = {1 => 'Some string'} #Strings are mutable
hash2 = hash.deep_dup

hash2[1] #=> 'Some string'
hash2[1].upcase!            # modifying referenced object
hash2[1] #=> 'SOME STRING'
hash[1] #=> 'Some string;   # now other hash point to original object's clone

You probably should write something similar for arrays. I would also thought about writing it for whole enumerable module, but it might be slightly trickier.

A: The easiest way to make a deep copy of most Ruby objects (including strings, arrays, hashes and combinations thereof) is to use Marshal:
def deep_copy(obj)
  Marshal.load(Marshal.dump(obj))
end

For example,
h        = {a: 1, b: [:c, d: {e: 4}]} # => {:a=>1, :b=>[:c, {:d=>{:e=>4}}]}
hclone   = h.clone
hdup     = h.dup
hmarshal = deep_copy(h)

h[:b][1][:d][:e] = 5
h        # => {:a=>1, :b=>[:c, {:d=>{:e=>5}}]}
hclone   # => {:a=>1, :b=>[:c, {:d=>{:e=>5}}]}
hdup     # => {:a=>1, :b=>[:c, {:d=>{:e=>5}}]}
hmarshal # => {:a=>1, :b=>[:c, {:d=>{:e=>4}}]}


text:
Q: Indy 10 TIdSMTP Messaging in BCB 6 In an application developed with Borland C++Builder 6, I am using TIdSMTP and TIdMessage to send email messages. Due to problems for external applications with the usual mail server in the configuration, I am defining the connection data through my Gmail account as follows:
Correo->From->Address           = "******@******.org";
Correo->ReplyTo->EMailAddresses = "******@******.org";
Correo->From->Name              = "*******";
Correo->Organization            = "*******";

Enviar->Host     = "smtp.gmail.com";
Enviar->Password = "******";
Enviar->Port     = 465;
Enviar->Username = "******@gmail.com";
Enviar->UseTLS   = utUseImplicitTLS;

SSLIOHandler->Port               = 465;
SSLIOHandler->Host               = "smtp.gmail.com";
SSLIOHandler->Destination        = "smtp.gmail.com:" + IntToStr(SSLIOHandler->Port);
SSLIOHandler->SSLOptions->Method = sslvTLSv1_2;
SSLIOHandler->SSLOptions->Mode   = sslmUnassigned;

The emails are sent without any problem, but I am checking that in addition to the copies that I send one to my Gmail address. I have verified that the Gmail address appears in the message headers in the Return-Path field.
I have been looking and, at least in Indy 10 for BCB 6, I have not found how to modify that field. How can I get copies to only reach the address indicated in the ReplyTo field of TIdMessage?

A: The TIdMessage.ReplyTo property has no effect on the Return-Path header.  The ReplyTo is only used for the Reply-To header, which recipients use to reply back to the sender.  The Reply-To header is not used by the receiving SMTP server at all.
The Return-Path header is generated by the receiving SMTP server using the address specified in the sending client's SMTP MAIL FROM command. You can specify that address in the TIdMessage.Sender and TIdMessage.From properties (in that order), or by using one of the other overloaded TIdSMTP.Send() methods that has an AFrom parameter.


text:
Q: QrScanner video element don't shown in lit-element When i'm using qrScanner in lit-element i see below warning in console.

QrScanner has overwritten the video hiding style to avoid Safari stopping the playback.

I test this on firefox and chrome in linux and android.
Also any suggestion for good replacement of qrscanner that works fine in lit is welcomed.


text:
Q: Build styleguide colors from SCSS I'm building a living styleguide and would like to automatically generate the color information from our colors.scss file. My goal is to make maintaining the color list as easy and simple as possible. My current setup is this:
$colors: (
//  Variable     Name          Color       Hover    Description
    white:      'White'       #ffffff     #CCCCCC   'Use this for page background and text color on dark elements',
    black:      'Black'       #000000     #333333
);

In another file:
@function color($label) {
  $color: map-get($colors,$label);

  @if $color{
    @return nth($color, 2);
  }

  @warn 'No specified color for "#{$label}"; add your own to colors.scss';
  @return null;
}

.color-values-data {
  font-family: sassToJs($colors);
}

I pass the data to JavaScript using sass-to-js and plan to build the color chart with that information. I can use the colors in my stylesheets like this:
.heading {
  color: color(white);
}

Is there some way I could simplify or otherwise improve this? For instance, I'd prefer using $white instead of color(white) but I believe that would require an additional compilation step before SCSS since it doesn't support dynamic variable names.
This project is not using any existing styleguide engine because it needs to generate a UI module for the CMS we're using (Magnolia) and this approach allows us to use the exact same components in the styleguide as the actual site itself.

A: You may just use SCSS variables, as you see here http://sass-lang.com/guide#topic-2
That's it.


text:
Q: Autofill Google Doc from Form Find Last Row I followed a youtube video to create a Google Apps Script that will autofill a Google Doc (template) with responses from a Form, on Submission as the trigger.  I had to add a number of calculated columns to calculate further based on the answer filled out in the Form submission.  I need to have all columns filled to the Google Doc.
I am pasting the full code below, I believe I am close.  The bold part is what I know I need to update, but I am unsure how.  Currently the script loops through all rows of data and creates a new Google Doc for each row.  I need it to find the last/most recent row of data from the spreadsheet (would be the most recent form submission) and populate the Doc with that data.  I have looked everywhere trying to find a solution- any help is appreciated!
function autoFillGoogleDocFromForm(e){
var PersonName = e.values[1];
var Month = e.values [2];
var ShowName = e.values [3];
var Sale = e.values [4];
var BuyType = e.values [5];
var Budget = e.values [6];
var Products = e.values [7];
var TermMonths = e.values [8];
var Title = e.values [9];
var Assets = e.values [10];
var NumberofShows = e.values [11];
var NumberofSales = e.values [12];
var ListSize = e.values [13];
var Agency = e.values [14];
var DataCadence = e.values [15];
var Other = e.values [16];
var AdditionalNotes = e.values [17];

**var rows = SpreadsheetApp.getActiveSpreadsheet().getDataRange().getDisplayValues();
rows.forEach(function(row){
var ContractID = row [18];
var Term = row [19];
var StartDate = row [20];
var EndDate = row [21];
var CustomerCost = row [22];
var CostShow = row [23];
var Cost = row [24];
var TotalEngagements = row [25];
var CostSplit = row [26];
var TotalEmails = row [27];
var CostData = row [28];**

var templateFile = DriveApp.getFileById("9fu1jGgpaQ");
var templateResponseFolder = DriveApp.getFolderById("15h3GnG");

var copy = templateFile.makeCopy('Name' + BrName, templateResponseFolder);
var doc = DocumentApp.openById(copy.getId());
var body = doc.getBody();

body.replaceText("{{Name of Manufacturer}}", Manufacturer);
body.replaceText("{{Name of Brand}}", BrandDrugName);
body.replaceText("{{Name of Products}}", ProductsPurchased);
body.replaceText("{{Start Date}}", StartDate);
body.replaceText("{{End Date}}", CalculatedEndDate);
body.replaceText("{{Title of Sponsorship}}", SeriesSponsorshipTitle);
body.replaceText("{{Name Generic}}", ClientAssets);
body.replaceText("{{Number of Videos}}", NumberofVideos);
body.replaceText("{{Cost Video Int}}", CustomerVideoIntegrationCost);
body.replaceText("{{Total Video Eng}}", TotalVideoEngagements);
body.replaceText("{{Video Eng}}", VideoEngSplit);
body.replaceText("{{Video Eng 2}}", VideoEngSplit);
body.replaceText("{{Target List Size}}", TargetListSize);
body.replaceText("{{Cost Video Eng}}", CostVideoEngagement);
body.replaceText("{{Total Email Eng}}", TotalEmailEngagements);
body.replaceText("{{Cost Email Eng}}", CostEmailEngagement);
body.replaceText("{{Target Size}}", TargetSize);
body.replaceText("{{Data Cadence}}", DataCadence);
body.replaceText("{{Cost Data}}", CostDataTransfer);

doc.saveAndClose();

})
}

A: You can replace your code block
**var rows = SpreadsheetApp.getActiveSpreadsheet()
...
var CostData = row [28];**

to the following
let entryRow = e.range.getRow(),
  rowData = SpreadsheetApp.getActive().getSheetByName('... yourSheetName here ...').getRange(entryRow,17,1,11).getDisplayValues().flat(),
  ContractID                    = rowData[0],
  CalculatedTerm                = rowData[1],
  StartDate                     = rowData[2],
  CalculatedEndDate             = rowData[3],
  CustomerVideoIntegrationCost  = rowData[4],
  CostVideoEngagement           = rowData[5],
  CostEmailEngagement           = rowData[6],
  TotalVideoEngagements         = rowData[7],
  VideoEngSplit                 = rowData[8],
  TotalEmailEngagements         = rowData[9],
  CostData                      = rowData[10];

but the question is whether the formulas in the Q:Z columns on your sheet will have time to process the information before you get the data with .getDisplayValues(). You might find it easier to translate all those formulas into a script and process the data from the form inside the script without using the formulas on the sheet


text:
Q: How to hide navigation bar when image is tapped How would I hide the navigation bar once my imageView is tapped, the navigation bar messes up the view of the full screen image once my imageView is tapped and I would like it hidden when the image is tapped and to reappear once the image is dismissed. Here is my code for my image being tapped.
//expandImage

@IBAction func expand(_ sender: UITapGestureRecognizer) {
    let imageView = sender.view as! UIImageView
    let newImageView = UIImageView(image: imageView.image)
    newImageView.frame = self.view.frame
    newImageView.backgroundColor = .black
    newImageView.contentMode = .scaleAspectFit
    newImageView.isUserInteractionEnabled = true
    let tap = UITapGestureRecognizer(target: self, action: #selector(dismissFullscreen))
    newImageView.addGestureRecognizer(tap)
    self.view.addSubview(newImageView)
}

func dismissFullscreen(_ sender: UITapGestureRecognizer) {
    sender.view?.removeFromSuperview()
}

A: So here is how you can do that:
class ViewController: UIViewController {

    @IBOutlet weak var imageView: UIImageView!

    override func viewDidLoad() {
        super.viewDidLoad()
        let tapImageScrollView = UITapGestureRecognizer(target: self, action: #selector(imageTapped(_:)))
        imageView.isUserInteractionEnabled = true
        imageView.addGestureRecognizer(tapImageScrollView)
    }

    func imageTapped(_ sender: UIGestureRecognizer) {
        if self.navigationController?.navigationBar.isHidden == false {
            self.navigationController?.navigationBar.isHidden = true
        } else {
            self.navigationController?.navigationBar.isHidden = false
        }
    }
}

So basically add a UITapGestureRecognizer to your imageView and in the imageTapped function you check if the navigationBar is not hidden then you want to show the image and hide the navigationBar and if you click on the imageView again you want to show the navigationBar again.
So simply add the logic in imageTapped to your dismissFullscreen function.

A: Add this to your expand() method:
self.navigationController?.setNavigationBarHidden(true, animated: true)

And in dismissFullscreen() method:
self.navigationController?.setNavigationBarHidden(false, animated: true)

Or you can create new ViewController, pass image to it (with segue e.g) and add this to viewDidLoad() of new ViewController:
self.navigationController?.hidesBarsOnTap = true


text:
Q: Yesod's TH generates incorrect code? I'm making a Yesod subsite and am getting a type error in some Template Haskell-generated code:
Yesod\DataSource\Data.hs:19:1:
Couldn't match type `[Char]' with `Text'
Expected type: () -> ([Text], [(Text, Text)]) -> Maybe (Route DataSource)
  Actual type: () -> ([[Char]], [(Text, Text)]) -> Maybe (Route DataSource)
In the first argument of `\ f_amMs x_amMt -> f_amMs () x_amMt ::
                            forall a_amMu.
                            (() -> ([Text], [(Text, Text)]) -> Maybe (Route a_amMu))
                            -> ([Text], [(Text, Text)]) -> Maybe (Route a_amMu)', namely
  `helper_amMr'
In the expression:
    \ f_amMs x_amMt -> f_amMs () x_amMt ::
      forall a_amMu.
      (() -> ([Text], [(Text, Text)]) -> Maybe (Route a_amMu))
      -> ([Text], [(Text, Text)]) -> Maybe (Route a_amMu)
    helper_amMr

The problem is clear, but I don't understand why it's generating incorrect code.
The issue occurs in this TH call:
mkYesodSubData "DataSource" [parseRoutes|
/ SubHomeR GET
/datasource DataSourceInputR POST GET
|]

Specifically, it is caused by the line:
/datasource DataSourceInputR POST GET

Removing this line fixes the issue.
I'm using Stackage LTS 1.15:
remote-repo: stackage-lts-1.15:http://www.stackage.org/snapshot/lts-1.15

And I'm inside a cabal sandbox.
Here are the relevant files: https://gist.github.com/BeerendLauwers/774cc432c3ada5b597e1
Any idea?

A: I think that the generated code expects that you have the OverloadedStrings extension enabled in your source file. Try adding
{-# LANGUAGE OverloadedStrings #-}

to the top of the source file where you splice in the Template Haskell code (i.e. Data.hs).


text:
Q: Cellular triangular matrix?! What is the English term for "cellular triangular matrix " i.e. a matrix like e.g.
$$
\begin{bmatrix}
1 & 2& 4 & &  &  &  &  \\
2 & 3& 5 &  &  &  &  &  \\
7 & 8& 1 &  &  &  &  &  \\
&&&7&&&&\\
&&&&4&5&&\\
&&&&2&1&&\\
&&&&&&8&9\\
&&&&&&2&6
\end{bmatrix}
 $$
All the other elements are zeros.
What happens when we raise it to some power n?
I think effectively the smaller matrices along the main diagonal are raised to power n.
I need the English term so that I can look up some more information about these matrices and their properties.

A: These matrices are called block diagonal matrices.


text:
Q: Averaging individual predictions in a group I created linear model to give prediction for a team member (individual). Can I use this model to give average (individual) prediction in a team by providing average values of features among team members, or by averaging predictions by each team member?

Example:
Training Data
Independent Variables are Task Count and Average Points while Points are y-value.
$$\begin{array}{c|c|c|}
\text{Team Id} & \text{Sprint Id} & \text{Team Member} & \text{Task Count} & \text{Avg Points} & \text{Points} \\ \hline
\text{1} & 123 & Mike & 4 & 5 & 20 \\ \hline
\text{2} & 273 & Chris & 5 & 3 & 15 \\ \hline
\text{3} & 403 & James & 7 & 2 & 14 \\ \hline
\text{4} & 298 & Paul & 2 & 6 & 12 \\ \hline
\end{array}$$
Actual Data that linear model will use to predict
I average independent values by category within a team. The averaged values for each category will be given to predict average story points for an individual within a team.
$$\begin{array}{c|c|c|}
\text{Team Id} & \text{Sprint Id} & \text{Avg. Task Count} & \text{Avg. Avg Points} & \text{Avg. Points} \\ \hline
\text{1} & 342 & 4 & 4 & 5 \\ \hline
\text{2} & 713 & 5 & 5 & 3 \\ \hline
\text{3} & 663 & 6 & 7 & 2 \\ \hline
\text{4} & 188 & 7 & 2 & 6 \\ \hline
\end{array}$$
Not sure if I can use the model with average values by category to predict average points.

A: If I understand your question correctly, what you are asking is:

*

*Given a linear model (e.g. y=a1*x1 + a2*x2+...+b),

*applied to a group of data points, (e.g. each data point is a player, with their own features (e.g. x1_i, x2_i,... for each player i),

*would averaging the features across players (e.g. using x1_avg, ...), and using them in the model, give the same result as using the features of each player and averaging the results?

If so, the answer is - yes, but only for a linear model (i.e. not a quadratic, polynomial, neural network or whatever).
This can be verified quite simply: for example, if there are only two players and two features:


text:
Q: call sqlite query from separated class i have some problems in my database... here the scenario
i want to make separated data base like this
class 1 : declare the data base --> master.sqlite
class 2 : declare the query toward the data base in class 1
class 3 : call the query from class 2 and get the result
in my class 1 i declare my database like this
public class Database_Login extends SQLiteOpenHelper {

public static int iconPos;

private static String DB_NAME = "Master.sqlite";

private SQLiteDatabase loginDataBase;

private final Context myContext;

private static String DB_PATH;

public Database_Login(Context context) {
    super(context, DB_NAME, null, 1);
    this.myContext = context;
    DB_PATH = "/data/data/" + myContext.getApplicationContext().getPackageName() + "/" + "databases/";
}

public void createDataBase() throws IOException {

    boolean dbExist = checkDataBase();

    if (dbExist) {

    } else {
        this.getReadableDatabase();

        try {

            copyDataBase();

        } catch (IOException e) {

            throw new Error("Error copying database");

        }
    }

}

public boolean checkDataBase() {
    SQLiteDatabase checkDB = null;
    try {
        String myPath = DB_PATH + DB_NAME;
        checkDB = SQLiteDatabase.openDatabase(myPath, null,SQLiteDatabase.OPEN_READWRITE);

    }

    catch (SQLiteException e){

    }

    if (checkDB != null) {

        checkDB.close();

    }

    return checkDB != null ? true : false;
}

/**
 * Copies your database from your local assets-folder to the just created
 * empty database in the system folder, from where it can be accessed and
 * handled. This is done by transfering bytestream.
 * */
private void copyDataBase() throws IOException {

    // Open your local db as the input stream
    InputStream myInput = myContext.getAssets().open(DB_NAME);

    // Path to the just created empty db
    String outFileName = DB_PATH + DB_NAME;

    // Open the empty db as the output stream
    OutputStream myOutput = new FileOutputStream(outFileName);

    // transfer bytes from the inputfile to the outputfile
    byte[] buffer = new byte[1024];
    int length;
    while ((length = myInput.read(buffer)) > 0) {
        myOutput.write(buffer, 0, length);
    }

    // Close the streams
    myOutput.flush();
    myOutput.close();
    myInput.close();

}

public void openDataBase() throws SQLException {

    // Open the database
    String myPath = DB_PATH + DB_NAME;
    loginDataBase = SQLiteDatabase.openDatabase(myPath, null,SQLiteDatabase.OPEN_READWRITE);

}

@Override
public synchronized void close() {

    if (loginDataBase != null)
        loginDataBase.close();

    super.close();

}

@Override
public void onCreate(SQLiteDatabase db) {

}

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

}

and in class 2 i declare like this
public class Login{
public static int iconPos;

Database_Login login;
SQLiteDatabase loginDataBase;

public Login(Context context) {
    login = new Database_Login(context);
    loginDataBase = login.getReadableDatabase();
}

public boolean cekLogin(String username, String password) throws SQLException {
    login.openDataBase();
    loginDataBase = login.getReadableDatabase();
    Cursor mCursor = loginDataBase.rawQuery("SELECT * FROM tblUser WHERE UserName=? AND Password=?", new String[] { username, password});
    if (mCursor != null) {
        if (mCursor.getCount() > 0) {
            return true;
        }
    }
    login.close();
    return false;
}

public String UserType(String username) throws SQLException{
    login.openDataBase();
    loginDataBase = login.getReadableDatabase();
    String UserType = "";
    Cursor mCursor = loginDataBase.rawQuery("SELECT UserType FROM tblUser WHERE UserName=?", new String[] { username });
    if(mCursor.moveToFirst()){
        UserType = mCursor.getString(mCursor.getColumnIndex("UserType"));
        return UserType;
    }
    login.close();
    return UserType;
}

public int checkIcon() {
    switch (iconPos) {
    case 0:
        iconPos = R.drawable.ic_action_help;
        break;
    case 1:
        iconPos = R.drawable.ic_action_good;
        break;
    case 2:
        iconPos = R.drawable.ic_action_labels;
        break;
    case 3:
        iconPos = R.drawable.ic_action_email;
        break;
    case 4:
        iconPos = R.drawable.ic_action_gamepad;
        break;
    case 5:
        iconPos = R.drawable.ic_action_search;
        break;
    case 6:
        iconPos = R.drawable.ic_action_cloud;
        break;
    case 7:
        iconPos = R.drawable.ic_action_camera;
        break;
    case 8:
        iconPos = R.drawable.ic_action_video;
        break;
    case 9:
        iconPos = R.drawable.ic_action_group;
        break;
    case 10:
        iconPos = R.drawable.ic_action_import_export;
        break;
    case 11:
        iconPos = R.drawable.ic_action_help;
        break;
    case 12:
        iconPos = R.drawable.ic_action_about;
        break;
    case 13:
        iconPos = R.drawable.ic_action_settings;
        break;
    case 14:
        iconPos = R.drawable.ic_action_gamepad;
        break;
    case 15:
        iconPos = R.drawable.ic_action_cloud;
        break;
    case 16:
        iconPos = R.drawable.ic_action_camera;
        break;
    case 17:
        iconPos = R.drawable.ic_action_video;
        break;
    case 18:
        iconPos = R.drawable.ic_action_import_export;
        break;
    case 19:
        iconPos = R.drawable.ic_action_about;
        break;
    case 20:
        iconPos = R.drawable.ic_action_good;
        break;
    case 21:
        iconPos = R.drawable.ic_action_gamepad;
        break;
    case 22:
        iconPos = R.drawable.ic_action_cloud;
        break;
    default:
        break;
    }
    return iconPos;
}

}
and in class 3 i just call the class 2 method
but when i run it, the log cat said that no tblUser found...
how i supposed to do to make my database work???
thx for your help...

A: Probably you have added the table after first install. When you install the application for debug it doesn't copy the database from assets again. To get the latest database you will have to uninstall the application and have a fresh install.


text:
Q: How to know when to use indexes and which type? I've searched a bit and didn't see any similar question, so here goes.
How do you know when to put an index in a table? How do you decide which columns to include in the index? When should a clustered index be used?
Can an index ever slow down the performance of select statements? How many indexes is too many and how big of a table do you need for it to benefit from an index?
EDIT:
What about column data types? Is it ok to have an index on a varchar or datetime?

A: Well, the first question is easy:

When should a clustered index be used?

Always. Period. Except for a very few, rare, edge cases. A clustered index makes a table faster, for every operation. YES! It does. See Kim Tripp's excellent The Clustered Index Debate continues for background info. She also mentions her main criteria for a clustered index:

*

*narrow

*static (never changes)

*unique

*if ever possible: ever increasing

INT IDENTITY fulfills this perfectly - GUID's do not. See GUID's as Primary Key for extensive background info.
Why narrow? Because the clustering key is added to each and every index page of each and every non-clustered index on the same table (in order to be able to actually look up the data row, if needed). You don't want to have VARCHAR(200) in your clustering key....
Why unique?? See above - the clustering key is the item and mechanism that SQL Server uses to uniquely find a data row. It has to be unique. If you pick a non-unique clustering key, SQL Server itself will add a 4-byte uniqueifier to your keys. Be careful of that!
Next: non-clustered indices. Basically there's one rule: any foreign key in a child table referencing another table should be indexed, it'll speed up JOINs and other operations.
Furthermore, any queries that have WHERE clauses are a good candidate - pick those first which are executed a lot. Put indices on columns that show up in WHERE clauses, in ORDER BY statements.
Next: measure your system, check the DMV's (dynamic management views) for hints about unused or missing indices, and tweak your system over and over again. It's an ongoing process, you'll never be done! See here for info on those two DMV's (missing and unused indices).
Another word of warning: with a truckload of indices, you can make any SELECT query go really really fast. But at the same time, INSERTs, UPDATEs and DELETEs which have to update all the indices involved might suffer. If you only ever SELECT - go nuts! Otherwise, it's a fine and delicate balancing act. You can always tweak a single query beyond belief - but the rest of your system might suffer in doing so. Don't over-index your database! Put a few good indices in place, check and observe how the system behaves, and then maybe add another one or two, and again: observe how the total system performance is affected by that.

A: Rule of thumb is primary key (implied and defaults to clustered) and each foreign key column
There is more but you could do worse than using SQL Server's missing index DMVs
An index may slow down a SELECT if the optimiser makes a bad choice, and it is possible to have too many. Too many will slow writes but it's also possible to overlap indexes

A: Answering the ones I can I would say that every table, no matter how small, will always benefit from at least one index as there has to be at least one way in which you are interested in looking up the data; otherwise why store it?
A general rule for adding indexes would be if you need to find data in the table using a particular field, or set of fields. This leads on to how many indexes are too many, generally the more indexes you have the slower inserts and updates will be as they also have to modify the indexes but it all depends on how you use your data. If you need fast inserts then don't use too many. In reporting "read only" type data stores you can have a number of them to make all your lookups faster.
Unfortunately there is no one rule to guide you on the number or type of indexes to use, although the query optimiser of your chosen DB can give hints based on the queries you are executing.
As to clustered indexes they are the Ace card you only get to use once, so choose carefully. It's worth calculating the selectivity of the field you are thinking of putting it on as it can be wasted to put it on something like a boolean field (contrived example) as the selectivity of the data is very low.

A: This is really a very involved question, though a good starting place would be to index any column that you will filter results on.  ie.  If you often break products into groups by sale price, index the sale_price column of the products table to improve scan times for that query, etc.

A: If you are querying based on the value in a column, you probably want to index that column.
i.e.
SELECT a,b,c FROM MyTable WHERE x = 1

You would want an index on X.
Generally, I add indexes for columns which are frequently queried, and I add compound indexes when I'm querying on more than one column.
Indexes won't hurt the performance of a SELECT, but they may slow down INSERTS (or UPDATES) if you have too many indexes columns per table.
As a rule of thumb - start off by adding indexes when you find yourself saying WHERE a = 123 (in this case, an index for "a").

A: You should use an index on columns that you use for selection and ordering - i.e. the WHERE and ORDER BY clauses.
Indexes can slow down select statements if there are many of them and you are using WHERE and ORDER BY on columns that have not been indexed.
As for size of table - several thousands rows and upwards would start showing real benefits to index usage.
Having said that, there are automated tools to do this, and SQL server has an Database Tuning Advisor that will help with this.


text:
Q: Keep getting exception in python webserver I have a pretty simple python webserver that returns a few web pages, and it keeps throwing TypeError: 'str' does not support the buffer interface. Here is my code, can anyone tell what is wrong?
from os import curdir
from os.path import join as pjoin
from http.server import BaseHTTPRequestHandler, HTTPServer
class StoreHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        if self.path == "/store.json":
            with open(pjoin(curdir, 'store.json')) as fh:
                self.send_response(200)
                self.send_header('Content-type','text/json')
                self.end_headers()
                self.wfile.write(fh.read())
        elif self.path == "/Stock.htm":
            with open(pjoin(curdir, 'stock.htm')) as fh:
                self.send_response(200)
                self.send_header('Content-type','text/html')
                self.end_headers()
                self.wfile.write(fh.read())
        else:
            with open(pjoin(curdir, 'index.htm')) as fh:
                self.send_response(200)
                self.send_header('Content-type','text/html')
                self.end_headers()
                self.wfile.write(fh.read())
    def do_POST(self):
        if self.path == '/store.json':
            length = self.headers.getheader('content-length')
            data = self.rfile.read(int(length))
            with open(pjoin(curdir, 'store.json'), 'w') as fh:
                fh.write(data)
            self.send_response(200)

server = HTTPServer(('', 8080), StoreHandler)
server.serve_forever()

Here is the exception output:
127.0.0.1 - - [30/Oct/2012 16:48:17] "GET / HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 58645)
Traceback (most recent call last):
  File "C:\Program Files\Python33\lib\socketserver.py", line 306, in _handle_request_noblock
    self.process_request(request, client_address)
  File "C:\Program Files\Python33\lib\socketserver.py", line 332, in process_request
    self.finish_request(request, client_address)
  File "C:\Program Files\Python33\lib\socketserver.py", line 345, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Program Files\Python33\lib\socketserver.py", line 666, in __init__
    self.handle()
  File "C:\Program Files\Python33\lib\http\server.py", line 400, in handle
    self.handle_one_request()
  File "C:\Program Files\Python33\lib\http\server.py", line 388, in handle_one_request
    method()
  File "C:\Users\Arlen\Desktop\Stock Recorder\webserver.py", line 25, in do_GET
    self.wfile.write(fh.read())
  File "C:\Program Files\Python33\lib\socket.py", line 317, in write
    return self._sock.send(b)
TypeError: 'str' does not support the buffer interface
----------------------------------------

Update: Here is how my updated code looks:
from os import curdir
from os.path import join as pjoin

from http.server import BaseHTTPRequestHandler, HTTPServer

class StoreHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        if self.path == "/store.json":
            with open(pjoin(curdir, 'store.json')) as fh:
                self.send_response(200)
                self.send_header('Content-type','text/json')
                self.end_headers()
                self.wfile.write(fh.read(), 'rb')
        elif self.path == "/Stock.htm":
            with open(pjoin(curdir, 'stock.htm')) as fh:
                self.send_response(200)
                self.send_header('Content-type','text/html')
                self.end_headers()
                self.wfile.write(fh.read(), 'rb')
        else:
            with open(pjoin(curdir, 'index.htm')) as fh:
                self.send_response(200)
                self.send_header('Content-type','text/html')
                self.end_headers()
                self.wfile.write(fh.read(),'rb')
    def do_POST(self):
        if self.path == '/store.json':
            length = self.headers.getheader('content-length')
            data = self.rfile.read(int(length))
            with open(pjoin(curdir, 'store.json'), 'w') as fh:
                fh.write(data)
            self.send_response(200)

server = HTTPServer(('', 8080), StoreHandler)
server.serve_forever()

A: Sockets send and receive bytes, but you are attempting to send over unicode strings since you opened the file without specifying the mode (remember, in Python 3 all strings are unicode by default).
You can either:

*

*Use the bytes built-in function to transform the data

- or -

*

*Open the file in binary mode - change open(pjoin(curdir, 'a.file')) to open(pjoin(curdir, 'store.json'), 'rb') (note the additional rb parameter).


text:
Q: Activity becomes white/black after onResume() I have a problem with my application, in my main activity I have a button which opens another activity that extends RajawaliActivity
public void onStartOpenCVViewActivity(View view) {
        Intent intent = new Intent(this, SelectSceneActivity.class);
        startActivity(intent);
}

When I return back from that activity, the main activity (and all other activities opened after) becomes all white (android 4.1.2 - samsung s3 mini) or black (sometimes after click, most of the time instantly) on android 4.4.4 (motorola moto g).
To be more precise, I can see proper overlay during onResume(), but then the 'white/black' overlay appears.
Funny thing is that I can still click the buttons that are under the 'white/black overlay', and I can see parts of the GUI.GUI being visible through white 'overlay'
After this 'overlay' appears, there is no way to get rid of it until I turn the application off and on again.
I am not doing any heavy calculation neither on onCreate(), nor on onResume (except loading OpenCV in onResume method: OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, this.mLoaderCallback); )
I don't see this problem on Android 5.1 (NVidia Shield tablet).
Any tips what might cause this?

A: It seems that Rajawali has a bug somewhere while working with OpenGL thread.
I don't quite understand what is the problem, but the workaround for me is turning off the hardware acceleration for the main activity, i.e. adding
android:hardwareAccelerated="false"
to the AndroidManifest.


text:
Q: Linking opencv 3.2 to an MFC project causes false memory leaks I recently linked openCV to my MFC project which ran before without any memory leaks,
when I added something as simple as
void function {
   Mat image;
}

visual studio detects a lot of memory leaks, which seems false positives  . this problem was fixed by delay loading the opencv_world320d.dll in the linker, but if I try to do something with the images like reading into it or using canny's edge detector the memory leaks reappear.
I also tried to statically load MFC library with no success.
(I run the same function on a new project without the MFC, and it works without leaks)
any suggestions on how to fix it? would really appreciate your help!
Thanks
here is the loading order:
'as2000pc.exe' (Win32): Loaded '******as2000pc.exe'. Symbols loaded.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\kernel32.dll'
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmm.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\win32u.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32full.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\mfc140ud.dll'. Cannot find or open the PDB file.
**'as2000pc.exe' (Win32): Loaded 'C:\****\opencv_world320d.dll'. Symbols** loaded.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbase.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winspool.drv'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp_win.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\comdlg32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140d.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\windows.storage.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\SHCore.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\powrprof.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\profapi.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcrypt.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ws2_32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.14393.447_none_5507ded2cb4f7f4c\comctl32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvfw32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\avifil32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140d.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\avicap32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\concrt140d.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.14393.953_none_baad48403594ab3f\GdiPlus.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\mpr.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msacm32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.14393.953_none_89c2555adb023171\comctl32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\clbcatq.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Program Files (x86)\Microsoft Office\root\VFS\SystemX86\FM20.DLL'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\riched20.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msls31.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usp10.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sxs.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Program Files (x86)\Microsoft Office\root\VFS\SystemX86\FM20ENU.DLL'. Module was built without symbols.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\quartz.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\qcap.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\qedit.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\devenum.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\setupapi.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntmarta.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\devobj.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\wintrust.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msasn1.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\crypt32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msdmo.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\BaslerGenICamSource_v5_0.ax'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\MVGenICamConfig_v5_0.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msimg32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleacc.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\PylonBase_MD_VC120_v5_0.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\Log_MD_VC120_v3_0_Basler_pylon_v5_0.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\GCBase_MD_VC120_v3_0_Basler_pylon_v5_0.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\GenApi_MD_VC120_v3_0_Basler_pylon_v5_0.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\MathParser_MD_VC120_v3_0_Basler_pylon_v5_0.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\XmlParser_MD_VC120_v3_0_Basler_pylon_v5_0.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\NodeMapData_MD_VC120_v3_0_Basler_pylon_v5_0.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\log4cpp_MD_VC120_v3_0_Basler_pylon_v5_0.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\PylonUsb_MD_VC120_V5_0_TL.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\uxapi_MD_VC120_v5_0.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uEyecapture.ax'. Module was built without symbols.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uEye_api.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\IPHLPAPI.DLL'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\opengl32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\glu32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ddraw.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dciman32.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nvd3dum.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\psapi.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\d3dim700.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\psapi.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\nvd3dum.dll'
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nvd3dum.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\psapi.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\psapi.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\nvd3dum.dll'
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nvd3dum.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\psapi.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\psapi.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\nvd3dum.dll'
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nvd3dum.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\psapi.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\d3d9.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ResourcePolicyClient.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ResourcePolicyClient.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\d3d9.dll'
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dxva2.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Loaded 'C:\Windows\SysWOW64\coml2.dll'. Cannot find or open the PDB file.
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\psapi.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\nvd3dum.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\dxva2.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\devenum.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\quartz.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\uEyecapture.ax'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\oleacc.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\MVGenICamConfig_v5_0.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\PROGRA~1\Basler\pylon 5\Runtime\Win32\BaslerGenICamSource_v5_0.ax'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\qedit.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\usp10.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\msls31.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\riched20.dll'
'as2000pc.exe' (Win32): Unloaded 'C:\Program Files (x86)\Microsoft Office\root\VFS\SystemX86\FM20ENU.DLL'
'as2000pc.exe' (Win32): Unloaded 'C:\Program Files (x86)\Microsoft Office\root\VFS\SystemX86\FM20.DLL'
'as2000pc.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\qcap.dll'

A: I recently faced an identical situation, here's my 2c.
When the application starts up you should get module-load messages in the VS output pane (if not, right click it and check 'Module load messages').  Take note of the module loading order - in particular mfc***.dll.  Any of your modules that load before that will be unloaded after it, and thus any static allocations they make would be falsely reported as leaks.
In my particular situation I was lucky, and I detected one module of mine that was loaded early and not built as an MFC module. Changing it to an MFC dll made the mfc framework load earlier, and these false leaks were gone.
That might be also the case for you. But I have no general solution.

A: Using opencv version 2.4.13 instead of 3.2 and loading delayed opencv ddls fixed the false memory leaks.


text:
Q: Most Efficient Way to Convert Strings.Builder to Byte Array I'm using the stringbuilder:
var sb strings.Builder

I need to convert this to []byte to finally send it with bytes.NewBuffer() via http post.  I need this to be as quick as possible.
Currently I do it as follows:
var sendText = sb.String()
var byteSend = []byte(sendText)

Is this the best way of doing this?

A: Use bytes.NewBufferString(sb.String()) if you must start from a strings.Buffer and end with bytes.Buffer.  This will incur the cost of a string to []byte conversion (allocation + copy).
There are better alternatives if the problem statement can be relaxed.
If you have control over the code that writes to the strings.Builder, then change the code to write to a bytes.Buffer directly.  This is a simple change because bytes.Buffer has all of the strings.Builder methods.
If your goal is to get an io.Reader to use as an HTTP request body, then use strings.NewReader(sb.String()) to get the io.Reader.
These two options do not incur the the cost of the string to []byte conversion.