问:
Hibernate XML configuration on OpenJ9 (JDK14)
I'm trying trying to load Hibernate XML configuration on OpenJ9 (JDK14) but since JAXB are not longer part of the JDK I get this error:

```<code>Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationEventHandler
</code>```

I tried to follow some of the answers on: How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9 but it seems like none are working on OpenJ9 and when trying to include any of the dependencies I'm getting the following error:

```<code>Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
 - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:278)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:421)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662)
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:122)
    ... 5 more
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:788)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:1081)
    at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122)
    at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:276)
    ... 9 more

</code>```

答:
I found the missing part in the puzzle, the javax.xml.bind.JAXBContextFactory needs to be set in the system property.

So the solution is adding JAXB to list of dependencies:

```<code>        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.moxy</artifactId>
            <version>2.7.3</version>
        </dependency>
</code>```

And then in the code (or when the JVM starts) set the system property to point to the right factory.

```<code>    System.setProperty("javax.xml.bind.JAXBContextFactory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
</code>```

Last since I'm running in a custom classloader the ContextClassLoader has to be set otherwise the factory can't be found.

```<code>Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
</code>```

Body:
I'm trying trying to load Hibernate XML configuration on OpenJ9 (JDK14) but since JAXB are not longer part of the JDK I get this error:

Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationEventHandler

I tried to follow some of the answers on: How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9 but it seems like none are working on OpenJ9 and when trying to include any of the dependencies I'm getting the following error:

Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
 - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:278)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:421)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662)
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:122)
    ... 5 more
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:788)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:1081)
    at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122)
    at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:276)
    ... 9 more

Body:
I found the missing part in the puzzle, the javax.xml.bind.JAXBContextFactory needs to be set in the system property.

So the solution is adding JAXB to list of dependencies:

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.moxy</artifactId>
            <version>2.7.3</version>
        </dependency>

And then in the code (or when the JVM starts) set the system property to point to the right factory.

    System.setProperty("javax.xml.bind.JAXBContextFactory", "org.eclipse.persistence.jaxb.JAXBContextFactory");

Last since I'm running in a custom classloader the ContextClassLoader has to be set otherwise the factory can't be found.

Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());


来源: stackexchange

问:
JQUERY: How to change the input value by clicking a button with a generic JQuery
I'm not an expert in JQuery but I'm trying to get a value from a button - when the user click a button and the input field will change the value.

But, I can have many buttons.. (In same cases, more than 100) for this reason I want to know if it's possible to get the value from the clicked button with a "generic" JQuery - to avoid a big JQuery with a $('#answer').val() for each button..

https://jsfiddle.net/Ldy01wb2/1/

HTML:

```<code><input type="button" id ='one' value="A">
<input type="button" id ='two' value="B">
<br><br>
Hidden: <input type="text" id="answer" value="">
</code>```

JQUERY: (what I want)

```<code>$(':button').click(function(){
    $('#answer').val = $(':button').val ;
});
</code>```

