问:
Scroll HTML page to specific div not working
I picked a code from http://jsfiddle.net/kevinPHPkevin/8tLdq/1/ about page scrolling to specific divs and it was working on their demo but failed on my side. Someone kindly answer with full code from top to bottom. I am still learning. I have tried many options from stackoverflow but I am not sure where to place the javascript code. Here is the code:

$("#button").click(function() {
  $('html, body').animate({
    scrollTop: $("#myDiv").offset().top
  }, 2000);
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.div {
  min-height: 1100px;
  background: red;
}

#myDiv {
  height: 100px;
  background: blue;
}</code>```

button

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has
    a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search
    for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random
    text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a
    Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero,
    written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has
    a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search
    for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random
    text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, classical literature,
    discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during
    the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has
    a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search
    for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random
    text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a
    Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero,
    written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of desktop publishing software like Aldus PageMaker including versions of Lorem
    Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content
    here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will u ncover many web sites still in their infancy. Various
    versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC,
    making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical
    literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very
    popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

```

答:
You can use this script to scrolldown at particular div</p>

```<code>$(document).on("click", "#button", function () {
            $('html, body').animate({
                scrollTop: $("#myDiv").offset().top
            }, 2000);
        });
</code>```

Body:
I picked a code from http://jsfiddle.net/kevinPHPkevin/8tLdq/1/ about page scrolling to specific divs and it was working on their demo but failed on my side. Someone kindly answer with full code from top to bottom. I am still learning. I have tried many options from stackoverflow but I am not sure where to place the javascript code. Here is the code:

$("#button").click(function() {
  $('html, body').animate({
    scrollTop: $("#myDiv").offset().top
  }, 2000);
});

.div {
  min-height: 1100px;
  background: red;
}

#myDiv {
  height: 100px;
  background: blue;
}

button

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has
    a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search
    for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random
    text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a
    Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero,
    written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has
    a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search
    for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random
    text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, classical literature,
    discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during
    the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has
    a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search
    for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random
    text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a
    Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero,
    written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of desktop publishing software like Aldus PageMaker including versions of Lorem
    Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content
    here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will u ncover many web sites still in their infancy. Various
    versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC,
    making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical
    literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very
    popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

Body:
You can use this script to scrolldown at particular div

$(document).on("click", "#button", function () {
            $('html, body').animate({
                scrollTop: $("#myDiv").offset().top
            }, 2000);
        });


来源: stackexchange

问:
Error is occurring in my interstitial ad code for AdMob when i am using my own ad unit id
I am new to AdMob i added app name and platform in admob account.In this app i have added unit ad of interstitial ad.And created its ad unit id.

Now in android studio i have wrote simple code as per the instructions from AdMob.
So when button gets clicked it shows ad perfectly when i use the testing ad unit id but when i use my own created id its not getting load and the logcat shows as follows:

```<code>07-04 23:47:25.165 17901-17914/h.safmical.kk W/Ads: There was a problem getting an ad response. ErrorCode: 0
07-04 23:47:25.169 17901-17901/h.safmical.kk W/Ads: Failed to load ad: 0
07-04 23:47:25.169 17901-17901/h.safmical.kk I/Ads: onAdFailedToLoad
07-04 23:47:33.028 17901-17901/h.safmical.kk D/TAG: The interstitial wasn't loaded yet.
07-04 23:50:57.947 17901-18143/h.safmical.kk E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb9aabcf0
</code>```

My mainactivity:

MainActivity.java:

```<code>package h.safmical.kk;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;

public class MainActivity extends Activity {
    private InterstitialAd mInterstitialAd;

    Button click;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId("*************************");
        mInterstitialAd.loadAd(new AdRequest.Builder().build());

        click = (Button) findViewById(R.id.click);
        click.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mInterstitialAd.isLoaded()) {
                    mInterstitialAd.show();
                } else {
                    Log.d("TAG", "The interstitial wasn't loaded yet.");
                }
            }
        });

        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
               Log.i("Ads", "onAdLoaded");
            }

            @Override
            public void onAdFailedToLoad(int errorCode) {
              Log.i("Ads", "onAdFailedToLoad");
            }

            @Override
            public void onAdOpened() {
            Log.i("Ads", "onAdOpened");
            }

            @Override
            public void onAdLeftApplication() {
            Log.i("Ads", "onAdLeftApplication");
            }

            @Override
            public void onAdClosed() {
              mInterstitialAd.loadAd(new AdRequest.Builder().build());
            }
        });
    }
}
</code>```

