问:
Choosing the most ideal font format
I should use the font family Nunito [»] from the Google font library.

Due to some improvements such as site speed performance and concerns like independence, I need to run this technology locally.

```<code><link href="https://fonts.googleapis.com/css2?family=Nunito" rel="stylesheet">
</code>```

I used this tool for this: google-webfonts-helper [»]

My minimum browser support (Modern Browsers) will be IE9+. In this case, when I select that option from the tool, it gives the following @font-face block.

```<code>/* nunito-regular - latin-ext_latin_cyrillic */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  src: local('Nunito Regular'), local('Nunito-Regular'),
       url('../fonts/nunito-v12-latin-ext_latin_cyrillic-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
       url('../fonts/nunito-v12-latin-ext_latin_cyrillic-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
</code>```

Since the opening speed of the project was our primary goal, some questions were kept in mind.

As you can see, this code tries to load both woff and woff2 fonts.
The thing that comes to my mind is that since I included woff, why should I try to include woff2?

Wouldn't it be enough to include the woff type font set for all modern browsers (IE9+)?

Finally, I learned that IOS operating system based devices use ttf type font. As a matter of fact, when I use only woff, what is my minimum IOS support?

答:
woff2 is the modern "standard font" and is supported on modern browsers. Woff2 is a more compressed font, so the woff2 files are smaller then the woff files. To support modern and some older browsers, both the woff2 and woff files has to be there. The priority is to ask if the font is present on the device, if not then present Woff2, and if woff2 fails, load the woff font.

If you look at the performance, the woff2 is the best choice. The woff is a fallback for older browsers.

Note that not both woff2 and woff are loaded. If woff2 is supported, the browser will only load woff2. On the other hand, if woff2 is not supported, then only the woff is loaded. Presenting both is the best option.

```<code>WOFF2 : modern browsers
WOFF  : fallback if woff2 is not supported
TTF   : Android-browser on Android 4.3 or older
EOT   : Internet Explorer 8 or older
SVG   : iOS-Safari 3.2-4.1. SVG webfonts are not supported anymore in most browsers
</code>```

Note that svg files are huge files and bad practice if you're working on performance optimization.

So for best performance, and for very good cross browser presentation, woff2 and woff are enough. Your css looks fine, first check local, then try woff2 and then, if woff2 fails, a fallback to woff.

RE: your comment

To test the performance, I uploaded a Bootstrap page with Font-Awsome and Open-Sans. These webfont files are located in a subfolder on my domain. Each font has this priority:

```<code>src: local('Open Sans Italic'),
     local('OpenSans-Italic'),
     url('../webfonts/OpenSans/OpenSans-Italic.woff2') format('woff2'),
     url('../webfonts/OpenSans/OpenSans-Italic.woff') format('woff'),
     url('../webfonts/OpenSans/OpenSans-Italic.ttf') format('truetype');
</code>```

The waterfall diagram shows that from each webfont only the woff2 is loaded. If you do not have to support the old 'Android-browser' on Android 4.3 or older then remove the TTF line from this css example.

Title: Choosing the most ideal font format

Body:
I should use the font family Nunito [»] from the Google font library.

Due to some improvements such as site speed performance and concerns like independence, I need to run this technology locally.

<link href="https://fonts.googleapis.com/css2?family=Nunito" rel="stylesheet">

I used this tool for this: google-webfonts-helper [»]

My minimum browser support (Modern Browsers) will be IE9+. In this case, when I select that option from the tool, it gives the following @font-face block.

/* nunito-regular - latin-ext_latin_cyrillic */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  src: local('Nunito Regular'), local('Nunito-Regular'),
       url('../fonts/nunito-v12-latin-ext_latin_cyrillic-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
       url('../fonts/nunito-v12-latin-ext_latin_cyrillic-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}

Since the opening speed of the project was our primary goal, some questions were kept in mind.

As you can see, this code tries to load both woff and woff2 fonts.
The thing that comes to my mind is that since I included woff, why should I try to include woff2?

Wouldn't it be enough to include the woff type font set for all modern browsers (IE9+)?

Finally, I learned that IOS operating system based devices use ttf type font. As a matter of fact, when I use only woff, what is my minimum IOS support?

Body:
woff2 is the modern "standard font" and is supported on modern browsers. Woff2 is a more compressed font, so the woff2 files are smaller then the woff files. To support modern and some older browsers, both the woff2 and woff files has to be there. The priority is to ask if the font is present on the device, if not then present Woff2, and if woff2 fails, load the woff font.

If you look at the performance, the woff2 is the best choice. The woff is a fallback for older browsers.

Note that not both woff2 and woff are loaded. If woff2 is supported, the browser will only load woff2. On the other hand, if woff2 is not supported, then only the woff is loaded. Presenting both is the best option.

WOFF2 : modern browsers
WOFF  : fallback if woff2 is not supported
TTF   : Android-browser on Android 4.3 or older
EOT   : Internet Explorer 8 or older
SVG   : iOS-Safari 3.2-4.1. SVG webfonts are not supported anymore in most browsers

Note that svg files are huge files and bad practice if you're working on performance optimization.

So for best performance, and for very good cross browser presentation, woff2 and woff are enough. Your css looks fine, first check local, then try woff2 and then, if woff2 fails, a fallback to woff.

RE: your comment

To test the performance, I uploaded a Bootstrap page with Font-Awsome and Open-Sans. These webfont files are located in a subfolder on my domain. Each font has this priority:

src: local('Open Sans Italic'),
     local('OpenSans-Italic'),
     url('../webfonts/OpenSans/OpenSans-Italic.woff2') format('woff2'),
     url('../webfonts/OpenSans/OpenSans-Italic.woff') format('woff'),
     url('../webfonts/OpenSans/OpenSans-Italic.ttf') format('truetype');

The waterfall diagram shows that from each webfont only the woff2 is loaded. If you do not have to support the old 'Android-browser' on Android 4.3 or older then remove the TTF line from this css example.


来源: stackexchange

问:
Apk crashes when Release mode but in debug mode works perfectly
I have get apk with release mode, but app crash.but apk with debug apk is not crash
this is my android/app/build.gradle

```<code>signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    } }
   buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://facebook.github.io/react-native/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    } }
</code>```

my react-native version is "react-native": "^0.62.2", and

```<code>ext {
  buildToolsVersion = "28.0.3"
  minSdkVersion = 16
  compileSdkVersion = 28
  targetSdkVersion = 28
}
</code>```

答:
Usually that's related to proguard obfuscation, you can check that commenting out the following lines:

```<code>   minifyEnabled enableProguardInReleaseBuilds
   proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
</code>```

if that helps - you'll need to adjust somehow proguard-rules.pro avoid renaming some classes.

To find what exactly causes the crash debug using adb logcat command (or just look at the "Run" window in Android Studio).

ContentLicense: CC BY-SA 4.0

Body:
I have get apk with release mode, but app crash.but apk with debug apk is not crash
this is my android/app/build.gradle

signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    } }
   buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://facebook.github.io/react-native/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    } }

my react-native version is "react-native": "^0.62.2", and

ext {
  buildToolsVersion = "28.0.3"
  minSdkVersion = 16
  compileSdkVersion = 28
  targetSdkVersion = 28
}

Body:
Usually that's related to proguard obfuscation, you can check that commenting out the following lines:

   minifyEnabled enableProguardInReleaseBuilds
   proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"

if that helps - you'll need to adjust somehow proguard-rules.pro avoid renaming some classes.

To find what exactly causes the crash debug using adb logcat command (or just look at the "Run" window in Android Studio).


问:
in_array() expects parameter 2 to be array, boolean given in line
In the error log of my server i was getting the following PHP Warning:

in_array() expects parameter 2 to be array, boolean given in " //..." on line 45.

In line 45 i have a function that checks wether WooCommerce plug-in is active.

```<code>    /**
     * Construction function
     */
    public function __construct() {
        // Check if Woocomerce plugin is actived
        if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
             return;
        }
</code>```

I changed this lines of code after creating a post and replaced it with:

```<code>if(!is_plugin_active('woocommerce/woocommerce.php')) {
    return;
}
</code>```

This then would lead to PHP Fatal error: Uncaught Error: Call to undefined function is_plugin_active() in *** It then proceeded to show me the stack race.

Tried to update it with:

```<code>if ( ! in_array( 'woocommerce/woocommerce.php', (array)apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
   return;
}
</code>```

But Wordpress Theme editor in "class-sober-wc.php" is giving me the eror: Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.

Any solutions?

Edit:

```<code>if ( ! in_array( 'woocommerce/woocommerce.php', (array)apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
   return;
}
</code>```