JQUERY: (works.. but if I have 100, I need 100 functions.. and I'm trying to get a generic solution for all buttons)

```<code>$('#one').click(function(){
    $('#answer').val("A") ;
});

$('#two').click(function(){
    $('#answer').val("B") ;
});
</code>```

答:
$(this) gives you the button you clicked on, I guess that's all you need.

$('[type=button]').click(function(){
    $('#answer').val($(this).val()) ;
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="button" id='one' value="A">
<input type="button" id='two' value="B">
<br><br>
Hidden: <input type="text" id="answer" value=""></code>```

ContentLicense: CC BY-SA 4.0

Body:
I'm not an expert in JQuery but I'm trying to get a value from a button - when the user click a button and the input field will change the value.

But, I can have many buttons.. (In same cases, more than 100) for this reason I want to know if it's possible to get the value from the clicked button with a "generic" JQuery - to avoid a big JQuery with a $('#answer').val() for each button..

https://jsfiddle.net/Ldy01wb2/1/

HTML:

<input type="button" id ='one' value="A">
<input type="button" id ='two' value="B">

Hidden: <input type="text" id="answer" value="">

JQUERY: (what I want)

$(':button').click(function(){
    $('#answer').val = $(':button').val ;
});

JQUERY: (works.. but if I have 100, I need 100 functions.. and I'm trying to get a generic solution for all buttons)

$('#one').click(function(){
    $('#answer').val("A") ;
});

$('#two').click(function(){
    $('#answer').val("B") ;
});

Body:
$(this) gives you the button you clicked on, I guess that's all you need.

$('[type=button]').click(function(){
    $('#answer').val($(this).val()) ;
});

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="button" id='one' value="A">
<input type="button" id='two' value="B">
<br><br>
Hidden: <input type="text" id="answer" value="">


问:
How to add extra imports to my js files during compilation. Want to theme my react components
I want to configure the following set up for developing a react app and it's components with a possibility of css theming.

Each React component will have a separate js file, and will
explicitly import its corresponding "component.css" file.

The css explicitly imported in the js file will have the essential none themed css for that component.

At compile time I want Webpack to be configured with a theme name, and directories where it needs to look for the theme files.

During the loading of component js files, the compiler will detect the .css imports in the form of "component.css", for each of those imports it will look for a theme .css file in the form of "component.themename.css" in the configured directories and subdirectories.

If a theme file is found the compiler will add the import for that file into the js file being loaded.

With the above set up I want to be able to define theme css files for each of my components separately and then use the appropriate theme file according to a theme of my choosing.

Is there anything already available that would achieve something like this? What's the best way of implementing something like this? A loader? a plugin?

答:
I have managed to achieve the above quite nicely with a custom css webpack loader and plugin.

The plugin searches for available theme files in the given directories.

The loader is added to the start of the loader chain. It is configured with a theme name and a reference to an object containing theme files found by the plugin.

For every css file imported it looks for a theme file with the same name and a .theme. suffix. Eg. for component.css it will look for component.theme.css in the given directories.

If it finds a theme .css file it appends it's contents to the css being loaded, and adds the theme file to the webpack watched dependencies.

Here's the code to achieve this:

webpack.config.js

```<code>const themeLoaderPlugin = new ThemeLoaderPlugin({theme: "themeName", dirs: ["dir/to/search/for/themefiles"] });
const css = {
        test: /\.(css|s[ac]ss)$/,
        use: ['style-loader', 'css-loader',
                {
                loader: path.resolve('/path/to/loader.js'),
                options: {
                    theme: "themeName",
                    filesContainer: themeLoaderPlugin.getState()
                }
            }]
    };
const config = {
...
    plugins: [
        themeLoaderPlugin
    ]
}
</code>```

loader code:

```<code>const loaderUtils = require('loader-utils')
const fs = require('fs')
const path = require('path')

module.exports = function(source) {
    let options = loaderUtils.getOptions(this);
    let themeName = options.theme;
    let files = options.filesContainer.files;
    let fileName = this.resourcePath.match(/.*(\/|\\)(.*)\..*/)[2];
    let themeFileName = fileName + "." + themeName + ".";
    for (const file of files) {
        if(file.indexOf(themeFileName) >= 0){
            let contents = fs.readFileSync(file);
            source = source + "\n" +  contents.toString("UTF-8");
            this.dependency(path.resolve(file));
        }
    }
    return source;
};
</code>```

Plugin code:

```<code>const glob = require('fast-glob')

module.exports = class ThemeLoaderPlugin {
    constructor(options){
        this.options = options;
        this.state = {};
    }

    getState(){
        return this.state;
    }

    refreshFiles() {
        this.state.files = getThemeFiles(this.options.dirs, this.options.theme);
    }

    apply(compiler){
        compiler.hooks.beforeRun.tap("ThemeFilesScanPlugin", ()=>{
            this.refreshFiles();
        });
        compiler.hooks.watchRun.tap("ThemeFilesScanPlugin", () =>{
            this.refreshFiles();
        });
    }
};

function getThemeFiles(paths, themeName){
    let res = [];
    for (const path of paths) {
        let options = {
            cwd:path,
            ignore: "**/node_modules/**",
            absolute: true
        };
        res.push(...glob.sync("**/*." + themeName +".*", options));
    }
    return res;
}
</code>```

Body:
I have managed to achieve the above quite nicely with a custom css webpack loader and plugin.

The plugin searches for available theme files in the given directories.

The loader is added to the start of the loader chain. It is configured with a theme name and a reference to an object containing theme files found by the plugin.

For every css file imported it looks for a theme file with the same name and a .theme. suffix. Eg. for component.css it will look for component.theme.css in the given directories.

If it finds a theme .css file it appends it's contents to the css being loaded, and adds the theme file to the webpack watched dependencies.

Here's the code to achieve this:

webpack.config.js

const themeLoaderPlugin = new ThemeLoaderPlugin({theme: "themeName", dirs: ["dir/to/search/for/themefiles"] });
const css = {
        test: /\.(css|s[ac]ss)$/,
        use: ['style-loader', 'css-loader',
                {
                loader: path.resolve('/path/to/loader.js'),
                options: {
                    theme: "themeName",
                    filesContainer: themeLoaderPlugin.getState()
                }
            }]
    };
const config = {
...
    plugins: [
        themeLoaderPlugin
    ]
}

loader code:

const loaderUtils = require('loader-utils')
const fs = require('fs')
const path = require('path')

module.exports = function(source) {
    let options = loaderUtils.getOptions(this);
    let themeName = options.theme;
    let files = options.filesContainer.files;
    let fileName = this.resourcePath.match(/.*(\/|\\)(.*)\..*/)[2];
    let themeFileName = fileName + "." + themeName + ".";
    for (const file of files) {
        if(file.indexOf(themeFileName) >= 0){
            let contents = fs.readFileSync(file);
            source = source + "\n" +  contents.toString("UTF-8");
            this.dependency(path.resolve(file));
        }
    }
    return source;
};

Plugin code:

const glob = require('fast-glob')

module.exports = class ThemeLoaderPlugin {
    constructor(options){
        this.options = options;
        this.state = {};
    }

    getState(){
        return this.state;
    }

    refreshFiles() {
        this.state.files = getThemeFiles(this.options.dirs, this.options.theme);
    }

    apply(compiler){
        compiler.hooks.beforeRun.tap("ThemeFilesScanPlugin", ()=>{
            this.refreshFiles();
        });
        compiler.hooks.watchRun.tap("ThemeFilesScanPlugin", () =>{
            this.refreshFiles();
        });
    }
};

function getThemeFiles(paths, themeName){
    let res = [];
    for (const path of paths) {
        let options = {
            cwd:path,
            ignore: "**/node_modules/**",
            absolute: true
        };
        res.push(...glob.sync("**/*." + themeName +".*", options));
    }
    return res;
}


问:
xamarin binding class property
I'm am trying to make a small app for android through xamarin. I'm also trying to include some MVVM.
I have a model class UserInfoM (with a name, password, ...). I have a viewmodel "mainpageVM" in which I want to use that class UserInfoM . This works until a certain pount. When i type something in the app, the getter and setter from the UserInfoM(odel) are triggered. But i can't seem to get the data in the VM. This is probably going to be some obvious mistake, but after searching a few days, i can't seem to find the answer.

In my view (xaml) I have bindings to the Viewmodel and the

```<code><ContentPage.BindingContext>
    <local:MainPageVM/>
</ContentPage.BindingContext>
</code>```

...

```<code>    <Entry Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Placeholder="Enter Username"
           Text="{Binding UserInfo.User, Mode=TwoWay}"
        >
        <Entry.BindingContext>
            <local:MainPageVM/>
        </Entry.BindingContext>
</code>```

In my MainPageVM use the UserInfoM(odel) as a property:

```<code>    public UserInfoM UserInfo
    {
        get { return _userInfo ?? (_userInfo = new UserInfoM()); }
        set
        {
            _userInfo = value;
        }
    }
</code>```

And in my UserInfoM(odel) I have the following property (amongst others):

```<code>    private string user;
    public string User
    {
        get { return user; }
        set
        {
            if (user != value)
            {
                user = value;
                RaisePropertyChanged(nameof(User));
            }
        }
    }
</code>```

So the xaml binding seems to work since the User-property getter and setter are triggerd. But only in the model, although in the view the binding is set to the MainPageVM. In the MainPageVM all the model-properties stay empty. It has to be some kind of logical error, i don't get errors, the entry is filled in nicely, the user-property in the UserInfoM(odel) is filled in (set) by the Entry-field but I can't access/use the UserInfo.User (or other) property from the model.

In short, i can bind a single property, but not one in from another class with properties. I watch a bunch of tutorials and searched a lot but can't find this.
I hope the explanation is clear enough... Any help would be much appreciated.
The raiseproperty-method implements the INotifyPropertyChanged and work perfect for a single property. The user-property in de UserInfoM(odel) is updated but not the one in the Viewmodel.

答:
You don't need to explicitly set the BindingContext to your Entry. When you have set the binding context to your page, it applies to all elements inside it. Your binding of the Entry is correct, so it should become like this:

<Entry Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Placeholder="Enter Username"
    Text="{Binding UserInfo.User, Mode=TwoWay}">
```

If you replace your code like this, the Entry will successfully find its BindingContext (from the page's one), it will look inside it in order to find UserInfo class and it will bind the UserInfo's User property to the Entry's Text property.

Title: xamarin binding class property

Body:
I'm am trying to make a small app for android through xamarin. I'm also trying to include some MVVM.
I have a model class UserInfoM (with a name, password, ...). I have a viewmodel "mainpageVM" in which I want to use that class UserInfoM . This works until a certain pount. When i type something in the app, the getter and setter from the UserInfoM(odel) are triggered. But i can't seem to get the data in the VM. This is probably going to be some obvious mistake, but after searching a few days, i can't seem to find the answer.

In my view (xaml) I have bindings to the Viewmodel and the

<ContentPage.BindingContext>
    <local:MainPageVM/>
</ContentPage.BindingContext>

...

    <Entry Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Placeholder="Enter Username"
           Text="{Binding UserInfo.User, Mode=TwoWay}"
        >
        <Entry.BindingContext>
            <local:MainPageVM/>
        </Entry.BindingContext>

In my MainPageVM use the UserInfoM(odel) as a property:

    public UserInfoM UserInfo
    {
        get { return _userInfo ?? (_userInfo = new UserInfoM()); }
        set
        {
            _userInfo = value;
        }
    }

And in my UserInfoM(odel) I have the following property (amongst others):

    private string user;
    public string User
    {
        get { return user; }
        set
        {
            if (user != value)
            {
                user = value;
                RaisePropertyChanged(nameof(User));
            }
        }
    }

So the xaml binding seems to work since the User-property getter and setter are triggerd. But only in the model, although in the view the binding is set to the MainPageVM. In the MainPageVM all the model-properties stay empty. It has to be some kind of logical error, i don't get errors, the entry is filled in nicely, the user-property in the UserInfoM(odel) is filled in (set) by the Entry-field but I can't access/use the UserInfo.User (or other) property from the model.

In short, i can bind a single property, but not one in from another class with properties. I watch a bunch of tutorials and searched a lot but can't find this.
I hope the explanation is clear enough... Any help would be much appreciated.
The raiseproperty-method implements the INotifyPropertyChanged and work perfect for a single property. The user-property in de UserInfoM(odel) is updated but not the one in the Viewmodel.

Body:
You don't need to explicitly set the BindingContext to your Entry. When you have set the binding context to your page, it applies to all elements inside it. Your binding of the Entry is correct, so it should become like this:

<Entry Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Placeholder="Enter Username"
    Text="{Binding UserInfo.User, Mode=TwoWay}">

If you replace your code like this, the Entry will successfully find its BindingContext (from the page's one), it will look inside it in order to find UserInfo class and it will bind the UserInfo's User property to the Entry's Text property.


问:
CouchDB POST response, which was sent via curl via Python's subprocess module, is getting lost (curl code 53). Why is that?
I'm trying to add a document to couchDB from python using curl via the subprocess module. I can do it fine from the command line but not from python.

Here is the command line code

```<code>curl -X POST http://doug:enter@localhost:5984/mydb/ -H "Content-Type: application/json" -d {}
</code>```

The document is created each and every time with this command. However, the same command from Python via the subprocess module fails. I'm wondering if anyone can pinpoint where, and why, the reply gets lost (CouchDB should send a response, but the error is that curl isn't receiving one).

here is the code.

```<code>import subprocess

args = ['curl', '-X', 'POST', 'http://doug:enter@localhost:5984/mydb/', '-H', '"Content-Type: application/json"', '-d', '{}']

try:
    retcode = subprocess.call(args)
except OSError:
    print('os error')
except ValueError:
    print('value error')

print(retcode)
</code>```

Additional Information:

I'm running Kubuntu 11.04, curl 7.21.3, and Python 2.7.1

The CouchDB database is on my local machine and as I mentioned above, its working perfectly.

答:
You aren't including shell=True. Subprocess won't use your shell if you don't, so you'll have differences from running on the command line.

```<code>retcode = subprocess.call(args, shell=True)
</code>```

That should fix your problem. Note that this may cause args to not work quite correctly, as it may want a string instead. If that is the case try:

```<code>retcode = subprocess.call(' '.join(args), shell=True)
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I'm trying to add a document to couchDB from python using curl via the subprocess module. I can do it fine from the command line but not from python.

Here is the command line code

curl -X POST http://doug:enter@localhost:5984/mydb/ -H "Content-Type: application/json" -d {}

The document is created each and every time with this command. However, the same command from Python via the subprocess module fails. I'm wondering if anyone can pinpoint where, and why, the reply gets lost (CouchDB should send a response, but the error is that curl isn't receiving one).

here is the code.

import subprocess

args = ['curl', '-X', 'POST', 'http://doug:enter@localhost:5984/mydb/', '-H', '"Content-Type: application/json"', '-d', '{}']

try:
    retcode = subprocess.call(args)
except OSError:
    print('os error')
except ValueError:
    print('value error')

print(retcode)

Additional Information:

I'm running Kubuntu 11.04, curl 7.21.3, and Python 2.7.1

The CouchDB database is on my local machine and as I mentioned above, its working perfectly.

Body:
You aren't including shell=True. Subprocess won't use your shell if you don't, so you'll have differences from running on the command line.

retcode = subprocess.call(args, shell=True)

That should fix your problem. Note that this may cause args to not work quite correctly, as it may want a string instead. If that is the case try:

retcode = subprocess.call(' '.join(args), shell=True)


问:
what's the best way to store same hash field in redis?
I store user-feeds in redis, every feed is stored as a hash and the key is the users ID, the field of the hash is user that created the content and the value is the content, how do I handle a case where the content-creator makes multiple posts, because it would overwrite what's in cache already and not store the new content.</p>

答:
It "mostly" depends on how do you want to query it. If you are going to get all hash fields/values at once(HGETALL) then you may append timestamp next to your identifier;

```<code>127.0.0.1:6379> hset user:1:feed user:2:1591081521 content1
(integer) 1
127.0.0.1:6379> hset user:1:feed user:2:1591081532 yet-another-content
(integer) 1
127.0.0.1:6379> hset user:1:feed user:3:1591081543 super-content
(integer) 1
127.0.0.1:6379> hgetall user:1:feed
1) "user:2:1591081521"
2) "content1"
3) "user:2:1591081532"
4) "yet-another-content"
5) "user:3:1591081543"
6) "super-content"
127.0.0.1:6379>
</code>```

If there is possibility to save multiple content at the same time(scheduling multiple content to be released at a certain time) then you may append some random string too.

If you are not getting all the contents of user but feed of a user displaying only the contents of a specific user then you may use sorted set. In this example score is the user id of the content owner and you can query them via using ZRANGEBYSCORE. You can still get all the contents of user:1 with ZRANGE

```<code>127.0.0.1:6379> zadd user:1:feed 2 content
(integer) 1
127.0.0.1:6379> zadd user:1:feed 2 content-another
(integer) 1
127.0.0.1:6379> zadd user:1:feed 2 content-another-some-another
(integer) 1
127.0.0.1:6379> ZRANGEBYSCORE user:1:feed 2 2 withscores
1) "content"
2) "2"
3) "content-another"
4) "2"
5) "content-another-some-another"
6) "2"
127.0.0.1:6379> zadd user:1:feed 3 content-of-user-3
(integer) 1
127.0.0.1:6379> zrange user:1:feed 0 -1 withscores
1) "content"
2) "2"
3) "content-another"
4) "2"
5) "content-another-some-another"
6) "2"
7) "content-of-user-3"
8) "3"
127.0.0.1:6379>
</code>```

Body:
It "mostly" depends on how do you want to query it. If you are going to get all hash fields/values at once(HGETALL) then you may append timestamp next to your identifier;

127.0.0.1:6379> hset user:1:feed user:2:1591081521 content1
(integer) 1
127.0.0.1:6379> hset user:1:feed user:2:1591081532 yet-another-content
(integer) 1
127.0.0.1:6379> hset user:1:feed user:3:1591081543 super-content
(integer) 1
127.0.0.1:6379> hgetall user:1:feed
1) "user:2:1591081521"
2) "content1"
3) "user:2:1591081532"
4) "yet-another-content"
5) "user:3:1591081543"
6) "super-content"
127.0.0.1:6379>

If there is possibility to save multiple content at the same time(scheduling multiple content to be released at a certain time) then you may append some random string too.

If you are not getting all the contents of user but feed of a user displaying only the contents of a specific user then you may use sorted set. In this example score is the user id of the content owner and you can query them via using ZRANGEBYSCORE. You can still get all the contents of user:1 with ZRANGE

127.0.0.1:6379> zadd user:1:feed 2 content
(integer) 1
127.0.0.1:6379> zadd user:1:feed 2 content-another
(integer) 1
127.0.0.1:6379> zadd user:1:feed 2 content-another-some-another
(integer) 1
127.0.0.1:6379> ZRANGEBYSCORE user:1:feed 2 2 withscores
1) "content"
2) "2"
3) "content-another"
4) "2"
5) "content-another-some-another"
6) "2"
127.0.0.1:6379> zadd user:1:feed 3 content-of-user-3
(integer) 1
127.0.0.1:6379> zrange user:1:feed 0 -1 withscores
1) "content"
2) "2"
3) "content-another"
4) "2"
5) "content-another-some-another"
6) "2"
7) "content-of-user-3"
8) "3"
127.0.0.1:6379>


问:
Busboy + Express: How to get the sended file and its specifications
I struggle on a very simple example for Express.js and Busboy.
The code is as simple as possible. That makes it easier for me and others to understand whats going on.
the form block:

```<code>            <form
              action="https:// ... this works ..."
              enctype="multipart/form-data"
              method="post"
            >
              <label class="up_styles">
                <input type="file" name="file" id="somethingTricky"/>
              </label>
              <br />
              <input class="sub" type="submit" value="Submit" />
            </form>
