问:
compile linux kernel on mac os x: clang error
I Wanna compile the linux kernel 2.6 on my mac osx 10.10, so I followed the steps: Linux kernel development and debugging using Eclipse CDT.

But I came across the problem at the step: make menuconfig O=/mnt/build/linux-2.6.
And the error is below, what should I do?

```<code>GEN     /mnt/build/linux-2.6/Makefile
  HOSTLD  scripts/kconfig/mconf
Undefined symbols for architecture x86_64:
  "_COLS", referenced from:
      _dialog_checklist in checklist.o
      _dialog_clear in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_LINES", referenced from:
      _dialog_checklist in checklist.o
      _dialog_clear in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_acs_map", referenced from:
      _dialog_checklist in checklist.o
      _print_arrows in checklist.o
      _dialog_clear in util.o
      _draw_box in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      ...
  "_cbreak", referenced from:
      _reset_dialog in util.o
  "_delwin", referenced from:
      _dialog_checklist in checklist.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_doupdate", referenced from:
      _dialog_checklist in checklist.o
  "_endwin", referenced from:
      _end_dialog in util.o
  "_flash", referenced from:
      _dialog_inputbox in inputbox.o
  "_getcurx", referenced from:
      _print_autowrap in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _print_line in textbox.o
      _print_arrows in menubox.o
  "_getcury", referenced from:
      _print_autowrap in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _print_line in textbox.o
      _print_arrows in menubox.o
  "_getmaxx", referenced from:
      _dialog_checklist in checklist.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_getmaxy", referenced from:
      _dialog_checklist in checklist.o
      _attr_clear in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
      ...
  "_has_colors", referenced from:
      _init_dialog in util.o
      _draw_shadow in util.o
  "_init_pair", referenced from:
      _init_dialog in util.o
  "_initscr", referenced from:
      _reset_dialog in util.o
  "_keypad", referenced from:
      _dialog_checklist in checklist.o
      _reset_dialog in util.o
      _on_key_esc in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
      ...
  "_newwin", referenced from:
      _dialog_checklist in checklist.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_nodelay", referenced from:
      _on_key_esc in util.o
  "_noecho", referenced from:
      _reset_dialog in util.o
  "_scrollok", referenced from:
      _dialog_checklist in checklist.o
      _dialog_textbox in textbox.o
      _dialog_menu in menubox.o
  "_start_color", referenced from:
      _init_dialog in util.o
  "_stdscr", referenced from:
      _dialog_checklist in checklist.o
      _dialog_clear in util.o
      _reset_dialog in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
      ...
  "_subwin", referenced from:
      _dialog_checklist in checklist.o
      _dialog_textbox in textbox.o
      _dialog_menu in menubox.o
  "_ungetch", referenced from:
      _on_key_esc in util.o
  "_waddch", referenced from:
      _dialog_checklist in checklist.o
      _print_item in checklist.o
      _print_arrows in checklist.o
      _attr_clear in util.o
      _dialog_clear in util.o
      _print_title in util.o
      _print_button in util.o
      ...
  "_waddnstr", referenced from:
      _print_item in checklist.o
      _print_arrows in checklist.o
      _dialog_clear in util.o
      _print_title in util.o
      _print_autowrap in util.o
      _print_button in util.o
      _dialog_inputbox in inputbox.o
      ...
  "_wattrset", referenced from:
      _dialog_checklist in checklist.o
      _print_item in checklist.o
      _print_arrows in checklist.o
      _attr_clear in util.o
      _dialog_clear in util.o
      _print_title in util.o
      _print_button in util.o
      ...
  "_wbkgdset", referenced from:
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
      _dialog_menu in menubox.o
  "_wclrtoeol", referenced from:
      _print_line in textbox.o
      _do_print_item in menubox.o
  "_wgetch", referenced from:
      _dialog_checklist in checklist.o
      _on_key_esc in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_winch", referenced from:
      _draw_shadow in util.o
  "_wmove", referenced from:
      _dialog_checklist in checklist.o
      _print_item in checklist.o
      _print_arrows in checklist.o
      _attr_clear in util.o
      _dialog_clear in util.o
      _print_title in util.o
      _print_autowrap in util.o
      ...
  "_wnoutrefresh", referenced from:
      _dialog_checklist in checklist.o
      _dialog_clear in util.o
      _draw_shadow in util.o
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
      _dialog_menu in menubox.o
  "_wprintw", referenced from:
      _print_item in checklist.o
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
  "_wrefresh", referenced from:
      _dialog_checklist in checklist.o
      _print_item in checklist.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
      ...
  "_wscrl", referenced from:
      _dialog_checklist in checklist.o
      _dialog_textbox in textbox.o
      _dialog_menu in menubox.o
  "_wtouchln", referenced from:
      _attr_clear in util.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [scripts/kconfig/mconf] Error 1
make[1]: *** [menuconfig] Error 2
make: *** [sub-make] Error 2
</code>```

答:
To run make menuconfig on OSX, install below packages

```<code>brew install pkg-config ncurses
</code>```

And add below line in your shell path.

```<code>export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig"
</code>```

Body:
I Wanna compile the linux kernel 2.6 on my mac osx 10.10, so I followed the steps: Linux kernel development and debugging using Eclipse CDT.

But I came across the problem at the step: make menuconfig O=/mnt/build/linux-2.6.
And the error is below, what should I do?

GEN     /mnt/build/linux-2.6/Makefile
  HOSTLD  scripts/kconfig/mconf
Undefined symbols for architecture x86_64:
  "_COLS", referenced from:
      _dialog_checklist in checklist.o
      _dialog_clear in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_LINES", referenced from:
      _dialog_checklist in checklist.o
      _dialog_clear in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_acs_map", referenced from:
      _dialog_checklist in checklist.o
      _print_arrows in checklist.o
      _dialog_clear in util.o
      _draw_box in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      ...
  "_cbreak", referenced from:
      _reset_dialog in util.o
  "_delwin", referenced from:
      _dialog_checklist in checklist.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_doupdate", referenced from:
      _dialog_checklist in checklist.o
  "_endwin", referenced from:
      _end_dialog in util.o
  "_flash", referenced from:
      _dialog_inputbox in inputbox.o
  "_getcurx", referenced from:
      _print_autowrap in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _print_line in textbox.o
      _print_arrows in menubox.o
  "_getcury", referenced from:
      _print_autowrap in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _print_line in textbox.o
      _print_arrows in menubox.o
  "_getmaxx", referenced from:
      _dialog_checklist in checklist.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_getmaxy", referenced from:
      _dialog_checklist in checklist.o
      _attr_clear in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
      ...
  "_has_colors", referenced from:
      _init_dialog in util.o
      _draw_shadow in util.o
  "_init_pair", referenced from:
      _init_dialog in util.o
  "_initscr", referenced from:
      _reset_dialog in util.o
  "_keypad", referenced from:
      _dialog_checklist in checklist.o
      _reset_dialog in util.o
      _on_key_esc in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
      ...
  "_newwin", referenced from:
      _dialog_checklist in checklist.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_nodelay", referenced from:
      _on_key_esc in util.o
  "_noecho", referenced from:
      _reset_dialog in util.o
  "_scrollok", referenced from:
      _dialog_checklist in checklist.o
      _dialog_textbox in textbox.o
      _dialog_menu in menubox.o
  "_start_color", referenced from:
      _init_dialog in util.o
  "_stdscr", referenced from:
      _dialog_checklist in checklist.o
      _dialog_clear in util.o
      _reset_dialog in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
      ...
  "_subwin", referenced from:
      _dialog_checklist in checklist.o
      _dialog_textbox in textbox.o
      _dialog_menu in menubox.o
  "_ungetch", referenced from:
      _on_key_esc in util.o
  "_waddch", referenced from:
      _dialog_checklist in checklist.o
      _print_item in checklist.o
      _print_arrows in checklist.o
      _attr_clear in util.o
      _dialog_clear in util.o
      _print_title in util.o
      _print_button in util.o
      ...
  "_waddnstr", referenced from:
      _print_item in checklist.o
      _print_arrows in checklist.o
      _dialog_clear in util.o
      _print_title in util.o
      _print_autowrap in util.o
      _print_button in util.o
      _dialog_inputbox in inputbox.o
      ...
  "_wattrset", referenced from:
      _dialog_checklist in checklist.o
      _print_item in checklist.o
      _print_arrows in checklist.o
      _attr_clear in util.o
      _dialog_clear in util.o
      _print_title in util.o
      _print_button in util.o
      ...
  "_wbkgdset", referenced from:
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
      _dialog_menu in menubox.o
  "_wclrtoeol", referenced from:
      _print_line in textbox.o
      _do_print_item in menubox.o
  "_wgetch", referenced from:
      _dialog_checklist in checklist.o
      _on_key_esc in util.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
  "_winch", referenced from:
      _draw_shadow in util.o
  "_wmove", referenced from:
      _dialog_checklist in checklist.o
      _print_item in checklist.o
      _print_arrows in checklist.o
      _attr_clear in util.o
      _dialog_clear in util.o
      _print_title in util.o
      _print_autowrap in util.o
      ...
  "_wnoutrefresh", referenced from:
      _dialog_checklist in checklist.o
      _dialog_clear in util.o
      _draw_shadow in util.o
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
      _dialog_menu in menubox.o
  "_wprintw", referenced from:
      _print_item in checklist.o
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
  "_wrefresh", referenced from:
      _dialog_checklist in checklist.o
      _print_item in checklist.o
      _dialog_inputbox in inputbox.o
      _dialog_textbox in textbox.o
      _refresh_text_box in textbox.o
      _dialog_yesno in yesno.o
      _dialog_menu in menubox.o
      ...
  "_wscrl", referenced from:
      _dialog_checklist in checklist.o
      _dialog_textbox in textbox.o
      _dialog_menu in menubox.o
  "_wtouchln", referenced from:
      _attr_clear in util.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [scripts/kconfig/mconf] Error 1