It worked. I couldn´t deploy through the main WP PHP console but after waiting some time i was able to deploy.

答:
Please include plugin.php file before calling is_plugin_active.

```<code>include_once( ABSPATH . 'wp-admin/includes/plugin.php' );

if(!is_plugin_active('woocommerce/woocommerce.php')) {
    return;
}
</code>```

When you include plugin.php file it will not throw an error. Because is_plugin_active function placed in the plugin.php file.

Happy coding

Body:
In the error log of my server i was getting the following PHP Warning:

in_array() expects parameter 2 to be array, boolean given in " //..." on line 45.

In line 45 i have a function that checks wether WooCommerce plug-in is active.

    /**
     * Construction function
     */
    public function __construct() {
        // Check if Woocomerce plugin is actived
        if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
             return;
        }

I changed this lines of code after creating a post and replaced it with:

if(!is_plugin_active('woocommerce/woocommerce.php')) {
    return;
}

This then would lead to PHP Fatal error: Uncaught Error: Call to undefined function is_plugin_active() in *** It then proceeded to show me the stack race.

Tried to update it with:

if ( ! in_array( 'woocommerce/woocommerce.php', (array)apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
   return;
}

But Wordpress Theme editor in "class-sober-wc.php" is giving me the eror: Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.

Any solutions?

Edit:

if ( ! in_array( 'woocommerce/woocommerce.php', (array)apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
   return;
}

It worked. I couldn´t deploy through the main WP PHP console but after waiting some time i was able to deploy.

Body:
Please include plugin.php file before calling is_plugin_active.

include_once( ABSPATH . 'wp-admin/includes/plugin.php' );

if(!is_plugin_active('woocommerce/woocommerce.php')) {
    return;
}

When you include plugin.php file it will not throw an error. Because is_plugin_active function placed in the plugin.php file.

Happy coding


ContentLicense: CC BY-SA 3.0

Title: Python print number range on multiple lines

Body:
I'm just trying to do some looping functions in Python, however I am pretty much stuck here.

I don't know if it should be a nested or simultaneous loop, and if so, how to use it probably.

Python is telling me (ValueError: too many values to unpack)

Here is my code:

rows = 16

for i in range(rows):

    for a,b,c,d,e,f,g,h,j in range(1, 17), range(18, 34), range(35, 40), range(41, 57), range(58, 74), range(75, 91), range(92, 108), range(109, 125), range(126, 127):
        print '{0:4d} {1:4d} {2:4d} {3:4d} {4:4d} {5:4d} {6:4d} {7:4d}'.format(a, b, c, d, e, f, g, h, j)

I basicly want the application to print out the range of numbers from 1 to 128 in this layout over 16 rows with the numbers going horisontal:

  1    2    3    4    5    6    7    8
  9   10   11   12   13   14   15   16
 122  122  122  122  122  122  122  122
 123  123  123  123  123  123  123  123
 124  124  124  124  124  124  124  124
 125  125  125  125  125  125  125  125
 126  126  126  126  126  126  126  126
 127  127  127  127  127  127  127  127
 128  128  128  128  128  128  128  128
 128  128  128  128  128  128  128  128
 124  124  124  124  124  124  124  124
 125  125  125  125  125  125  125  125
 126  126  126  126  126  126  126  126
 127  127  127  127  127  127  127  127
 128  128  128  128  128  128  128  128
 128  128  128  128  128  128  128  128

Body:
x = []
for e in range(1, 129):
    x.append(e)
strt = 0
end = 8
for i in range(0, 16):
    print(*x[strt:end])
    strt = end
    end += 8

#Output:
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64
65 66 67 68 69 70 71 72
73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88
89 90 91 92 93 94 95 96
97 98 99 100 101 102 103 104
105 106 107 108 109 110 111 112
113 114 115 116 117 118 119 120
121 122 123 124 125 126 127 128


问:
Custom Installer in .Net showing Form behind installer
```<code>[RunInstaller(true)]
public partial class Installer1 : Installer
{
    public Installer1()
    {
        InitializeComponent();
    }

    public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);
    }
    private void Installer1_AfterInstall(object sender, InstallEventArgs e)
    {
        Form1 topmostForm = new Form1();
        topmostForm.BringToFront();
        topmostForm.TopMost = true;
        topmostForm.ShowDialog();
  } }
</code>```

I need to display the topmostForm in front of the default Windows Installer UI. The above is sample code inside my CustomAction that I am using to create a Form. Setting the TopMost property or using ShowDialog is not helping. Is there any other solution to make my form the top most and focussed?

答:
If you want to show your own UI in the installer, you won't be able to use a setup and deployment project, because it lacks the features necessary to implement that. Consider using an installer toolkit like WiX or Inno Setup instead.

Concerning the first part of your question, are you passing the custom dialog box in the owner argument to MessageBox.Show()?

Body:
[RunInstaller(true)]
public partial class Installer1 : Installer
{
    public Installer1()
    {
        InitializeComponent();
    }

    public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);
    }
    private void Installer1_AfterInstall(object sender, InstallEventArgs e)
    {
        Form1 topmostForm = new Form1();
        topmostForm.BringToFront();
        topmostForm.TopMost = true;
        topmostForm.ShowDialog();
  } }

I need to display the topmostForm in front of the default Windows Installer UI. The above is sample code inside my CustomAction that I am using to create a Form. Setting the TopMost property or using ShowDialog is not helping. Is there any other solution to make my form the top most and focussed?


问:
Is it possible to call krun on the configurations output by krun?
I'd like K to generate a bunch of configurations which I can then process externally. But then, I may want resume the computation by calling K on each configuration. Is this possible?

I tried looking at the krun --help options, but I don't think I saw what I needed. The closest was term parsing, but I'd like to pass it full configurations rather than just a term.

Alternatively, is there API for K to use with OCaml?
e.g. if I have an already compiled K semantics, is there any API to call K on a file, gain access to the AST, and run K over them?

答:
It looks like what you want is the following:</p>

```<code>krun $args --output kast --output-file output.kast
krun --term --parser cat output.kast
</code>```

Body:
It looks like what you want is the following:

krun $args --output kast --output-file output.kast
krun --term --parser cat output.kast


问:
How to make ag-grid column as wide as largest text in column
I wanna remove those gaps which I marked with black line.Because I wanna sizeToFit and when I add new columns to dataset,I dont wanna see texts in these columns with .... .

Plunkr example: https://plnkr.co/edit/510MSisTzhw4t6Cy

答:
You have to call gridOptions.columnApi.autoSizeColumns at initialisation time:

```<code>function autoSizeAll(skipHeader) {
  var allColumnIds = [];
  gridOptions.columnApi.getAllColumns().forEach(function(column) {
    allColumnIds.push(column.colId);
  });

  gridOptions.columnApi.autoSizeColumns(allColumnIds, skipHeader);
}
</code>```

https://www.ag-grid.com/javascript-grid-resizing/#auto-size-columns

Body:
You have to call gridOptions.columnApi.autoSizeColumns at initialisation time:

function autoSizeAll(skipHeader) {
  var allColumnIds = [];
  gridOptions.columnApi.getAllColumns().forEach(function(column) {
    allColumnIds.push(column.colId);
  });

  gridOptions.columnApi.autoSizeColumns(allColumnIds, skipHeader);
}

https://www.ag-grid.com/javascript-grid-resizing/#auto-size-columns


问:
Turning column into POSIXct date/time series
I am trying to reconfigure a column in my data frame (str = 'character') that has the format: 'MM/DD/YYYY HH:MM:SS' into a date/time series column (str = POSIXct) for use with the rmweather package.

```<code>> DNO2$`Date & Time`
    `Date & Time`
    <dttm>
[1] "31/12/2017 24:00"
[2] "01/01/2018 01:00"
[3] "01/01/2018 02:00"
[4] "01/01/2018 03:00"
[5] "01/01/2018 04:00"
[6] "01/01/2018 05:00"
</code>```

In brief, I want to go from:
'MM/DD/YYYY HH:MM:SS'
to:
'YYYY-MM-DD HH:MM:SS'

I've tried using the as_datetime() function in the lubridate package to do this, but I receive a strange output:

```<code>> DNO_18$`Date & Time` <- as_datetime(DNO_18$`Date & Time`, tz="Europe/London")
> head(DNO_18)
# A tibble: 6 x 8
  `Date & Time`       Rathmines Ringsend `St John`
  <dttm>              <chr>     <chr>    <chr>
1 2031-12-20 17:24:00 0.299999… 0.90000… NoData
2 2001-01-20 18:01:00 0.299999… 0.80000… NoData
3 2001-01-20 18:02:00 0.299999… 0.90000… NoData
4 2001-01-20 18:03:00 0.100000… 0.80000… NoData
5 2001-01-20 18:04:00 0.200000… 1        NoData
6 2001-01-20 18:05:00 0.200000… 0.90000… NoData
</code>```