</code>```

and the backend:

```<code>const functions = require("firebase-functions");

const Busboy = require('busboy');

const express = require("express");

const app = express();

app.post("/api/fileanalyse", (req, res) => {
 const busboy = new Busboy({
    headers: req.headers
});

busboy.on('error', function(err) {
    console.log(err);
});

busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
    console.log(fieldname);
    console.log(file);
    console.log(filename);
    console.log(encoding);
    console.log(mimetype);

    // see other question
    file.resume();

});

busboy.on('finish', function() {
    console.log('finish');
});

return req.pipe(busboy);
});

exports.App = functions.region("europe-west1").https.onRequest(app);
</code>```

All the console.logs in the function(fieldname, file, filename, encoding, mimetype) dont work, console.log('finish') works.
How do I get the file and the filedata, for example filename and filesize from the request?

答:
Okay, it had to go on and found another solution without using Node.js, Express.js and busboy (or something like "express-busboy", "connect-busboy" ...).
Using React.js (create-react-app) and Firebase/storage:

Running solution:
https://filemeta-4dcb1.firebaseapp.com/

And the code:

App.js(will be attached to the Div(root) by index.js):

```<code>import React from 'react';
import Upload from './component/upload';

function App() {
  return (
    <div className="App">
        <h1>file metaservice</h1>
        <Upload />
    </div>
  );
}