My Gradle file:

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "h.safmical.kk"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-ads:10.2.4'
    testCompile 'junit:junit:4.12'
}
</code>```

Please help me to solve this.

答:
According to your post Google's interstitial ad units.ca-app-pub-3940256099942544/1033173712 is working fine.

If you want to test own adUnitId, enable your device as test device and check. If it is working but you're not getting live ad, check this answer.

Make sure you've all required entry in AndroidManifest.xml file.

ContentLicense: CC BY-SA 3.0

Body:
I am new to AdMob i added app name and platform in admob account.In this app i have added unit ad of interstitial ad.And created its ad unit id.

Now in android studio i have wrote simple code as per the instructions from AdMob.
So when button gets clicked it shows ad perfectly when i use the testing ad unit id but when i use my own created id its not getting load and the logcat shows as follows:

07-04 23:47:25.165 17901-17914/h.safmical.kk W/Ads: There was a problem getting an ad response. ErrorCode: 0
07-04 23:47:25.169 17901-17901/h.safmical.kk W/Ads: Failed to load ad: 0
07-04 23:47:25.169 17901-17901/h.safmical.kk I/Ads: onAdFailedToLoad
07-04 23:47:33.028 17901-17901/h.safmical.kk D/TAG: The interstitial wasn't loaded yet.
07-04 23:50:57.947 17901-18143/h.safmical.kk E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb9aabcf0

My mainactivity:

MainActivity.java:

package h.safmical.kk;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;

public class MainActivity extends Activity {
    private InterstitialAd mInterstitialAd;

    Button click;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId("*************************");
        mInterstitialAd.loadAd(new AdRequest.Builder().build());

        click = (Button) findViewById(R.id.click);
        click.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mInterstitialAd.isLoaded()) {
                    mInterstitialAd.show();
                } else {
                    Log.d("TAG", "The interstitial wasn't loaded yet.");
                }
            }
        });

        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
               Log.i("Ads", "onAdLoaded");
            }

            @Override
            public void onAdFailedToLoad(int errorCode) {
              Log.i("Ads", "onAdFailedToLoad");
            }

            @Override
            public void onAdOpened() {
            Log.i("Ads", "onAdOpened");
            }

            @Override
            public void onAdLeftApplication() {
            Log.i("Ads", "onAdLeftApplication");
            }

            @Override
            public void onAdClosed() {
              mInterstitialAd.loadAd(new AdRequest.Builder().build());
            }
        });
    }
}

My Gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "h.safmical.kk"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-ads:10.2.4'
    testCompile 'junit:junit:4.12'
}

Please help me to solve this.


问:
Convert Varchar to Ascii
I'm trying to convert the contents of a VARCHAR field to be unique number that can be easily referenced by a 3rd party.

How can I convert a varchar to the ascii string equivalent? In TSQL? The ASCII() function converts a single character but what can I do to convert an entire string?

I've tried using

```<code>CAST(ISNULL(ASCII(Substring(RTRIM(LTRIM(PrimaryContactRegion)),1,1)),'')AS VARCHAR(3))
+ CAST(ISNULL(ASCII(Substring(RTRIM(LTRIM(PrimaryContactRegion)),2,1)),'')AS VARCHAR(3))
</code>```

....but this is tedious, stupid looking, and just doesn't really work if I had long strings.  Or if it is better how would I do the same thing in SSRS?

答:
Well, I think that a solution to this will be very slow, but i guess that you could do something like this:

```<code>DECLARE @count INT, @string VARCHAR(100), @ascii VARCHAR(MAX)

SET @count = 1
SET @string = 'put your string here'
SET @ascii = ''

WHILE @count <= DATALENGTH(@string)
BEGIN
    SELECT @ascii = @ascii + '&#' + ASCII(SUBSTRING(@string, @count, 1)) + ';'
    SET @count = @count + 1
END