Any help with this would be appreciated.

答:
We can use as.POSIXct from base R

```<code>DNO_18$`Date & Time` <- as.POSIXct(DNO_18$`Date & Time`, format = "%d/%m/%Y %H:%M")
</code>```

Or with lubridate

```<code>library(lubridate)
DNO_18$`Date & Time` <- dmy_hm(DNO_18$`Date & Time`)
</code>```

Body:
I am trying to reconfigure a column in my data frame (str = 'character') that has the format: 'MM/DD/YYYY HH:MM:SS' into a date/time series column (str = POSIXct) for use with the rmweather package.

> DNO2$`Date & Time`
    `Date & Time`
    <dttm>
[1] "31/12/2017 24:00"
[2] "01/01/2018 01:00"
[3] "01/01/2018 02:00"
[4] "01/01/2018 03:00"
[5] "01/01/2018 04:00"
[6] "01/01/2018 05:00"

In brief, I want to go from:
'MM/DD/YYYY HH:MM:SS'
to:
'YYYY-MM-DD HH:MM:SS'

I've tried using the as_datetime() function in the lubridate package to do this, but I receive a strange output:

> DNO_18$`Date & Time` <- as_datetime(DNO_18$`Date & Time`, tz="Europe/London")
> head(DNO_18)
# A tibble: 6 x 8
  `Date & Time`       Rathmines Ringsend `St John`
  <dttm>              <chr>     <chr>    <chr>
1 2031-12-20 17:24:00 0.299999… 0.90000… NoData
2 2001-01-20 18:01:00 0.299999… 0.80000… NoData
3 2001-01-20 18:02:00 0.299999… 0.90000… NoData
4 2001-01-20 18:03:00 0.100000… 0.80000… NoData
5 2001-01-20 18:04:00 0.200000… 1        NoData
6 2001-01-20 18:05:00 0.200000… 0.90000… NoData

Any help with this would be appreciated.

Body:
We can use as.POSIXct from base R

DNO_18$`Date & Time` <- as.POSIXct(DNO_18$`Date & Time`, format = "%d/%m/%Y %H:%M")

Or with lubridate

library(lubridate)
DNO_18$`Date & Time` <- dmy_hm(DNO_18$`Date & Time`)


问:
Why is the H1 overflowing my containers, when I shrink the page verticaly
I am having a problem with overflowing text. I am trying to create portfolio with several pages, that will take 100% of user's screen. Everything goes nice and easy, but I have noticed that when I go to dev tools the page goes wild when I shrink the page verticaly. The elements starts to overflow their containers.. even though the width is still ok. I thought the problem was that I had 100 vh on each page, so I removed it and went the way with html,body{height:100%, width:100%}, but that wasn't the problem.

1# EDIT: I can see that if I put min-height:300px for example, then it fixes the problem, but why I cant set min-height: 100% ? I dont want to put some random pixels

jsfiddle : https://jsfiddle.net/7abd1pLr/1/

HTML

```<code><div class="first-page">
        <header class = "header">
            <p>KONTAKT</p>
        </header>

        <main class = "main">
            <div class="portfolio">
                <p class="first-line">POR</p>
                <p class="second-line">TFO</p>
                <p class="third-line">LIO</p>
            </div>

            <div class= "blank"></div>
            <div class= "text">
                <h1>JOHN DOE</h1>
                <h2>ARCHITECTURE STUDENT</h2>
            </div>
            <!--<div class= "blank2"></div>-->
        </main>

        <footer class= "footer">
            <img src="images/mesto.svg" alt="" srcset="">
        </footer>

        <section class = "page-navigation">
            <button class="page-1 button-active"></button>
            <button class="page-2 "></button>
            <button class="page-3"></button>
        </section>
    </div>

    <div class="second-page">
        <div class="flex">
            <div class= "text-main flex">
                <div class="skills">
                    <h1>SKILLS</h1>
                    <div class="text-sub">
                        <p>Photoshop</p>
                        <p>Illustrator</p>
                        <p>InDesign</p>
                        <p>Rhino</p>
                        <p>SketchUp</p>
                        <p>Lumion</p>
                        <p>3D max</p>
                        <p>AutoCad</p>
                    </div>
                </div>
                <div class="education">
                    <h1>EDUCATION</h1>
                    <div class="text-sub">
                        <h2>some text</h2>
                        <p>some text</p>
                        <br>
                        <h2>some text</h2>
                        <p>some text</p>
                    </div>
                </div>
                <div class="experiences">
                    <h1>EXPERIENCES</h1>
                    <div class="text-sub">
                        <P>some text</P>
                        <p>some text</p>
                        <p>some text</p>
                    </div>
                </div>
                <div class="about-me">
                    <h1>ABOUT ME</h1>
                    <div class="text-sub">
                        <p>some textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome text.
                        </p>

                    </div>
                </div>
            </div>
            <div class="profile-pic">
                <img src="images/.svg" alt="profile" srcset="">
            </div>
        </div>
    </div>
</code>```

CSS

```<code>    .flex {
      display: flex; }

    html, body {
      height: 100%;
      width: 100%; }

    body {
      font-family: 'Roboto', sans-serif;
      line-height: 1.6;
      color: black;
      box-sizing: border-box;
      min-height: 100%;
      font-weight: 300; }

    .first-page {
      height: 100%;
      position: relative; }

      .first-page .main {
        display: flex;
        position: relative;
        top: 30%;
        justify-content: center;
        z-index: 2; }

    .second-page {
      position: relative;
      height: 100%;
      background-color: #DCDCDC; }

      .second-page .flex {
        position: relative;
        height: 100%;
        justify-content: flex-end;
}
        .second-page .flex .text-main {
          height: 80%;
          min-height: 80%;
          align-self: flex-end;
          flex: 0 0 55%;
          flex-wrap: wrap; }
</code>```

答: Looks like it happens because of 55% in flex: 0 0 55%; in .second-page .flex .text-main

Body:
I am having a problem with overflowing text. I am trying to create portfolio with several pages, that will take 100% of user's screen. Everything goes nice and easy, but I have noticed that when I go to dev tools the page goes wild when I shrink the page verticaly. The elements starts to overflow their containers.. even though the width is still ok. I thought the problem was that I had 100 vh on each page, so I removed it and went the way with html,body{height:100%, width:100%}, but that wasn't the problem.

1# EDIT: I can see that if I put min-height:300px for example, then it fixes the problem, but why I cant set min-height: 100% ? I dont want to put some random pixels

jsfiddle : https://jsfiddle.net/7abd1pLr/1/

HTML

KONTAKT

POR

TFO

LIO

JOHN DOE

ARCHITECTURE STUDENT

            <button class="page-1 button-active"></button>
            <button class="page-2 "></button>
            <button class="page-3"></button>

SKILLS

Photoshop

Illustrator

InDesign

Rhino

SketchUp

Lumion

3D max

AutoCad

EDUCATION

some text

some text

some text

some text

EXPERIENCES

some text

some text

some text

ABOUT ME

some textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome text.