export default App;
</code>```

upload.js(this component includes everything except of the Firebase init):

```<code>import React, { Component } from "react";
import Firebase from "./firebase";

class Upload extends Component {
  constructor(props) {
    super(props);
    this.state = {
      file: "",
    };
    this.setFileState = this.setFileState.bind(this);
    this.fileUpload = this.fileUpload.bind(this);
  }
  setFileState = (e) => {
    this.setState({ [e.target.name]: e.target.files[0] });
  };
  fileUpload = (e) => {
    e.preventDefault();
    // if no file is selected
    if (!this.state.file) {
      console.log("please select a file");
    } else {
      // send file to the database
      const storageRef = Firebase.db.ref('fileupload/' + this.state.file.name);
      storageRef.put(this.state.file);
      storageRef.getMetadata().then(res => {
        document.getElementById('fileDiv').innerText = 'fileName: ' + res.name + ', fileSize: ' + res.size + "b"
      })
    }
  };
  render() {
    return (
      <div id="fileDiv">
        <form>
          <label>
            <input type="file" name="file" onChange={this.setFileState} />
          </label>
          <br />
          <input type="submit" value="Submit" onClick={this.fileUpload} />
        </form>
      </div>
    );
  }
}

export default Upload;
</code>```

and the firebase.js(to init Firebase):

```<code>import app from "firebase/app";
import "firebase/storage";

const firebaseConfig = {
    my firebaseConfig - data ...
  };

class Firebase {
  constructor() {
    app.initializeApp(firebaseConfig);
    this.db = app.storage();
  };
};

export default new Firebase();
</code>```

package.json(dependencies):

```<code>{
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1",
    "firebase": "*"
  }