make[1]: *** [menuconfig] Error 2
make: *** [sub-make] Error 2

Body:
To run make menuconfig on OSX, install below packages

brew install pkg-config ncurses

And add below line in your shell path.

export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig"


来源: stackexchange

问:
How to manually sort/arrange a Power BI funnel chart?
I have searched all over for an answer to this, including Microsoft's Power BI documentation, but I have not been able to find a solution. I did find a Microsoft document that said "funnel charts can be sorted", but then it did not go on to explain HOW to do that!

My funnel chart is sorting by default from the item with the highest count on top to the item with the lowest count on bottom. That is to be expected from a funnel chart, but we want to sort our chart in a specific order that has to do with the chronology of landing a new customer.

Here is how Power BI sorts our data by default:

Power BI funnel chart in the default sorted order:

However, this puts the items out of chronological order, so we want it sorted as follows to represent the life cycle of a customer from initial lead to a signed contract:

Power BI funnel chart the way we'd like to sort it:

I tried adding numbers in front of our category names to override the sorting (e.g. 1.Prospect, 2.Qualified Lead, 3.Contract Sent, 4.Signed Customer), but that did not work.

Is there a way to manually order the items in a funnel chart? Many thanks for any assistance!

答: A bit of a hack: sometimes you can add the column you want to sort on, in the 'tooltips' field of the visual. This does not change the visual, but you can then (through the three dots on the visual) select that field to order the data on.</p>

ContentLicense: CC BY-SA 4.0


问:
Select all values in 1 view ( can't use procedure and temp tables)
I need to create a View with select in my database. It must be view can't use stored procedure so it needs to be created in just one query without temp tales.

I create a simple example:

```<code>CREATE TABLE #TemporaryTable          -- Local temporary table - starts with single #
(
    id int,
    date_order date,
    order_status varchar(50)
);

insert into #TemporaryTable
VALUES
('1','2022-01-01','Completed'),
('2','2022-01-01','Cancelled'),
('3','2022-01-01','Completed'),
('4','2022-01-01','Completed'),
('5','2022-01-02','Cancelled'),
('6','2022-01-02','Cancelled'),
('7','2022-01-02','Completed'),
('8','2022-01-02','Completed'),
('9','2022-01-02','Completed'),
('10','2022-01-03','Cancelled'),
('11','2022-01-04','Completed')

select * from #TemporaryTable

SELECT COUNT(crm1.date_order) AS [count_all_orders], crm1.date_order AS [date_order],COUNT(crm2.date_order) AS [[count_cancelled_orders]
FROM            #TemporaryTable crm1 WITH (nolock)
left outer join #TemporaryTable crm2 WITH (nolock) on crm2.id = crm1.id and crm2.order_status ='Cancelled'
GROUP BY crm1.date_order,crm2.date_order
</code>```

SQL fiddle

The endpoint is to have 1 date and count all orders + count cancelled orders.

Now the date is doubled and giving bad values. Please check that in SQL fiddle and help me.
Thank you!

答:
There is no need to join, you can simply use conditional aggregation:

COUNT(someNonNullValue) and COUNT(*) are the same thing

SELECT
  COUNT(*) AS count_all_orders,
  crm1.date_order,
  COUNT(CASE WHEN crm2.order_status = 'Cancelled' THEN 1 END) AS count_cancelled_orders
FROM #TemporaryTable crm
GROUP BY
  crm.date_order;
```

NOLOCK is a very bad idea. Only use it in exceptional circumstances.

Body:
I need to create a View with select in my database. It must be view can't use stored procedure so it needs to be created in just one query without temp tales.

I create a simple example:

CREATE TABLE #TemporaryTable          -- Local temporary table - starts with single #
(
    id int,
    date_order date,
    order_status varchar(50)
);

insert into #TemporaryTable
VALUES
('1','2022-01-01','Completed'),
('2','2022-01-01','Cancelled'),
('3','2022-01-01','Completed'),
('4','2022-01-01','Completed'),
('5','2022-01-02','Cancelled'),
('6','2022-01-02','Cancelled'),
('7','2022-01-02','Completed'),
('8','2022-01-02','Completed'),
('9','2022-01-02','Completed'),
('10','2022-01-03','Cancelled'),
('11','2022-01-04','Completed')

select * from #TemporaryTable

SELECT COUNT(crm1.date_order) AS [count_all_orders], crm1.date_order AS [date_order],COUNT(crm2.date_order) AS [[count_cancelled_orders]
FROM            #TemporaryTable crm1 WITH (nolock)
left outer join #TemporaryTable crm2 WITH (nolock) on crm2.id = crm1.id and crm2.order_status ='Cancelled'
GROUP BY crm1.date_order,crm2.date_order

SQL fiddle

The endpoint is to have 1 date and count all orders + count cancelled orders.

Now the date is doubled and giving bad values. Please check that in SQL fiddle and help me.
Thank you!

Body:
There is no need to join, you can simply use conditional aggregation:

COUNT(someNonNullValue) and COUNT(*) are the same thing

SELECT
  COUNT(*) AS count_all_orders,
  crm1.date_order,
  COUNT(CASE WHEN crm2.order_status = 'Cancelled' THEN 1 END) AS count_cancelled_orders
FROM #TemporaryTable crm
GROUP BY
  crm.date_order;

NOLOCK is a very bad idea. Only use it in exceptional circumstances.


问:
Warning after upgrading Android Gradle Plugin to 7.1.1
After upgrading  Android Gradle Plugin from 7.0.3 to 7.1.1, while building my project I get the following warning:

```<code>> Task :app:hiltAggregateDepsDebug
WARNING: [Processor] Library '/home/XXXX/.gradle/caches/transforms-3/XXXXXXX/transformed/core-1.7.0-api.jar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
 Example of androidX reference: 'androidx/core/R$styleable'
 Example of support library reference: 'android/support/v4/app/INotificationSideChannel$Default'
[Processor] Library '/home/XXXXX/.gradle/caches/transforms-3/XXXXXXX/transformed/core-1.7.0-api.jar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
</code>```

Project info - Android Kotlin w/ Jetpack compose:

```<code>kotlin_version = '1.5.31'
compose_version = '1.0.5'
hilt_version = '2.40.5'
classpath 'com.android.tools.build:gradle:7.1.1'
</code>```

I am using Android Studio Bumblebee | 2021.1.1 Patch 1.

Why is this warning happening? How can I fix this?

答:
In all likelihood, your Compose and Kotlin versions are out of date. Try using these settings in your project's gradle.build:

```<code>buildscript {
    ext {
        compose_version = '1.1.0-rc01'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.1'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0'
    }
}
</code>```

You should also update your app's build.gradle file (and those in other modules) to have something like this:

```<code>plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 31
    buildToolsVersion "31.0.0"

    defaultConfig {
        applicationId "dev.wirespec.topdog"
        minSdkVersion 21
        targetSdkVersion 31
        versionName "1.0.0"

    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion '1.6.0'
    }
}
</code>```

While this uses Java 11, you can still stick with Java 8 if you have to.

Finally, you should update the latest version of the Kotlin plugin which is version 211-1.6.10-release-923-AS7442.40

Android Studio > Preferences > Languages & Frameworks > Kotlin

Body:
After upgrading  Android Gradle Plugin from 7.0.3 to 7.1.1, while building my project I get the following warning:

> Task :app:hiltAggregateDepsDebug
WARNING: [Processor] Library '/home/XXXX/.gradle/caches/transforms-3/XXXXXXX/transformed/core-1.7.0-api.jar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
 Example of androidX reference: 'androidx/core/R$styleable'
 Example of support library reference: 'android/support/v4/app/INotificationSideChannel$Default'
[Processor] Library '/home/XXXXX/.gradle/caches/transforms-3/XXXXXXX/transformed/core-1.7.0-api.jar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.

Project info - Android Kotlin w/ Jetpack compose:

kotlin_version = '1.5.31'
compose_version = '1.0.5'
hilt_version = '2.40.5'
classpath 'com.android.tools.build:gradle:7.1.1'

I am using Android Studio Bumblebee | 2021.1.1 Patch 1.

Why is this warning happening? How can I fix this?

Body:
In all likelihood, your Compose and Kotlin versions are out of date. Try using these settings in your project's gradle.build:

buildscript {
    ext {
        compose_version = '1.1.0-rc01'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.1'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0'
    }
}

You should also update your app's build.gradle file (and those in other modules) to have something like this:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 31
    buildToolsVersion "31.0.0"

    defaultConfig {
        applicationId "dev.wirespec.topdog"
        minSdkVersion 21
        targetSdkVersion 31
        versionName "1.0.0"

    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
        kotlinCompilerVersion '1.6.0'
    }
}

While this uses Java 11, you can still stick with Java 8 if you have to.

Finally, you should update the latest version of the Kotlin plugin which is version 211-1.6.10-release-923-AS7442.40

Android Studio > Preferences > Languages & Frameworks > Kotlin


问:
Different types of mobile Ads network
Can anyone tell me what are the different types of Ads Network available for mobile apps..
I know about AdMob and Adwhrill...But other than these two what are the other types of ads network present and which one is the best.for business prospective

with regards
Anshuman

答:
Well for this, i just got list of all Ads Network : http://www.gomonews.com/mads/

You can download a list of all info from http://www.gomonews.com/wp-content/uploads/2008/11/mobileadvertisinglist062010.pdf

ContentLicense: CC BY-SA 3.0

Title: Different types of mobile Ads network


问:
Echo newline to powershell console
Is it possible to write a newline to the console in powershell?

I tried echo "\n" but it is not translated to a new line, it just outputs \n.

答:
```<code>echo "Test `nNewLine"
</code>```

or

```<code>echo "Test " "NewLine"
</code>```

Title: Echo newline to powershell console

Body:
echo "Test `nNewLine"