CSS

    .flex {
      display: flex; }

    html, body {
      height: 100%;
      width: 100%; }

    body {
      font-family: 'Roboto', sans-serif;
      line-height: 1.6;
      color: black;
      box-sizing: border-box;
      min-height: 100%;
      font-weight: 300; }

    .first-page {
      height: 100%;
      position: relative; }

      .first-page .main {
        display: flex;
        position: relative;
        top: 30%;
        justify-content: center;
        z-index: 2; }

    .second-page {
      position: relative;
      height: 100%;
      background-color: #DCDCDC; }

      .second-page .flex {
        position: relative;
        height: 100%;
        justify-content: flex-end;
}
        .second-page .flex .text-main {
          height: 80%;
          min-height: 80%;
          align-self: flex-end;
          flex: 0 0 55%;
          flex-wrap: wrap; }


问:
Hide a process from Task Manager
I'm trying to hide a process from the taskmanager but it doesn't work .
I dont understand why ...

Thank you for your help in advance... !

This is my function who inject the hider_dll.dll :

```<code>int Inject(char* dll)
{
    int pid = getpid();

    HANDLE hProc=OpenProcess(PROCESS_ALL_ACCESS,false,pid);
    if(hProc)
    {
        cout<<"OpenProcess success"<<endl;
    }
    else
    {
        cout<<"OpenProcess failed..."<<endl;
        return 0;
    }
    LPVOID Vmem=VirtualAllocEx(hProc,0,strlen(dll)+1,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE);
    DWORD wrt;
    WriteProcessMemory(hProc,Vmem,dll,strlen(dll),(SIZE_T*)&wrt);

    stringstream sstr;
    sstr << wrt;
    string str = sstr.str();

    cout<<"Writed "+str+" bytes"<<endl;

    FARPROC LoadLib=GetProcAddress(LoadLibrary(L"kernel32.dll"),"LoadLibraryA");
    HANDLE h=CreateRemoteThread(hProc,0,0,(LPTHREAD_START_ROUTINE)LoadLib,Vmem,0,0);
    if(h)
    {
        cout<<"CreateRemoteThread success"<<endl;
    }
    else
    {
        cout<<"CreateRemoteThread failed\r\nError:"<<GetLastError()<<endl;
        return 0;
    }
    WaitForSingleObject(h,INFINITE);
    DWORD exit;
    GetExitCodeThread(h,&exit);
    cout<<"Dll loaded to "<<exit<<endl;
    return 1;
    }
</code>```

答:
Here is a proper injector:

```<code>#include <iostream>
#include <Windows.h>
#include <TlHelp32.h>

DWORD GetProcId(const char* procName)
{
    DWORD procId = 0;
    HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

    if (hSnap != INVALID_HANDLE_VALUE)
    {
        PROCESSENTRY32 procEntry;
        procEntry.dwSize = sizeof(procEntry);

        if (Process32First(hSnap, &procEntry))
        {
            do
            {
                if (!_stricmp(procEntry.szExeFile, procName))
                {
                    procId = procEntry.th32ProcessID;
                    break;
                }
            } while (Process32Next(hSnap, &procEntry));
        }
    }
    CloseHandle(hSnap);
    return procId;
}

int main()
{
    const char* dllPath = "C:\\Users\\'%USERNAME%'\\Desktop\\dll.dll"; //
    const char* procName = "processname.exe"; //
    DWORD procId = 0;

    while (!procId)
    {
        procId = GetProcId(procName);
        Sleep(30);
    }

    HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, procId);

    if (hProc && hProc != INVALID_HANDLE_VALUE)
    {
        void* loc = VirtualAllocEx(hProc, 0, MAX_PATH, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);

        WriteProcessMemory(hProc, loc, dllPath, strlen(dllPath) + 1, 0);

        HANDLE hThread = CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)LoadLibraryA, loc, 0, 0);

        if (hThread)
        {
            CloseHandle(hThread);
        }
    }

    if (hProc)
    {
        CloseHandle(hProc);
    }
    return 0;
}
</code>```

To hide processes from Task Manager you need to hook NtQuerySystemInformation() and if the argument SYSTEM_PROCESS_INFORMATION is used, you need to remove your process from the linked list of processes.

This is what your hook would look like:

```<code>// Hooked function
NTSTATUS WINAPI HookedNtQuerySystemInformation(
    __in       SYSTEM_INFORMATION_CLASS SystemInformationClass,
    __inout    PVOID                    SystemInformation,
    __in       ULONG                    SystemInformationLength,
    __out_opt  PULONG                   ReturnLength
)
{
    NTSTATUS status = OriginalNtQuerySystemInformation(SystemInformationClass,
        SystemInformation,
        SystemInformationLength,
        ReturnLength);
    if (SystemProcessInformation == SystemInformationClass && STATUS_SUCCESS == status)
    {
        // Loop through the list of processes
        PMY_SYSTEM_PROCESS_INFORMATION pCurrent = NULL;
        PMY_SYSTEM_PROCESS_INFORMATION pNext = (PMY_SYSTEM_PROCESS_INFORMATION)
            SystemInformation;

        do
        {
            pCurrent = pNext;
            pNext = (PMY_SYSTEM_PROCESS_INFORMATION)((PUCHAR)pCurrent + pCurrent->
                NextEntryOffset);
            if (!wcsncmp(pNext->ImageName.Buffer, L"notepad.exe", pNext->ImageName.Length))
            {
                if (!pNext->NextEntryOffset)
                {
                    pCurrent->NextEntryOffset = 0;
                }
                else
                {
                    pCurrent->NextEntryOffset += pNext->NextEntryOffset;
                }
                pNext = pCurrent;
            }
        } while (pCurrent->NextEntryOffset != 0);
    }
    return status;
}
</code>```

OwnerDisplayName: Neolex

Title: Hide a process from Task Manager

Body:
I'm trying to hide a process from the taskmanager but it doesn't work .
I dont understand why ...

Thank you for your help in advance... !

This is my function who inject the hider_dll.dll :

int Inject(char* dll)
{
    int pid = getpid();

    HANDLE hProc=OpenProcess(PROCESS_ALL_ACCESS,false,pid);
    if(hProc)
    {
        cout<<"OpenProcess success"<<endl;
    }
    else
    {
        cout<<"OpenProcess failed..."<<endl;
        return 0;
    }
    LPVOID Vmem=VirtualAllocEx(hProc,0,strlen(dll)+1,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE);
    DWORD wrt;
    WriteProcessMemory(hProc,Vmem,dll,strlen(dll),(SIZE_T*)&wrt);

    stringstream sstr;
    sstr << wrt;
    string str = sstr.str();

    cout<<"Writed "+str+" bytes"<<endl;

    FARPROC LoadLib=GetProcAddress(LoadLibrary(L"kernel32.dll"),"LoadLibraryA");
    HANDLE h=CreateRemoteThread(hProc,0,0,(LPTHREAD_START_ROUTINE)LoadLib,Vmem,0,0);
    if(h)
    {
        cout<<"CreateRemoteThread success"<<endl;
    }
    else
    {
        cout<<"CreateRemoteThread failed\r\nError:"<<GetLastError()<<endl;
        return 0;
    }
    WaitForSingleObject(h,INFINITE);
    DWORD exit;
    GetExitCodeThread(h,&exit);
    cout<<"Dll loaded to "<<exit<<endl;
    return 1;
    }

Body:
Here is a proper injector:

#include <iostream>
#include <Windows.h>
#include <TlHelp32.h>

DWORD GetProcId(const char* procName)
{
    DWORD procId = 0;
    HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

    if (hSnap != INVALID_HANDLE_VALUE)
    {
        PROCESSENTRY32 procEntry;
        procEntry.dwSize = sizeof(procEntry);

        if (Process32First(hSnap, &procEntry))
        {
            do
            {
                if (!_stricmp(procEntry.szExeFile, procName))
                {
                    procId = procEntry.th32ProcessID;
                    break;
                }
            } while (Process32Next(hSnap, &procEntry));
        }
    }
    CloseHandle(hSnap);
    return procId;
}

int main()
{
    const char* dllPath = "C:\\Users\\'%USERNAME%'\\Desktop\\dll.dll"; //
    const char* procName = "processname.exe"; //
    DWORD procId = 0;

    while (!procId)
    {
        procId = GetProcId(procName);
        Sleep(30);
    }

    HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, procId);

    if (hProc && hProc != INVALID_HANDLE_VALUE)
    {
        void* loc = VirtualAllocEx(hProc, 0, MAX_PATH, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);

        WriteProcessMemory(hProc, loc, dllPath, strlen(dllPath) + 1, 0);

        HANDLE hThread = CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)LoadLibraryA, loc, 0, 0);

        if (hThread)
        {
            CloseHandle(hThread);
        }
    }

    if (hProc)
    {
        CloseHandle(hProc);
    }
    return 0;
}

To hide processes from Task Manager you need to hook NtQuerySystemInformation() and if the argument SYSTEM_PROCESS_INFORMATION is used, you need to remove your process from the linked list of processes.

This is what your hook would look like:

// Hooked function
NTSTATUS WINAPI HookedNtQuerySystemInformation(
    __in       SYSTEM_INFORMATION_CLASS SystemInformationClass,
    __inout    PVOID                    SystemInformation,
    __in       ULONG                    SystemInformationLength,
    __out_opt  PULONG                   ReturnLength
)
{
    NTSTATUS status = OriginalNtQuerySystemInformation(SystemInformationClass,
        SystemInformation,
        SystemInformationLength,
        ReturnLength);
    if (SystemProcessInformation == SystemInformationClass && STATUS_SUCCESS == status)
    {
        // Loop through the list of processes
        PMY_SYSTEM_PROCESS_INFORMATION pCurrent = NULL;
        PMY_SYSTEM_PROCESS_INFORMATION pNext = (PMY_SYSTEM_PROCESS_INFORMATION)
            SystemInformation;

        do
        {
            pCurrent = pNext;
            pNext = (PMY_SYSTEM_PROCESS_INFORMATION)((PUCHAR)pCurrent + pCurrent->
                NextEntryOffset);
            if (!wcsncmp(pNext->ImageName.Buffer, L"notepad.exe", pNext->ImageName.Length))
            {
                if (!pNext->NextEntryOffset)
                {
                    pCurrent->NextEntryOffset = 0;
                }
                else
                {
                    pCurrent->NextEntryOffset += pNext->NextEntryOffset;
                }
                pNext = pCurrent;
            }
        } while (pCurrent->NextEntryOffset != 0);
    }
    return status;
}