</code>```

Cheers!

Body:
I struggle on a very simple example for Express.js and Busboy.
The code is as simple as possible. That makes it easier for me and others to understand whats going on.
the form block:

            <form
              action="https:// ... this works ..."
              enctype="multipart/form-data"
              method="post"
            >

                <input type="file" name="file" id="somethingTricky"/>

              <input class="sub" type="submit" value="Submit" />
            </form>

and the backend:

const functions = require("firebase-functions");

const Busboy = require('busboy');

const express = require("express");

const app = express();

app.post("/api/fileanalyse", (req, res) => {
 const busboy = new Busboy({
    headers: req.headers
});

busboy.on('error', function(err) {
    console.log(err);
});

busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
    console.log(fieldname);
    console.log(file);
    console.log(filename);
    console.log(encoding);
    console.log(mimetype);

    // see other question
    file.resume();

});

busboy.on('finish', function() {
    console.log('finish');
});

return req.pipe(busboy);
});

exports.App = functions.region("europe-west1").https.onRequest(app);

All the console.logs in the function(fieldname, file, filename, encoding, mimetype) dont work, console.log('finish') works.
How do I get the file and the filedata, for example filename and filesize from the request?

Body:
Okay, it had to go on and found another solution without using Node.js, Express.js and busboy (or something like "express-busboy", "connect-busboy" ...).
Using React.js (create-react-app) and Firebase/storage:

Running solution:
https://filemeta-4dcb1.firebaseapp.com/

And the code:

App.js(will be attached to the Div(root) by index.js):

import React from 'react';
import Upload from './component/upload';

function App() {
  return (
    <div className="App">
        <h1>file metaservice</h1>
        <Upload />
    </div>
  );
}

export default App;

upload.js(this component includes everything except of the Firebase init):

import React, { Component } from "react";
import Firebase from "./firebase";

class Upload extends Component {
  constructor(props) {
    super(props);
    this.state = {
      file: "",
    };
    this.setFileState = this.setFileState.bind(this);
    this.fileUpload = this.fileUpload.bind(this);
  }
  setFileState = (e) => {
    this.setState({ [e.target.name]: e.target.files[0] });
  };
  fileUpload = (e) => {
    e.preventDefault();
    // if no file is selected
    if (!this.state.file) {
      console.log("please select a file");
    } else {
      // send file to the database
      const storageRef = Firebase.db.ref('fileupload/' + this.state.file.name);
      storageRef.put(this.state.file);
      storageRef.getMetadata().then(res => {
        document.getElementById('fileDiv').innerText = 'fileName: ' + res.name + ', fileSize: ' + res.size + "b"
      })
    }
  };
  render() {
    return (
      <div id="fileDiv">
        <form>
          <label>
            <input type="file" name="file" onChange={this.setFileState} />
          </label>
          <br />
          <input type="submit" value="Submit" onClick={this.fileUpload} />
        </form>
      </div>
    );
  }
}

export default Upload;

and the firebase.js(to init Firebase):

import app from "firebase/app";
import "firebase/storage";

const firebaseConfig = {
    my firebaseConfig - data ...
  };

class Firebase {
  constructor() {
    app.initializeApp(firebaseConfig);
    this.db = app.storage();
  };
};

export default new Firebase();

package.json(dependencies):

{
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1",
    "firebase": "*"
  }

Cheers!


问:
Facebook send app in review, how i can generate a free privacy policy?
I'm trying to send in review to facebook my facebook-app (related to an ios app) that post on users walls, photos and text (i'm using publish_action). Facebook require my a privacy url:

```<code>"privacy policy for login dialog and app details"
</code>```

How i can create a privacy policy for my facebook app? I'm not a lawyer and my ios app doesn't require registration so i haven't a privacy and terms... I have found only a privacy generator focused on "facebook app" it is Iubenta but it's free only for the first privacy generation... The other generators aren't focused on "facebook app login dialog and app details", there a free solution?

答:
I did exactly the same as in the comment of Silviu St but I put the text in a markdown file on my GitHub repo instead:

I copied the text from this website.

I changed [COMPANY-NAME] to mine and changed the date at the end.

Then I put the text in a .md file on my GitHub repo (instead of using wordpress) and it worked

Body:
I'm trying to send in review to facebook my facebook-app (related to an ios app) that post on users walls, photos and text (i'm using publish_action). Facebook require my a privacy url:

"privacy policy for login dialog and app details"

How i can create a privacy policy for my facebook app? I'm not a lawyer and my ios app doesn't require registration so i haven't a privacy and terms... I have found only a privacy generator focused on "facebook app" it is Iubenta but it's free only for the first privacy generation... The other generators aren't focused on "facebook app login dialog and app details", there a free solution?


问:
Defining common methods for React functional component
I have created a 4 page application using typescript and hooks. There are few methods within each file which is common. Is there any way so that same methods can be extended in all file. Something like abstract in typescript without changing my component to class from functional?</p>

答:
You can do this very easily. Create js File Message.js and write the below function

```<code>export function getMessage() {
    return "Hello World";
}
</code>```

import that function to your another js file where you want to call:

```<code>import {getMessage} from './Message'
</code>```

Then call the getMessage function:

```<code>alert("This is the Message: " + getMessage());
</code>```

Body:
You can do this very easily. Create js File Message.js and write the below function

export function getMessage() {
    return "Hello World";
}

import that function to your another js file where you want to call:

import {getMessage} from './Message'

Then call the getMessage function:

alert("This is the Message: " + getMessage());


问:
React input field onKeyPress problem of calling other function
```<code>class A extends React.Component{
   constructor(props){
      this.sendMsg = this.sendMsg.bind(this)
   }

   sendMsg(){
     console.log("Message is send!!!")
   }

keyPressed(event){
    if (event.key === "Enter") {
        this.sendMsg()
    }
}

render(){
   return(
      <input
          type="text"
          className="form-control input-chat border-0"
          id="inputMessage"
          placeholder="Type a new message"
          onKeyPress={this.keyPressed}
      />
   )
}
</code>```

}

Error: this.sendMsg() is undefined.

The above code show a component of input box, if the user click enter, I would like to display a console message. But there have a problem occur as above.
What need to be added to the code to run it properly?

答:
You need to bind the keyPressed function too.

```<code>class A extends React.Component{
constructor(props){
super(props);
  this.sendMsg = this.sendMsg.bind(this)
 this.keyPressed = this.keyPressed.bind(this)
}

sendMsg(){
 console.log("Message is send!!!")
}

keyPressed(event){
if (event.key === "Enter") {
    this.sendMsg()
}
}

render(){

return(
      <input
          type="text"
          className="form-control input-chat border-0"
          id="inputMessage"
          placeholder="Type a new message"
          onKeyPress={this.keyPressed}
      />
   )
}
}
</code>```

Body:
class A extends React.Component{
   constructor(props){
      this.sendMsg = this.sendMsg.bind(this)
   }

   sendMsg(){
     console.log("Message is send!!!")
   }

keyPressed(event){
    if (event.key === "Enter") {
        this.sendMsg()
    }
}

render(){
   return(
      <input
          type="text"
          className="form-control input-chat border-0"
          id="inputMessage"
          placeholder="Type a new message"
          onKeyPress={this.keyPressed}
      />
   )
}

}

Error: this.sendMsg() is undefined.

The above code show a component of input box, if the user click enter, I would like to display a console message. But there have a problem occur as above.
What need to be added to the code to run it properly?

Body:
You need to bind the keyPressed function too.

class A extends React.Component{
constructor(props){
super(props);
  this.sendMsg = this.sendMsg.bind(this)
 this.keyPressed = this.keyPressed.bind(this)
}

sendMsg(){
 console.log("Message is send!!!")
}

keyPressed(event){
if (event.key === "Enter") {
    this.sendMsg()
}
}

render(){

return(
      <input
          type="text"
          className="form-control input-chat border-0"
          id="inputMessage"
          placeholder="Type a new message"
          onKeyPress={this.keyPressed}
      />
   )
}
}


问:
JSONObject etc instantiation crashing
I am trying to learn how to use JSON and writing a simple program however whenever I instantiate a JSON Object it crashes.
What am I missing if I receive this error when trying to instantiate a JSONObject or JSONArray. I have added http://sourceforge.net/projects/json-lib/files/ this JSON library to the build path. Is there anything I am missing?

The error message is as follows:

```<code>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at jsonexp.JSONexp.<init>(JSONexp.java:36)
    at jsonexp.JSONexp.main(JSONexp.java:55)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException
</code>```

I have learned that this sort of error occurs when the library being used depends on another library.

I do not know how to deal with this problem and would very much appreciate some help.

Thanks.

答: A simple way to do this would be to use findjar to find the jar containing missing class for you and add it to you lib folder.</p>

Title: JSONObject etc instantiation crashing

Body:
I am trying to learn how to use JSON and writing a simple program however whenever I instantiate a JSON Object it crashes.
What am I missing if I receive this error when trying to instantiate a JSONObject or JSONArray. I have added http://sourceforge.net/projects/json-lib/files/ this JSON library to the build path. Is there anything I am missing?

The error message is as follows:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at jsonexp.JSONexp.<init>(JSONexp.java:36)
    at jsonexp.JSONexp.main(JSONexp.java:55)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException

I have learned that this sort of error occurs when the library being used depends on another library.

I do not know how to deal with this problem and would very much appreciate some help.

Thanks.


问:
How to "sort by" using a button for the data i am displaying out here
How to add sort to the data by using a button</p>

```<code>import React, { useState } from "react";
import { Container, Row, Col } from "reactstrap";
import EmployeeCard from "./EmployeeCard";
import data from "./data.json";
import Modal from "./Modal";
import Subheader from "./Subheader";
import "./Employeelist.css";

function Employeelist() {
  const [state, setState] = useState({ search: null });
  const searchSpace = event => {
    let keyword = event.target.value;
    setState({ search: keyword });
  };
  const employeeCards = data.employee
    .filter(data => {
      if (state.search == null) return data;
      else if (
        data.firstName.toLowerCase().includes(state.search.toLowerCase()) ||
        data.lastName.toLowerCase().includes(state.search.toLowerCase())
      ) {
        return data;
      }
    })
    .map(person => {
      return (
        <Col sm="4">
          <EmployeeCard key={person.id} person={person} />
        </Col>
      );
    });
  return (
    <div>
      <input
        type="text"
        placeholder="Search"
        class="elementStyle"
        onChange={e => searchSpace(e)}
      />
      <br />
      <br />
      <br />
      <Container fluid>
        <Row>{employeeCards}</Row>
      </Container>
    </div>
  );
}
export default Employeelist;
</code>```

答:
Add some state to hold the sorted/unsorted data and a sortActive boolean, and a handler to toggle the sort active or not. Use an effect to sort/unsort using the sortActive as a dependency.

Also fixed other discrepancies, I tried noting them.

```<code>function Employeelist() {
  const [state, setState] = useState({ search: null });

  const searchSpace = event => {
    let keyword = event.target.value;
    setState({ search: keyword });
  };

  // state to hold sorted/unsorted data array, sortActive, and handler
  const [sortedData, setSortedData] = useState(data.employee);
  const [sortActive, setSortActive] = useState(false);
  const toggleSortActiveHandler = () => setSortActive(a => !a);

  useEffect(() => {
    if (sortActive) {
      setSortedData(
        // Gotcha: array::sort is an in-place sort, meaning it mutates
        // the existing array.
        // Spreading it into a new array then sorting addresses this.
        [...data.employee].sort((a, b) => {
          if (a.lastName < b.lastName) return -1;
          if (a.lastName > b.lastName) return 1;
          return 0;
        })
      );
    } else {
      setSortedData(data.employee);
    }
  }, [sortActive]);

  const employeeCards = sortedData
    .filter(data => {
      // filter returns true/false if element should be filtered
      if (state.search == null) return true;

      return (
        data.firstName.toLowerCase().includes(state.search.toLowerCase()) ||
        data.lastName.toLowerCase().includes(state.search.toLowerCase())
      );
    })
    .map(person => {
      return (
        <Col key={person.id} sm="4"> { /* <-- react key on outer most element */ }
          <EmployeeCard person={person} />
        </Col>
      );
    });

  return (
    <div>
      <input
        type="text"
        placeholder="Search"
        className="elementStyle"
        onChange={e => searchSpace(e)}
      />
      <br />
      <br />
      <br />
      <Container fluid>
        <Row>{employeeCards}</Row>
      </Container>

      { /* button to toggle the sort */ }
      <button type="button" onClick={toggleSortActiveHandler}>
        Toggle Alpha Sort
      </button>
    </div>
  );
}
</code>```

Body:
How to add sort to the data by using a button

import React, { useState } from "react";
import { Container, Row, Col } from "reactstrap";
import EmployeeCard from "./EmployeeCard";
import data from "./data.json";
import Modal from "./Modal";
import Subheader from "./Subheader";
import "./Employeelist.css";

function Employeelist() {
  const [state, setState] = useState({ search: null });
  const searchSpace = event => {
    let keyword = event.target.value;
    setState({ search: keyword });
  };
  const employeeCards = data.employee
    .filter(data => {
      if (state.search == null) return data;
      else if (
        data.firstName.toLowerCase().includes(state.search.toLowerCase()) ||
        data.lastName.toLowerCase().includes(state.search.toLowerCase())
      ) {
        return data;
      }
    })
    .map(person => {
      return (
        <Col sm="4">
          <EmployeeCard key={person.id} person={person} />
        </Col>
      );
    });
  return (

      <input
        type="text"
        placeholder="Search"
        class="elementStyle"
        onChange={e => searchSpace(e)}
      />

      <Container fluid>
        <Row>{employeeCards}</Row>
      </Container>

  );
}
export default Employeelist;

Body:
Add some state to hold the sorted/unsorted data and a sortActive boolean, and a handler to toggle the sort active or not. Use an effect to sort/unsort using the sortActive as a dependency.

Also fixed other discrepancies, I tried noting them.

function Employeelist() {
  const [state, setState] = useState({ search: null });

  const searchSpace = event => {
    let keyword = event.target.value;
    setState({ search: keyword });
  };

  // state to hold sorted/unsorted data array, sortActive, and handler
  const [sortedData, setSortedData] = useState(data.employee);
  const [sortActive, setSortActive] = useState(false);
  const toggleSortActiveHandler = () => setSortActive(a => !a);

  useEffect(() => {
    if (sortActive) {
      setSortedData(
        // Gotcha: array::sort is an in-place sort, meaning it mutates
        // the existing array.
        // Spreading it into a new array then sorting addresses this.
        [...data.employee].sort((a, b) => {
          if (a.lastName < b.lastName) return -1;
          if (a.lastName > b.lastName) return 1;
          return 0;
        })
      );
    } else {
      setSortedData(data.employee);
    }
  }, [sortActive]);

  const employeeCards = sortedData
    .filter(data => {
      // filter returns true/false if element should be filtered
      if (state.search == null) return true;

      return (
        data.firstName.toLowerCase().includes(state.search.toLowerCase()) ||
        data.lastName.toLowerCase().includes(state.search.toLowerCase())
      );
    })
    .map(person => {
      return (
        <Col key={person.id} sm="4"> { /* <-- react key on outer most element */ }
          <EmployeeCard person={person} />
        </Col>
      );
    });

  return (
    <div>
      <input
        type="text"
        placeholder="Search"
        className="elementStyle"
        onChange={e => searchSpace(e)}
      />
      <br />
      <br />
      <br />
      <Container fluid>
        <Row>{employeeCards}</Row>
      </Container>

      { /* button to toggle the sort */ }
      <button type="button" onClick={toggleSortActiveHandler}>
        Toggle Alpha Sort
      </button>
    </div>
  );
}


问:
How to clear the gridview,literal and panel values?
I have a textbox called customer id and if the id is not valid, it should display a warning message and needs to go back to the main page where the user retries entering Id again. It works fine if the ID is valid. If the entered Id is invalid, panel and gridview are updating with some random values. How can I clear them? Any suggestions.</p>

```<code>       DataTable dt = oRecord.GetCustomerName(sId);

        if (dt.Rows.Count == 0)
        {
           // making panel and gridview visible false does not work.
            pnlDetails.visible = false;
            gvInfo.visible= false
            pnlSuccess.Visible = false;
            btnOk.Visible = false;
            txtId.Text = string.Empty;
            txtIdentifier.Focus();

            ViewState["sId"] = string.Empty;

        }
</code>```

答:
You should not set visible false as it will be setting controls to invisible along with existing data but data is available and bind with these controls in memory. you should clear content of these controls to empty or null.</p>

```<code>    DataTable dt = oRecord.GetCustomerName(sId);

    if (dt.Rows.Count == 0)
    {
        gvInfo.DataSource = null;
        txtId.Text = string.Empty;
        txtIdentifier.Focus();
        ViewState["sId"] = string.Empty;
    }
</code>```

Body:
I have a textbox called customer id and if the id is not valid, it should display a warning message and needs to go back to the main page where the user retries entering Id again. It works fine if the ID is valid. If the entered Id is invalid, panel and gridview are updating with some random values. How can I clear them? Any suggestions.

       DataTable dt = oRecord.GetCustomerName(sId);

        if (dt.Rows.Count == 0)
        {
           // making panel and gridview visible false does not work.
            pnlDetails.visible = false;
            gvInfo.visible= false
            pnlSuccess.Visible = false;
            btnOk.Visible = false;
            txtId.Text = string.Empty;
            txtIdentifier.Focus();

            ViewState["sId"] = string.Empty;

        }

Body:
You should not set visible false as it will be setting controls to invisible along with existing data but data is available and bind with these controls in memory. you should clear content of these controls to empty or null.

    DataTable dt = oRecord.GetCustomerName(sId);

    if (dt.Rows.Count == 0)
    {
        gvInfo.DataSource = null;
        txtId.Text = string.Empty;
        txtIdentifier.Focus();
        ViewState["sId"] = string.Empty;
    }


问:
How do i center everything?
I have made a really simple calculator, but it being on the top right of the screen makes it look weird. Vertical-align does not work and text-align only works for the text box. How do i make all the buttons centered in the screen???

I put all of the buttons and stuff inside a div called main. How do i center that div vertically and horizontally?

I could manually position it by giving some px values to the left and top but it would not work different screens. I want to make it in a way that it remains centered in a huge variety of screens.

答:
You can easily do this with flex-box features.

try this:

```<code>display: flex;
align-items: center;
justify-content: center;
</code>```

Title: How do i center everything?

Body:
You can easily do this with flex-box features.

try this:

display: flex;
align-items: center;
justify-content: center;


问:
How to skip to a specific cell
How do I skip to cell D14 when D10 is filled?

I am trying to input a timestamp, when I click a button, into cell D14 after cell D10 has been filled. Is this possible? I have tried (r == 10, 'D14') but it did not work. I have tried to write a skipTo function that did not work, and I tried reading the Google Sheets Help page but I could not find a solution. Please help..!

This is what I have so far:

```<code>function setValue(cellName, value) {
  SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).setValue(value);
}