or

echo "Test " "NewLine"


问:
Update Entity Property if Not Null Using Expressions
I've been trying to make a generic function that will check if a value is null, otherwise it'll set the property on the entity to that value. Seems simple, thought I had it, but got a bit of a problem when the Type of the Property is not nullable (int) but the type of the value is obviously nullable (int?). Strings work fine, as they are nullable anyway.

Example:

```<code>UpdateEntityPropertyIfNotNull(entity, entity => entity.Id, request.Id);
</code>```

So here, the entity Id is of type int but the request Id value is of type int? => generic function ends up just thinking they are both int?

This is my attempt at making the generic function:

```<code>private void UpdateEntityPropertyIfNotNull<T, TProperty>(T entity, Expression<Func<T, TProperty>> propertyFunc, TProperty valueToSet)
{
    if (valueToSet == null)
    {
        return;
    }

    //if (propertyFunc.Body.NodeType != ExpressionType.MemberAccess)
    //{
    //    throw new ArgumentException("This should be a member getter", nameof(propertyFunc));
    //}

    MemberExpression? member;
    switch (propertyFunc.Body.NodeType)
    {
        case ExpressionType.Convert:
        case ExpressionType.ConvertChecked:
            var unary = propertyFunc.Body as UnaryExpression;
            member = (unary?.Operand) as MemberExpression;
            break;
        default:
            member = propertyFunc.Body as MemberExpression;
            break;
    }

    var underlyingType = Nullable.GetUnderlyingType(typeof(TProperty)) ?? typeof(TProperty);
    var model = propertyFunc.Parameters[0];
    var value = Expression.Variable(underlyingType, nameof(model));
    var assignment = Expression.Assign(member, value);
    var lambdaExpression = Expression.Lambda<Action<T, TProperty>>(assignment, model, value).Compile();
    lambdaExpression(entity, valueToSet);
}
</code>```

Any advice would be great, I hate the idea of having to do the conditional checks manually...

答:
You need to group your constraints together, essentially creating a nullable value type constraint, and an other:

private void UpdateEntityPropertyIfNotNull<T, TProperty>(T entity, Expression<Func<T, TProperty>> propertyFunc, TProperty valueToSet)
{
    if (!typeof(TProperty).IsValueType && valueToSet is null)
    {
        return;
    }

    UpdateEntityProperty(entity, propertyFunc, valueToSet);
}

private void UpdateEntityPropertyIfNotNull<T, TProperty>(T entity, Expression<Func<T, TProperty>> propertyFunc, TProperty? valueToSet)
    where TProperty : struct
{
    if (!valueToSet.HasValue)
    {
        return;
    }

    UpdateEntityProperty(entity, propertyFunc, valueToSet.Value);
}

private void UpdateEntityPropertyIfNotNull<T, TProperty>(T entity, Expression<Func<T, TProperty?>> propertyFunc, TProperty? valueToSet)
    where TProperty : struct
{
    if (!valueToSet.HasValue)
    {
        return;
    }

    UpdateEntityProperty(entity, propertyFunc, valueToSet.Value);
}

private void UpdateEntityProperty<T, TProperty>(T entity, Expression<Func<T, TProperty>> propertyFunc, TProperty valueToSet)
{
    // snip
}
```
<p>You get compile-time validity that your parameters are correctly handled, and it encompasses reference-types, value-types, and nullable value-types.</p>
<p>The last change is to update <code>UpdateEntityProperty<T, TProperty>()</code> to either</p>
<pre class="lang-cs prettyprint-override"><code>var underlyingType = Nullable.GetUnderlyingType(typeof(TProperty)) ?? typeof(TProperty);
</code>```

to

var underlyingType = typeof(TProperty);
```
<p>or remove it and just use <code>typeof()</code> directly:</p>
<pre class="lang-cs prettyprint-override"><code>var value = Expression.Variable(typeof(TProperty), nameof(model));
</code>```

Body:
I've been trying to make a generic function that will check if a value is null, otherwise it'll set the property on the entity to that value. Seems simple, thought I had it, but got a bit of a problem when the Type of the Property is not nullable (int) but the type of the value is obviously nullable (int?). Strings work fine, as they are nullable anyway.

Example:

UpdateEntityPropertyIfNotNull(entity, entity => entity.Id, request.Id);

So here, the entity Id is of type int but the request Id value is of type int? => generic function ends up just thinking they are both int?

This is my attempt at making the generic function:

private void UpdateEntityPropertyIfNotNull<T, TProperty>(T entity, Expression<Func<T, TProperty>> propertyFunc, TProperty valueToSet)
{
    if (valueToSet == null)
    {
        return;
    }

    //if (propertyFunc.Body.NodeType != ExpressionType.MemberAccess)
    //{
    //    throw new ArgumentException("This should be a member getter", nameof(propertyFunc));
    //}

    MemberExpression? member;
    switch (propertyFunc.Body.NodeType)
    {
        case ExpressionType.Convert:
        case ExpressionType.ConvertChecked:
            var unary = propertyFunc.Body as UnaryExpression;
            member = (unary?.Operand) as MemberExpression;
            break;
        default:
            member = propertyFunc.Body as MemberExpression;
            break;
    }

    var underlyingType = Nullable.GetUnderlyingType(typeof(TProperty)) ?? typeof(TProperty);
    var model = propertyFunc.Parameters[0];
    var value = Expression.Variable(underlyingType, nameof(model));
    var assignment = Expression.Assign(member, value);
    var lambdaExpression = Expression.Lambda<Action<T, TProperty>>(assignment, model, value).Compile();
    lambdaExpression(entity, valueToSet);
}