SET @ascii = LEFT(@ascii,LEN(@ascii)-1)
SELECT @ascii
</code>```

I'm not in a pc with a database engine, so i can't really test this code. If it works, then you can create a UDF based on this.

ContentLicense: CC BY-SA 2.5

Title: Convert Varchar to Ascii

Body:
I'm trying to convert the contents of a VARCHAR field to be unique number that can be easily referenced by a 3rd party.

How can I convert a varchar to the ascii string equivalent? In TSQL? The ASCII() function converts a single character but what can I do to convert an entire string?

I've tried using

CAST(ISNULL(ASCII(Substring(RTRIM(LTRIM(PrimaryContactRegion)),1,1)),'')AS VARCHAR(3))
+ CAST(ISNULL(ASCII(Substring(RTRIM(LTRIM(PrimaryContactRegion)),2,1)),'')AS VARCHAR(3))

....but this is tedious, stupid looking, and just doesn't really work if I had long strings.  Or if it is better how would I do the same thing in SSRS?

Body:
Well, I think that a solution to this will be very slow, but i guess that you could do something like this:

DECLARE @count INT, @string VARCHAR(100), @ascii VARCHAR(MAX)

SET @count = 1
SET @string = 'put your string here'
SET @ascii = ''

WHILE @count <= DATALENGTH(@string)
BEGIN
    SELECT @ascii = @ascii + '&#' + ASCII(SUBSTRING(@string, @count, 1)) + ';'
    SET @count = @count + 1
END

SET @ascii = LEFT(@ascii,LEN(@ascii)-1)
SELECT @ascii

I'm not in a pc with a database engine, so i can't really test this code. If it works, then you can create a UDF based on this.


答:
You need to add the jquery ready function to load your script only when all the dom elements have loaded.
here is the code working</p>

```<code><!DOCTYPE html>
<html>

<head>
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
    </script>
    <style type="text/css">
    .div {
        min-height: 1100px;
        background: red;
    }

    #myDiv {
        height: 100px;
        background: blue;
    }
    </style>
    <script type="text/javascript">
    $(function() {
        $("#button").click(function() {
            $('html, body').animate({
                scrollTop: $("#myDiv").offset().top
            }, 2000);
        });
    })
    </script>
</head>

<body>
    <div id="button">button</div>
    <div class="div">
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will u ncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
    </div>
    <div id="myDiv"></div>
</body>

</html>
</code>```

Title: Scroll HTML page to specific div not working

Body:
You need to add the jquery ready function to load your script only when all the dom elements have loaded.
here is the code working

<!DOCTYPE html>
<html>

<head>
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
    </script>
    <style type="text/css">
    .div {
        min-height: 1100px;
        background: red;
    }

    #myDiv {
        height: 100px;
        background: blue;
    }
    </style>
    <script type="text/javascript">
    $(function() {
        $("#button").click(function() {
            $('html, body').animate({
                scrollTop: $("#myDiv").offset().top
            }, 2000);
        });
    })
    </script>
</head>

<body>
    <div id="button">button</div>
    <div class="div">
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will u ncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
    </div>
    <div id="myDiv"></div>
</body>

</html>


问:
Jquery each with where clause or similar
I have this bit of code

```<code>newDocumentState.documents = jQuery.grep(newDocumentState.documents,
    item => item["documentId"] !== docToRemove.name);

    $.each(newDocumentState.documents), (index, value ) => {
    this.documentState.addDocument(new DocumentMeta(value.documentId));
    });
</code>```

I was wondering if I could have something like this or similar instead.

```<code>$.each(newDocumentState.documents.where(x => x.documentId !== docToRemove.name),
    (index, value ) => {
    this.documentState.addDocument(new DocumentMeta(value.documentId));
    });
</code>```

答:
```<code>      var docToRemoveName ="New";
      var documents =[
            {"documentId": "New", "class": "class1"},
            {"documentId": "New", "class": "class2"},
            {"documentId": "Close", "class": "class3"},
            {"documentId": "send", "class": "class3"},
            {"documentId": "receive", "class": "class3"}];

        $.each(documents.filter(
            function (el) {
               return el.documentId !== docToRemoveName ;
            }),
            function( index, value ) {
                alert( index + ": " + value.documentId );
            });