function getValue(cellName) {
  return SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).getValue();
}

function getNextRow1() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet();
  for (var r = 4; r <= 10; r++); {
    if (sheet.getRange("D" + r).isBlank()) {
      return r;
      }
    }
  }

function getNextRow2() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet();
  for (var r = 4; r <= 10; r++) {
    if (sheet.getRange("E" + r).isBlank()) {
      return r;
    }
  }
}

function addRecord1(d,) {
  var row = getNextRow1();
  setValue('D' + row, d);
}

function addRecord2(e,) {
  var row = getNextRow2();
  setValue('E' + row, e);
}

function btn_start() {
  addRecord1(new Date());
}

function btn_stop() {
  addRecord2(new Date());
}
</code>```

答:
Answer:

Make make a check if r - 1 is a multiple of 10 and if it is, +3. Do this for two weeks.

Code example:

```<code>function getNextRow1() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet();
  for (var r = 4; r <= 20; r++); {

    if ((r - 1) % 10) == 0) r =+ 3;

    if (sheet.getRange("D" + r).isBlank()) {
      return r;
    }
  }
}
</code>```

Title: How to skip to a specific cell

Body:
How do I skip to cell D14 when D10 is filled?

I am trying to input a timestamp, when I click a button, into cell D14 after cell D10 has been filled. Is this possible? I have tried (r == 10, 'D14') but it did not work. I have tried to write a skipTo function that did not work, and I tried reading the Google Sheets Help page but I could not find a solution. Please help..!

This is what I have so far:

function setValue(cellName, value) {
  SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).setValue(value);
}

function getValue(cellName) {
  return SpreadsheetApp.getActiveSpreadsheet().getRange(cellName).getValue();
}

function getNextRow1() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet();
  for (var r = 4; r <= 10; r++); {
    if (sheet.getRange("D" + r).isBlank()) {
      return r;
      }
    }
  }

function getNextRow2() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet();
  for (var r = 4; r <= 10; r++) {
    if (sheet.getRange("E" + r).isBlank()) {
      return r;
    }
  }
}

function addRecord1(d,) {
  var row = getNextRow1();
  setValue('D' + row, d);
}

function addRecord2(e,) {
  var row = getNextRow2();
  setValue('E' + row, e);
}

function btn_start() {
  addRecord1(new Date());
}

function btn_stop() {
  addRecord2(new Date());
}

Body:
Answer:

Make make a check if r - 1 is a multiple of 10 and if it is, +3. Do this for two weeks.

Code example:

function getNextRow1() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet();
  for (var r = 4; r <= 20; r++); {

    if ((r - 1) % 10) == 0) r =+ 3;

    if (sheet.getRange("D" + r).isBlank()) {
      return r;
    }
  }
}


问:
Not redirecting to desired page
How can I get the loginState in Navigation, so after successful login system should redirect to Profile screen. Now after successful login, it is not Redirecting to profile screen.
I have read few tutorials but all with complex details, I would like to have some simple way of implementing this, as I have only 4 screens.

I have added a demo below:

https://codesandbox.io/s/amazing-ellis-2h3pd?file=/src/components/Home.js

答:
Since it's a funcional component it won't re-render and therefore calling the ternary in the return statement again. What I recomment you to do is, in the handleSubmit:

```<code>const Login = (props) => {
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");
  const userEmail = "sample@test.com";
  const userPassword = "1234";

  const handleSubmit = e => {
    e.preventDefault();
    if (email === userEmail && password === userPassword) {
      alert("Success");
      setLoginState(true);
      props.history.replace('/');
    } else {
      alert("Login details not correct !");
    }
  };

  return (
    <div className="login_wrapper">
      <div className="login_player_column_layout_one">
        <div className="login_player_Twocolumn_layout_two">
          <form onSubmit={handleSubmit} className="myForm">
            <div className="formInstructionsDiv formElement">
              <h2 className="formTitle">Login</h2>
            </div>
            <div className="loginfillContentDiv formElement">
              <label>
                <input
                  className="inputRequest formContentElement"
                  type="text"
                  placeholder="Email"
                  onChange={e => setEmail(e.target.value)}
                />
              </label>
              <label>
                <input
                  className="inputRequest formContentElement"
                  type="password"
                  placeholder="Password"
                  onChange={e => setPassword(e.target.value)}
                />
              </label>
              <label>
                <span className="loginValidationText" />
              </label>
            </div>
            <div className="loginsubmitButtonDiv formElement">
              <button type="submit" className="submitButton">
                Login
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>
  );
};
</code>```

And then you can avoid using the <Redirect /> component.
Hope this helps :)

Title: Not redirecting to desired page

Body:
Since it's a funcional component it won't re-render and therefore calling the ternary in the return statement again. What I recomment you to do is, in the handleSubmit:

const Login = (props) => {
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");
  const userEmail = "sample@test.com";
  const userPassword = "1234";

  const handleSubmit = e => {
    e.preventDefault();
    if (email === userEmail && password === userPassword) {
      alert("Success");
      setLoginState(true);
      props.history.replace('/');
    } else {
      alert("Login details not correct !");
    }
  };

  return (
    <div className="login_wrapper">
      <div className="login_player_column_layout_one">
        <div className="login_player_Twocolumn_layout_two">
          <form onSubmit={handleSubmit} className="myForm">
            <div className="formInstructionsDiv formElement">
              <h2 className="formTitle">Login</h2>
            </div>
            <div className="loginfillContentDiv formElement">
              <label>
                <input
                  className="inputRequest formContentElement"
                  type="text"
                  placeholder="Email"
                  onChange={e => setEmail(e.target.value)}
                />
              </label>
              <label>
                <input
                  className="inputRequest formContentElement"
                  type="password"
                  placeholder="Password"
                  onChange={e => setPassword(e.target.value)}
                />
              </label>
              <label>
                <span className="loginValidationText" />
              </label>
            </div>
            <div className="loginsubmitButtonDiv formElement">
              <button type="submit" className="submitButton">
                Login
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>
  );
};

And then you can avoid using the <Redirect /> component.
Hope this helps :)


问:
How to save the minimum time taken in unity?
I am making a maze game in unity 3d where the least time taken to complete the level is the highscore. Is there a way to save the highscore using Playerprefs? Scripting is done in C#.</p>

答:
You can first put this check in your homescript in awake function:

```<code>   if(!PlayerPrefs.HasKey("HighestScore"))
        {
            PlayerPrefs.SetString("HighestScore", "keep some big number");
        }