Any advice would be great, I hate the idea of having to do the conditional checks manually...

Body:
You need to group your constraints together, essentially creating a nullable value type constraint, and an other:

private void UpdateEntityPropertyIfNotNull<T, TProperty>(T entity, Expression<Func<T, TProperty>> propertyFunc, TProperty valueToSet)
{
    if (!typeof(TProperty).IsValueType && valueToSet is null)
    {
        return;
    }

    UpdateEntityProperty(entity, propertyFunc, valueToSet);
}

private void UpdateEntityPropertyIfNotNull<T, TProperty>(T entity, Expression<Func<T, TProperty>> propertyFunc, TProperty? valueToSet)
    where TProperty : struct
{
    if (!valueToSet.HasValue)
    {
        return;
    }

    UpdateEntityProperty(entity, propertyFunc, valueToSet.Value);
}

private void UpdateEntityPropertyIfNotNull<T, TProperty>(T entity, Expression<Func<T, TProperty?>> propertyFunc, TProperty? valueToSet)
    where TProperty : struct
{
    if (!valueToSet.HasValue)
    {
        return;
    }

    UpdateEntityProperty(entity, propertyFunc, valueToSet.Value);
}

private void UpdateEntityProperty<T, TProperty>(T entity, Expression<Func<T, TProperty>> propertyFunc, TProperty valueToSet)
{
    // snip
}

You get compile-time validity that your parameters are correctly handled, and it encompasses reference-types, value-types, and nullable value-types.

The last change is to update UpdateEntityProperty<T, TProperty>() to either

var underlyingType = Nullable.GetUnderlyingType(typeof(TProperty)) ?? typeof(TProperty);

to

var underlyingType = typeof(TProperty);

or remove it and just use typeof() directly:

var value = Expression.Variable(typeof(TProperty), nameof(model));


问:
Service Fabric Application Deployment Timeouts
We recently upgraded our development Service Fabric cluster from version 7.1 to the latest and greatest version (8.2) and now a number of our microservice applications are failing to deploy.  They are failing during 'Deploy Service Fabric Application' step in Azure DevOps at the point at which the PowerShell script is attempting to create the application with an error of 'System.TimeoutException'.  By this point, the script has successfully copied the application to the image store and registered it with Service Fabric.

The 'Publish-NewServiceFabricApplication.ps1' PowerShell script operates with a two minute timeout by default and I have tried increasing the timeout by supplying a higher value via the -TimeoutSec parameter but it seems to simply ignore this.  When I try to deploy the applications manually (using the New-ServiceFabricApplication PowerShell cmdlet) the deployment succeeds but it takes just over three minutes.

Has anyone come across this, is it a known issue?

答:
In the end I ended up 'hacking' the 'Utilities.ps1' file (which is supplied with the Microsoft Azure Service Fabric SDK) in order to get it to respect the increased timeout values that I was supplying.  But I intend to raise this issue with MS because it appears to be a bug.

Here's the relevant function New-ServiceFabricApplicationAction (line 741 of the Utilities.ps1 file) with my change included (asterisks added for emphasis):

```<code>function New-ServiceFabricApplicationAction
{
    Param (
        [string]
        $ApplicationName,

        [string]
        $ApplicationTypeName,

        [string]
        $ApplicationTypeVersion,

        [hashtable]
        $ApplicationParameter
    )

    $global:operationId = $SF_Operations.CreateNewApplication
    $createAction = {
        New-ServiceFabricApplication -ApplicationName
        $ApplicationName -ApplicationTypeName
        $ApplicationTypeName -ApplicationTypeVersion $ApplicationTypeVersion
        ***-TimeoutSec 600*** -ApplicationParameter $ApplicationParameter
    }
    $exceptionRetryEvaluator = {
        param($ex)

        # If app already created, don't retry
        if ($ex.GetType().FullName -eq "System.Fabric.FabricElementAlreadyExistsException")
        {
            return $false
        }
        return $true
    }

    try
    {
        Invoke-ActionWithDefaultRetries -Action $createAction `
            -RetryMessage (Get-VstsLocString -Key SFSDK_RetryingCreateApplication) `
            -ExceptionRetryEvaluator $exceptionRetryEvaluator `
            -RetryableExceptions @("System.Fabric.FabricTransientException", "System.Fabric.FabricElementAlreadyExistsException", "System.TimeoutException")
    }
    catch [System.TimeoutException]
    {
        Write-Host (Get-VstsLocString -Key SFSDK_CreateApplicationFailed)
        # print application health status if create did not succeed
        Trace-ServiceFabricApplicationHealth -ApplicationName $ApplicationName
        throw
    }
}
</code>```

Body:
In the end I ended up 'hacking' the 'Utilities.ps1' file (which is supplied with the Microsoft Azure Service Fabric SDK) in order to get it to respect the increased timeout values that I was supplying.  But I intend to raise this issue with MS because it appears to be a bug.

Here's the relevant function New-ServiceFabricApplicationAction (line 741 of the Utilities.ps1 file) with my change included (asterisks added for emphasis):

function New-ServiceFabricApplicationAction
{
    Param (
        [string]
        $ApplicationName,

        [string]
        $ApplicationTypeName,

        [string]
        $ApplicationTypeVersion,

        [hashtable]
        $ApplicationParameter
    )

    $global:operationId = $SF_Operations.CreateNewApplication
    $createAction = {
        New-ServiceFabricApplication -ApplicationName
        $ApplicationName -ApplicationTypeName
        $ApplicationTypeName -ApplicationTypeVersion $ApplicationTypeVersion
        ***-TimeoutSec 600*** -ApplicationParameter $ApplicationParameter
    }
    $exceptionRetryEvaluator = {
        param($ex)

        # If app already created, don't retry
        if ($ex.GetType().FullName -eq "System.Fabric.FabricElementAlreadyExistsException")
        {
            return $false
        }
        return $true
    }

    try
    {
        Invoke-ActionWithDefaultRetries -Action $createAction `
            -RetryMessage (Get-VstsLocString -Key SFSDK_RetryingCreateApplication) `
            -ExceptionRetryEvaluator $exceptionRetryEvaluator `
            -RetryableExceptions @("System.Fabric.FabricTransientException", "System.Fabric.FabricElementAlreadyExistsException", "System.TimeoutException")
    }
    catch [System.TimeoutException]
    {
        Write-Host (Get-VstsLocString -Key SFSDK_CreateApplicationFailed)
        # print application health status if create did not succeed
        Trace-ServiceFabricApplicationHealth -ApplicationName $ApplicationName
        throw
    }
}


问:
Getting original date time from EXIF
I'm trying to get the date of creation of a picture with this code :

```<code>private void GetEXIFDate()
        {
            var directories = ImageMetadataReader.ReadMetadata(@"\\s2.rpn.ch\home\CPLN\Eleves\ET\CamiloDLe\My Pictures\Temp.jpg");
            var subIfdDirectory = directories.OfType<ExifSubIfdDirectory>().FirstOrDefault();
            var dateTime = subIfdDirectory?.GetDateTime(ExifDirectoryBase.TagDateTime);
            MessageBox.Show(dateTime.ToString());
        }
</code>```

The MessageBox shows null and when i try to see the EXIF from windows i can see the modifiedDate and the date of creation.

I'm using .net 5.0 and MetadataExtractor to make this

Edit :
I was searching the wrong informations, I'd have the same informations that windows give, I want the EXIF informations instead.

答:
Using FileMetadataDirectory instead of ExifSubIfdDirectory

Using random jpg from output-onlinejpgtools.jpg

```<code>using MetadataExtractor;
using MetadataExtractor.Formats.Exif;
using MetadataExtractor.Formats.FileSystem;
using MetadataExtractor.Formats.FileType;

var directories = ImageMetadataReader.ReadMetadata(@"C:\Users\username\Pictures\output-onlinejpgtools.jpg");
var metadataDirectory = directories.OfType<FileMetadataDirectory>().FirstOrDefault();
Console.WriteLine(metadataDirectory.GetDateTime(3));
</code>```