</code>```

jsfiddle Link
https://jsfiddle.net/o2gxgz9r/9600/

Body:
I have this bit of code

newDocumentState.documents = jQuery.grep(newDocumentState.documents,
    item => item["documentId"] !== docToRemove.name);

    $.each(newDocumentState.documents), (index, value ) => {
    this.documentState.addDocument(new DocumentMeta(value.documentId));
    });

I was wondering if I could have something like this or similar instead.

$.each(newDocumentState.documents.where(x => x.documentId !== docToRemove.name),
    (index, value ) => {
    this.documentState.addDocument(new DocumentMeta(value.documentId));
    });

Body:
      var docToRemoveName ="New";
      var documents =[
            {"documentId": "New", "class": "class1"},
            {"documentId": "New", "class": "class2"},
            {"documentId": "Close", "class": "class3"},
            {"documentId": "send", "class": "class3"},
            {"documentId": "receive", "class": "class3"}];

        $.each(documents.filter(
            function (el) {
               return el.documentId !== docToRemoveName ;
            }),
            function( index, value ) {
                alert( index + ": " + value.documentId );
            });

jsfiddle Link
https://jsfiddle.net/o2gxgz9r/9600/


问:
How can i make an object (for example imageview) appear or disappear smoothly in android ?
How can I make an object appear or disappear smoothly?

答:
Use alpha animation.

1) To hide, increase alpha to FF.  Then set visibility to View.GONE

2) To show, set visibility to View. VISIBLE and then decrease alpha from FF to 00.

Example code:

```<code>AlphaAnimation blinkAnimation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
    blinkAnimation.setDuration(1000); // duration
    blinkAnimation.setInterpolator(new LinearInterpolator());
</code>```

Body:
Use alpha animation.

1) To hide, increase alpha to FF.  Then set visibility to View.GONE

2) To show, set visibility to View. VISIBLE and then decrease alpha from FF to 00.

Example code:

AlphaAnimation blinkAnimation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
    blinkAnimation.setDuration(1000); // duration
    blinkAnimation.setInterpolator(new LinearInterpolator());


问:
print 1 to 5 and even and odd in HTML and JavaScript
I have to create a html page which satisfy below requirement-
1. print 1 to 5 with another array
2. take number input from textbox then print on page whether it is Even or Odd.

I have create a page but it is not working as desired.

```<code>    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
        <p id="demo"></p>
        <input type="number" id="myNumber">
        <button onclick="oddOrEven()">Try it</button>
        <input type="text" name="result" id="result" readonly="true"/>
            <SCRIPT>
            var numbers = [1,2,3,4,5];
            var myObjects = ["One","Two","Three","Four","Five"];
            var text = "";
            var myObjectsList =""
            var i;
            for (i = 0; i < numbers.length; i++) {
                text += numbers[i] + " : " + myObjects[i] + "<br>";
            }
            document.getElementById("demo").innerHTML = text;

            function oddOrEven() {
            var value = document.getElementById("myNumber").value;
            var res = if((value % 2) == 0) {"Even"} else {"Odd"}*/
            //if(value % 2 == 0) document.write("Even")
            //document.write(value);
            //document.getElementById("demo").innerHTML = res;
            readonly.value=res;
            }
            //document.write("Hello World!");

        </SCRIPT>

    </BODY>
    </HTML>
