RedPajama-Tiny / stackexchange_sample.jsonl
ivanzhou-uber's picture
Create RedPajama tiny
dbe8248
raw
history blame
48.4 kB
{"text": "Q: How to modify non-configurable, non-writable properties in Javascript? I'm writing a simple EventEmitter is ES5.\nThe objective is to ensure that all properties on EventEmitter instances are\nnon-writable and non-configurable.\"\nAfter 6 hours of racking my brain I still can't figure out how to, increase the listenerCount, for example if the configurable descriptor is set to false.\nHere's an example of what I have:\nvar eventEmitter = function(){\n var listeners = listeners || 0;\n var events = events || {};\n\n Object.defineProperties(this, {\n listeners: {\n value : 0,\n configurable: false,\n writable: false\n },\n events: {\n value: {},\n configurable : false,\n writable: false\n }\n });\n return this;\n};\n\n\neventEmmitter.prototype.on = function(ev, cb) {\n if (typeof ev !== 'string') throw new TypeError(\"Event should be type string\", \"index.js\", 6);\n if (typeof cb !== 'function' || cb === null || cb === undefined) throw new TypeError(\"callback should be type function\", \"index.js\", 7);\n\n if (this.events[ev]){\n this.events[ev].push(cb);\n } else {\n this.events[ev] = [cb];\n }\n\n this.listeners ++;\n return this;\n};\n\n\nA: I would recommend the use of an IIFE (immediatly invoked function expression):\nvar coolObj=(function(){\nvar public={};\nvar nonpublic={};\nnonpublic.a=0;\npublic.getA=function(){nonpublic.a++;return nonpublic.a;};\n\nreturn public;\n})();\n\nNow you can do:\ncoolObj.getA();//1\ncoolObj.getA();//2\ncoolObj.a;//undefined\ncoolObj.nonpublic;//undefined\ncoolObj.nonpublic.a;//undefined\n\nI know this is not the answer youve expected, but i think its the easiest way of doing sth like that.\n\nA: You can use a proxy which requires a key in order to define properties:\n\n\nfunction createObject() {\r\n var key = {configurable: true};\r\n return [new Proxy({}, {\r\n defineProperty(target, prop, desc) {\r\n if (desc.value === key) {\r\n return Reflect.defineProperty(target, prop, key);\r\n }\r\n }\r\n }), key];\r\n}\r\nfunction func() {\r\n var [obj, key] = createObject();\r\n key.value = 0;\r\n Reflect.defineProperty(obj, \"value\", {value: key});\r\n key.value = function() {\r\n key.value = obj.value + 1;\r\n Reflect.defineProperty(obj, \"value\", {value: key});\r\n };\r\n Reflect.defineProperty(obj, \"increase\", {value: key});\r\n return obj;\r\n}\r\nvar obj = func();\r\nconsole.log(obj.value); // 0\r\ntry { obj.value = 123; } catch(err) {}\r\ntry { Object.defineProperty(obj, \"value\", {value: 123}); } catch(err) {}\r\nconsole.log(obj.value); // 0\r\nobj.increase();\r\nconsole.log(obj.value); // 1\n\n\n", "meta": {"language": "en", "url": "https://stackoverflow.com/questions/41069927", "timestamp": "2023-03-29", "source": "stackexchange", "question_score": "2"}}
{"text": "Q: Image hiding under button android Image view is hiding under the button what changes I can do so that the image view can be above the button view pager also have bottom padding so that button can properly accommodate. The image is showing on the other parts but not above the button.\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <androidx.constraintlayout.widget.ConstraintLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:orientation=\"vertical\"\n tools:context=\".McqActivity\"\n android:id=\"@+id/fragment\"\n >\n \n <RelativeLayout\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n app:layout_constraintBottom_toBottomOf=\"parent\"\n app:layout_constraintEnd_toEndOf=\"parent\"\n app:layout_constraintStart_toStartOf=\"parent\">\n \n \n <ImageView\n android:id=\"@+id/starFirst\"\n android:layout_width=\"50dp\"\n android:layout_height=\"50dp\"\n android:src=\"@drawable/ic_baseline_star_24\"\n /> \n \n \n <com.google.android.material.button.MaterialButton\n android:id=\"@+id/right\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n />\n \n </RelativeLayout>\n \n <androidx.viewpager2.widget.ViewPager2\n android:id=\"@+id/questions_view_frag\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"0dp\"\n app:layout_constraintBottom_toBottomOf=\"parent\"\n app:layout_constraintEnd_toEndOf=\"parent\"\n app:layout_constraintHorizontal_bias=\"0.0\"\n app:layout_constraintStart_toStartOf=\"parent\"\n app:layout_constraintTop_toTopOf=\"parent\"\n app:layout_constraintVertical_bias=\"0.0\"\n android:orientation=\"horizontal\"\n android:paddingBottom=\"20dp\"\n android:paddingTop=\"50dp\"\n >\n \n </androidx.viewpager2.widget.ViewPager2>\n \n \n </androidx.constraintlayout.widget.ConstraintLayout>\n\n\nA: layout_constraintBottom_toBottomOf and other layout_constraint... won't work inside RelativeLayout, these are desired to work with ConstraintLayout as strict parent. if you want to align two Views next to/below/above inside RelativeLayoyut you have to use other attributes, e.g.\nandroid:layout_below=\"@+id/starFirst\"\nandroid:layout_above=\"@+id/starFirst\"\nandroid:layout_toRightOf=\"@id/starFirst\"\nandroid:layout_toLeftOf=\"@id/starFirst\"\n\nnote that every attr which starts with layout_ is desired to be read by strict parent, not by View which have such attrs set. every ViewGroup have own set of such\nedit: turned out that this is an elevation case/issue (Z axis), so useful attributes are\nandroid:translationZ=\"100dp\"\nandroid:elevation=\"100dp\"\n\n", "meta": {"language": "en", "url": "https://stackoverflow.com/questions/70017985", "timestamp": "2023-03-29", "source": "stackexchange", "question_score": "0"}}
{"text": "Q: Handling multiple exceptions I have written a class which loads configuration objects of my application and keeps track of them so that I can easily write out changes or reload the whole configuration at once with a single method call. However, each configuration object might potentially throw an exception when doing IO, yet I do not want those errors to cancel the overall process in order to give the other objects still a chance to reload/write. Therefore I collect all exceptions which are thrown while iterating over the objects and store them in a super-exception, which is thrown after the loop, since each exception must still be handled and someone has to be notified of what exactly went wrong. However, that approach looks a bit odd to me. Someone out there with a cleaner solution? \nHere is some code of the mentioned class:\npublic synchronized void store() throws MultipleCauseException\n {\n MultipleCauseException me = new MultipleCauseException(\"unable to store some resources\");\n for(Resource resource : this.resources.values())\n {\n try\n {\n resource.store();\n }\n catch(StoreException e)\n {\n me.addCause(e);\n }\n }\n if(me.hasCauses())\n throw me;\n }\n\n\nA: If you want to keep the results of the operations, which it seems you do as you purposely carry on, then throwing an exception is the wrong thing to do. Generally you should aim not to disturb anything if you throw an exception.\nWhat I suggest is passing the exceptions, or data derived from them, to an error handling callback as you go along.\npublic interface StoreExceptionHandler {\n void handle(StoreException exc);\n}\n\npublic synchronized void store(StoreExceptionHandler excHandler) {\n for (Resource resource : this.resources.values()) {\n try {\n resource.store();\n } catch (StoreException exc) {\n excHandler.handle(exc);\n }\n }\n /* ... return normally ... */\n]\n\n\nA: There are guiding principles in designing what and when exceptions should be thrown, and the two relevant ones for this scenario are:\n\n\n*\n\n*Throw exceptions appropriate to the abstraction (i.e. the exception translation paradigm)\n\n*Throw exceptions early if possible\n\n\nThe way you translate StoreException to MultipleCauseException seems reasonable to me, although lumping different types of exception into one may not be the best idea. Unfortunately Java doesn't support generic Throwables, so perhaps the only alternative is to create a separate MultipleStoreException subclass instead.\nWith regards to throwing exceptions as early as possible (which you're NOT doing), I will say that it's okay to bend the rule in certain cases. I feel like the danger of delaying a throw is when exceptional situations nest into a chain reaction unnecessarily. Whenever possible, you want to avoid this and localize the exception to the smallest scope possible.\nIn your case, if it makes sense to conceptually think of storing of resources as multiple independent tasks, then it may be okay to \"batch process\" the exception the way you did. In other situations where the tasks has more complicated interdependency relationship, however, lumping it all together will make the task of analyzing the exceptions harder.\nIn a more abstract sense, in graph theory terms, I think it's okay to merge a node with multiple childless children into one. It's probably not okay to merge a whole big subtree, or even worse, a cyclic graph, into one node.\n", "meta": {"language": "en", "url": "https://stackoverflow.com/questions/2444580", "timestamp": "2023-03-29", "source": "stackexchange", "question_score": "8"}}
{"text": "Q: What is the meaning of Duration in Amazon RDS Backup window What does Duration specify?\nDoes it mean that the backup will start between 01:00 to 01:30 and keep running until it has completed? Or does it have a different meaning?\n\n\nA: The duration window indicates the time in which the backup will start. I can start anywhere between the time specified and could last longer than the window.\n", "meta": {"language": "en", "url": "https://stackoverflow.com/questions/58445170", "timestamp": "2023-03-29", "source": "stackexchange", "question_score": "-1"}}
{"text": "Q: Uncontrolled input of type text to be controlled warning I'm trying to create a multi step registration form using React and Redux.\nThe main component is as follows : \nimport React, {PropTypes} from 'react';\nimport {connect} from 'react-redux';\nimport {bindActionCreators} from 'redux';\nimport * as actionCreators from '../../actions/actionCreators';\nimport countries from '../../data/countries';\n\nimport RegistrationFormStepOne from './registrationFormStepOne';\nimport RegistrationFormStepTwo from './registrationFormStepTwo';\nimport RegistrationFormStepThree from './registrationFormStepThree';\nimport RegistrationFormStepFour from './registrationFormStepFour';\n\nclass RegistrationPage extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n user: Object.assign({}, this.props.userData),\n fileNames: {},\n selectedFile: {},\n icons: {\n idCard: 'upload',\n statuten: 'upload',\n blankLetterhead: 'upload',\n companyPhoto: 'upload'\n },\n step: 1,\n errors: {}\n };\n\n this.setUser = this.setUser.bind(this);\n this.onButtonClick = this.onButtonClick.bind(this);\n this.onButtonPreviousClick = this.onButtonPreviousClick.bind(this);\n this.changeCheckboxState = this.changeCheckboxState.bind(this);\n this.onFileChange = this.onFileChange.bind(this);\n this.routerWillLeave = this.routerWillLeave.bind(this);\n }\n\n componentDidMount() {\n this.context.router.setRouteLeaveHook(this.props.route, this.routerWillLeave);\n }\n\n routerWillLeave(nextLocation) {\n if (this.state.step > 1) {\n this.setState({step: this.state.step - 1});\n return false;\n }\n }\n\n getCountries(){\n return countries;\n }\n\n\n setUser(event) {\n const field = event.target.name;\n const value = event.target.value;\n\n let user = this.state.user;\n user[field] = value;\n this.setState({user: user});\n\n }\n\n validation(){\n const user = this.state.user;\n const languageReg = this.props.currentLanguage.default.registrationPage;\n let formIsValid = true;\n let errors = {};\n\n if(!user.companyName){\n formIsValid = false;\n errors.companyName = languageReg.companyNameEmpty;\n }\n\n if(!user.btwNumber){\n formIsValid = false;\n errors.btwNumber = languageReg.btwNumberEmpty;\n }\n\n if(!user.address){\n formIsValid = false;\n errors.address = languageReg.addressEmpty;\n }\n\n if(!user.country){\n formIsValid = false;\n errors.country = languageReg.countryEmpty;\n }\n\n if(!user.zipcode){\n formIsValid = false;\n errors.zipcode = languageReg.zipcodeEmpty;\n }\n\n if(!user.place){\n formIsValid = false;\n errors.place = languageReg.placeEmpty;\n }\n\n\n if(!user.firstName){\n formIsValid = false;\n errors.firstName = languageReg.firstnameEmpty;\n }\n\n\n\n this.setState({errors: errors});\n return formIsValid;\n }\n\n onFileChange(name, event) {\n event.preventDefault();\n let file = event.target.value;\n\n let filename = file.split('\\\\').pop(); //We get only the name of the file\n let filenameWithoutExtension = filename.replace(/\\.[^/.]+$/, \"\"); //We get the name of the file without extension\n\n let user = this.state.user;\n let fileNames = this.state.fileNames;\n let selectedFile = this.state.selectedFile;\n let icons = this.state.icons;\n\n switch (name.btnName) {\n case \"idCard\" :\n fileNames[name.btnName] = filenameWithoutExtension;\n //Check if file is selected\n if(file){\n selectedFile[name.btnName] = \"fileSelected\";\n user[\"idCardFile\"] = true;\n icons[\"idCard\"] = \"check\";\n }else{\n selectedFile[name.btnName] = \"\";\n user[\"idCardFile\"] = false;\n icons[\"idCard\"] = \"upload\";\n }\n break;\n case \"statuten\" :\n fileNames[name.btnName] = filenameWithoutExtension;\n\n //Check if file is selected\n if(file){\n selectedFile[name.btnName] = \"fileSelected\";\n user[\"statutenFile\"] = true;\n icons[\"statuten\"] = \"check\";\n }else{\n selectedFile[name.btnName] = \"\";\n user[\"statutenFile\"] = false;\n icons[\"statuten\"] = \"upload\";\n }\n break;\n case \"blankLetterhead\" :\n fileNames[name.btnName] = filenameWithoutExtension;\n\n //Check if file is selected\n if(file){\n selectedFile[name.btnName] = \"fileSelected\";\n user[\"blankLetterheadFile\"] = true;\n icons[\"blankLetterhead\"] = \"check\";\n }else{\n selectedFile[name.btnName] = \"\";\n user[\"blankLetterheadFile\"] = false;\n icons[\"blankLetterhead\"] = \"upload\";\n }\n break;\n default:\n fileNames[name.btnName] = filenameWithoutExtension;\n //Check if file is selected\n if(file){\n selectedFile[name.btnName] = \"fileSelected\";\n user[\"companyPhotoFile\"] = true;\n icons[\"companyPhoto\"] = \"check\";\n }else{\n selectedFile[name.btnName] = \"\";\n user[\"companyPhotoFile\"] = false;\n icons[\"companyPhoto\"] = \"upload\";\n }\n }\n\n this.setState({user: user, fileNames: fileNames, selectedFile: selectedFile, icons: icons});\n }\n\n changeCheckboxState(event) {\n let chcName = event.target.name;\n let user = this.state.user;\n\n switch (chcName) {\n case \"chcEmailNotificationsYes\":\n user[\"emailNotifications\"] = event.target.checked;\n break;\n case \"chcEmailNotificationsNo\":\n user[\"emailNotifications\"] = !event.target.checked;\n break;\n case \"chcTerms\":\n if(typeof this.state.user.terms === \"undefined\"){\n user[\"terms\"] = false;\n }else{\n user[\"terms\"] = !this.state.user.terms;\n }\n\n break;\n case \"chcSmsYes\":\n user[\"smsNotifications\"] = event.target.checked;\n break;\n default:\n user[\"smsNotifications\"] = !event.target.checked;\n }\n this.setState({user: user});\n this.props.actions.userRegistration(this.state.user);\n }\n\n onButtonClick(name, event) {\n event.preventDefault();\n this.props.actions.userRegistration(this.state.user);\n switch (name) {\n case \"stepFourConfirmation\":\n this.setState({step: 1});\n break;\n case \"stepTwoNext\":\n this.setState({step: 3});\n break;\n case \"stepThreeFinish\":\n this.setState({step: 4});\n break;\n default:\n if(this.validation()) {\n this.setState({step: 2});\n }\n }\n }\n\n\n onButtonPreviousClick(){\n this.setState({step: this.state.step - 1});\n }\n\n render() {\n const languageReg = this.props.currentLanguage.default.registrationPage;\n\n console.log(this.state.user);\n let formStep = '';\n let step = this.state.step;\n switch (step) {\n case 1:\n formStep = (<RegistrationFormStepOne user={this.props.userData}\n onChange={this.setUser}\n onButtonClick={this.onButtonClick}\n countries={this.getCountries(countries)}\n errors={this.state.errors}\n step={step}/>);\n break;\n case 2:\n formStep = (<RegistrationFormStepTwo user={this.props.userData}\n onChange={this.setUser}\n onButtonClick={this.onButtonClick}\n onButtonPreviousClick={this.onButtonPreviousClick}\n errors={this.state.errors}/>);\n break;\n case 3:\n formStep = (<RegistrationFormStepThree user={this.props.userData}\n onFileChange={this.onFileChange}\n onButtonClick={this.onButtonClick}\n onButtonPreviousClick={this.onButtonPreviousClick}\n errors={this.state.errors}\n fileNames={this.state.fileNames}\n icons={this.state.icons}\n fileChosen={this.state.selectedFile}/>);\n break;\n\n default:\n formStep = (<RegistrationFormStepFour user={this.props.userData}\n onChange={this.setUser}\n onChangeCheckboxState={this.changeCheckboxState}\n onButtonClick={this.onButtonClick}\n onButtonPreviousClick={this.onButtonPreviousClick}\n errors={this.state.errors}/>);\n }\n\n return (\n <div className=\"sidebar-menu-container\" id=\"sidebar-menu-container\">\n\n <div className=\"sidebar-menu-push\">\n\n <div className=\"sidebar-menu-overlay\"></div>\n\n <div className=\"sidebar-menu-inner\">\n <div className=\"contact-form\">\n <div className=\"container\">\n <div className=\"row\">\n <div className=\"col-md-10 col-md-offset-1 col-md-offset-right-1\">\n {React.cloneElement(formStep, {currentLanguage: languageReg})}\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n }\n}\n\nRegistrationPage.contextTypes = {\n router: PropTypes.object\n};\n\nfunction mapStateToProps(state, ownProps) {\n return {\n userData: state.userRegistrationReducer\n };\n}\n\nfunction mapDispatchToProps(dispatch) {\n return {\n actions: bindActionCreators(actionCreators, dispatch)\n };\n}\n\nexport default connect(mapStateToProps, mapDispatchToProps)(RegistrationPage);\n\nThe first step component is as follows\n import React from 'react';\nimport Button from '../../common/formElements/button';\nimport RegistrationFormHeader from './registrationFormHeader';\nimport TextInput from '../../common/formElements/textInput';\nimport SelectInput from '../../common/formElements/selectInput';\n\nconst RegistrationFormStepOne = ({user, onChange, onButtonClick, errors, currentLanguage, countries}) => {\n\n const language = currentLanguage;\n\n return (\n <div className=\"contact_form\">\n <form role=\"form\" action=\"\" method=\"post\" id=\"contact_form\">\n <div className=\"row\">\n <RegistrationFormHeader activeTab={0} currentLanguage={language}/>\n <div className=\"hideOnBigScreens descBox\">\n <div className=\"headerTitle\">{language.businessInfoConfig}</div>\n <div className=\"titleDesc\">{language.businessBoxDesc}</div>\n </div>\n <div className=\"col-lg-12\">\n <h6 className=\"registrationFormDesc col-lg-10 col-lg-offset-1 col-lg-offset-right-2 col-xs-12\">\n {language.businessDesc}\n </h6>\n <div className=\"clearfix\"></div>\n <div className=\"col-sm-6\">\n <TextInput\n type=\"text\"\n name=\"companyName\"\n label={language.companyNameLabel}\n labelClass=\"control-label\"\n placeholder={language.companyNameLabel}\n className=\"templateInput\"\n id=\"company\"\n onChange={onChange}\n value={user.companyName}\n errors={errors.companyName}\n />\n </div>\n <div className=\"col-sm-6\">\n <TextInput\n type=\"text\"\n name=\"btwNumber\"\n label={language.vatNumberLabel}\n placeholder={language.vatNumberLabel}\n className=\"templateInput\"\n id=\"btwNumber\"\n onChange={onChange}\n value={user.btwNumber}\n errors={errors.btwNumber}\n />\n </div>\n\n <div className=\"col-sm-12\" style={{marginBottom: 25}}>\n <TextInput\n type=\"text\"\n name=\"address\"\n label={language.addressLabel}\n placeholder={language.address1Placeholder}\n className=\"templateInput\"\n id=\"address\"\n onChange={onChange}\n value={user.address}\n errors={errors.address}\n />\n </div>\n\n <div className=\"col-sm-12\" style={{marginBottom: 25}}>\n <TextInput\n type=\"text\"\n name=\"address1\"\n placeholder={language.address2Placeholder}\n className=\"templateInput\"\n id=\"address\"\n onChange={onChange}\n value={user.address1}\n errors=\"\"\n />\n </div>\n\n <div className=\"col-sm-12\">\n <TextInput\n type=\"text\"\n name=\"address2\"\n placeholder={language.address3Placeholder}\n className=\"templateInput\"\n id=\"address\"\n onChange={onChange}\n value={user.address2}\n errors=\"\"\n />\n </div>\n\n <div className=\"col-sm-3\">\n <SelectInput name=\"country\"\n label={language.selectCountryLabel}\n onChange={onChange}\n options={countries}\n className=\"templateInput selectField\"\n defaultOption={language.selectCountry}\n value={user.country}\n errors={errors.country}\n />\n </div>\n\n <div className=\"col-sm-3\">\n\n <TextInput\n type=\"text\"\n name=\"zipcode\"\n label={language.zipcodeLabel}\n placeholder={language.zipcodeLabel}\n className=\"templateInput\"\n id=\"zipcode\"\n onChange={onChange}\n value={user.zipcode}\n errors={errors.zipcode}\n />\n </div>\n <div className=\"col-sm-6\">\n <TextInput\n type=\"text\"\n name=\"place\"\n label={language.placeLabel}\n placeholder={language.placeLabel}\n className=\"templateInput\"\n id=\"place\"\n onChange={onChange}\n value={user.place}\n errors={errors.place}\n />\n </div>\n </div>\n <div className=\"clearfix\"></div>\n <div className=\"col-lg-12\" style={{marginLeft: 15, marginTop: 30}}>\n <Button onClick={onButtonClick.bind(this)}\n name=\"stepOneNext\"\n value={language.btnNext}\n icon=\"arrow-circle-right\"\n style={{margin: '0 auto 60px'}}/>\n </div>\n </div>\n </form>\n </div>\n );\n};\n\nexport default RegistrationFormStepOne;\n\nI try to add some simple validation and I've added validation function in my main component and then I check on button click if the returned value true or false is. If it's true, than I set step state to a appropriate value. And it works if I validate only the form fields of the first step, but when I try to also validate one or more form fields of the next step (now I'm trying to validate also the first field of the second step)\nif(!user.firstName){\n formIsValid = false;\n errors.firstName = languageReg.firstnameEmpty;\n }\n\nI get than \nWarning: TextInput is changing an uncontrolled input of type text to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component.\nWithout the validation function works everything perfect.\nAny advice?\nEDIT\n import React, {propTypes} from 'react';\nimport _ from 'lodash';\n\nconst TextInput = ({errors, style, name, labelClass, label, className, placeholder, id, value, onChange, type}) => {\n let wrapperClass = \"form-group\";\n\n if (errors) {\n wrapperClass += \" \" + \"inputHasError\";\n }\n\n return (\n <div className={wrapperClass} style={style}>\n <label htmlFor={name} className={labelClass}>{label}</label>\n <input type={type}\n className={className}\n placeholder={placeholder}\n name={name}\n id={id}\n value={value}\n style={{}}\n onChange={onChange}\n />\n <div className=\"errorBox\">{errors}</div>\n </div>\n );\n};\n\nTextInput.propTypes = {\n name: React.PropTypes.string.isRequired,\n label: React.PropTypes.string,\n onChange: React.PropTypes.func.isRequired,\n type: React.PropTypes.string.isRequired,\n id: React.PropTypes.string,\n style: React.PropTypes.object,\n placeholder: React.PropTypes.string,\n className: React.PropTypes.string,\n labelClass: React.PropTypes.string,\n value: React.PropTypes.string,\n errors: React.PropTypes.string\n};\n\nexport default TextInput;\n\nThis is second step component : \nimport React from 'react';\nimport Button from '../../common/formElements/button';\nimport RegistrationFormHeader from './registrationFormHeader';\nimport TextInput from '../../common/formElements/textInput';\n\n\nconst RegistrationFormStepTwo = ({user, onChange, onButtonClick, onButtonPreviousClick, errors, currentLanguage}) => {\n const language = currentLanguage;\n\n return (\n <div className=\"contact_form\">\n <form role=\"form\" action=\"\" method=\"post\" id=\"contact_form\">\n <div className=\"row\">\n <RegistrationFormHeader activeTab={1} currentLanguage={language}/>\n <div className=\"hideOnBigScreens descBox\">\n <div className=\"headerTitle\">{language.personalInfoConfig}</div>\n <div className=\"titleDesc\">{language.personalBoxDesc}</div>\n </div>\n <div className=\"col-lg-12\">\n <h6 className=\"registrationFormDesc col-lg-10 col-lg-offset-1 col-lg-offset-right-2 col-xs-12\">\n {language.personalDesc}\n </h6>\n <div className=\"col-lg-6 col-md-6 col-sm-6 col-xs-12\">\n <TextInput\n type=\"text\"\n name=\"firstName\"\n label={language.firsnameLabel}\n placeholder={language.firsnameLabel}\n className=\"templateInput\"\n id=\"name\"\n onChange={onChange}\n value={user.firstName}\n errors={errors.firstName}\n />\n </div>\n <div className=\"col-lg-6 col-md-6 col-sm-6 col-xs-12\">\n <TextInput\n type=\"text\"\n name=\"lastName\"\n label={language.lastnameLabel}\n placeholder={language.lastnameLabel}\n className=\"templateInput\"\n id=\"name\"\n onChange={onChange}\n value={user.lastName}\n errors={errors.lastName}\n />\n </div>\n\n <div className=\"col-lg-6 col-md-6 col-sm-6 col-xs-12\">\n <TextInput\n type=\"text\"\n name=\"phone\"\n label={language.phoneLabel}\n placeholder={language.phoneLabel}\n className=\"templateInput\"\n id=\"phone\"\n onChange={onChange}\n value={user.phone}\n errors={errors.phone}\n\n />\n </div>\n\n <div className=\"col-lg-6 col-md-6 col-sm-6 col-xs-12\">\n <TextInput\n type=\"text\"\n name=\"mobilePhone\"\n label={language.mobileLabel}\n placeholder={language.mobileLabel}\n className=\"templateInput\"\n id=\"phone\"\n style={{}}\n onChange={onChange}\n value={user.mobilePhone}\n errors={errors.mobilePhone}\n />\n </div>\n <div className=\"clearfix\"></div>\n\n <div className=\"col-lg-12 col-md-12 col-sm-12 col-xs-12\">\n <TextInput\n type=\"text\"\n name=\"email\"\n id=\"email\"\n label={language.emailLabel}\n placeholder={language.emailLabel}\n className=\"templateInput\"\n style={{}}\n onChange={onChange}\n value={user.email}\n errors={errors.email}\n />\n </div>\n\n <div className=\"col-lg-12 col-md-12 col-sm-12 col-xs-12\">\n <TextInput\n type=\"text\"\n name=\"userName\"\n label={language.usernameLabel}\n placeholder={language.usernameLabel}\n className=\"templateInput\"\n id=\"name\"\n onChange={onChange}\n value={user.userName}\n errors={errors.userName}\n />\n </div>\n\n <div className=\"col-lg-6 col-md-6 col-sm-6 col-xs-12\">\n <TextInput\n type=\"password\"\n name=\"password\"\n label={language.passwordLabel}\n placeholder={language.passwordLabel}\n className=\"templateInput\"\n id=\"password\"\n onChange={onChange}\n value={user.password}\n errors={errors.password}\n />\n </div>\n <div className=\"col-lg-6 col-md-6 col-sm-6 col-xs-12\">\n <TextInput\n type=\"password\"\n name=\"confirmPassword\"\n label={language.passwordConfirmLabel}\n placeholder={language.passwordConfirmLabel}\n className=\"templateInput\"\n id=\"password\"\n onChange={onChange}\n value={user.confirmPassword}\n errors={errors.confirmPassword}\n />\n </div>\n\n </div>\n <div className=\"clearfix\"></div>\n <div className=\"col-lg-6 col-xs-6\" style={{marginTop: 30}}>\n <Button onClick={onButtonPreviousClick}\n name=\"btnPrevious\"\n value={language.btnPrevious}\n icon=\"arrow-circle-left\"\n style={{marginRight: 10, float: 'right'}}/>\n </div>\n <div className=\"col-lg-6 col-xs-6\" style={{marginTop: 30}}>\n <Button onClick={onButtonClick} name=\"stepTwoNext\" value={language.btnNext}\n icon=\"arrow-circle-right\" style={{marginLeft: 10, float: 'left'}}/>\n </div>\n </div>\n </form>\n </div>\n\n );\n};\n\nexport default RegistrationFormStepTwo;\n\n\nA: This is why the warning exists: When the value is specified as undefined, React has no way of knowing if you intended to render a component with an empty value or if you intended for the component to be uncontrolled. It is a source of bugs. \nYou could do a null/undefined check, before passing the value to the input.\na source\n\nA: @Kokovin Vladislav is right. To put this in code, you can do this in all your input values:\n<TextInput\n // your other code\n value={user.firstName || ''}\n/>\n\nThat is, if you don't find the value of first name, then give it an empty value.\n", "meta": {"language": "en", "url": "https://stackoverflow.com/questions/38014397", "timestamp": "2023-03-29", "source": "stackexchange", "question_score": "6"}}
{"text": "Q: Interleaving the rows of two different SQL tables, group by one row My Sql query is like this\n$view = mysql_query (\"SELECT domain,count(distinct session_id) as \n views FROM `statistik` left join statistik_strippeddomains on \n statistik_strippeddomains.id = statistik.strippeddomain WHERE\n `angebote_id` = '\".(int)$_GET['id'].\"' and strippeddomain!=1 \n group by domain having count (distinct session_id) >\n \".(int)($film_daten['angebote_views']/100).\" order \n count(distinct session_id$vladd) desc limit 25\");\n\nHow can I write its Codeigniter Model I appreciate any Help\n\nA: try this\n$this->db->select('statistik.domain,statistik.count(DISTINCT(session_id)) as views');\n$this->db->from('statistik');\n$this->db->join('statistik_strippeddomains', 'statistik_strippeddomains.id = statistik.strippeddomain', 'left'); \n$this->db->where('angebote_id',$_GET['id']);\n$this->db->where('strippeddomain !=',1);\n$this->db->group_by('domain');\n$this->db->having('count > '.$film_daten['angebote_views']/100, NULL, FALSE);\n$this->db->order_by('count','desc');\n$this->db->limit('25');\n$query = $this->db->get();\n\nComment me If you have any query.\n", "meta": {"language": "en", "url": "https://stackoverflow.com/questions/39852573", "timestamp": "2023-03-29", "source": "stackexchange", "question_score": "0"}}
{"text": "Q: Query conditions to insert data from a form What I'm trying to do is: \nIf the age input in my form = 28, 30, 25 or 21 then I want to auto insert value 8 in the column (VE), else keep it empty. Is this the right way to do that?\nif($form_data->action == 'Insert')\n {\n\n $age=array(28, 30, 25, 21);\n $age_str=implode(\"','\", $age);\n\n if($form_data->age == $age_str){\n\n $query=\"INSERT INTO tbl\n (VE) VALUE ('8') WHERE id= '\".$form_data->id.\"'\n \";\n $statement = $connect->prepare($query);\n $statement->execute();\n }\n $data = array(\n ':date' => $date,\n ':first_name' => $first_name,\n ':last_name' => $last_name,\n ':age' => $age\n );\n $query = \"\n INSERT INTO tbl\n (date, first_name, last_name, age) VALUES \n (:date, :first_name, :last_name, :age)\n \";\n $statement = $connect->prepare($query);\n\n\n if($statement->execute($data))\n {\n $message = 'Data Inserted';\n }\n }\n\n\n\nAlso, how do I insert the new row with the row id from the other form data going into tbl?\n\nA: Use php's in_array instead of trying to compare a string. To get the id of the query where you insert the form data, you can return the id of the insert row from your prepared statement.\nif ($form_data->action == 'Insert') {\n\n // assuming $age, $date, $first_name, $last_name\n // already declared prior to this block\n $data = array(\n ':date' => $date,\n ':first_name' => $first_name,\n ':last_name' => $last_name,\n ':age' => $age\n );\n\n $query = \"\n INSERT INTO tbl\n (date, first_name, last_name, age) VALUES \n (:date, :first_name, :last_name, :age)\n \";\n $statement = $connect->prepare($query);\n\n if ($statement->execute($data)) {\n $message = 'Data Inserted';\n\n // $id is the last inserted id for (tbl)\n $id = $connect->lastInsertID();\n\n // NOW you can insert your child row in the other table\n $ages_to_insert = array(28, 30, 25, 21);\n\n // in_array uses your array...so you don't need\n // if($form_data->age == $age_str){\n\n if (in_array($form_data->age, $ages_to_insert)) {\n\n $query=\"UPDATE tbl SER VE = '8' WHERE id= '\".$id.\"'\";\n $statement2 = $connect->prepare($query);\n $statement2->execute();\n }\n }\n}\n\n", "meta": {"language": "en", "url": "https://stackoverflow.com/questions/58903757", "timestamp": "2023-03-29", "source": "stackexchange", "question_score": "1"}}
{"text": "Q: Is the function $\\ln(ax + b)$ increasing/decreasing, concave/convex? $h(x) = \\ln(ax + b)$ \nNB. Examine your results acccording to values of $(a,b)$\nI've differentiated twice in order to get the following:\n$$\nh''(x) = -\\frac{a^2}{(ax+b)^2}\n$$\nI think this proves that $h(x)$ is concave for all value of $a$ and $b$ since $h''(x)\\le0$. Is this correct?\nI don't know how to prove whether it's increasing/decreasing or what the NB really means so any help with that would be great.\n\nA: we now that the domain of the function is:\n$$ax+b\\gt 0\\Rightarrow x\\gt\\frac{-b}{a}\\text{so the domain is:}(\\frac{-b}{a},+\\infty)$$\n$$f'(x)=\\frac{a}{ax+b}$$\nin the domain of the function since we have $x\\gt\\frac{-b}{a}\\Rightarrow ax+b>0 $ the sign of $f'(x)=\\frac{a}{ax+b}$ will be dependent to the sign of $a$ so:\nif $a\\gt 0\\Rightarrow f'(x)\\gt 0$ and $f(x)$ will be increasing in its domain\nif $a\\lt 0\\Rightarrow f'(x)\\lt 0$ and $f(x)$ will be decreasing in its domain\nNote the phrases in its domain in the above expression, we always study the behaviors of functions in their domain\n$$f''(x)=\\frac{-a^2}{(ax+b)^2}$$\nas you said without we always have $f''(x)<0$ so without considering the sign of $a$, $f(x)$ will be a convex function\nThe value of $b$ doesnot influence the first and second derivation and so will not affect concavity, convexity, increase or decrease of the function \nhere is the diagram for $f(x)=\\ln(2x+1)$ as you see $a=2\\gt 0$ and $f(x)$ is increasing and convex\n \nhere is the diagram for $f(x)=\\ln(-2x+1)$ as you see $a=-2\\lt 0$ and $f(x)$ is decreasing and convex\n\n\nA: $$h^{ \\prime }\\left( x \\right) =\\frac { a }{ ax+b } >0$$\n$1$.if $a>0$ $ax+b>0$ $\\Rightarrow $ $ax>-b$ $\\Rightarrow $ $x>-\\frac { b }{ a } $ function is increasing\n$2$.if $a<0 $ $x<-\\frac { b }{ a } $ function is decreasing\nAnd about concavity you are right,find second derivative and check intervals\n", "meta": {"language": "en", "url": "https://math.stackexchange.com/questions/1400530", "timestamp": "2023-03-29", "source": "stackexchange", "question_score": "1"}}
{"text": "Q: Accessing array value is null Hello I have decoded a json string that I sent to my server and Im trying to get the values from him.\nMy problem is that I cant get the values from the inner arrays.\nThis is my code:\n<?php\n\n $post = file_get_contents('php://input');\n\n $arrayBig = json_decode($post, true);\n\n foreach ($arrayBig as $array)\n {\n\n\n $exercise = $array['exercise'];\n\n $response[\"exercise\"] = $exercise;\n $response[\"array\"] = $array;\n\n echo json_encode($response);\n\n\n }\n\n?>\n\nWhen I get the answer from my $response I get this values:\n{\"exercise\":null,\"array\":[{\"exercise\":\"foo\",\"reps\":\"foo\"}]}\n\nWhy is $array['exercise'] null if I can see that is not null in the array\nThanks.\n\nA: Because of the [{...}] you are getting an array in an array when you decode your array key.\nSo:\n$exercise = $array['exercise'];\n\nShould be:\n$exercise = $array[0]['exercise'];\n\nSee the example here.\n\nA: From looking at the result of $response['array'], it looks like $array is actually this\n[['exercise' => 'foo', 'reps' => 'foo']]\n\nthat is, an associative array nested within a numeric one. You should probably do some value checking before blindly assigning values but in the interest of brevity...\n$exercise = $array[0]['exercise'];\n\n", "meta": {"language": "en", "url": "https://stackoverflow.com/questions/21893968", "timestamp": "2023-03-29", "source": "stackexchange", "question_score": "1"}}
{"text": "Q: Composer update show this error: VirtualAlloc() failed: [0x00000008] Composer worked find yesterday, but today after I trying install:\ncomposer require --prefer-dist \"himiklab/yii2-recaptcha-widget\" \"*\"\nWhile run composer update command it show me error:\n\nVirtualAlloc() failed: [0x00000008] VirtualAlloc() failed:\n[0x00000008] PHP Fatal error: Out of memory (allocated 956301312)\n(tried to allocate 201326600 bytes) in\nphar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleSet.php\non line 84\nFatal error: Out of memory (allocated 956301312) (tried to allocate\n201326600 bytes) in\nphar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleSet.php\non line 84\n\nI try update composer on my other projects, it is worked fine. After some researching I increased memory_limit: 4096M(also -1) in php.ini file. Then I tried to increase virtual memory in Computer->Properties, but still show error.\nI try to run next command:\ncomposer update -vvv --profile, result in attached image\nComposer error\nAny help would be greatly appreciated.\n\nA: You are probably using 32bit PHP. This version cannot allocate enough memory for composer even if you change the memory_limit to -1 (unlimited).\nPlease use 64 bit PHP with the Composer to get rid of these memory problems.\n", "meta": {"language": "en", "url": "https://stackoverflow.com/questions/49994946", "timestamp": "2023-03-29", "source": "stackexchange", "question_score": "2"}}