Title: Getting original date time from EXIF

Body:
I'm trying to get the date of creation of a picture with this code :

private void GetEXIFDate()
        {
            var directories = ImageMetadataReader.ReadMetadata(@"\\s2.rpn.ch\home\CPLN\Eleves\ET\CamiloDLe\My Pictures\Temp.jpg");
            var subIfdDirectory = directories.OfType<ExifSubIfdDirectory>().FirstOrDefault();
            var dateTime = subIfdDirectory?.GetDateTime(ExifDirectoryBase.TagDateTime);
            MessageBox.Show(dateTime.ToString());
        }

The MessageBox shows null and when i try to see the EXIF from windows i can see the modifiedDate and the date of creation.

I'm using .net 5.0 and MetadataExtractor to make this

Edit :
I was searching the wrong informations, I'd have the same informations that windows give, I want the EXIF informations instead.

Body:
Using FileMetadataDirectory instead of ExifSubIfdDirectory

Using random jpg from output-onlinejpgtools.jpg

using MetadataExtractor;
using MetadataExtractor.Formats.Exif;
using MetadataExtractor.Formats.FileSystem;
using MetadataExtractor.Formats.FileType;

var directories = ImageMetadataReader.ReadMetadata(@"C:\Users\username\Pictures\output-onlinejpgtools.jpg");
var metadataDirectory = directories.OfType<FileMetadataDirectory>().FirstOrDefault();
Console.WriteLine(metadataDirectory.GetDateTime(3));


问:
How to convert the date set from DD:MM:YY HH::MM to morning, afternoon, evening, night in quicksights?
Hi i column in quick sights in the following format:
21/01/2022 9AM
27/01/2022 8pm
4/02/2022 2PM
and so on.
I want to change them morning, afternoon and night in amazon quicksights. I tried everything that is available in internet but nothing worked for me. As there is HOUR function in quicksight.</p>

答:
You could use the extract('HH', {date}) function to extract the hour portion from your date field. https://docs.aws.amazon.com/quicksight/latest/user/extract-function.html
Then you can use an ifelse() logic to classify the time into day periods.

Example, if your field is called {date}, then you could try something like this:

```<code>ifelse(
  extract('HH', {date}) < 6, 'NIGHT',
  extract('HH', {date}) < 12, 'MORNING',
  extract('HH', {date}) < 17, 'ATERNOON',
  extract('HH', {date}) < 20, 'EVENING',
  'NIGHT'
)
</code>```

Body:
You could use the extract('HH', {date}) function to extract the hour portion from your date field. https://docs.aws.amazon.com/quicksight/latest/user/extract-function.html
Then you can use an ifelse() logic to classify the time into day periods.

Example, if your field is called {date}, then you could try something like this:

ifelse(
  extract('HH', {date}) < 6, 'NIGHT',
  extract('HH', {date}) < 12, 'MORNING',
  extract('HH', {date}) < 17, 'ATERNOON',
  extract('HH', {date}) < 20, 'EVENING',
  'NIGHT'
)


问:
Why my form is not visible when I am adding if-else block in my code?
Why my form is not visible after filling submit button  and when I am removing these line of codes form is visible:

```<code> if (data.trim() === 'Done') {
     $("#msg").html("Succesfully Registered !!!");
     $("#msg").addClass("green-text");
 } else  {
     $("#msg").html("Something went wrong !!!");
     $("#msg").addClass("red-text");}
</code>```

I cross-checked it many times but it is not working please help

```<code>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <!-- Compiled and minified CSS -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

        <!-- Compiled and minified JavaScript -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

    </head>
    <body style="background-image: url(images/bg.jpg); background-size: cover;background-attachment: fixed;">
        <div class="container">
            <div class="row">
                <div class="col m6 offset-m3">

                    <div class="card">
                         <div class="card-content">
                             <div class="form center-align">
                                 <h3 style="margin-top: 10px;"class="center-align">Register Here !!</h3>
                                 <h5 id="msg" class="center-align"</h5>
                                <div class="form">
                                <!-- creating form -->
                                <form action="Register" method="post" id="myform">
                                    <input type="text" name="user_name" placeholder="Enter user_name"\>
                                    <input type="password" name="user_password" placeholder="Enter password"\>
                                    <input type="email" name="user_email" placeholder="Enter your email"\>

                                    <button type="submit" name="btn" style="background-color:#b3e5fc;">Submit</button>

                                </form>

                            </div>
                    </div>
                             <div class="loader center-align" style="margin-top: 10px; display: none;" >
                                        <div class="preloader-wrapper big active">
                                            <div class="spinner-layer spinner-blue-only">
                                              <div class="circle-clipper left">
                                                <div class="circle"></div>
                                              </div><div class="gap-patch">
                                                <div class="circle"></div>
                                              </div><div class="circle-clipper right">
                                                <div class="circle"></div>
                                              </div>
                                            </div>

                                    <h5>Please Wait....</h5>
                                </div>
                </div>
            </div>
        </div>
      </div>
    </div>
        <script
            src="https://code.jquery.com/jquery-3.6.0.min.js"
            integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
            crossorigin="anonymous">

        </script>
        <script>
                $(document).ready(function(){
                console.log("Page is ready...... ") ;
                $("#myform").on('submit',function(event){
                event.preventDefault();
                var f = $(this).serialize();
                console.log(f);
                $(".loader").show();
                $(".form").hide();

                    $.ajax({
                       url:"Register",
                       data:f,
                       type:'POST',
                       success:function(data,textStatus,jqXHR){
                           console.log(data);
                           console.log("Success......");
                           $(".loader").hide();
                           $(".form").show();
                           if (data.trim() === 'Done')
                           {
                            $("#msg").html("Succesfully Registered !!!");
                            $("#msg").addClass("green-text");
                          }
                          else
                          {
                            $("#msg").html("Something went wrong !!!");
                            $("#msg").addClass("red-text");
                          }

                       },
                       error:function(jqXHR,textStatus,errorThrown){
                           console.log(data);
                           console.log("error");
                           $(".loader").hide();
                           $(".form").show();
                           $("#msg").html("Something went wrong !!!");
                           $("#msg").addClass("red-text");
                       }
                   });
                });
                });

        </script>
    </body>
</html>
</code>```

答:
Try this :</p>
```<code><!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    <!-- Compiled and minified CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

    <!-- Compiled and minified JavaScript -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

</head>
<body style="background-image: url(images/bg.jpg); background-size: cover;background-attachment: fixed;">
<div class="container">
    <div class="row">
        <div class="col m6 offset-m3">
            <div class="card">
                <div class="card-content">
                    <div class="form center-align">
                        <h3 style="margin-top: 10px;" class="center-align">Register Here !!</h3>
                        <h5 id="msg" class="center-align"></h5>
                        <div class="form">
                            <!-- creating form -->
                            <form action="Register" method="post" id="myform">
                                <input type="text" name="user_name" placeholder="Enter user_name" />
                                <input type="password" name="user_password" placeholder="Enter password" />
                                <input type="email" name="user_email" placeholder="Enter your email" />

                                <button type="submit" name="btn" style="background-color:#b3e5fc;">Submit</button>
                            </form>
                        </div>
                    </div>
                    <div class="loader center-align" style="margin-top: 10px; display: none;">
                        <div class="preloader-wrapper big active">
                            <div class="spinner-layer spinner-blue-only">
                                <div class="circle-clipper left">
                                    <div class="circle"></div>
                                </div>
                                <div class="gap-patch">
                                    <div class="circle"></div>
                                </div>
                                <div class="circle-clipper right">
                                    <div class="circle"></div>
                                </div>
                            </div>

                            <h5>Please Wait....</h5>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script
        src="https://code.jquery.com/jquery-3.6.0.min.js"
        integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
        crossorigin="anonymous">

</script>
<script>
  $(document).ready(function () {
    console.log('Page is ready...... ');
    $('#myform').on('submit', function (event) {
      event.preventDefault();
      var f = $(this).serialize();
      console.log(f);
      $('.loader').show();
      $('.form').hide();

      $.ajax({
        url: 'Register',
        data: f,
        type: 'POST',
        success: function (data, textStatus, jqXHR) {
          console.log(data);
          console.log('Success......');
          $('.loader').hide();
          $('.form').show();
          if (data.trim() === 'Done') {
            $('#msg').html('Succesfully Registered !!!');
            $('#msg').addClass('green-text');
          } else {
            $('#msg').html('Something went wrong !!!');
            $('#msg').addClass('red-text');
          }

        },
        error: function (jqXHR, textStatus, errorThrown) {
          console.log(data);
          console.log('error');
          $('.loader').hide();
          $('.form').show();
          $('#msg').html('Something went wrong !!!');
          $('#msg').addClass('red-text');
        }
      });
    });
  });

</script>
</body>
</html>

</code>```