</code>```

Could someone please help me with the code.

答:
There is a problem with the way you are assigning res, it should be as follows:

```<code>var res = value % 2 == 0 ? "Even" : "Odd";
</code>```

Alternatively you can use an if statement if you want like so:

```<code>var res = "Odd";
if(value % 2 == 0) {
    res = "Even";
}
</code>```

In addition, there is also an issue with this line:

```<code>readonly.value=res;
</code>```

In this case, readonly does not exist. You probably mean to do this:

```<code>document.getElementById("result").value = res;
</code>```

Body:
I have to create a html page which satisfy below requirement-
1. print 1 to 5 with another array
2. take number input from textbox then print on page whether it is Even or Odd.

I have create a page but it is not working as desired.

        <input type="number" id="myNumber">
        <button onclick="oddOrEven()">Try it</button>
        <input type="text" name="result" id="result" readonly="true"/>

Could someone please help me with the code.

Body:
There is a problem with the way you are assigning res, it should be as follows:

var res = value % 2 == 0 ? "Even" : "Odd";

Alternatively you can use an if statement if you want like so:

var res = "Odd";
if(value % 2 == 0) {
    res = "Even";
}

In addition, there is also an issue with this line:

readonly.value=res;

In this case, readonly does not exist. You probably mean to do this:

document.getElementById("result").value = res;


答:
The problem is statement is:

```<code>$("#button").click(function() {
    $('html, body').animate({
        scrollTop: $("#myDiv").offset().top
    }, 2000);
});
</code>```

Instead of directly writing "scrolltop: $("#mydiv").Offset().top" what you should do is to calculate and store the value of offset().Top in a variable. This variable can be updated with each click event.

Suggested usage:

```<code>$("#button").click(function() {
    var divTop = $("#myDiv").offset().top;
    $('html, body').animate({
        scrollTop: divTop
    }, 2000);
});
</code>```

Body:
The problem is statement is:

$("#button").click(function() {
    $('html, body').animate({
        scrollTop: $("#myDiv").offset().top
    }, 2000);
});

Instead of directly writing "scrolltop: $("#mydiv").Offset().top" what you should do is to calculate and store the value of offset().Top in a variable. This variable can be updated with each click event.

Suggested usage:

$("#button").click(function() {
    var divTop = $("#myDiv").offset().top;
    $('html, body').animate({
        scrollTop: divTop
    }, 2000);
});


问:
Image carousel with circular scroll view
Actually i want to implement the following carousel.The idea is that as long as you spin the circular bar it displays images categorized with different colors.I don't know where to start from .I thought about mixing a circular scroll view with the carousel but i am not sure if it's right. Could you please share ideas or tutorials with me ? i will be grateful to that.

答:
I think the best solution is to create a kind of circular seekbar with a custom style that will be modified on progress changed. You will be able the section you want by checking the progress of the seekbar.

A github project exist to make a circular seekbar :
https://github.com/RaghavSood/AndroidCircularSeekBar


问:
ElasticSearch.net NEST use a Wildcard index in query
Hi I'm new to Elastic Search and I'm making some experiments to understand the basics of query through ElasticSearch.net and NEST.
I'm trying to translate a query with this syntax:

```<code>curl -XGET 'http://myserver.com:9200/myindexes-*/XY/_search/?size=1000&pretty=1' -d '
{
  "query": {
    "bool": {
      "filter": [
        { "match":  { "LOGTYPE" : "XY" }},
        { "match": { "USER" : "mrossi" }},
        { "wildcard": { "DATA": "m.rossi*" }},
        { "match": { "CODE" : "WZ" }},
        { "range": { "timestamp": { "gte": "2015-05-02" }}}
      ]
    }
  }
}
'
</code>```

I've found how to build the multiple field query, (thanks to those who posted it) but I still need to understand how to create the Wildcard index in the query.
The team feeding the Elastic Search engine has created an index in the format MyIndexes-YYYYMMDD with an index per each date because each date has millions of rows of data (they are log files). I haven't yet found a way to make a query on more than one index, if it is so simple as writing the wildcard in the index name or if I need to do something different.
If you have any clue, Thank you in advance.

Edited after some tests on the answer received: I've tried some tests and even if the call to elastic search seems to be successful reading the results I'm not able to understand if I have a problem in my query or if there are no data.

```<code>Valid NEST response built from a successful low level call on POST: /myindex-%2A/ml/_search?pretty=true
# Audit trail of this API call:
 - [1] HealthyResponse: Node: http://username:pwd@mydomain.com:9200/ Took: 00:00:00.0580006
