{"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 \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \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 = ();\n break;\n case 2:\n formStep = ();\n break;\n case 3:\n formStep = ();\n break;\n\n default:\n formStep = ();\n }\n\n return (\n
\n\n
\n\n
\n\n
\n
\n
\n
\n
\n {React.cloneElement(formStep, {currentLanguage: languageReg})}\n
\n
\n
\n
\n
\n
\n
\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
\n
\n
\n \n
\n
{language.businessInfoConfig}
\n
{language.businessBoxDesc}
\n
\n
\n
\n {language.businessDesc}\n
\n
\n
\n \n
\n
\n \n
\n\n
\n \n
\n\n
\n \n
\n\n
\n \n
\n\n
\n \n
\n\n
\n\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\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
\n \n \n
{errors}
\n
\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
\n
\n
\n \n
\n
{language.personalInfoConfig}
\n
{language.personalBoxDesc}
\n
\n
\n
\n {language.personalDesc}\n
\n
\n \n
\n
\n \n
\n\n
\n \n
\n\n
\n \n
\n
\n\n
\n \n
\n\n
\n \n
\n\n
\n \n
\n
\n \n
\n\n
\n
\n
\n
\n
\n
\n
\n
\n
\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\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\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"}}