Body:
Why my form is not visible after filling submit button  and when I am removing these line of codes form is visible:

 if (data.trim() === 'Done') {
     $("#msg").html("Succesfully Registered !!!");
     $("#msg").addClass("green-text");
 } else  {
     $("#msg").html("Something went wrong !!!");
     $("#msg").addClass("red-text");}

I cross-checked it many times but it is not working please help

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>

        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

Register Here !!

                                 <h5 id="msg" class="center-align"

                                <form action="Register" method="post" id="myform">
                                    <input type="text" name="user_name" placeholder="Enter user_name"\>
                                    <input type="password" name="user_password" placeholder="Enter password"\>
                                    <input type="email" name="user_email" placeholder="Enter your email"\>

                                    <button type="submit" name="btn" style="background-color:#b3e5fc;">Submit</button>

                                </form>

Please Wait....

Body:
Try this :

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    <!-- Compiled and minified CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

    <!-- Compiled and minified JavaScript -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

</head>
<body style="background-image: url(images/bg.jpg); background-size: cover;background-attachment: fixed;">
<div class="container">
    <div class="row">
        <div class="col m6 offset-m3">
            <div class="card">
                <div class="card-content">
                    <div class="form center-align">
                        <h3 style="margin-top: 10px;" class="center-align">Register Here !!</h3>
                        <h5 id="msg" class="center-align"></h5>
                        <div class="form">
                            <!-- creating form -->
                            <form action="Register" method="post" id="myform">
                                <input type="text" name="user_name" placeholder="Enter user_name" />
                                <input type="password" name="user_password" placeholder="Enter password" />
                                <input type="email" name="user_email" placeholder="Enter your email" />

                                <button type="submit" name="btn" style="background-color:#b3e5fc;">Submit</button>
                            </form>
                        </div>
                    </div>
                    <div class="loader center-align" style="margin-top: 10px; display: none;">
                        <div class="preloader-wrapper big active">
                            <div class="spinner-layer spinner-blue-only">
                                <div class="circle-clipper left">
                                    <div class="circle"></div>
                                </div>
                                <div class="gap-patch">
                                    <div class="circle"></div>
                                </div>
                                <div class="circle-clipper right">
                                    <div class="circle"></div>
                                </div>
                            </div>

                            <h5>Please Wait....</h5>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script
        src="https://code.jquery.com/jquery-3.6.0.min.js"
        integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
        crossorigin="anonymous">

</script>
<script>
  $(document).ready(function () {
    console.log('Page is ready...... ');
    $('#myform').on('submit', function (event) {
      event.preventDefault();
      var f = $(this).serialize();
      console.log(f);
      $('.loader').show();
      $('.form').hide();

      $.ajax({
        url: 'Register',
        data: f,
        type: 'POST',
        success: function (data, textStatus, jqXHR) {
          console.log(data);
          console.log('Success......');
          $('.loader').hide();
          $('.form').show();
          if (data.trim() === 'Done') {
            $('#msg').html('Succesfully Registered !!!');
            $('#msg').addClass('green-text');
          } else {
            $('#msg').html('Something went wrong !!!');
            $('#msg').addClass('red-text');
          }

        },
        error: function (jqXHR, textStatus, errorThrown) {
          console.log(data);
          console.log('error');
          $('.loader').hide();
          $('.form').show();
          $('#msg').html('Something went wrong !!!');
          $('#msg').addClass('red-text');
        }
      });
    });
  });

</script>
</body>
</html>


问:
Spring Integration: Split message again after using aggregate?
In my Spring Integration powered project I have a splitter and payload-router for sending my data to various transformers. The new "transformed" objects are then passed back to an aggregator and processed.

Now I want to split up my aggregated results so they are persisted properly, since I need to route some of the objects to a seperate outbound-channel-adapter. To achieve this, I added a second splitter after my aggregator; but it seems only the first element in the aggregated collection is passed to the router.

This is my current flow:

```<code><splitter ref="articleContentExtractor" />

<!-- This router works exactly as expected -->
<payload-type-router>
    ... routing to various transformers ...
    ... results are sent to articleOutAggregateChannel ...
</payload-type-router>

<aggregator ref="articleAggregator" />

<splitter />

<!-- This is where it seems to go wrong, the second
        splitter returns only the first object in the collection -->
<payload-type-router resolution-required="true">
    <mapping type="x.y.z.AbstractContent" channel="contentOutChannel" />
    <mapping type="x.y.z.Staff" channel="staffOutChannel" />
</payload-type-router>

<outbound-channel-adapter id="contentSaveService" ref="contentExporter"
    method="persist" channel="contentOutChannel" />

<outbound-channel-adapter id="staffSaveService" ref="staffExporter"
    method="persist" channel="staffOutChannel" />
</code>```

And my Aggregator code:

```<code>@Aggregator
public List<? super BaseObject> compileArticle(List<? super BaseObject> parts) {

    // Search for the required objects for referencing
    Iterator<? super BaseObject> it = parts.iterator();
    Article article = null;
    List<Staff> authors = new ArrayList<Staff>();

    while (it.hasNext()) {
        Object part = it.next();
        if (part instanceof Article) {
            article = (Article)part;
        }
        else if (part instanceof Staff) {
            authors.add((Staff)part);
        }
    }

    // Apply references
    article.setAuthors(authors);

    return parts;
}
</code>```

What am I doing wrong? Am I using my aggregator properly?

Note: If I just remove both the aggregator and second splitter altogether, the rest of the flow works perfectly.

答:
It is hard to tell everything that is going on since I don't have all your code, but I was able to make this flow work the way I think you wanted.  The baseObjectTransformer does nothing but set a flag on the objects passing through it:

...
<context:component-scan base-package="net.grogscave.example" />

<channel id="inputChannel" />

<splitter ref="articleContentExtractor" input-channel="inputChannel"
    output-channel="splitArticleStaff" />

<channel id="splitArticleStaff" />

<payload-type-router input-channel="splitArticleStaff">
    <mapping type="net.grogscave.example.domain.Article" channel="articleChannel" />
    <mapping type="net.grogscave.example.domain.Staff" channel="staffChannel" />
</payload-type-router>

<channel id="articleChannel" />

<transformer input-channel="articleChannel" output-channel="articleOutAggregateChannel"
    ref="baseObjectTransformer"/>

<channel id="staffChannel" />

<transformer input-channel="staffChannel" output-channel="articleOutAggregateChannel"
    ref="baseObjectTransformer"/>

<channel id="articleOutAggregateChannel" />

<aggregator ref="articleAggregator" input-channel="articleOutAggregateChannel" output-channel="splitArticleInChannel"/>

<channel id="splitArticleInChannel" />

<splitter input-channel="splitArticleInChannel" output-channel="splitArticleOutChannel" />

<channel id="splitArticleOutChannel" />

<payload-type-router resolution-required="true" input-channel="splitArticleOutChannel">
    <mapping type="net.grogscave.example.domain.Article" channel="contentOutChannel" />
    <mapping type="net.grogscave.example.domain.Staff" channel="staffOutChannel" />
</payload-type-router>

<channel id="contentOutChannel">
    <queue capacity="10" />
</channel>

<channel id="staffOutChannel">
    <queue capacity="10" />