# Request:
{"size":1000,"query":{"bool":{"filter":[{"match":{"LOGTYPE":{"query":"XY"}}}]}}}
# Response:
{
  "took" : 31,
  "timed_out" : false,
  "_shards" : {
    "total" : 270,
    "successful" : 270,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}
</code>```

The above data is what I can see from the DebugInformation of the response. My uncertainty is connected with how the POST command is built, in fact even if my entity is named XY uppercase in the post appears in lowercase, and also the pretty variable has a value of true instead of 1. the size parameter is set inside the request and not as a variable of the POST as in the sample I posted in the first message.
I've simplified the filters to set just one filter and also in the request data I see that in my sample the "XY" filter has a query: instead of nothing as it is in the sample.
so at the moment the query seems to be sintactically correct but I don't know if it is correct on my index data.
can you suggest how to try and use something like select top 100 * from my table just to see if I can find the data, and then try and implement filters???
thank you again

答:
You can use a wildcard in the Index name portion of your query.</p>

```<code>var client = new ElasticClient();

client.Search<MyObject>(s=>s
     .Index("myindexes-*")
     ...
)
</code>```

Body:
Hi I'm new to Elastic Search and I'm making some experiments to understand the basics of query through ElasticSearch.net and NEST.
I'm trying to translate a query with this syntax:

curl -XGET 'http://myserver.com:9200/myindexes-*/XY/_search/?size=1000&pretty=1' -d '
{
  "query": {
    "bool": {
      "filter": [
        { "match":  { "LOGTYPE" : "XY" }},
        { "match": { "USER" : "mrossi" }},
        { "wildcard": { "DATA": "m.rossi*" }},
        { "match": { "CODE" : "WZ" }},
        { "range": { "timestamp": { "gte": "2015-05-02" }}}
      ]
    }
  }
}
'

I've found how to build the multiple field query, (thanks to those who posted it) but I still need to understand how to create the Wildcard index in the query.
The team feeding the Elastic Search engine has created an index in the format MyIndexes-YYYYMMDD with an index per each date because each date has millions of rows of data (they are log files). I haven't yet found a way to make a query on more than one index, if it is so simple as writing the wildcard in the index name or if I need to do something different.
If you have any clue, Thank you in advance.

Edited after some tests on the answer received: I've tried some tests and even if the call to elastic search seems to be successful reading the results I'm not able to understand if I have a problem in my query or if there are no data.

Valid NEST response built from a successful low level call on POST: /myindex-%2A/ml/_search?pretty=true
# Audit trail of this API call:
 - [1] HealthyResponse: Node: http://username:pwd@mydomain.com:9200/ Took: 00:00:00.0580006
# Request:
{"size":1000,"query":{"bool":{"filter":[{"match":{"LOGTYPE":{"query":"XY"}}}]}}}
# Response:
{
  "took" : 31,
  "timed_out" : false,
  "_shards" : {
    "total" : 270,
    "successful" : 270,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}

The above data is what I can see from the DebugInformation of the response. My uncertainty is connected with how the POST command is built, in fact even if my entity is named XY uppercase in the post appears in lowercase, and also the pretty variable has a value of true instead of 1. the size parameter is set inside the request and not as a variable of the POST as in the sample I posted in the first message.
I've simplified the filters to set just one filter and also in the request data I see that in my sample the "XY" filter has a query: instead of nothing as it is in the sample.
so at the moment the query seems to be sintactically correct but I don't know if it is correct on my index data.
can you suggest how to try and use something like select top 100 * from my table just to see if I can find the data, and then try and implement filters???
thank you again

Body:
You can use a wildcard in the Index name portion of your query.

var client = new ElasticClient();

client.Search<MyObject>(s=>s
     .Index("myindexes-*")
     ...
)


问:
Are there any good 3rd party GUI products for Python?
In .Net you have companies like DevEpxress, and Infragistics that offer a range of GUI widgets.  Is there any market like that for Python GUI widgets?  I'm thinking specifically about widgets like the DevExpress xtraGrid Suite.

Edit 01-16-09:  For Example:

http://www.devexpress.com/Downloads/NET/OnlineDemos.xml
http://demos.devexpress.com/ASPxGridViewDemos/

http://www.infragistics.com/products/default.aspx

答:
wxPython is a wrapper around wxWidgets, LGPL (approximately) and very comprehensive

pyQT is a similair wrapper around QT, it's available as GPL or commercial

Although QT is now under the LGPL pyQT is a separate commercial product, it may be that they now release it under the LGPL or a community effort might now produce a LGPL alternative.

Both run on MS/Linux/Mac and are pretty comprehensive, there are excellent communities and books for both.

OwnerDisplayName: mchean

LastEditorDisplayName: mchean

OwnerDisplayName: mgb

LastEditorDisplayName: mgb


问:
c# reading in a text file into datatable
i need to read files that look like this into a datatable:

```<code>A02   BLANK031
B02   F357442
C02   F264977
D02   BLANK037
E02   F272521
F02   E121562
G02   F264972
H02   F332321
A03   E208240
B03   F313854
C03   E229786
D03   E229787
E03   F307584
F03   F357478
</code>```

i have a weird delimitter and some trailing spaces.
how would i read this into a datatable such that the first column will contain 'A02','B02'... and the second column will contain 'BLANK031','F357442',etc..

currently i am doing:

```<code>DataTable dt = new DataTable();
                using (TextReader tr = File.OpenText(batchesAddresses[index]))
                {
                    string line;
                    while ((line = tr.ReadLine()) != null)
                    {

                    string[] items = Regex.Split(line, ' ');
                    if (dt.Columns.Count == 0)
                    {
                        // Create the data columns for the data table based on the number of items
                        // on the first line of the file
                        for (int i = 0; i < items.Length; i++)
                            dt.Columns.Add(new DataColumn("Column" + i, typeof(string)));
                    }
                        dt.Rows.Add(items);

                    }
                }
</code>```

but this is not working because i have trailing spaces and multiple spaces between columns

答:
If you use:

```<code>static readonly char[] space = { ' ' };
...
string[] items = line.Split(space, StringSplitOptions.RemoveEmptyEntries);
</code>```

you should get the 2 values you expect, although something more selective might be desirable, especially if the right-hand-side might contain a space in the middle.

Body:
i need to read files that look like this into a datatable:

A02   BLANK031
B02   F357442
C02   F264977
D02   BLANK037
E02   F272521
F02   E121562
G02   F264972
H02   F332321
A03   E208240
B03   F313854
C03   E229786
D03   E229787
E03   F307584
F03   F357478

i have a weird delimitter and some trailing spaces.
how would i read this into a datatable such that the first column will contain 'A02','B02'... and the second column will contain 'BLANK031','F357442',etc..

currently i am doing:

DataTable dt = new DataTable();
                using (TextReader tr = File.OpenText(batchesAddresses[index]))
                {
                    string line;
                    while ((line = tr.ReadLine()) != null)
                    {

                    string[] items = Regex.Split(line, ' ');
                    if (dt.Columns.Count == 0)
                    {
                        // Create the data columns for the data table based on the number of items
                        // on the first line of the file
                        for (int i = 0; i < items.Length; i++)
                            dt.Columns.Add(new DataColumn("Column" + i, typeof(string)));
                    }
                        dt.Rows.Add(items);

                    }
                }

but this is not working because i have trailing spaces and multiple spaces between columns

Body:
If you use:

static readonly char[] space = { ' ' };
...
string[] items = line.Split(space, StringSplitOptions.RemoveEmptyEntries);

you should get the 2 values you expect, although something more selective might be desirable, especially if the right-hand-side might contain a space in the middle.


问:
swift - how can i check if a specific viewController is the previous viewController
I am trying to detect if my previous viewController is one specific and if it is when i press back it will load the tabBar controller.
I am changing view controllers with revealViewController
here is my code :
here i save the previous view controller:

```<code>let newVC =
self.storyboard?.instantiateViewController(withIdentifier:
storyboardIdentifiers.newViewControllerID) as! newViewController
newVC.previousVC = self
self.revealViewController().setFront(newVC, animated: true)
</code>```

this is my back action where i need to check if previous is the first viewController

```<code>func backAction() {
let first  = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.firstViewControllerID) as! firstViewController
let second = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.secondViewControllerID) as! secondViewController