问:
Error Insert into a table with data from XML in SQL Server
My stored procedure to insert data in XML to the table CCobro, doesn't work and it doesn't throw any error.
I think it is because in the table I have column Activo, which is not null, and in the XML file this attribute is not there.
So maybe it is the problem. I don't know how can I combine the XML data with my own data.

Table where the data must be insert:

```<code>CREATE TABLE [dbo].[CCobro](
    [ID] [int] NOT NULL,
    [Nombre] [varchar](100) NOT NULL,
    [TasaInteresMoratorio] [real] NOT NULL,
    [DiaEmisionRecibo] [tinyint] NOT NULL,
    [QDiasVencimiento] [tinyint] NOT NULL,
    [EsImpuesto] [varchar](10) NULL,
    [EsRecurrente] [varchar](10) NULL,
    [EsFijo] [varchar](10) NULL,
    [TipoCC] [varchar](30) NOT NULL,
    [Activo] [bit] NOT NULL,
    CONSTRAINT [PK_Concepto Cobro] PRIMARY KEY CLUSTERED
    (
        [ID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
     ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
</code>```

Stored Procedure to insert into CCobro table:

```<code>CREATE OR ALTER PROCEDURE [dbo].[spCargarDatosCC]

AS
BEGIN
    SET NOCOUNT ON;

    -- VARIABLES --
    DECLARE @DocHandle int, @temp xml, @CCobro xml

    BEGIN TRY
        --Insercion de los tipos de documentos de identificacion
        SELECT @CCobro = CC
        FROM OPENROWSET (Bulk 'D:\Base de datos\FacturacionMunicipal_BD\Base de Datos\XML\Concepto_de_Cobro.xml', Single_BLOB) AS CCobro(CC)
        EXEC sp_xml_preparedocument @DocHandle OUTPUT, @CCobro

        INSERT INTO CCobro (ID, Nombre, TasaInteresMoratorio, DiaEmisionRecibo, QDiasVencimiento, EsImpuesto, EsRecurrente, EsFijo, TipoCC)
        SELECT *
        FROM OPENXML(@DocHandle, '/Conceptos_de_Cobro/conceptocobro', 1)
        WITH
        (
            ID int '@id' ,
            Nombre VARCHAR(100) '@Nombre',
            TasaInteresMoratorio real '@TasaInteresMoratoria',
            DiaEmisionRecibo tinyint '@DiaCobro',
            QDiasVencimiento tinyint '@QDiasVencimiento',
            EsImpuesto varchar(10) '@EsImpuesto',
            EsRecurrente varchar(10) '@EsRecurrente',
            EsFijo varchar(10) '@EsFijo',
            TipoCC varchar(30) '@TipoCC'
        )

        EXEC sp_xml_removedocument @DocHandle

    END TRY

    BEGIN CATCH
        return @@ERROR * -1
    END CATCH
 END
</code>```

In this line

```<code>INSERT INTO CCobro (ID, Nombre, TasaInteresMoratorio, DiaEmisionRecibo, QDiasVencimiento, EsImpuesto, EsRecurrente, EsFijo, TipoCC)
</code>```

I don't enter the Activo column because the xml doesn't have this attribute. But I want to insert a 1, every time that a new data is insert.

The xml file:

```<code><Conceptos_de_Cobro>
    <conceptocobro id="1" Nombre="Agua" DiaCobro="25" QDiasVencimiento="4" EsImpuesto="No" EsRecurrente="Si" EsFijo="No" TasaInteresMoratoria="5.2" TipoCC="CC Consumo" Monto="" ValorM3="500" ValorPorcentaje="" />
    <conceptocobro id="2" Nombre="Patente Licores" DiaCobro="8" QDiasVencimiento="12" EsImpuesto="Si" EsRecurrente="No" EsFijo="No" TasaInteresMoratoria="2.6" TipoCC="CC Fijo" Monto="50000" ValorM3="" ValorPorcentaje="" />
    <conceptocobro id="3" Nombre="impuesto Propiedad" DiaCobro="8" QDiasVencimiento="12" EsImpuesto="Si" EsRecurrente="No" EsFijo="Si" TasaInteresMoratoria="1.5" TipoCC="CC Porcentual" Monto="" ValorM3="" ValorPorcentaje="0.25" />
    <conceptocobro id="4" Nombre="Recolectar Basura" DiaCobro="4" QDiasVencimiento="5" EsImpuesto="No" EsRecurrente="Si" EsFijo="Si" TasaInteresMoratoria="2.2" TipoCC="CC Fijo" Monto="3000" ValorM3="" ValorPorcentaje="" />
    <conceptocobro id="5" Nombre="Mantenimiento de Parques" DiaCobro="3" QDiasVencimiento="7" EsImpuesto="Si" EsRecurrente="Si" EsFijo="Si" TasaInteresMoratoria="0.87" TipoCC="CC Fijo" Monto="970" ValorM3="" ValorPorcentaje="" />
    <conceptocobro id="6" Nombre="Reconexion de Agua" DiaCobro="15" QDiasVencimiento="10" EsImpuesto="No" EsRecurrente="No" EsFijo="Si" TasaInteresMoratoria="3.8" TipoCC="CC Fijo" Monto="780" ValorM3="" ValorPorcentaje="" />
    <conceptocobro id="7" Nombre="Impuesto a la Renta" DiaCobro="5" QDiasVencimiento="15" EsImpuesto="Si" EsRecurrente="Si" EsFijo="No" TasaInteresMoratoria="12.6" TipoCC="CC Porcentual" Monto="" ValorM3="" ValorPorcentaje="0.15" />
    <conceptocobro id="8" Nombre="Mantenimiento de Parques" DiaCobro="7" QDiasVencimiento="6" EsImpuesto="No" EsRecurrente="Si" EsFijo="Si" TasaInteresMoratoria="0.32" TipoCC="CC Fijo" Monto="7850" ValorM3="" ValorPorcentaje="" />
   <conceptocobro id="9" Nombre="Aseo de sitios Publico" DiaCobro="1" QDiasVencimiento="10" EsImpuesto="No" EsRecurrente="Si" EsFijo="Si" TasaInteresMoratoria="7.8" TipoCC="CC Fijo" Monto="580" ValorM3="" ValorPorcentaje="" />
</Conceptos_de_Cobro>
</code>```

答:
Microsoft proprietary OPENXML and its companions sp_xml_preparedocument  and sp_xml_removedocument are kept just for backward compatibility with the obsolete SQL Server 2000.

Starting from SQL Server 2005 onwards, it is better to start using using SQL Server XML data type methods and XQuery.
So the stored procedure would be as follows:

SQL

```<code>CREATE OR ALTER PROCEDURE [dbo].[spCargarDatosCC]
AS
BEGIN
    SET NOCOUNT ON;

    -- VARIABLES --
    DECLARE @CCobro xml

    BEGIN TRY
        --Insercion de los tipos de documentos de identificacion
        SELECT @CCobro = CC
        FROM OPENROWSET (Bulk 'D:\Base de datos\FacturacionMunicipal_BD\Base de Datos\XML\Concepto_de_Cobro.xml', Single_BLOB) AS CCobro(CC)

        INSERT INTO CCobro (ID, Nombre, TasaInteresMoratorio, DiaEmisionRecibo, QDiasVencimiento, EsImpuesto, EsRecurrente, EsFijo, TipoCC, Activo)
        SELECT c.value('@id','INT') AS ID
            , c.value('@Nombre','VARCHAR(100)') AS Nombre
            , c.value('@TasaInteresMoratoria','DECIMAL(10,2)') AS TasaInteresMoratorio
            , c.value('@DiaCobro','TINYINT') AS DiaEmisionRecibo
            , c.value('@QDiasVencimiento','TINYINT') AS QDiasVencimiento
            , c.value('@EsImpuesto','VARCHAR(10)') AS EsImpuesto
            , c.value('@EsRecurrente','VARCHAR(10)') AS EsRecurrente
            , c.value('@EsFijo','VARCHAR(10)') AS EsFijo
            , c.value('@TipoCC','VARCHAR(10)') AS TipoCC
            , 1 AS Activo
        FROM @CCobro.nodes('/Conceptos_de_Cobro/conceptocobro') AS t(c);

    END TRY

    BEGIN CATCH
        return @@ERROR * -1
    END CATCH
 END
</code>```