</channel>
...
```

<p>I then just exercise this flow with the following code in a test case:</p>

```    ...
    AbstractApplicationContext context = new ClassPathXmlApplicationContext(
            "/META-INF/spring/split-agg-split.xml",
            SplitAggSplitTests.class);

    MessageChannel inputChannel = context.getBean("inputChannel",
            MessageChannel.class);

    PollableChannel contentOutChannel = context.getBean("contentOutChannel",
            PollableChannel.class);

    PollableChannel staffOutChannel = context.getBean("staffOutChannel",
            PollableChannel.class);

    inputChannel.send(new GenericMessage<String>("Dewey Wins!,A. Fool, C. Lewlis"));

    logger.info("==> Article recieved: "
            + contentOutChannel.receive(0).getPayload());

    for(int i = 0; i < 2; i++)
    {
        logger.info("==> Staff recieved: "
                + staffOutChannel.receive(0).getPayload());
    }
    ...
```

My logging output produces all three entities.

All that being said, have you considered simply removing the extra splitter/aggregator and simply moving the setAuthors logic to your first splitter?  I don't know all the details of your flow, but it would seem to simplify things.

Body:
In my Spring Integration powered project I have a splitter and payload-router for sending my data to various transformers. The new "transformed" objects are then passed back to an aggregator and processed.

Now I want to split up my aggregated results so they are persisted properly, since I need to route some of the objects to a seperate outbound-channel-adapter. To achieve this, I added a second splitter after my aggregator; but it seems only the first element in the aggregated collection is passed to the router.

This is my current flow:

<splitter ref="articleContentExtractor" />

<payload-type-router>
    ... routing to various transformers ...
    ... results are sent to articleOutAggregateChannel ...
</payload-type-router>

<aggregator ref="articleAggregator" />

<splitter />

<payload-type-router resolution-required="true">
    <mapping type="x.y.z.AbstractContent" channel="contentOutChannel" />
    <mapping type="x.y.z.Staff" channel="staffOutChannel" />
</payload-type-router>

<outbound-channel-adapter id="contentSaveService" ref="contentExporter"
    method="persist" channel="contentOutChannel" />

<outbound-channel-adapter id="staffSaveService" ref="staffExporter"
    method="persist" channel="staffOutChannel" />

And my Aggregator code:

@Aggregator
public List<? super BaseObject> compileArticle(List<? super BaseObject> parts) {

    // Search for the required objects for referencing
    Iterator<? super BaseObject> it = parts.iterator();
    Article article = null;
    List<Staff> authors = new ArrayList<Staff>();

    while (it.hasNext()) {
        Object part = it.next();
        if (part instanceof Article) {
            article = (Article)part;
        }
        else if (part instanceof Staff) {
            authors.add((Staff)part);
        }
    }

    // Apply references
    article.setAuthors(authors);

    return parts;
}

What am I doing wrong? Am I using my aggregator properly?

Note: If I just remove both the aggregator and second splitter altogether, the rest of the flow works perfectly.

Body:
It is hard to tell everything that is going on since I don't have all your code, but I was able to make this flow work the way I think you wanted.  The baseObjectTransformer does nothing but set a flag on the objects passing through it:

...
<context:component-scan base-package="net.grogscave.example" />

<channel id="inputChannel" />

<splitter ref="articleContentExtractor" input-channel="inputChannel"
    output-channel="splitArticleStaff" />

<channel id="splitArticleStaff" />

<payload-type-router input-channel="splitArticleStaff">
    <mapping type="net.grogscave.example.domain.Article" channel="articleChannel" />
    <mapping type="net.grogscave.example.domain.Staff" channel="staffChannel" />
</payload-type-router>

<channel id="articleChannel" />

<transformer input-channel="articleChannel" output-channel="articleOutAggregateChannel"
    ref="baseObjectTransformer"/>

<channel id="staffChannel" />

<transformer input-channel="staffChannel" output-channel="articleOutAggregateChannel"
    ref="baseObjectTransformer"/>

<channel id="articleOutAggregateChannel" />

<aggregator ref="articleAggregator" input-channel="articleOutAggregateChannel" output-channel="splitArticleInChannel"/>

<channel id="splitArticleInChannel" />

<splitter input-channel="splitArticleInChannel" output-channel="splitArticleOutChannel" />

<channel id="splitArticleOutChannel" />

<payload-type-router resolution-required="true" input-channel="splitArticleOutChannel">
    <mapping type="net.grogscave.example.domain.Article" channel="contentOutChannel" />
    <mapping type="net.grogscave.example.domain.Staff" channel="staffOutChannel" />
</payload-type-router>

<channel id="contentOutChannel">
    <queue capacity="10" />
</channel>

<channel id="staffOutChannel">
    <queue capacity="10" />
</channel>
...

I then just exercise this flow with the following code in a test case:

    ...
    AbstractApplicationContext context = new ClassPathXmlApplicationContext(
            "/META-INF/spring/split-agg-split.xml",
            SplitAggSplitTests.class);

    MessageChannel inputChannel = context.getBean("inputChannel",
            MessageChannel.class);

    PollableChannel contentOutChannel = context.getBean("contentOutChannel",
            PollableChannel.class);

    PollableChannel staffOutChannel = context.getBean("staffOutChannel",
            PollableChannel.class);

    inputChannel.send(new GenericMessage<String>("Dewey Wins!,A. Fool, C. Lewlis"));

    logger.info("==> Article recieved: "
            + contentOutChannel.receive(0).getPayload());

    for(int i = 0; i < 2; i++)
    {
        logger.info("==> Staff recieved: "
                + staffOutChannel.receive(0).getPayload());
    }
    ...

My logging output produces all three entities.

All that being said, have you considered simply removing the extra splitter/aggregator and simply moving the setAuthors logic to your first splitter?  I don't know all the details of your flow, but it would seem to simplify things.


问:
is it possible to define multidim arrays with #define directive in pure C?
I want to manage my packs of string constants separately from the computational code. I want to do it in separate file.

So, I need to create a multidim array of strings and conclude it under a STR_PACK_X.

If it is possible, can anyone route me right way with #define multidim-string-constants syntax?

Help me please, what's wrong with that attempt:

```<code>#define STR_PACK_X \
({ \
\ // comm1
    { "string1", "string2", "string3" }, \
\ // comm2
    { "string11", "string22", "string33" }, \
\ // comm3
    { "string111", "string222", "string333" } \
})
</code>```

I want to use it like that:

```<code>int line_lim = 4, word_lim = 4, char_lim = 50;

if (flag1)
{
  char array[line_lim][word_lim][char_lim] = STR_PACK_1;
  /* array processing */
  ...
}
if (flag2)
{
  char array[line_lim][word_lim][char_lim] = STR_PACK_2;
  /* array processing */
  ...
}
</code>```

答:
As noted, you have several language violations here:

Parenthesis around an initializer list isn't valid, it gives the wrong syntax for what you wish to achieve.

You can't initialize a variable-length array.

You can't place characters after a \ line wrap, using // comments together with them is always problematic. I'd advise to indent all \ to a fixed source column.

It would seem that instead of an initializer list, you are rather looking to use a compound literal and then copy the contents from that one in run-time:

```<code>#include <stdio.h>
#include <string.h>

#define STR_PACK_X                                          \
(const char* [3][3])                                        \
{                                                           \
    { "string1",   "string2",   "string3"   }, /* comm1 */  \
    { "string11",  "string22",  "string33"  }, /* comm2 */  \
    { "string111", "string222", "string333" }, /* comm3 */  \
}