if previousVC  ==  first || previousVC == second {
            previousVC = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.revealViewControllerID) as! SWRevealViewController
self.revealViewController().setFront(previousVC, animated: true)
}
else {
 self.revealViewController().setFront(previousVC, animated: true)
}
</code>```

but when i press back it doesn't detect that it is from one of these view controllers.

when i print "self" it gives me this result

```<code><MyPackege.firstViewController: 0x7f9e80f2b5a0>
</code>```

but it doesn't load the TabBarController

答:
Instead of using == operator try using  isKind(of: ) method to check the type of viewcontroller

```<code>func backAction() {
let first  = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.firstViewControllerID) as! firstViewController
let second = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.secondViewControllerID) as! secondViewController

if previousVC.isKind(of:firstViewController ) || previousVC.isKind(of:secondViewController ) {
            previousVC = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.revealViewControllerID) as! SWRevealViewController
self.revealViewController().setFront(previousVC, animated: true)
}
else {
 self.revealViewController().setFront(previousVC, animated: true)
}
</code>```

Body:
I am trying to detect if my previous viewController is one specific and if it is when i press back it will load the tabBar controller.
I am changing view controllers with revealViewController
here is my code :
here i save the previous view controller:

let newVC =
self.storyboard?.instantiateViewController(withIdentifier:
storyboardIdentifiers.newViewControllerID) as! newViewController
newVC.previousVC = self
self.revealViewController().setFront(newVC, animated: true)

this is my back action where i need to check if previous is the first viewController

func backAction() {
let first  = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.firstViewControllerID) as! firstViewController
let second = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.secondViewControllerID) as! secondViewController

if previousVC  ==  first || previousVC == second {
            previousVC = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.revealViewControllerID) as! SWRevealViewController
self.revealViewController().setFront(previousVC, animated: true)
}
else {
 self.revealViewController().setFront(previousVC, animated: true)
}

but when i press back it doesn't detect that it is from one of these view controllers.

when i print "self" it gives me this result

<MyPackege.firstViewController: 0x7f9e80f2b5a0>

but it doesn't load the TabBarController

Body:
Instead of using == operator try using  isKind(of: ) method to check the type of viewcontroller

func backAction() {
let first  = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.firstViewControllerID) as! firstViewController
let second = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.secondViewControllerID) as! secondViewController

if previousVC.isKind(of:firstViewController ) || previousVC.isKind(of:secondViewController ) {
            previousVC = self.storyboard?.instantiateViewController(withIdentifier: storyboardIdentifiers.revealViewControllerID) as! SWRevealViewController
self.revealViewController().setFront(previousVC, animated: true)
}
else {
 self.revealViewController().setFront(previousVC, animated: true)
}


问:
Capturing the customers email from Stripe
Perhaps I have this wrong but looking at the documentation I expect the customers email address to be returned as receipt_email, this information is asked for when paying but it is not currently logged in the DB, there is a DB column for it.

Here is the code to create a Charge.

```<code>def do_transaction(self, token, price, amount, address):
    charge  = self.stripe_charge(token, price, amount)
    txid    = coin.sendtoaddress(address, amount)
    ret     = db.insert('transactions', txid=txid, price=price,
                        amount=amount, address=address, ip=df.ctx['ip'],
                        charge_id=charge.id)

    self.stripe_finish(charge)
    return ret