Body:
My stored procedure to insert data in XML to the table CCobro, doesn't work and it doesn't throw any error.
I think it is because in the table I have column Activo, which is not null, and in the XML file this attribute is not there.
So maybe it is the problem. I don't know how can I combine the XML data with my own data.

Table where the data must be insert:

CREATE TABLE [dbo].[CCobro](
    [ID] [int] NOT NULL,
    [Nombre] [varchar](100) NOT NULL,
    [TasaInteresMoratorio] [real] NOT NULL,
    [DiaEmisionRecibo] [tinyint] NOT NULL,
    [QDiasVencimiento] [tinyint] NOT NULL,
    [EsImpuesto] [varchar](10) NULL,
    [EsRecurrente] [varchar](10) NULL,
    [EsFijo] [varchar](10) NULL,
    [TipoCC] [varchar](30) NOT NULL,
    [Activo] [bit] NOT NULL,
    CONSTRAINT [PK_Concepto Cobro] PRIMARY KEY CLUSTERED
    (
        [ID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
     ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

Stored Procedure to insert into CCobro table:

CREATE OR ALTER PROCEDURE [dbo].[spCargarDatosCC]

AS
BEGIN
    SET NOCOUNT ON;

    -- VARIABLES --
    DECLARE @DocHandle int, @temp xml, @CCobro xml

    BEGIN TRY
        --Insercion de los tipos de documentos de identificacion
        SELECT @CCobro = CC
        FROM OPENROWSET (Bulk 'D:\Base de datos\FacturacionMunicipal_BD\Base de Datos\XML\Concepto_de_Cobro.xml', Single_BLOB) AS CCobro(CC)
        EXEC sp_xml_preparedocument @DocHandle OUTPUT, @CCobro

        INSERT INTO CCobro (ID, Nombre, TasaInteresMoratorio, DiaEmisionRecibo, QDiasVencimiento, EsImpuesto, EsRecurrente, EsFijo, TipoCC)
        SELECT *
        FROM OPENXML(@DocHandle, '/Conceptos_de_Cobro/conceptocobro', 1)
        WITH
        (
            ID int '@id' ,
            Nombre VARCHAR(100) '@Nombre',
            TasaInteresMoratorio real '@TasaInteresMoratoria',
            DiaEmisionRecibo tinyint '@DiaCobro',
            QDiasVencimiento tinyint '@QDiasVencimiento',
            EsImpuesto varchar(10) '@EsImpuesto',
            EsRecurrente varchar(10) '@EsRecurrente',
            EsFijo varchar(10) '@EsFijo',
            TipoCC varchar(30) '@TipoCC'
        )

        EXEC sp_xml_removedocument @DocHandle

    END TRY

    BEGIN CATCH
        return @@ERROR * -1
    END CATCH
 END

In this line

INSERT INTO CCobro (ID, Nombre, TasaInteresMoratorio, DiaEmisionRecibo, QDiasVencimiento, EsImpuesto, EsRecurrente, EsFijo, TipoCC)

I don't enter the Activo column because the xml doesn't have this attribute. But I want to insert a 1, every time that a new data is insert.

The xml file:

<Conceptos_de_Cobro>
    <conceptocobro id="1" Nombre="Agua" DiaCobro="25" QDiasVencimiento="4" EsImpuesto="No" EsRecurrente="Si" EsFijo="No" TasaInteresMoratoria="5.2" TipoCC="CC Consumo" Monto="" ValorM3="500" ValorPorcentaje="" />
    <conceptocobro id="2" Nombre="Patente Licores" DiaCobro="8" QDiasVencimiento="12" EsImpuesto="Si" EsRecurrente="No" EsFijo="No" TasaInteresMoratoria="2.6" TipoCC="CC Fijo" Monto="50000" ValorM3="" ValorPorcentaje="" />
    <conceptocobro id="3" Nombre="impuesto Propiedad" DiaCobro="8" QDiasVencimiento="12" EsImpuesto="Si" EsRecurrente="No" EsFijo="Si" TasaInteresMoratoria="1.5" TipoCC="CC Porcentual" Monto="" ValorM3="" ValorPorcentaje="0.25" />
    <conceptocobro id="4" Nombre="Recolectar Basura" DiaCobro="4" QDiasVencimiento="5" EsImpuesto="No" EsRecurrente="Si" EsFijo="Si" TasaInteresMoratoria="2.2" TipoCC="CC Fijo" Monto="3000" ValorM3="" ValorPorcentaje="" />
    <conceptocobro id="5" Nombre="Mantenimiento de Parques" DiaCobro="3" QDiasVencimiento="7" EsImpuesto="Si" EsRecurrente="Si" EsFijo="Si" TasaInteresMoratoria="0.87" TipoCC="CC Fijo" Monto="970" ValorM3="" ValorPorcentaje="" />
    <conceptocobro id="6" Nombre="Reconexion de Agua" DiaCobro="15" QDiasVencimiento="10" EsImpuesto="No" EsRecurrente="No" EsFijo="Si" TasaInteresMoratoria="3.8" TipoCC="CC Fijo" Monto="780" ValorM3="" ValorPorcentaje="" />
    <conceptocobro id="7" Nombre="Impuesto a la Renta" DiaCobro="5" QDiasVencimiento="15" EsImpuesto="Si" EsRecurrente="Si" EsFijo="No" TasaInteresMoratoria="12.6" TipoCC="CC Porcentual" Monto="" ValorM3="" ValorPorcentaje="0.15" />
    <conceptocobro id="8" Nombre="Mantenimiento de Parques" DiaCobro="7" QDiasVencimiento="6" EsImpuesto="No" EsRecurrente="Si" EsFijo="Si" TasaInteresMoratoria="0.32" TipoCC="CC Fijo" Monto="7850" ValorM3="" ValorPorcentaje="" />
   <conceptocobro id="9" Nombre="Aseo de sitios Publico" DiaCobro="1" QDiasVencimiento="10" EsImpuesto="No" EsRecurrente="Si" EsFijo="Si" TasaInteresMoratoria="7.8" TipoCC="CC Fijo" Monto="580" ValorM3="" ValorPorcentaje="" />
</Conceptos_de_Cobro>

Body:
Microsoft proprietary OPENXML and its companions sp_xml_preparedocument  and sp_xml_removedocument are kept just for backward compatibility with the obsolete SQL Server 2000.

Starting from SQL Server 2005 onwards, it is better to start using using SQL Server XML data type methods and XQuery.
So the stored procedure would be as follows:

SQL

CREATE OR ALTER PROCEDURE [dbo].[spCargarDatosCC]
AS
BEGIN
    SET NOCOUNT ON;

    -- VARIABLES --
    DECLARE @CCobro xml

    BEGIN TRY
        --Insercion de los tipos de documentos de identificacion
        SELECT @CCobro = CC
        FROM OPENROWSET (Bulk 'D:\Base de datos\FacturacionMunicipal_BD\Base de Datos\XML\Concepto_de_Cobro.xml', Single_BLOB) AS CCobro(CC)

        INSERT INTO CCobro (ID, Nombre, TasaInteresMoratorio, DiaEmisionRecibo, QDiasVencimiento, EsImpuesto, EsRecurrente, EsFijo, TipoCC, Activo)
        SELECT c.value('@id','INT') AS ID
            , c.value('@Nombre','VARCHAR(100)') AS Nombre
            , c.value('@TasaInteresMoratoria','DECIMAL(10,2)') AS TasaInteresMoratorio
            , c.value('@DiaCobro','TINYINT') AS DiaEmisionRecibo
            , c.value('@QDiasVencimiento','TINYINT') AS QDiasVencimiento
            , c.value('@EsImpuesto','VARCHAR(10)') AS EsImpuesto
            , c.value('@EsRecurrente','VARCHAR(10)') AS EsRecurrente
            , c.value('@EsFijo','VARCHAR(10)') AS EsFijo
            , c.value('@TipoCC','VARCHAR(10)') AS TipoCC
            , 1 AS Activo
        FROM @CCobro.nodes('/Conceptos_de_Cobro/conceptocobro') AS t(c);

    END TRY

    BEGIN CATCH
        return @@ERROR * -1
    END CATCH
 END


问:
Executing multiple case using PHP switch statement
I have to execute multiple set of instructions based upon a value, for example.

```<code>$value = 'AA';
switch ($value) {
    case 'AA':
        echo "value equals  1";
    continue;
    case 'BB':
        echo "value equals 2";
    continue;
    case 'CC' || 'AA':
        echo "value equals 3";
    break;
}
</code>```

What i am expecting from the above code is it should execute multiple cases based upon the values passed, the variable $value contains AA as the value so hence i am expecting it to execute both

case 'AA' and

case 'CC' || 'AA'

so it should print out value equals  1 value equals 3 however it does not execute it that way i am getting only value equals 1 as output. and if i remove continue from the statement it executes all three cases which is logically wrong.  does the PHP's switch statement support multiple cases to be executed based on a single value? is there any workaround for this?

thank you..

答:
```<code>$value = 'AA';
switch ($value) {
    case 'AA':
        echo "value equals 1";
        echo "value equals 3";
    break;
    case 'BB':
        echo "value equals 2";
    break;
    case 'CC':
        echo "value equals 3";
    break;
}
</code>```

Body:
I have to execute multiple set of instructions based upon a value, for example.

$value = 'AA';
switch ($value) {
    case 'AA':
        echo "value equals  1";
    continue;
    case 'BB':
        echo "value equals 2";
    continue;
    case 'CC' || 'AA':
        echo "value equals 3";
    break;
}

What i am expecting from the above code is it should execute multiple cases based upon the values passed, the variable $value contains AA as the value so hence i am expecting it to execute both

case 'AA' and

case 'CC' || 'AA'

so it should print out value equals  1 value equals 3 however it does not execute it that way i am getting only value equals 1 as output. and if i remove continue from the statement it executes all three cases which is logically wrong.  does the PHP's switch statement support multiple cases to be executed based on a single value? is there any workaround for this?

thank you..


问:
How should I externally call a method contained in the "Main" class in JavaFX?
I have a method called changeScene() that I want to be able to call from a separate controller class. For example, when the "settings" button is pressed on the initial scene, the controller class of the fxml file for the initial scene needs to call Main.changeScene("settings.fxml").

Current code of the Main class (no errors):

```<code>public class Main extends Application {

    private Stage window;
    private Scene home, editor;

    public static void main(String[] args){
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        window = stage;

        Parent root = FXMLLoader.load(getClass().getResource("/Scenes/MainPage.fxml"));
        home = new Scene(root, 640, 400);

        window.setTitle("Home");
        window.setScene(home);
        window.show();
    }

    //Method I want to be able to call externally
    public void changeScene(String fxml) throws Exception{
        Parent pane = FXMLLoader.load(
               getClass().getResource(fxml));

       Scene scene = new Scene(pane);
       window.getScene().setRoot(pane);
    }
}
</code>```

My initial thought was to simply add a constructor to the Main class in order to make it initalizeable and call the method that way, but I doubt that's the best solution. Thanks for the help in advance, I'm very knew to JavaFX.

答:
The best way I have seen to handle problems like this with JavaFX is to create an AbstractController class that your FXML controllers extend.

AbstractController.java

/**
 * Class for controllers to extend in order to get access to the primary stage
 */
public abstract class AbstractController
{
    /**
     * The primary stage accessible by derived classes.
     */
    protected Stage primaryStage;

    /**
     * Sets the primary stage.
     *
     * @param primaryStage the primary stage for the application
     */
    public void setPrimaryStage(Stage primaryStage)
    {
        this.primaryStage = primaryStage;
    }
}

```

<p>Assuming your FXML controller class is <em>MainController.java</em> for MainPage.fxml, update it to extend AbstractController and then update your Main::start function like so:</p>

<pre class="lang-java prettyprint-override"><code>        FXMLLoader loader = new FXMLLoader(getClass().getResource("/Scenes/MainPage.fxml"));
        Parent root = (Parent)loader.load();
        AbstractController controller = (AbstractController)loader.getController();
        controller.setPrimaryStage(window);
</code>```

At this point, your MainController has access to the primary stage (i.e "window" as you have it named).  If you move the changeScene function to AbstractController, then all controllers that extend AbstractController will have access to changeScene().  Don't forget to update changeScene() to call SetPrimaryStage for each FXML file loaded just like in Main::start

Body:
I have a method called changeScene() that I want to be able to call from a separate controller class. For example, when the "settings" button is pressed on the initial scene, the controller class of the fxml file for the initial scene needs to call Main.changeScene("settings.fxml").

Current code of the Main class (no errors):

public class Main extends Application {

    private Stage window;
    private Scene home, editor;

    public static void main(String[] args){
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        window = stage;

        Parent root = FXMLLoader.load(getClass().getResource("/Scenes/MainPage.fxml"));
        home = new Scene(root, 640, 400);

        window.setTitle("Home");
        window.setScene(home);
        window.show();
    }

    //Method I want to be able to call externally
    public void changeScene(String fxml) throws Exception{
        Parent pane = FXMLLoader.load(
               getClass().getResource(fxml));

       Scene scene = new Scene(pane);
       window.getScene().setRoot(pane);
    }
}

My initial thought was to simply add a constructor to the Main class in order to make it initalizeable and call the method that way, but I doubt that's the best solution. Thanks for the help in advance, I'm very knew to JavaFX.

Body:
The best way I have seen to handle problems like this with JavaFX is to create an AbstractController class that your FXML controllers extend.

AbstractController.java

/**
 * Class for controllers to extend in order to get access to the primary stage
 */
public abstract class AbstractController
{
    /**
     * The primary stage accessible by derived classes.
     */
    protected Stage primaryStage;

    /**
     * Sets the primary stage.
     *
     * @param primaryStage the primary stage for the application
     */
    public void setPrimaryStage(Stage primaryStage)
    {
        this.primaryStage = primaryStage;
    }
}

Assuming your FXML controller class is MainController.java for MainPage.fxml, update it to extend AbstractController and then update your Main::start function like so:

        FXMLLoader loader = new FXMLLoader(getClass().getResource("/Scenes/MainPage.fxml"));
        Parent root = (Parent)loader.load();
        AbstractController controller = (AbstractController)loader.getController();
        controller.setPrimaryStage(window);

At this point, your MainController has access to the primary stage (i.e "window" as you have it named).  If you move the changeScene function to AbstractController, then all controllers that extend AbstractController will have access to changeScene().  Don't forget to update changeScene() to call SetPrimaryStage for each FXML file loaded just like in Main::start


问:
How to find specific strings in a file?
This is a script that I have written to find all the lines with usb in it. However, the problem is that if also returns lines if they have words such as usbcore as well. I am interested in lines that contain only the words usb.</p>

```<code>#!/usr/bin/python

import sys

logFile = open(sys.argv[1])

print("Printing all lines with USB in it...")

for line in logFile.readlines():
    if line.lower().find('usb') != -1:
        print(line)

print('Done!')
</code>```

答:
Here`s a one-liner:</p>

```<code>with open(sys.arg[1]) as f:
    print(''.join([l for l in f.readlines() if ' ubs ' in l.lower()])
</code>```

Title: How to find specific strings in a file?

Body:
This is a script that I have written to find all the lines with usb in it. However, the problem is that if also returns lines if they have words such as usbcore as well. I am interested in lines that contain only the words usb.

#!/usr/bin/python

import sys

logFile = open(sys.argv[1])

print("Printing all lines with USB in it...")

for line in logFile.readlines():
    if line.lower().find('usb') != -1:
        print(line)

print('Done!')

Body:
Here`s a one-liner:

with open(sys.arg[1]) as f:
    print(''.join([l for l in f.readlines() if ' ubs ' in l.lower()])


问:
check if database exits in union sql server
i want to union query from multiple database. but before union i want to check if database exits then union, if second database exits then union and so on...

```<code>IF EXISTS(SELECT * FROM sys.sysdatabases where name='FirstDB')
select * from FirstDB.dbo.tablename
union
IF EXISTS(SELECT * FROM sys.sysdatabases where name='SecondDB')
select * from SecondDB.dbo.tablename.
</code>```

How to do that.
Thanks in advance.

答:
Define a view with a fixed name in each server:
In FirstDB server:

```<code>CREATE DATABASE SOME_DATABASE;
CREATE VIEW SOME_DATABASE.FIXED_TABLENAME AS SELECT * FROM FirstDB.dbo.tablename
</code>```

In SecondDB server:

```<code>CREATE DATABASE SOME_DATABASE;
CREATE VIEW SOME_DATABASE.FIXED_TABLENAME AS SELECT * FROM SecondDB.dbo.tablename
</code>```

In code in either DB:

```<code>SELECT * FROM SOME_DATABASE.FIXED_TABLENAME;
</code>```

Body:
i want to union query from multiple database. but before union i want to check if database exits then union, if second database exits then union and so on...

IF EXISTS(SELECT * FROM sys.sysdatabases where name='FirstDB')
select * from FirstDB.dbo.tablename
union
IF EXISTS(SELECT * FROM sys.sysdatabases where name='SecondDB')
select * from SecondDB.dbo.tablename.

How to do that.
Thanks in advance.

Body:
Define a view with a fixed name in each server:
In FirstDB server:

CREATE DATABASE SOME_DATABASE;
CREATE VIEW SOME_DATABASE.FIXED_TABLENAME AS SELECT * FROM FirstDB.dbo.tablename

In SecondDB server:

CREATE DATABASE SOME_DATABASE;
CREATE VIEW SOME_DATABASE.FIXED_TABLENAME AS SELECT * FROM SecondDB.dbo.tablename

In code in either DB:

SELECT * FROM SOME_DATABASE.FIXED_TABLENAME;


问:
The data from Firestore database is not displayed in the tableview
I'm using Swift and Firestore database to implement an app like Twitter.

I want to add sweet (it's like tweet) when button is clicked to the database. And then display it in the tableview.
The data is added to the database. But is not displayed in the tableview. So when I run an app I see empty tableview.

Please help!!

TableViewController file:

```<code>import UIKit
import FirebaseFirestore
import Firebase

class TableViewController: UITableViewController {

    var db:Firestore!

    var sweetArray = [Sweet]()

    override func viewDidLoad() {
        super.viewDidLoad()

        db = Firestore.firestore()

        loadData()
    }

    func loadData() {
        db.collection("sweets").getDocuments() {
            querySnapshot, error in

            if let error = error {

                print("Error loading documents to the db: \(error.localizedDescription)")

            } else {

                self.sweetArray = querySnapshot!.documents.flatMap({Sweet(dictionary: $0.data())})

                DispatchQueue.main.async {
                    self.tableView.reloadData()
                }

            }
        }
    }

    @IBAction func composeSweet(_ sender: Any) {

           let composeAlert = UIAlertController(title: "New Sweet", message: "Enter your name and message", preferredStyle: .alert)

           composeAlert.addTextField { (textField:UITextField) in
               textField.placeholder = "Your name"
           }

           composeAlert.addTextField { (textField:UITextField) in
               textField.placeholder = "Your message"
           }

           composeAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
           composeAlert.addAction(UIAlertAction(title: "Send", style: .default, handler: { (action:UIAlertAction) in

            if let name = composeAlert.textFields?.first?.text, let content = composeAlert.textFields?.last?.text {
                let newSweet = Sweet(name: name, content: content, timeStamp: Date())

                var ref:DocumentReference? = nil
                ref = self.db.collection("sweets").addDocument(data: newSweet.dictionary) {
                    error in

                    if let error = error {
                        print("Error adding document: \(error.localizedDescription)")
                    } else {
                        print("Document added with ID: \(ref!.documentID)")
                    }
                }
            }
           }))

           self.present(composeAlert, animated: true, completion: nil)

       }

       override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
       }

       override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
           return sweetArray.count
       }

       override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)

        let sweet = sweetArray[indexPath.row]

        cell.textLabel?.text = "\(sweet.name) : \(sweet.content)"

        cell.detailTextLabel?.text = "\(sweet.timeStamp)"

        return cell
       }

}
</code>```

Sweet file:

```<code>import Foundation
import FirebaseFirestore

protocol DocumentSerializable {
    init?(dictionary:[String:Any])
}

struct Sweet {
    var name: String
    var content: String
    var timeStamp: Date

    var dictionary:[String:Any] {
        return [
            "name": name,
            "content": content,
            "timeStamp": timeStamp
        ]
    }
}

extension Sweet:DocumentSerializable {
    init?(dictionary: [String : Any]) {
        guard let name = dictionary["name"] as? String,
            let content = dictionary["content"] as? String,
            let timeStamp = dictionary["timeStamp"] as? Date else {return nil}

        self.init(name: name, content: content, timeStamp: timeStamp)
    }
}
</code>```

My storyboards:

My running app:

答:
Seems you have data in querySnapshot but empty in sweetArray which means only one this your are parsing and mapping the data received into structs incorrectly. Modify this line to fix your issue:

self.sweetArray = querySnapshot!.documents.flatMap({Sweet(dictionary: $0.data())})
```

Body:
I'm using Swift and Firestore database to implement an app like Twitter.

I want to add sweet (it's like tweet) when button is clicked to the database. And then display it in the tableview.
The data is added to the database. But is not displayed in the tableview. So when I run an app I see empty tableview.

Please help!!

TableViewController file:

import UIKit
import FirebaseFirestore
import Firebase

class TableViewController: UITableViewController {

    var db:Firestore!

    var sweetArray = [Sweet]()

    override func viewDidLoad() {
        super.viewDidLoad()

        db = Firestore.firestore()

        loadData()
    }

    func loadData() {
        db.collection("sweets").getDocuments() {
            querySnapshot, error in

            if let error = error {

                print("Error loading documents to the db: \(error.localizedDescription)")

            } else {

                self.sweetArray = querySnapshot!.documents.flatMap({Sweet(dictionary: $0.data())})

                DispatchQueue.main.async {
                    self.tableView.reloadData()
                }

            }
        }
    }

    @IBAction func composeSweet(_ sender: Any) {

           let composeAlert = UIAlertController(title: "New Sweet", message: "Enter your name and message", preferredStyle: .alert)

           composeAlert.addTextField { (textField:UITextField) in
               textField.placeholder = "Your name"
           }

           composeAlert.addTextField { (textField:UITextField) in
               textField.placeholder = "Your message"
           }

           composeAlert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
           composeAlert.addAction(UIAlertAction(title: "Send", style: .default, handler: { (action:UIAlertAction) in

            if let name = composeAlert.textFields?.first?.text, let content = composeAlert.textFields?.last?.text {
                let newSweet = Sweet(name: name, content: content, timeStamp: Date())

                var ref:DocumentReference? = nil
                ref = self.db.collection("sweets").addDocument(data: newSweet.dictionary) {
                    error in

                    if let error = error {
                        print("Error adding document: \(error.localizedDescription)")
                    } else {
                        print("Document added with ID: \(ref!.documentID)")
                    }
                }
            }
           }))

           self.present(composeAlert, animated: true, completion: nil)

       }

       override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
       }

       override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
           return sweetArray.count
       }

       override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)

        let sweet = sweetArray[indexPath.row]

        cell.textLabel?.text = "\(sweet.name) : \(sweet.content)"

        cell.detailTextLabel?.text = "\(sweet.timeStamp)"

        return cell
       }

}

Sweet file:

import Foundation
import FirebaseFirestore

protocol DocumentSerializable {
    init?(dictionary:[String:Any])
}

struct Sweet {
    var name: String
    var content: String
    var timeStamp: Date

    var dictionary:[String:Any] {
        return [
            "name": name,
            "content": content,
            "timeStamp": timeStamp
        ]
    }
}

extension Sweet:DocumentSerializable {
    init?(dictionary: [String : Any]) {
        guard let name = dictionary["name"] as? String,
            let content = dictionary["content"] as? String,
            let timeStamp = dictionary["timeStamp"] as? Date else {return nil}

        self.init(name: name, content: content, timeStamp: timeStamp)
    }
}

My storyboards:

My running app:


问:
How to convert Time into decimal float in Google Sheets using Script?
I want to convert the time HH:MM into H.xx

Like I am getting it in this format: Sat Dec 30 00:00:00 GMT+05:21 1899

But this value is 04:29 in cell. I want it to be 4.5 hours to multiply it to hourly rate.

答:
All you need is TO_PURE_NUMBER()

https://support.google.com/docs/answer/3094243?hl=en

Example:

```<code>// The following
A1=DATEVALUE("2020-05-18 06:09:18.821 ")+TIMEVALUE("2020-05-18 06:09:18.821 ")
A2=TO_PURE_NUMBER(A1)
A3=TO_DATE(A2)

// Results in the following, first result is just a formatted date
2020-05-18 6:09:19
43969.25647
5/18/2020
</code>```

Body:
All you need is TO_PURE_NUMBER()

https://support.google.com/docs/answer/3094243?hl=en

Example:

// The following
A1=DATEVALUE("2020-05-18 06:09:18.821 ")+TIMEVALUE("2020-05-18 06:09:18.821 ")
A2=TO_PURE_NUMBER(A1)
A3=TO_DATE(A2)

// Results in the following, first result is just a formatted date
2020-05-18 6:09:19
43969.25647
5/18/2020