int main (void)
{
  int line_lim = 4, word_lim = 4, char_lim = 50;
  char array[line_lim][word_lim][char_lim]; // VLA, can't be initialized

  for(size_t i=0; i<3; i++)
  {
    for(size_t j=0; j<3; j++)
    {
      strcpy(array[i][j], STR_PACK_X[i][j]);
      puts(array[i][j]);
    }
  }
}
</code>```

Body:
I want to manage my packs of string constants separately from the computational code. I want to do it in separate file.

So, I need to create a multidim array of strings and conclude it under a STR_PACK_X.

If it is possible, can anyone route me right way with #define multidim-string-constants syntax?

Help me please, what's wrong with that attempt:

#define STR_PACK_X \
({ \
\ // comm1
    { "string1", "string2", "string3" }, \
\ // comm2
    { "string11", "string22", "string33" }, \
\ // comm3
    { "string111", "string222", "string333" } \
})

I want to use it like that:

int line_lim = 4, word_lim = 4, char_lim = 50;

if (flag1)
{
  char array[line_lim][word_lim][char_lim] = STR_PACK_1;
  /* array processing */
  ...
}
if (flag2)
{
  char array[line_lim][word_lim][char_lim] = STR_PACK_2;
  /* array processing */
  ...
}

Body:
As noted, you have several language violations here:

Parenthesis around an initializer list isn't valid, it gives the wrong syntax for what you wish to achieve.

You can't initialize a variable-length array.

You can't place characters after a \ line wrap, using // comments together with them is always problematic. I'd advise to indent all \ to a fixed source column.

It would seem that instead of an initializer list, you are rather looking to use a compound literal and then copy the contents from that one in run-time:

#include <stdio.h>
#include <string.h>

#define STR_PACK_X                                          \
(const char* [3][3])                                        \
{                                                           \
    { "string1",   "string2",   "string3"   }, /* comm1 */  \
    { "string11",  "string22",  "string33"  }, /* comm2 */  \
    { "string111", "string222", "string333" }, /* comm3 */  \
}

int main (void)
{
  int line_lim = 4, word_lim = 4, char_lim = 50;
  char array[line_lim][word_lim][char_lim]; // VLA, can't be initialized

  for(size_t i=0; i<3; i++)
  {
    for(size_t j=0; j<3; j++)
    {
      strcpy(array[i][j], STR_PACK_X[i][j]);
      puts(array[i][j]);
    }
  }
}


问:
Comparing timespan object if it's between hours in C#
I want to filter an array of objects. The goal is to filter the objects between two timespan objects:

```<code>  TimeSpan tsFrom = TimeSpan.Parse("16:00");
  TimeSpan tsTo = TimeSpan.Parse("00:59");
</code>```

For example I have this object:

```<code>TimeSpan dateObject = TimeSpan.Parse("22:05:22");
</code>```

The problem comes when I try to compare if the dateObject is between tsFrom and tsTo:

```<code>if (dateObject > tsFrom && dateObject < tsTo)
{
// do something ....
}
</code>```

This won't work for cases like that. Do you have any ideas how I can make this work ?

答:
You're wanting to works with times of day. The TimeSpan data type works with time spans (somewhat obvious to say). These are distinct concepts.

Times of day are precisely what motivated the creation of the new TimeOnly type in .NET 6. It has an IsBetween method:

Determines if a time falls within the range provided. Supports both "normal" ranges such as 10:00-12:00, and ranges that span midnight such as 23:00-01:00.

Note that IsBetween use the more sensible convention of inclusive start, exclusive end which means that you'd use 01:00 as the to moment and not accidentally exclude e.g. 00:59:17 from your period

For older versions, I'd suggest you realise that if To is less than From (e.g. it's representing a period that crosses midnight) you should check:

```<code>if ((tsTo > tsFrom && dateObject >= tsFrom && dateObject < tsTo) ||
    (tsFrom > tsTo && (dateObject < tsTo || dateObject >= tsFrom)))
{

}
</code>```

Note, again, that this logic is assuming inclusive From and exclusive To (Your original logic treated both ends as exclusive which is rarely correct)

Body:
I want to filter an array of objects. The goal is to filter the objects between two timespan objects:

  TimeSpan tsFrom = TimeSpan.Parse("16:00");
  TimeSpan tsTo = TimeSpan.Parse("00:59");

For example I have this object:

TimeSpan dateObject = TimeSpan.Parse("22:05:22");

The problem comes when I try to compare if the dateObject is between tsFrom and tsTo:

if (dateObject > tsFrom && dateObject < tsTo)
{
// do something ....
}

This won't work for cases like that. Do you have any ideas how I can make this work ?

Body:
You're wanting to works with times of day. The TimeSpan data type works with time spans (somewhat obvious to say). These are distinct concepts.

Times of day are precisely what motivated the creation of the new TimeOnly type in .NET 6. It has an IsBetween method:

Determines if a time falls within the range provided. Supports both "normal" ranges such as 10:00-12:00, and ranges that span midnight such as 23:00-01:00.

Note that IsBetween use the more sensible convention of inclusive start, exclusive end which means that you'd use 01:00 as the to moment and not accidentally exclude e.g. 00:59:17 from your period

For older versions, I'd suggest you realise that if To is less than From (e.g. it's representing a period that crosses midnight) you should check:

if ((tsTo > tsFrom && dateObject >= tsFrom && dateObject < tsTo) ||
    (tsFrom > tsTo && (dateObject < tsTo || dateObject >= tsFrom)))
{

}

Note, again, that this logic is assuming inclusive From and exclusive To (Your original logic treated both ends as exclusive which is rarely correct)


问:
How can i save model while training in torch
I am training RoBERTa model for a new language, and it takes some hours to train the data. So I think it is a good idea to save the model while training so that I can continue training the model from where it stops next time.

I am using torch library and google Colab GPU to train the model.

Here is my colab file.
https://colab.research.google.com/drive/1jOYCaLdxYRwGMqMciG6c3yPYZAsZRySZ?usp=sharing

答:
You can use the Trainer from transformers to train the model. This trainer will also need you to specify the TrainingArguments, which will allow you to save checkpoints of the model while training.

Some of the parameters you set when creating TrainingArguments are:

save_strategy: The checkpoint save strategy to adopt during training. Possible values are:

"no": No save is done during training.

"epoch": Save is done at the end of each epoch.

"steps": Save is done every save_steps.

save_steps: Number of updates steps before two checkpoint saves if save_strategy="steps".

save_total_limit: If a value is passed, will limit the total amount of checkpoints. Deletes the older checkpoints in output_dir.

load_best_model_at_end: Whether or not to load the best model found during training at the end of training.

One important thing about load_best_model_at_end is that when set to True, the parameter save_strategy needs to be the same as eval_strategy, and in the case it is “steps”, save_steps must be a round multiple of eval_steps.


问:
Image values with rgb2gray python
I'm a beginner in image processing.

I work with an RGB image image.shape = (4512,3000,3)

I saw the value of the the first pixel: image[0][0] = [210 213 220]

When I use the rgb2gray function the result is rgb2gray(image[0][0]) = 0.8347733333333334

But I saw that the relation used by the function is Y = 0.2125 * R + 0.7454 * G +  0.0721 * B. I did the calculation, I should have Y = im[0,0,0] * 0.2125 + im[0,0,1] * 0.7154 + im[0,0,2] * 0.0721 = 212.8672

It seems my result is 212.8672/255 = 0.8347733333333334

Why is the result between 0 and 1 and not between 0 and 255?

答:
I assume you are using scikit-image's rgb2gray. In that case, you can see in the code from https://github.com/scikit-image/scikit-image/blob/main/skimage/color/colorconv.py that every color conversion in the color module starts with the _prepare_colorarray methods which converts to floating point representation.

```<code>def _prepare_colorarray(arr, force_copy=False, *, channel_axis=-1):
    """Check the shape of the array and convert it to
    floating point representation.
    """
    arr = np.asanyarray(arr)

    if arr.shape[channel_axis] != 3:
        msg = (f'the input array must have size 3 along `channel_axis`, '
               f'got {arr.shape}')
        raise ValueError(msg)

    float_dtype = _supported_float_type(arr.dtype)
    if float_dtype == np.float32:
        _func = dtype.img_as_float32
    else:
        _func = dtype.img_as_float64
return _func(arr, force_copy=force_copy)
</code>```

The module does (thankfully) support 8-bit int representation as an input, but converts the image array to float representation and uses that representation all along.

Title: Image values with rgb2gray python

Body:
I assume you are using scikit-image's rgb2gray. In that case, you can see in the code from https://github.com/scikit-image/scikit-image/blob/main/skimage/color/colorconv.py that every color conversion in the color module starts with the _prepare_colorarray methods which converts to floating point representation.

def _prepare_colorarray(arr, force_copy=False, *, channel_axis=-1):
    """Check the shape of the array and convert it to
    floating point representation.
    """
    arr = np.asanyarray(arr)

    if arr.shape[channel_axis] != 3:
        msg = (f'the input array must have size 3 along `channel_axis`, '
               f'got {arr.shape}')
        raise ValueError(msg)

    float_dtype = _supported_float_type(arr.dtype)
    if float_dtype == np.float32:
        _func = dtype.img_as_float32
    else:
        _func = dtype.img_as_float64
return _func(arr, force_copy=force_copy)

The module does (thankfully) support 8-bit int representation as an input, but converts the image array to float representation and uses that representation all along.