def stripe_charge(self, token, price, amount):
    return stripe.Charge.create(
        amount=int(price * 100), currency='usd', card=token,
        capture=False, description='%f ArtBytes' % amount)
</code>```

The Charge id is accessible with charge.id so I hoped to get the email with email=charge.receipt_email as below but nothing is returned. No destination is set for the charge and it could be that is required for receipt_email to be valid.

```<code>db.insert('transactions', txid=txid, price=price, amount=amount,
address=address, email=charge.receipt_email, ip=df.ctx['ip'], charge_id=charge.id)
</code>```

Can I get the customers email from the charge object or should I get it another way?

API Reference: https://stripe.com/docs/api?lang=python#retrieve_charge

答:
In order for Stripe to send an email receipt, one of the following conditions must be met:

you created the charge with a customer ID in the customer parameter, AND this customer has a valid email address in its email attribute, AND you've checked the "Email customers for successful payments" box in your account settings

you created the charge with a valid email address in the receipt_email parameter

From the code you shared, neither condition is met (your charge creation request parameters do not include either a customer or a receipt_email parameter), so Stripe has no way of knowing the customer's email address and sending a receipt.

Body:
Perhaps I have this wrong but looking at the documentation I expect the customers email address to be returned as receipt_email, this information is asked for when paying but it is not currently logged in the DB, there is a DB column for it.

Here is the code to create a Charge.

def do_transaction(self, token, price, amount, address):
    charge  = self.stripe_charge(token, price, amount)
    txid    = coin.sendtoaddress(address, amount)
    ret     = db.insert('transactions', txid=txid, price=price,
                        amount=amount, address=address, ip=df.ctx['ip'],
                        charge_id=charge.id)

    self.stripe_finish(charge)
    return ret

def stripe_charge(self, token, price, amount):
    return stripe.Charge.create(
        amount=int(price * 100), currency='usd', card=token,
        capture=False, description='%f ArtBytes' % amount)

The Charge id is accessible with charge.id so I hoped to get the email with email=charge.receipt_email as below but nothing is returned. No destination is set for the charge and it could be that is required for receipt_email to be valid.

db.insert('transactions', txid=txid, price=price, amount=amount,
address=address, email=charge.receipt_email, ip=df.ctx['ip'], charge_id=charge.id)

Can I get the customers email from the charge object or should I get it another way?

API Reference: https://stripe.com/docs/api?lang=python#retrieve_charge


问:
What is the file `modules.txt` in Prestashop at the root directory for?
What is the file modules.txt in Prestashop at the root directory for ?

Is it safe to delete it or is it necessary for Prestahop to work ?

答: It's not supposed to be here actually. I have checked on 1.5 to 1.7. You should make a security check. </p>