</code>```

Or alternatively can use (Preferably)

```<code>if(!PlayerPrefs.HasKey("HighestScore"))
            {
                PlayerPrefs.SetFloat("HighestScore", 100000f);
            }
</code>```

Then when the particular level ends and you need to save the score
Compare the existing PlayerPref with the current Player score.

For example for float

```<code>if(PlayerPrefs.GetFloat("HighestScore")>=current_score)
{
PlayerPrefs.SetFloat("HighestScore",current_score);
}
</code>```

Hope this helps !

Body:
You can first put this check in your homescript in awake function:

   if(!PlayerPrefs.HasKey("HighestScore"))
        {
            PlayerPrefs.SetString("HighestScore", "keep some big number");
        }

Or alternatively can use (Preferably)

if(!PlayerPrefs.HasKey("HighestScore"))
            {
                PlayerPrefs.SetFloat("HighestScore", 100000f);
            }

Then when the particular level ends and you need to save the score
Compare the existing PlayerPref with the current Player score.

For example for float

if(PlayerPrefs.GetFloat("HighestScore")>=current_score)
{
PlayerPrefs.SetFloat("HighestScore",current_score);
}

Hope this helps !


问:
Does implementing the MVP Pattern on webforms app make it easier to transition to MVC?
Since the MVP pattern allows more testability and some reuse in webforms apps, i thought it would be a good first step to moving to MVC for legacy(webforms with code in codebehind, no pattern).  As I refresh myself with MVP internals, it doesn't seem so.  Anyone have experience using this approach. Would it be better to just add MVC to your project and start porting pages/views?

Note: I have webform apps that inject controls dynamically, keepin the amount of pages down to 4 or less (single page webforms app).

答:
Proper separation of concerns should make the transition easier if needed.

MVC framework is suitable only for web applications, while MVP can be more universal and can work for Web forms and Windows forms - views implement interfaces for presenters to use and views themselves handle implementation details pertaining to navigation.

You say that you insert controls dynamically. If you do this to have UI consist of reusable and self-sufficient components then this principle does not work well with MVC - controllers there want to have complete authority over a page and implementing that on MVC would lead to a mess of sub-actions, partial views and view model sharing.

In my opinion, MVP + Web Forms is best suited for Enterprise Web Applications where pages are highly modular with interconnected components,MVC - for general Web Sites where a page corresponds to a single action with domain object, usually CRUD or is optimized more for reading.


问:
Add default value option in select tag
I use a select tag in my application:

<Select
    showSearch={false}
    defaultValue={["Lucy"]}
    mode="multiple"
    style={{ width: 200 }}
    placeholder="Select a person"
    optionFilterProp="children"
    onChange={onChange}
    onFocus={onFocus}
    onBlur={onBlur}
    onSearch={onSearch}
    filterOption={(input, option) =>
      option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
    }
  >
    <Option value="jack">Jack</Option>
    <Option value="lucy">Lucy</Option>
    <Option value="tom">Tom</Option>
  </Select>,
  document.getElementById("container")```

I want to set a default selected value for this Select, to get something like this:

 So, when i will open first time this dropdown, i want to have a default value selected in the way like in the image. I tried defaultValue but it does not work as i described., So, how to achive what i described above?

demo: https://codesandbox.io/s/select-with-search-field-ant-design-demo-4f9op?file=/index.js:410-955

答: The option value is 'lucy', and you set the default value to 'Lucy' (with a capital letter). Therefore, the default value does not work. Set the default value to 'lucy'.</p>

Title: Add default value option in select tag

Body:
I use a select tag in my application:

<Select
    showSearch={false}
    defaultValue={["Lucy"]}
    mode="multiple"
    style={{ width: 200 }}
    placeholder="Select a person"
    optionFilterProp="children"
    onChange={onChange}
    onFocus={onFocus}
    onBlur={onBlur}
    onSearch={onSearch}
    filterOption={(input, option) =>
      option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
    }
  >
    <Option value="jack">Jack</Option>
    <Option value="lucy">Lucy</Option>
    <Option value="tom">Tom</Option>
  </Select>,
  document.getElementById("container")

I want to set a default selected value for this Select, to get something like this:

 So, when i will open first time this dropdown, i want to have a default value selected in the way like in the image. I tried defaultValue but it does not work as i described., So, how to achive what i described above?

demo: https://codesandbox.io/s/select-with-search-field-ant-design-demo-4f9op?file=/index.js:410-955


问:
Compress and Minify a PHP Cached Page
I am using the following page caching technique as described here and shown below:

```<code><?php
$cachefile = 'cached-files/'.date('M-d-Y').'.php';
$cachetime = 18000;

// Check if the cached file is still fresh. If it is, serve it up and exit.
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile))
{
    include($cachefile);
    exit;
}

// no file OR the file to too old, render the page and capture the HTML.
ob_start( 'ob_gzhandler' );
?>

<html>
    <!-- CONTENT GOES HERE -->
</html>

<?php
// Save the cached content to a file
$fp = fopen($cachefile, 'w');
fwrite($fp, ob_get_contents());
fclose($fp);

// finally send browser output
ob_end_flush();
?>
</code>```

That all works fine but I want to compress and minify the cached file.

I've added ob_gzhandler onto;

```<code>ob_start( 'ob_gzhandler' );
</code>```

And have an htaccess file containing the following:

```<code><IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive on

# Your document html
  ExpiresByType text/html "access plus 0 seconds"

# Media: images, video, audio
  ExpiresByType audio/ogg "access plus 1 month"
  ExpiresByType image/gif "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType video/mp4 "access plus 1 month"
  ExpiresByType video/ogg "access plus 1 month"
  ExpiresByType video/webm "access plus 1 month"

# CSS and JavaScript
  ExpiresByType application/javascript "access plus 1 week"
  ExpiresByType text/css "access plus 1 week”

# Fonts
  AddType application/vnd.ms-fontobject .eot
  AddType application/x-font-ttf .ttf
  AddType application/x-font-opentype .otf
  AddType application/x-font-woff .woff
  AddType image/svg+xml .svg

  AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml

  ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
  ExpiresByType application/x-font-ttf "access plus 1 year"
  ExpiresByType application/x-font-opentype "access plus 1 year"
  ExpiresByType application/x-font-woff "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
</IfModule>
</code>```

Yet when I use any online tools to check gzip compression they all come back No.
Am I missing something?

Is there also a way to minify the cached HTML contained in ob_get_contents?

答:
it is very easy to solve your problem. I also had the same problem, for this you have to anticipate the compression method to the cachefil funtion, your repaired code would look like this

```<code><?php

    /* importat */
 ob_start ('ob_gzhandler');

 /* importat */

    $ cachefile = 'cached-files /'. date ('M-d-Y'). '. php';
    $ cachetime = 18000;

    // Check if the cached file is still fresh. If it is, serve it up and exit`enter code here`.
    if (file_exists ($ cachefile) && time () - $ cachetime <filemtime ($ cachefile))
    {
         include ($ cachefile);
         exit;
    }

    // no file OR the file to too old, render the page and capture the HTML.

    ?>

    <html>
         <! - CONTENT GOES HERE ->
    </html>

    <? php
    // Save the cached content to a file
    $ fp = fopen ($ cachefile, 'w');
    fwrite ($ fp, ob_get_contents ());
    fclose ($ fp);

    // finally send browser output

?>
</code>```

you're welcome greetings

Title: Compress and Minify a PHP Cached Page

Body:
I am using the following page caching technique as described here and shown below:

<?php
$cachefile = 'cached-files/'.date('M-d-Y').'.php';
$cachetime = 18000;

// Check if the cached file is still fresh. If it is, serve it up and exit.
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile))
{
    include($cachefile);
    exit;
}

// no file OR the file to too old, render the page and capture the HTML.
ob_start( 'ob_gzhandler' );
?>

<?php
// Save the cached content to a file
$fp = fopen($cachefile, 'w');
fwrite($fp, ob_get_contents());
fclose($fp);

// finally send browser output
ob_end_flush();
?>

That all works fine but I want to compress and minify the cached file.

I've added ob_gzhandler onto;

ob_start( 'ob_gzhandler' );

And have an htaccess file containing the following:

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive on

# Your document html
  ExpiresByType text/html "access plus 0 seconds"

# Media: images, video, audio
  ExpiresByType audio/ogg "access plus 1 month"
  ExpiresByType image/gif "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType video/mp4 "access plus 1 month"
  ExpiresByType video/ogg "access plus 1 month"
  ExpiresByType video/webm "access plus 1 month"

# CSS and JavaScript
  ExpiresByType application/javascript "access plus 1 week"
  ExpiresByType text/css "access plus 1 week”

# Fonts
  AddType application/vnd.ms-fontobject .eot
  AddType application/x-font-ttf .ttf
  AddType application/x-font-opentype .otf
  AddType application/x-font-woff .woff
  AddType image/svg+xml .svg

  AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml

  ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
  ExpiresByType application/x-font-ttf "access plus 1 year"
  ExpiresByType application/x-font-opentype "access plus 1 year"
  ExpiresByType application/x-font-woff "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
</IfModule>

Yet when I use any online tools to check gzip compression they all come back No.
Am I missing something?

Is there also a way to minify the cached HTML contained in ob_get_contents?

Body:
it is very easy to solve your problem. I also had the same problem, for this you have to anticipate the compression method to the cachefil funtion, your repaired code would look like this

<?php

    /* importat */
 ob_start ('ob_gzhandler');

 /* importat */

    $ cachefile = 'cached-files /'. date ('M-d-Y'). '. php';
    $ cachetime = 18000;

    // Check if the cached file is still fresh. If it is, serve it up and exit`enter code here`.
    if (file_exists ($ cachefile) && time () - $ cachetime <filemtime ($ cachefile))
    {
         include ($ cachefile);
         exit;
    }

    // no file OR the file to too old, render the page and capture the HTML.

    ?>

    <html>
         <! - CONTENT GOES HERE ->
    </html>

    <? php
    // Save the cached content to a file
    $ fp = fopen ($ cachefile, 'w');
    fwrite ($ fp, ob_get_contents ());
    fclose ($ fp);

    // finally send browser output

?>

you're welcome greetings


问:
JNI native method missing but no build error
In MyClass.java I have

```<code>package com.example.foo;
public class MyClass {
    public native void MyMethod();
</code>```

and in MyClass.cpp I have

```<code>JNIEXPORT void JNICALL xJava_com_example_foo_MyClass_MyMethod(JNIEnv* env, jobject thiz)
{
    blah blah blah
}
</code>```

Elsewhere in the Java code there's a call MyMethod();  However, as the eagle-eyed amongst you will have spotted, I've accidentally splatted an "x" at the start of my native method name, and this causes an uncaught exception runtime error No implementation found for void com.example.foo.MyClass.MyMethod().  Is there some linty magic I can turn on that checks whether all my public native methods have an implementation and throws a build-timer error if they don't?  Thanks.

答: Android Studio 3.6.3 shows this error pop-up for me if I rename the Java...boe function to xJava...boe.

Body:
In MyClass.java I have

package com.example.foo;
public class MyClass {
    public native void MyMethod();

and in MyClass.cpp I have

JNIEXPORT void JNICALL xJava_com_example_foo_MyClass_MyMethod(JNIEnv* env, jobject thiz)
{
    blah blah blah
}

Elsewhere in the Java code there's a call MyMethod();  However, as the eagle-eyed amongst you will have spotted, I've accidentally splatted an "x" at the start of my native method name, and this causes an uncaught exception runtime error No implementation found for void com.example.foo.MyClass.MyMethod().  Is there some linty magic I can turn on that checks whether all my public native methods have an implementation and throws a build-timer error if they don't?  Thanks.