qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
30,090,008
Is it possible to convert fractions that are entered into UITextField into decimals? So far, this is what I have tried. If I enter in 2/3 into my UITextField, I get 2.0 as my answer. ``` @IBOutlet weak var answer: UITextField! var sAnswer = (answer.text as NSString).doubleValue println(sAnswer) ``` If I just use this, I will get 2/3 but it is a string and not a decimal answer of 0.6666666666... ``` @IBOutlet weak var answer: UITextField! var sAnswer = answer.text as NSString println(sAnswer) ```
2015/05/07
[ "https://Stackoverflow.com/questions/30090008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4358488/" ]
You need to parse and then calculate the fraction by yourself in a method or extension. One way of doing is as follows: ``` extension UITextField { var fraction: Float { var comps = text.componentsSeparatedByString("/") //Do some validation here so as to check the correct format of fraction text. var op1 = NSString(string: comps[0]).floatValue var op2 = NSString(string: comps[1]).floatValue return op1/op2 } } ```
No. The text will always be a string. But what you could do is, make an extension for your UITextField where you split your string at the `/` and divide it. Then you return the double-value. Like that: ``` extension UITextField { var xo: Double! { get { var value = self.text.componentsSeparatedByString("/") return (value[0] as NSString).doubleValue / (value[1] as NSString).doubleValue } } } ``` Then you use it like that: ``` answer.doubleValue ```
30,090,008
Is it possible to convert fractions that are entered into UITextField into decimals? So far, this is what I have tried. If I enter in 2/3 into my UITextField, I get 2.0 as my answer. ``` @IBOutlet weak var answer: UITextField! var sAnswer = (answer.text as NSString).doubleValue println(sAnswer) ``` If I just use this, I will get 2/3 but it is a string and not a decimal answer of 0.6666666666... ``` @IBOutlet weak var answer: UITextField! var sAnswer = answer.text as NSString println(sAnswer) ```
2015/05/07
[ "https://Stackoverflow.com/questions/30090008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4358488/" ]
No. The text will always be a string. But what you could do is, make an extension for your UITextField where you split your string at the `/` and divide it. Then you return the double-value. Like that: ``` extension UITextField { var xo: Double! { get { var value = self.text.componentsSeparatedByString("/") return (value[0] as NSString).doubleValue / (value[1] as NSString).doubleValue } } } ``` Then you use it like that: ``` answer.doubleValue ```
A more modern Swift 5 solution: ``` func parse(fractionString: String) -> Float? { guard fractionString.range(of: "^\\d+\\/\\d+$", options: .regularExpression) != nil else { return nil } let components = fractionString.split(separator: "/") if let numerator = Float(components[0]), let denominator = Float(components[1]), denominator != 0 { return numerator / denominator } return nil } ``` The regex check at the beginning is just making sure that the input string is just digits with a single "/" in the middle.
30,090,008
Is it possible to convert fractions that are entered into UITextField into decimals? So far, this is what I have tried. If I enter in 2/3 into my UITextField, I get 2.0 as my answer. ``` @IBOutlet weak var answer: UITextField! var sAnswer = (answer.text as NSString).doubleValue println(sAnswer) ``` If I just use this, I will get 2/3 but it is a string and not a decimal answer of 0.6666666666... ``` @IBOutlet weak var answer: UITextField! var sAnswer = answer.text as NSString println(sAnswer) ```
2015/05/07
[ "https://Stackoverflow.com/questions/30090008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4358488/" ]
No. The text will always be a string. But what you could do is, make an extension for your UITextField where you split your string at the `/` and divide it. Then you return the double-value. Like that: ``` extension UITextField { var xo: Double! { get { var value = self.text.componentsSeparatedByString("/") return (value[0] as NSString).doubleValue / (value[1] as NSString).doubleValue } } } ``` Then you use it like that: ``` answer.doubleValue ```
SWIFT 5.3 var fraction: String = "1/3" var new = fraction.components(separatedBy: "/") print(new) ["1", "3"] From this point you can return the divided result. I provided this answer because the "separated by"notation was changed in a newer version of swift. --- func convertStringToFraction(stringNumber: String) -> Float { ``` let stringFloat = stringNumber.components(separatedBy: "/") let numerator = Float(stringFloat[0])! let denominator = Float(stringFloat[1])! return numerator / denominator ``` }
30,090,008
Is it possible to convert fractions that are entered into UITextField into decimals? So far, this is what I have tried. If I enter in 2/3 into my UITextField, I get 2.0 as my answer. ``` @IBOutlet weak var answer: UITextField! var sAnswer = (answer.text as NSString).doubleValue println(sAnswer) ``` If I just use this, I will get 2/3 but it is a string and not a decimal answer of 0.6666666666... ``` @IBOutlet weak var answer: UITextField! var sAnswer = answer.text as NSString println(sAnswer) ```
2015/05/07
[ "https://Stackoverflow.com/questions/30090008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4358488/" ]
You need to parse and then calculate the fraction by yourself in a method or extension. One way of doing is as follows: ``` extension UITextField { var fraction: Float { var comps = text.componentsSeparatedByString("/") //Do some validation here so as to check the correct format of fraction text. var op1 = NSString(string: comps[0]).floatValue var op2 = NSString(string: comps[1]).floatValue return op1/op2 } } ```
A more modern Swift 5 solution: ``` func parse(fractionString: String) -> Float? { guard fractionString.range(of: "^\\d+\\/\\d+$", options: .regularExpression) != nil else { return nil } let components = fractionString.split(separator: "/") if let numerator = Float(components[0]), let denominator = Float(components[1]), denominator != 0 { return numerator / denominator } return nil } ``` The regex check at the beginning is just making sure that the input string is just digits with a single "/" in the middle.
30,090,008
Is it possible to convert fractions that are entered into UITextField into decimals? So far, this is what I have tried. If I enter in 2/3 into my UITextField, I get 2.0 as my answer. ``` @IBOutlet weak var answer: UITextField! var sAnswer = (answer.text as NSString).doubleValue println(sAnswer) ``` If I just use this, I will get 2/3 but it is a string and not a decimal answer of 0.6666666666... ``` @IBOutlet weak var answer: UITextField! var sAnswer = answer.text as NSString println(sAnswer) ```
2015/05/07
[ "https://Stackoverflow.com/questions/30090008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4358488/" ]
You need to parse and then calculate the fraction by yourself in a method or extension. One way of doing is as follows: ``` extension UITextField { var fraction: Float { var comps = text.componentsSeparatedByString("/") //Do some validation here so as to check the correct format of fraction text. var op1 = NSString(string: comps[0]).floatValue var op2 = NSString(string: comps[1]).floatValue return op1/op2 } } ```
SWIFT 5.3 var fraction: String = "1/3" var new = fraction.components(separatedBy: "/") print(new) ["1", "3"] From this point you can return the divided result. I provided this answer because the "separated by"notation was changed in a newer version of swift. --- func convertStringToFraction(stringNumber: String) -> Float { ``` let stringFloat = stringNumber.components(separatedBy: "/") let numerator = Float(stringFloat[0])! let denominator = Float(stringFloat[1])! return numerator / denominator ``` }
33,189,474
I have four controllers in Rails (`Pages`, `Sessions`, `Records`, `Users`,) and each has a separate stylesheet named by default `pages.css.scss`, `sessions.css.scss`, and so on. All my global styling goes into `application.css`. However, my CSS from the separate stylesheets seems to overlap and shows up on the wrong pages. For example, I have a *main* div with different width for my Sessions controller (login page) and my Records controller (search function.) However, when I update the CSS for one of these, the new styling shows up on both pages. What is happening, and how do I fix this?
2015/10/17
[ "https://Stackoverflow.com/questions/33189474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3434304/" ]
This is due to [Sprockets](http://guides.rubyonrails.org/asset_pipeline.html#what-is-the-asset-pipeline-questionmark) & bad CSS structuring. --- ``` #app/assets/stylesheets/application.css *= require_all ``` It's not CSS which will be the problem, but *the way you're calling it* - both in your asset pipeline and your application. The above will be concatenating all your css into the main `application.css` file. Whilst this might seem harmless, if you have conflicting CSS definitions, they'll override themselves. [![enter image description here](https://i.stack.imgur.com/UpPGX.jpg)](https://i.stack.imgur.com/UpPGX.jpg) The way around this is to firstly ensure you're not conflicting your CSS *and* you are calling *only* the appropriate CSS for your application. --- **Sprockets** To better understand a fix, you need to know about [sprockets](https://github.com/sstephenson/sprockets). Sprockets *compiles* your assets to make them as efficient as possible. Your assets reside in the asset pipeline, which has been created to be such that it will load the appropriate CSS for the different parts of your app -- both efficient and versatile. The "conventional" way for Rails to do this is to encourage you to use *controller* centric assets and *application* level assets: ``` #app/assets/stylesheets/controller.css #app/assets/stylesheets/application.css ``` This is okay if your CSS works in situ, but if it doesn't, you've got a problem (like what you're experiencing). As such, the way to fix is to firstly ensure that you're splitting your CSS as you need, and you're coding the CSS properly (more in a second). --- Controller-Centric Assets ========================= **1. Remove all references in "application.css"** Sprockets gives you the ability to "include" other files in your main `application.css` file: ``` #app/assets/stylesheets/application.css *= require_all <- remove this line ``` This will prevent your "application.css" file having all the others compiled into it. The others will be compiled on their own, allowing you to [call them separately](http://guides.rubyonrails.org/asset_pipeline.html#controller-specific-assets): **2. Layout** ``` #app/layouts/application.html.erb <%= stylesheet_link_tag "application", controller_name %> ``` This will allow you to call the controller-centric assets you have with base-level application CSS. The drawbacks to this are that you'll have to repeat a lot of your CSS, and will end up having completely different CSS for different parts of your app -- not the best. --- CSS Structure ============= The alternative is to make your CSS structured properly. This is much harder to achieve, but will give you much clearer results... > > I have a *main* div with different width for my Sessions controller (login page) and my **Records** controller (*search* function.) > > > ``` #app/assets/stylesheets/application.sass .main /* main styling */ &.search /* search styling here */ &.results /* results styling here */ ``` This will allow you to call: ``` #app/views/layouts/application.haml .main.search search stuff here .main.results results stuff here ```
The idea behind having a CSS file for controller is to to create pieces of functionality completely independent between each other, not just independent regarding the ruby code. If you want to stick to it you could either have different layouts for each controller that only includes the corresponding CSS file, rails automatically tries to use a layout named as the controller and it falls back to application.html.erb if not found. In practice, I think it is easier to disable the automatic generation of CSS files for each controller by adding `config.generators.stylesheets = false` to your `application.rb` config file and have your own hierarchy of CSS files. Take a look at [this](https://stackoverflow.com/questions/7366273/how-do-i-turn-off-automatic-stylesheet-javascript-generation-on-rails-3-1). Hope that helps **EDIT** The other logical solution if you plan to stick to having separate css files is to have different class attributes on the views, e.g. all views for Users have a `<div class="userPage"></div>` wrapping the content and use that on the css files to prevent overlapping.
33,189,474
I have four controllers in Rails (`Pages`, `Sessions`, `Records`, `Users`,) and each has a separate stylesheet named by default `pages.css.scss`, `sessions.css.scss`, and so on. All my global styling goes into `application.css`. However, my CSS from the separate stylesheets seems to overlap and shows up on the wrong pages. For example, I have a *main* div with different width for my Sessions controller (login page) and my Records controller (search function.) However, when I update the CSS for one of these, the new styling shows up on both pages. What is happening, and how do I fix this?
2015/10/17
[ "https://Stackoverflow.com/questions/33189474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3434304/" ]
This is due to [Sprockets](http://guides.rubyonrails.org/asset_pipeline.html#what-is-the-asset-pipeline-questionmark) & bad CSS structuring. --- ``` #app/assets/stylesheets/application.css *= require_all ``` It's not CSS which will be the problem, but *the way you're calling it* - both in your asset pipeline and your application. The above will be concatenating all your css into the main `application.css` file. Whilst this might seem harmless, if you have conflicting CSS definitions, they'll override themselves. [![enter image description here](https://i.stack.imgur.com/UpPGX.jpg)](https://i.stack.imgur.com/UpPGX.jpg) The way around this is to firstly ensure you're not conflicting your CSS *and* you are calling *only* the appropriate CSS for your application. --- **Sprockets** To better understand a fix, you need to know about [sprockets](https://github.com/sstephenson/sprockets). Sprockets *compiles* your assets to make them as efficient as possible. Your assets reside in the asset pipeline, which has been created to be such that it will load the appropriate CSS for the different parts of your app -- both efficient and versatile. The "conventional" way for Rails to do this is to encourage you to use *controller* centric assets and *application* level assets: ``` #app/assets/stylesheets/controller.css #app/assets/stylesheets/application.css ``` This is okay if your CSS works in situ, but if it doesn't, you've got a problem (like what you're experiencing). As such, the way to fix is to firstly ensure that you're splitting your CSS as you need, and you're coding the CSS properly (more in a second). --- Controller-Centric Assets ========================= **1. Remove all references in "application.css"** Sprockets gives you the ability to "include" other files in your main `application.css` file: ``` #app/assets/stylesheets/application.css *= require_all <- remove this line ``` This will prevent your "application.css" file having all the others compiled into it. The others will be compiled on their own, allowing you to [call them separately](http://guides.rubyonrails.org/asset_pipeline.html#controller-specific-assets): **2. Layout** ``` #app/layouts/application.html.erb <%= stylesheet_link_tag "application", controller_name %> ``` This will allow you to call the controller-centric assets you have with base-level application CSS. The drawbacks to this are that you'll have to repeat a lot of your CSS, and will end up having completely different CSS for different parts of your app -- not the best. --- CSS Structure ============= The alternative is to make your CSS structured properly. This is much harder to achieve, but will give you much clearer results... > > I have a *main* div with different width for my Sessions controller (login page) and my **Records** controller (*search* function.) > > > ``` #app/assets/stylesheets/application.sass .main /* main styling */ &.search /* search styling here */ &.results /* results styling here */ ``` This will allow you to call: ``` #app/views/layouts/application.haml .main.search search stuff here .main.results results stuff here ```
Typically, what I do is put classes on the body tag that match the controller and action. Then, in your stylesheets, you can wrap controller specific styles so they don't bleed into other areas of your app. Here's an example of what I'm talking about. In your layout: ``` <body class="<%= params[:controller].parameterize %> <%= params[:action] %>"> ``` In your stylesheet: ``` body.sessions.new { .main { width: 200px; } } ```
1,857,677
I am a math master student and have done fundamental math courses like probability theory, measure theory, linear algebra and know a little bit about functional analysis. What is good way for me to learn machine learning in depth? I have read the classical text [Pattern-Recognition and Machine Learning](http://rads.stackoverflow.com/amzn/click/0387310738) last summer; my impression was that it was very ineffective to read the book chapter by chapter like a mathematical text. The book does not go deep enough for many algorithms and skip too many steps considered too technical by engineers. Is there a machine learning book that maybe does not cover too many topics, but treat each one in depth and takes advantage of math when necessary? It will be great to be able connect fundamental mathematical objects with machine learning (I am thinking about Lp spaces, hilbert space etc).
2016/07/13
[ "https://math.stackexchange.com/questions/1857677", "https://math.stackexchange.com", "https://math.stackexchange.com/users/188265/" ]
Hmm, that is a very good question! I see a couple avenues you could proceed: 1. In general, once you start doing rigorous machine learning, the distinction with modern statistics really starts to vanish. So you could pick up a book from that literature. I would recommend for example, the [book](http://rads.stackoverflow.com/amzn/click/3642201911) by Peter Bühlmann and Sara van de Geer. It essentially only considers one model: The LASSO (as well as slight variations, such as L1-penalized logistic regression), and is a "math" book (lots of definitions, lemmata, theorems, proofs). 2. Keeping with the idea of only studying one method, you could read the [book on boosting](http://rads.stackoverflow.com/amzn/click/0262526034) by Schapire and Freund. This would give a flavour of rigorous results, but with more of a CS rather than stats perspective. [Caveat: I have not actually read this one, but have heard good things about it.] 3. The two previous recommendation focus on understanding one specific method (L1 regularization, boosting respectively); if instead you want a unifying framework in terms of a specific mathematical space, then there is a very nice [review paper](https://projecteuclid.org/euclid.aos/1211819561) of RKHS (reproducing kernel Hilbert space) machine learning methods in the Annals of Statistics. It's not a textbook, but it seems to perfectly suit your needs. 4. Larry Wasserman has been teaching an amazing course on [Statistical Machine Learning](http://www.stat.cmu.edu/~larry/=sml/). There he goes through a whole bunch of unrelated methods (what you complained about), but for each one he explains what the main mathematical tools and results are, and proves many of these. The website provides both videos of the lectures, exercises and lecture notes (which I think he is compiling into a textbook). Highly recommended.
I think, your difficulty arises from being used to developed unified theories (e.g., theory of bounded linear operators on Hilbert spaces), whereas Machine Learning is no such thing. It is, rather, a collection of (classes of) techniques, most based on optimization of some sort. So, I would start with reading the individual Wikipedia articles on the different techniques and areas of Machine Learning: regression, logistic regression, Principal Component Analysis, Support Vector Machines, Vapnik-Chervonenkis theory, deep learning, and nonlinear dimensionality reduction. If you want to connect these to fundamental mathematical objects, then there are these articles, but the objects have more to do with differential geometry than with functional analysis: \*) Smale et. al., ''Finding the homology of submanifolds with high confidence'' \*) R. Ghrist, “Three examples of applied and computational homology," Nieuw Archief voor Wiskunde 5/9(2).
1,857,677
I am a math master student and have done fundamental math courses like probability theory, measure theory, linear algebra and know a little bit about functional analysis. What is good way for me to learn machine learning in depth? I have read the classical text [Pattern-Recognition and Machine Learning](http://rads.stackoverflow.com/amzn/click/0387310738) last summer; my impression was that it was very ineffective to read the book chapter by chapter like a mathematical text. The book does not go deep enough for many algorithms and skip too many steps considered too technical by engineers. Is there a machine learning book that maybe does not cover too many topics, but treat each one in depth and takes advantage of math when necessary? It will be great to be able connect fundamental mathematical objects with machine learning (I am thinking about Lp spaces, hilbert space etc).
2016/07/13
[ "https://math.stackexchange.com/questions/1857677", "https://math.stackexchange.com", "https://math.stackexchange.com/users/188265/" ]
I think, your difficulty arises from being used to developed unified theories (e.g., theory of bounded linear operators on Hilbert spaces), whereas Machine Learning is no such thing. It is, rather, a collection of (classes of) techniques, most based on optimization of some sort. So, I would start with reading the individual Wikipedia articles on the different techniques and areas of Machine Learning: regression, logistic regression, Principal Component Analysis, Support Vector Machines, Vapnik-Chervonenkis theory, deep learning, and nonlinear dimensionality reduction. If you want to connect these to fundamental mathematical objects, then there are these articles, but the objects have more to do with differential geometry than with functional analysis: \*) Smale et. al., ''Finding the homology of submanifolds with high confidence'' \*) R. Ghrist, “Three examples of applied and computational homology," Nieuw Archief voor Wiskunde 5/9(2).
There is a good book that is probably easier to start with: An introduction to statistical learning, by hastie and tibshirani. I also have an online course that will go through the basic topics in machine learning. You can find out more by checking out: [Math for Machine Learning Online Course](http://www.youtube.com/watch?list=PLtljwqHr0TOooYUZBMXpWJ-AtwI1Cndqf&v=3WvS6keWVS8)
1,857,677
I am a math master student and have done fundamental math courses like probability theory, measure theory, linear algebra and know a little bit about functional analysis. What is good way for me to learn machine learning in depth? I have read the classical text [Pattern-Recognition and Machine Learning](http://rads.stackoverflow.com/amzn/click/0387310738) last summer; my impression was that it was very ineffective to read the book chapter by chapter like a mathematical text. The book does not go deep enough for many algorithms and skip too many steps considered too technical by engineers. Is there a machine learning book that maybe does not cover too many topics, but treat each one in depth and takes advantage of math when necessary? It will be great to be able connect fundamental mathematical objects with machine learning (I am thinking about Lp spaces, hilbert space etc).
2016/07/13
[ "https://math.stackexchange.com/questions/1857677", "https://math.stackexchange.com", "https://math.stackexchange.com/users/188265/" ]
Hmm, that is a very good question! I see a couple avenues you could proceed: 1. In general, once you start doing rigorous machine learning, the distinction with modern statistics really starts to vanish. So you could pick up a book from that literature. I would recommend for example, the [book](http://rads.stackoverflow.com/amzn/click/3642201911) by Peter Bühlmann and Sara van de Geer. It essentially only considers one model: The LASSO (as well as slight variations, such as L1-penalized logistic regression), and is a "math" book (lots of definitions, lemmata, theorems, proofs). 2. Keeping with the idea of only studying one method, you could read the [book on boosting](http://rads.stackoverflow.com/amzn/click/0262526034) by Schapire and Freund. This would give a flavour of rigorous results, but with more of a CS rather than stats perspective. [Caveat: I have not actually read this one, but have heard good things about it.] 3. The two previous recommendation focus on understanding one specific method (L1 regularization, boosting respectively); if instead you want a unifying framework in terms of a specific mathematical space, then there is a very nice [review paper](https://projecteuclid.org/euclid.aos/1211819561) of RKHS (reproducing kernel Hilbert space) machine learning methods in the Annals of Statistics. It's not a textbook, but it seems to perfectly suit your needs. 4. Larry Wasserman has been teaching an amazing course on [Statistical Machine Learning](http://www.stat.cmu.edu/~larry/=sml/). There he goes through a whole bunch of unrelated methods (what you complained about), but for each one he explains what the main mathematical tools and results are, and proves many of these. The website provides both videos of the lectures, exercises and lecture notes (which I think he is compiling into a textbook). Highly recommended.
There is a good book that is probably easier to start with: An introduction to statistical learning, by hastie and tibshirani. I also have an online course that will go through the basic topics in machine learning. You can find out more by checking out: [Math for Machine Learning Online Course](http://www.youtube.com/watch?list=PLtljwqHr0TOooYUZBMXpWJ-AtwI1Cndqf&v=3WvS6keWVS8)
1,857,677
I am a math master student and have done fundamental math courses like probability theory, measure theory, linear algebra and know a little bit about functional analysis. What is good way for me to learn machine learning in depth? I have read the classical text [Pattern-Recognition and Machine Learning](http://rads.stackoverflow.com/amzn/click/0387310738) last summer; my impression was that it was very ineffective to read the book chapter by chapter like a mathematical text. The book does not go deep enough for many algorithms and skip too many steps considered too technical by engineers. Is there a machine learning book that maybe does not cover too many topics, but treat each one in depth and takes advantage of math when necessary? It will be great to be able connect fundamental mathematical objects with machine learning (I am thinking about Lp spaces, hilbert space etc).
2016/07/13
[ "https://math.stackexchange.com/questions/1857677", "https://math.stackexchange.com", "https://math.stackexchange.com/users/188265/" ]
Hmm, that is a very good question! I see a couple avenues you could proceed: 1. In general, once you start doing rigorous machine learning, the distinction with modern statistics really starts to vanish. So you could pick up a book from that literature. I would recommend for example, the [book](http://rads.stackoverflow.com/amzn/click/3642201911) by Peter Bühlmann and Sara van de Geer. It essentially only considers one model: The LASSO (as well as slight variations, such as L1-penalized logistic regression), and is a "math" book (lots of definitions, lemmata, theorems, proofs). 2. Keeping with the idea of only studying one method, you could read the [book on boosting](http://rads.stackoverflow.com/amzn/click/0262526034) by Schapire and Freund. This would give a flavour of rigorous results, but with more of a CS rather than stats perspective. [Caveat: I have not actually read this one, but have heard good things about it.] 3. The two previous recommendation focus on understanding one specific method (L1 regularization, boosting respectively); if instead you want a unifying framework in terms of a specific mathematical space, then there is a very nice [review paper](https://projecteuclid.org/euclid.aos/1211819561) of RKHS (reproducing kernel Hilbert space) machine learning methods in the Annals of Statistics. It's not a textbook, but it seems to perfectly suit your needs. 4. Larry Wasserman has been teaching an amazing course on [Statistical Machine Learning](http://www.stat.cmu.edu/~larry/=sml/). There he goes through a whole bunch of unrelated methods (what you complained about), but for each one he explains what the main mathematical tools and results are, and proves many of these. The website provides both videos of the lectures, exercises and lecture notes (which I think he is compiling into a textbook). Highly recommended.
With a background in pure math you will surely enjoy these books: Mohri's [Foundations of Machine Learning](https://rads.stackoverflow.com/amzn/click/com/0262039400) which is available [for free](https://cs.nyu.edu/%7Emohri/mlbook/), Shalev-Shwartz's [Understanding Machine Learning: From Theory to Algorithms](https://rads.stackoverflow.com/amzn/click/com/1107057132) also available [for free](https://www.cs.huji.ac.il/w%7Eshais/UnderstandingMachineLearning/copy.html), Devroye's [A Probabilistic Theory of Pattern Recognition](https://rads.stackoverflow.com/amzn/click/com/0387946187), Lattimore's [Bandit Algorithms](https://tor-lattimore.com/downloads/book/book.pdf). You will also like the publications of [Foundations and Trends in Machine Learning](https://www.nowpublishers.com/MAL).
1,857,677
I am a math master student and have done fundamental math courses like probability theory, measure theory, linear algebra and know a little bit about functional analysis. What is good way for me to learn machine learning in depth? I have read the classical text [Pattern-Recognition and Machine Learning](http://rads.stackoverflow.com/amzn/click/0387310738) last summer; my impression was that it was very ineffective to read the book chapter by chapter like a mathematical text. The book does not go deep enough for many algorithms and skip too many steps considered too technical by engineers. Is there a machine learning book that maybe does not cover too many topics, but treat each one in depth and takes advantage of math when necessary? It will be great to be able connect fundamental mathematical objects with machine learning (I am thinking about Lp spaces, hilbert space etc).
2016/07/13
[ "https://math.stackexchange.com/questions/1857677", "https://math.stackexchange.com", "https://math.stackexchange.com/users/188265/" ]
With a background in pure math you will surely enjoy these books: Mohri's [Foundations of Machine Learning](https://rads.stackoverflow.com/amzn/click/com/0262039400) which is available [for free](https://cs.nyu.edu/%7Emohri/mlbook/), Shalev-Shwartz's [Understanding Machine Learning: From Theory to Algorithms](https://rads.stackoverflow.com/amzn/click/com/1107057132) also available [for free](https://www.cs.huji.ac.il/w%7Eshais/UnderstandingMachineLearning/copy.html), Devroye's [A Probabilistic Theory of Pattern Recognition](https://rads.stackoverflow.com/amzn/click/com/0387946187), Lattimore's [Bandit Algorithms](https://tor-lattimore.com/downloads/book/book.pdf). You will also like the publications of [Foundations and Trends in Machine Learning](https://www.nowpublishers.com/MAL).
There is a good book that is probably easier to start with: An introduction to statistical learning, by hastie and tibshirani. I also have an online course that will go through the basic topics in machine learning. You can find out more by checking out: [Math for Machine Learning Online Course](http://www.youtube.com/watch?list=PLtljwqHr0TOooYUZBMXpWJ-AtwI1Cndqf&v=3WvS6keWVS8)
1,525
I'm looking for photo-sets taken by drones as part of a science assignment to generate 3D Models. Where in the net can I find some sites which can share some samples?
2020/08/20
[ "https://drones.stackexchange.com/questions/1525", "https://drones.stackexchange.com", "https://drones.stackexchange.com/users/980/" ]
Search youtube for videos with the keywords FPV and ORBIT. This is the motion that will give you 360 degree frames of an object. Also search for Point of Interest mode for DJI drones. Then you can use a youtube downloader service to download the video and then extract the frames you are interested in. Here is an example of a dji poi video <https://youtu.be/hlfOVBAmc4o?t=48> If you put -tutorial in your search terms it will weed out all the tutorial videos that you don't want <https://www.youtube.com/results?search_query=dji+point+of+interest+examples+-tutorial>
[Open drone map on GitHub](https://github.com/OpenDroneMap) has high quality data sets taken from drones for 3d models
39,599,012
I'm waiting for something like the following from the front end ``` ....?isUpdated=true ``` so I did something like this in code (as I'm processing only `isUpdated=true`, false need to be ignored) ``` var isUpdated = (req.query.isUpdated === 'true') ``` but it seems bit odd to me. How to do this in proper way? I mean to parse a Boolean parameter from the query string.
2016/09/20
[ "https://Stackoverflow.com/questions/39599012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4923852/" ]
[Docs](https://github.com/sindresorhus/query-string#parsebooleans) if you are using query-string ``` const queryString = require('query-string'); queryString.parse('foo=true', {parseBooleans: true}); //=> {foo: true} ```
With some ideas from previous answers, I ended up using this function to consider undefined values as well ``` const parseBool = (params) => { return !( params === "false" || params === "0" || params === "" || params === undefined ); }; ```
39,599,012
I'm waiting for something like the following from the front end ``` ....?isUpdated=true ``` so I did something like this in code (as I'm processing only `isUpdated=true`, false need to be ignored) ``` var isUpdated = (req.query.isUpdated === 'true') ``` but it seems bit odd to me. How to do this in proper way? I mean to parse a Boolean parameter from the query string.
2016/09/20
[ "https://Stackoverflow.com/questions/39599012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4923852/" ]
Here is my generic solution for getting a query params as a boolean: ```js const isTrue = Boolean((req.query.myParam || "").replace(/\s*(false|null|undefined|0)\s*/i, "")) ``` It converts the query param into a string which is then cleaned by suppressing any falsy string. Any resulting non-empty string will be `true`.
With some ideas from previous answers, I ended up using this function to consider undefined values as well ``` const parseBool = (params) => { return !( params === "false" || params === "0" || params === "" || params === undefined ); }; ```
39,599,012
I'm waiting for something like the following from the front end ``` ....?isUpdated=true ``` so I did something like this in code (as I'm processing only `isUpdated=true`, false need to be ignored) ``` var isUpdated = (req.query.isUpdated === 'true') ``` but it seems bit odd to me. How to do this in proper way? I mean to parse a Boolean parameter from the query string.
2016/09/20
[ "https://Stackoverflow.com/questions/39599012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4923852/" ]
The only thing I would change about your approach is to make it case insensitive: ``` var isUpdated = ((req.query.isUpdated+'').toLowerCase() === 'true') ``` You could make this a utility function as well if you like: ``` function queryParamToBool(value) { return ((value+'').toLowerCase() === 'true') } var isUpdated = queryParamToBool(req.query.isUpdated) ```
With some ideas from previous answers, I ended up using this function to consider undefined values as well ``` const parseBool = (params) => { return !( params === "false" || params === "0" || params === "" || params === undefined ); }; ```
39,599,012
I'm waiting for something like the following from the front end ``` ....?isUpdated=true ``` so I did something like this in code (as I'm processing only `isUpdated=true`, false need to be ignored) ``` var isUpdated = (req.query.isUpdated === 'true') ``` but it seems bit odd to me. How to do this in proper way? I mean to parse a Boolean parameter from the query string.
2016/09/20
[ "https://Stackoverflow.com/questions/39599012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4923852/" ]
[Docs](https://github.com/sindresorhus/query-string#parsebooleans) if you are using query-string ``` const queryString = require('query-string'); queryString.parse('foo=true', {parseBooleans: true}); //=> {foo: true} ```
Here is my generic solution for getting a query params as a boolean: ```js const isTrue = Boolean((req.query.myParam || "").replace(/\s*(false|null|undefined|0)\s*/i, "")) ``` It converts the query param into a string which is then cleaned by suppressing any falsy string. Any resulting non-empty string will be `true`.
39,599,012
I'm waiting for something like the following from the front end ``` ....?isUpdated=true ``` so I did something like this in code (as I'm processing only `isUpdated=true`, false need to be ignored) ``` var isUpdated = (req.query.isUpdated === 'true') ``` but it seems bit odd to me. How to do this in proper way? I mean to parse a Boolean parameter from the query string.
2016/09/20
[ "https://Stackoverflow.com/questions/39599012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4923852/" ]
``` var myBoolean = (req.query.myParam === undefined || req.query.myParam.toLowerCase() === 'false' ? false : true) ```
You can use [qs](https://www.npmjs.com/package/qs) package A little code to parse int and booleans ```js qs.parse(request.querystring, { decoder(str, decoder, charset) { const strWithoutPlus = str.replace(/\+/g, ' '); if (charset === 'iso-8859-1') { // unescape never throws, no try...catch needed: return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); } if (/^(\d+|\d*\.\d+)$/.test(str)) { return parseFloat(str) } const keywords = { true: true, false: false, null: null, undefined, } if (str in keywords) { return keywords[str] } // utf-8 try { return decodeURIComponent(strWithoutPlus); } catch (e) { return strWithoutPlus; } } }) ```
39,599,012
I'm waiting for something like the following from the front end ``` ....?isUpdated=true ``` so I did something like this in code (as I'm processing only `isUpdated=true`, false need to be ignored) ``` var isUpdated = (req.query.isUpdated === 'true') ``` but it seems bit odd to me. How to do this in proper way? I mean to parse a Boolean parameter from the query string.
2016/09/20
[ "https://Stackoverflow.com/questions/39599012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4923852/" ]
I use this pair of lines: `let test = (value).toString().trim().toLowerCase(); let result = !((test === 'false') || (test === '0') || (test === ''));`
``` var myBoolean = (req.query.myParam === undefined || req.query.myParam.toLowerCase() === 'false' ? false : true) ```
39,599,012
I'm waiting for something like the following from the front end ``` ....?isUpdated=true ``` so I did something like this in code (as I'm processing only `isUpdated=true`, false need to be ignored) ``` var isUpdated = (req.query.isUpdated === 'true') ``` but it seems bit odd to me. How to do this in proper way? I mean to parse a Boolean parameter from the query string.
2016/09/20
[ "https://Stackoverflow.com/questions/39599012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4923852/" ]
[Docs](https://github.com/sindresorhus/query-string#parsebooleans) if you are using query-string ``` const queryString = require('query-string'); queryString.parse('foo=true', {parseBooleans: true}); //=> {foo: true} ```
I use this pair of lines: `let test = (value).toString().trim().toLowerCase(); let result = !((test === 'false') || (test === '0') || (test === ''));`
39,599,012
I'm waiting for something like the following from the front end ``` ....?isUpdated=true ``` so I did something like this in code (as I'm processing only `isUpdated=true`, false need to be ignored) ``` var isUpdated = (req.query.isUpdated === 'true') ``` but it seems bit odd to me. How to do this in proper way? I mean to parse a Boolean parameter from the query string.
2016/09/20
[ "https://Stackoverflow.com/questions/39599012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4923852/" ]
[Docs](https://github.com/sindresorhus/query-string#parsebooleans) if you are using query-string ``` const queryString = require('query-string'); queryString.parse('foo=true', {parseBooleans: true}); //=> {foo: true} ```
The only thing I would change about your approach is to make it case insensitive: ``` var isUpdated = ((req.query.isUpdated+'').toLowerCase() === 'true') ``` You could make this a utility function as well if you like: ``` function queryParamToBool(value) { return ((value+'').toLowerCase() === 'true') } var isUpdated = queryParamToBool(req.query.isUpdated) ```
39,599,012
I'm waiting for something like the following from the front end ``` ....?isUpdated=true ``` so I did something like this in code (as I'm processing only `isUpdated=true`, false need to be ignored) ``` var isUpdated = (req.query.isUpdated === 'true') ``` but it seems bit odd to me. How to do this in proper way? I mean to parse a Boolean parameter from the query string.
2016/09/20
[ "https://Stackoverflow.com/questions/39599012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4923852/" ]
I use this pair of lines: `let test = (value).toString().trim().toLowerCase(); let result = !((test === 'false') || (test === '0') || (test === ''));`
I created a package called `boolean-query-express` <https://www.npmjs.com/package/booleanize-query-express> The difference between it and the other packages is that it treats values as 1 and 0 as booleans and will consider params like isHere, isValid, hasSomething (camelcased). You can read more about it as it's documented.
39,599,012
I'm waiting for something like the following from the front end ``` ....?isUpdated=true ``` so I did something like this in code (as I'm processing only `isUpdated=true`, false need to be ignored) ``` var isUpdated = (req.query.isUpdated === 'true') ``` but it seems bit odd to me. How to do this in proper way? I mean to parse a Boolean parameter from the query string.
2016/09/20
[ "https://Stackoverflow.com/questions/39599012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4923852/" ]
I use this pair of lines: `let test = (value).toString().trim().toLowerCase(); let result = !((test === 'false') || (test === '0') || (test === ''));`
With some ideas from previous answers, I ended up using this function to consider undefined values as well ``` const parseBool = (params) => { return !( params === "false" || params === "0" || params === "" || params === undefined ); }; ```
54,779
Note: Answering my own question as a wiki for future reference. When loading a .Net DLL: ``` << NetLink` InstallNET[] LoadNETAssembly["C:\\Temp\\XYZ.dll"] NETAssembly["XYZ", 1] ``` I get the error: > > NET::netexcptn: A .NET exception occurred: System.IO.FileLoadException: Could not load file or assembly > file:///C:\Temp\XYZ.dll'or one of its dependencies. Operation is not supported.(ExceptionfromHRESULT:0x80131515) > > > Filename:'file:///C:\Temp\XYZ.dll'--->System.NotSupportedException:An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default,so this load may be dangerous. If this load is not intended to sandbox the assembly.... > > >
2014/07/14
[ "https://mathematica.stackexchange.com/questions/54779", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/1056/" ]
The DLL file was Blocked. **The solution was to Unblock it** (right click on DLL > choose Properties > click the Unblock button). You need to restart Mathematica and load the DLL in again. ![enter image description here](https://i.stack.imgur.com/LpJ34.png)
As per [MSDN](https://msdn.microsoft.com/en-us/library/dd409252(VS.100).aspx): > > **Note** > You may get a FileLoadException in a Windows Virtual PC application when you try to load a file from linked folders on the hosting computer. This error may also occur when you try to load a file from a folder linked over Remote Desktop Services (Terminal Services). To avoid the exception, set enabled to true. > > > I was able to resolve this problem using the [<loadFromRemoteSources> Element](https://msdn.microsoft.com/en-us/library/dd409252(VS.100).aspx) and adding the settings to my config. ``` <configuration> <runtime> <loadFromRemoteSources enabled="true"/> </runtime> </configuration> ```
432,267
$\sum \_{p\leq n}\frac{\ln p}{p}=\ln n+O(1),n\geq 2,$ where $p$ is a prime number, prove: $$\sum \_{p\leq n}\frac{1}{p}=C+\ln \ln n+O\left(\frac{1}{\ln n}\right)~~~(1)$$ one examination question,I think you're strong in solving this with complete answer in 20/30 minutes. of course I cannot, give me some hints? :)
2013/06/29
[ "https://math.stackexchange.com/questions/432267", "https://math.stackexchange.com", "https://math.stackexchange.com/users/76942/" ]
First, this code returns the analytical solution to the [Stratonovich](http://en.wikipedia.org/wiki/Stratonovich_integral) stochastic differential equation for [geometric Brownian motion](http://en.wikipedia.org/wiki/Geometric_Brownian_motion): $$dY = \mu Y dt+\sigma Y \circ dW$$ The full solution to this is: $$Y(t) = Y\_0 \exp(\mu t+\sigma W\_t)$$ Your code assumes $Y\_0=1$. The solution is slightly different if you use the [Itô formulation](https://en.wikipedia.org/wiki/It%C5%8D_calculus). The function `randn` returns random variates (values) independently drawn from the [normal distribution](https://en.wikipedia.org/wiki/Normal_distribution). So, `randn(1,N)` returns a sequence of independent normally-distributed values (500 in this case). `N` in this case is just the number of time-steps. These are used to produce the independent Wiener increments, $dW\_t$. Thus, `dW = sqrt(dt)*randn(1,N)` produces `N` independent Wiener increments where the standard deviation is equal to the square root of the time span, `dt`, between them $\dagger$. These correspond to the `N` points in the vector `t`. The code `[0,cumsum(dW)]` integrates these increments to produce $W\_t$, a [Wiener process](http://en.wikipedia.org/wiki/Wiener_process), which is also called standard Brownian motion For further details on [SDEs](http://en.wikipedia.org/wiki/Stochastic_differential_equation), Brownian motion, and simulating them with Matlab I recommend this excellent paper: > > Desmond J. Higham, 2001, An Algorithmic Introduction to Numerical Simulation of Stochastic Differential Equations, *SIAM Rev. (Educ. Sect.)*, 43 525–46. <http://dx.doi.org/10.1137/S0036144500378302> > > > The URL to the Matlab files in the paper won't work, use this one: [https://www.maths.ed.ac.uk/~dhigham/algfiles.html](https://www.maths.ed.ac.uk/%7Edhigham/algfiles.html) $\dagger$ Why is `dW` scaled by `sqrt(dt)` instead of just `dt` like when numerically integrating ODEs? A discrete Wiener process by definition has a variance equal to the time step between the increments, in this case `dt`. However, to scale output of `randn` properly, we need to express this in terms of a standard deviation.
A normal random variable $\zeta$ distributed like $\mathcal{N}(\mu,\sigma^2)$ can be written in terms of a standard normal random variable $\chi$ very easily as: $$\zeta = \mu + \sigma \chi.$$ Thus, your line of code is just generating a Gaussian random variable with a different standard deviation.
33,785,530
I have simple question but i dont know how to implement this. I need to create an app that can get list of available wifi networks and when user click on some network iphone have to connect to this network. Can i do this? I want to publish app to the app store. I dont want to use private api. I knew that application osminoWifi pubblished on the appstore and do this. So, what frameworks and technologies I can use for this?
2015/11/18
[ "https://Stackoverflow.com/questions/33785530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5381554/" ]
Technically yes you can get that info. Take a look at this project for example: <https://code.google.com/p/iphone-wireless/> However, according to AppStore terms and conditions you are only allowed to get the SSID of the network you are currently connected to but your are not allowed to publish an app that uses private libraries. Take a look at this issue [How do I use CaptiveNetwork to get the current WiFi Hotspot Name](https://stackoverflow.com/questions/4712535/how-do-i-use-captivenetwork-to-get-the-current-wifi-hotspot-name)
Without the use of **private library (Apple80211)** it will not provide you other reachable wifi list or other info. You can refer to: [How do I use CaptiveNetwork to get the current WiFi Hotspot Name](https://stackoverflow.com/questions/4712535/how-do-i-use-captivenetwork-to-get-the-current-wifi-hotspot-name) for more information.
33,785,530
I have simple question but i dont know how to implement this. I need to create an app that can get list of available wifi networks and when user click on some network iphone have to connect to this network. Can i do this? I want to publish app to the app store. I dont want to use private api. I knew that application osminoWifi pubblished on the appstore and do this. So, what frameworks and technologies I can use for this?
2015/11/18
[ "https://Stackoverflow.com/questions/33785530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5381554/" ]
You can do this with abilities of the system, but you can't publish it on the appstore because it is private api.
Without the use of **private library (Apple80211)** it will not provide you other reachable wifi list or other info. You can refer to: [How do I use CaptiveNetwork to get the current WiFi Hotspot Name](https://stackoverflow.com/questions/4712535/how-do-i-use-captivenetwork-to-get-the-current-wifi-hotspot-name) for more information.
33,785,530
I have simple question but i dont know how to implement this. I need to create an app that can get list of available wifi networks and when user click on some network iphone have to connect to this network. Can i do this? I want to publish app to the app store. I dont want to use private api. I knew that application osminoWifi pubblished on the appstore and do this. So, what frameworks and technologies I can use for this?
2015/11/18
[ "https://Stackoverflow.com/questions/33785530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5381554/" ]
You can do this with abilities of the system, but you can't publish it on the appstore because it is private api.
Technically yes you can get that info. Take a look at this project for example: <https://code.google.com/p/iphone-wireless/> However, according to AppStore terms and conditions you are only allowed to get the SSID of the network you are currently connected to but your are not allowed to publish an app that uses private libraries. Take a look at this issue [How do I use CaptiveNetwork to get the current WiFi Hotspot Name](https://stackoverflow.com/questions/4712535/how-do-i-use-captivenetwork-to-get-the-current-wifi-hotspot-name)
64,998,225
I am trying to create a program that encrypts a string from user input then saves it into a 2-dimensional array. For instance, if I typed in the word "Car", C is at [0][0], a is at [1][0], and r is [2][0]. Then I would input a number of 1-4 and "shift" the letters down that many times and stores it in index [][1]. So if I chose 3, Car would change into Fdu and it would be stored inside index [0][1],[1][1], and [2][1]. For the actual encryption, I have to create a separate method called caesarCipher to do all the calculations and assignments based on the number supplied by the user. My problem is being a very new coder, is that I can't figure out exactly how to create the method to accomplish this. I believe a switch statement would be easiest to handle each case of 1, 2,3, or 4 but not certain as to what I can use to actually change the characters. ``` String userInput; int encryption; Scanner scan = new Scanner(System.in); System.out.println("Please enter a message you would like to encrypt."); userInput = scan.nextLine(); int arrayLength = userInput.length(); //creates the array for outputting the message before and after encryption char[][] outputArray = new char [arrayLength][3]; //for loop that supplies the message into the array, a different index per character for (int index = 0; index < arrayLength; index++) { outputArray[index][0] = userInput.charAt(index); System.out.print(outputArray[index]); } System.out.println(); System.out.println(); System.out.println("Please enter a number between 1 and 4. This will decide how to encrypt your message"); encryption = scan.nextInt(); //switch statement that changes the message based on the selected number switch(encryption) { case 1: if (encryption == 1) for (int index = 0; index < arrayLength; index++) outputArray[index][1] = userInput.charAt(index); break; case 2: if (encryption == 2) for (int index = 0; index < arrayLength; index++) outputArray[index][1] = userInput.charAt(index); break; case 3: if (encryption == 3) for (int index = 0; index < arrayLength; index++) outputArray[index][1] = userInput.charAt(index); break; case 4: if (encryption == 4) for (int index = 0; index < arrayLength; index++) outputArray[index][1] = userInput.charAt(index); break; } ``` This is what I have so far with the switch statement set-up for each case, but obviously, nothing that changes the characters.
2020/11/25
[ "https://Stackoverflow.com/questions/64998225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14694041/" ]
According to my test, we should use double quotes to expand the access key in `.evn`. For example 1. Add this in `.env` file ``` AZURE_STORAGE_NAME=<account name> AZURE_STORAGE_KEY="<account key>" AZURE_STORAGE_CONTAINER= AZURE_STORAGE_URL=https://<account name>.blob.core.windows.net/ ``` 2. Add this to the `disks` section of `config/filesystems.php`: ``` 'azure' => [ 'driver' => 'azure', 'name' => env('AZURE_STORAGE_NAME'), 'key' => env('AZURE_STORAGE_KEY'), 'container' => env('AZURE_STORAGE_CONTAINER'), 'url' => env('AZURE_STORAGE_URL'), 'prefix' => null, ], ``` 3. Uplaod code ``` public function fileUpload(Request $req){ $req->validate([ 'file' => 'required|mimes:csv,txt,xlx,xls,pdf|max:2048' ]); if($req->file()) { $fileName = time().'_'.$req->file->getClientOriginalName(); // save file to azure blob virtual directory uplaods in your container $filePath = $req->file('file')->storeAs('uploads/', $fileName, 'azure'); return back() ->with('success','File has been uploaded.') } } ``` [![enter image description here](https://i.stack.imgur.com/tiIuB.gif)](https://i.stack.imgur.com/tiIuB.gif) [![enter image description here](https://i.stack.imgur.com/Q5ssz.png)](https://i.stack.imgur.com/Q5ssz.png)
Thanks @Jim Xu, tested out the logic from your example and it works great. If someone stumbled upon this, by default azure blob containers are private. To serve file or images publicly for your Laravel app, **don't forget to change the container's access level to either Blob or Container**
525,735
I have a longitudinal outcome of two time points(2018 and 2020), the outcome is a quality of life score generated from a validated instrument, the score ranges from -0.158 to 1, a value of 1 indicate perfect health state, a values of 0 indicate a health state equal to death, negative values indicate a health state worse than death. I have a sample size of 457 longitudinal profile, the distribution of this outcome is heavily skewed to the left and multimodal, 55% of the scores lies in [0.8 ; 1 ]. [![Histogram of data](https://i.stack.imgur.com/RJRpE.png)](https://i.stack.imgur.com/RJRpE.png) I tried the linear mixed model using some covariates such as age gender region, the plot of the residuals looked like this : [![residuals](https://i.stack.imgur.com/FOcqx.png)](https://i.stack.imgur.com/FOcqx.png) It was clearly that the linear mixed model would not fit well, the log or square root transformations are not applicable since I have negative values, I tried this transformation : * transform into scale of 0-1 by a normal linear transformation. * apply the logit and transform to the whole real line. then the distribution looked like this [![hist](https://i.stack.imgur.com/I4Idd.png)](https://i.stack.imgur.com/I4Idd.png) and when i fitted a linear mixed model the residuals were like this : [![res](https://i.stack.imgur.com/3lWtO.png)](https://i.stack.imgur.com/3lWtO.png) both raw variable and the transformed one are not suitable for modelling. How to handle this type of data? > > A social preference valuations set for EQ-5D health states > in Flanders, Belgium > Irina Cleemput > > >
2021/05/24
[ "https://stats.stackexchange.com/questions/525735", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/320963/" ]
Apparently, the terms are used ambiguously, but I always seen them used as that there are three (or more) sets of data: *train* set used for training the model, *validation* set for assessing the performance of the model when tuning it, and held-out *test* set that you use at the very end to assess the performance of the model. These names are used in Google's [Machine Learning Crash Course](https://developers.google.com/machine-learning/crash-course/validation/another-partition), the [*Deep Learning with Python*](https://www.manning.com/books/deep-learning-with-python) book by François Chollet, the [*Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow*](https://www.goodreads.com/book/show/40363665-hands-on-machine-learning-with-scikit-learn-keras-and-tensorflow) book by Aurélien Géron, [*The Elements of Statistical Learning*](https://web.stanford.edu/%7Ehastie/ElemStatLearn/) by Trevor Hastie, Robert Tibshirani, and Jerome Friedman, and a number of other books. If you find this naming convention confusing, [you can, as Andrew Ng, use the train/dev/test](https://www.youtube.com/watch?v=1waHlpKiNyY) naming, where the *dev* set is used for *dev*elopment.
I was taught that you have a train/test split for tuning then you have a validation set to 'validate' that you haven't overfitted your test split. If you have a small dataset then you just have your train/test split, I would never call it a train/validation split because I think of validation as the final step to 'validate' all of your results, whereas test is to 'test' your model on unseen data. But you could easily flip them and it's all the same! I have noticed the terms used back and forth but it doesn't really matter what you call it as long as everyone is on the same page. EDIT after some digging: Your usage is the correct usage although it is known that the flip side is frequently used (although incorrectly). [Wiki](https://en.wikipedia.org/wiki/Training,_validation,_and_test_sets#cite_note-14) even has a section reviewing this discrepancy. Pure conjecture but I think it most likely stems from this: [![enter image description here](https://i.stack.imgur.com/xTmSM.png)](https://i.stack.imgur.com/xTmSM.png) Where if you just have a simple split it is train/test and this split used to be a standard way to tune for simple models so the 'test' set was everything. And to add further to this, it seems if you only do 5 fold cross validation then you are doing 5 train sets and 5 test sets. BUT if you then add a third holdout set then you now have 5 train sets, 5 **validation** sets, and 1 test set.
525,735
I have a longitudinal outcome of two time points(2018 and 2020), the outcome is a quality of life score generated from a validated instrument, the score ranges from -0.158 to 1, a value of 1 indicate perfect health state, a values of 0 indicate a health state equal to death, negative values indicate a health state worse than death. I have a sample size of 457 longitudinal profile, the distribution of this outcome is heavily skewed to the left and multimodal, 55% of the scores lies in [0.8 ; 1 ]. [![Histogram of data](https://i.stack.imgur.com/RJRpE.png)](https://i.stack.imgur.com/RJRpE.png) I tried the linear mixed model using some covariates such as age gender region, the plot of the residuals looked like this : [![residuals](https://i.stack.imgur.com/FOcqx.png)](https://i.stack.imgur.com/FOcqx.png) It was clearly that the linear mixed model would not fit well, the log or square root transformations are not applicable since I have negative values, I tried this transformation : * transform into scale of 0-1 by a normal linear transformation. * apply the logit and transform to the whole real line. then the distribution looked like this [![hist](https://i.stack.imgur.com/I4Idd.png)](https://i.stack.imgur.com/I4Idd.png) and when i fitted a linear mixed model the residuals were like this : [![res](https://i.stack.imgur.com/3lWtO.png)](https://i.stack.imgur.com/3lWtO.png) both raw variable and the transformed one are not suitable for modelling. How to handle this type of data? > > A social preference valuations set for EQ-5D health states > in Flanders, Belgium > Irina Cleemput > > >
2021/05/24
[ "https://stats.stackexchange.com/questions/525735", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/320963/" ]
For machine learning, I've predominantly seen the usage OP describes, but I've also encountered *lots* of confusion coming from this usage. --- Historically, I guess what happened (at least in my field, analytical chemistry) is that as models became more complex, at some point people noticed that independent data is needed for verification and validation purposes (in our terminology, almost all testing that is routinely done with models would be considered part of verification which in turn is part of the much wider task of method validation). Enter the validation set and methods such as cross validation (with its original purpose of estimating generalization error). Later, people started to use generalization error estimates from what we call internal verification/validation such as cross validation or a random split to refine/optimize their models. Enter hyperparameter tuning. Again, it was realized that estimating generalization error of the refined model needs independent data. And a new name was needed as well, as the usage of "validation set" for the data used for refining/optimizing had already been established. Enter the test set. Thus we have the situation where a so-called *validation* set is used for model development/optimization/refining and is therefore *not* suitable any more for the purpose of model verification and validation. --- Someone with e.g. an analytical chemistry (or engineering) background will certainly refer to the data they use/acquire for method validation purposes as their validation data\* - and that is correct usage of the terms in these fields. \*(unless they know the different use of terminology in machine learning, in which case they'd usually explain what exactly they are talking about). --- Personally, in order to avoid the ongoing confusion that comes from this clash of terminology between fields, I've moved to using "optimization data/set" for the data used for hyperparameter tuning (Andrew Ng's development set is fine with me as well) and "verification data/set" for the final independent test data (the testing we typically do is actually verification rather than validation, so that avoids another common mistake: the testing we typically do is not even close to a full method validation in analytical chemistry, and it's good to be aware of that) Another strategy I find helpful to avoid confusion is moving from splitting into 3 data sets back to splitting into training and verification data, and then describing the hyperparameter tuning as part of the training procedure which happens to include another split into data used to fit the model parameters and data used to optimize the hyperparameters.
I was taught that you have a train/test split for tuning then you have a validation set to 'validate' that you haven't overfitted your test split. If you have a small dataset then you just have your train/test split, I would never call it a train/validation split because I think of validation as the final step to 'validate' all of your results, whereas test is to 'test' your model on unseen data. But you could easily flip them and it's all the same! I have noticed the terms used back and forth but it doesn't really matter what you call it as long as everyone is on the same page. EDIT after some digging: Your usage is the correct usage although it is known that the flip side is frequently used (although incorrectly). [Wiki](https://en.wikipedia.org/wiki/Training,_validation,_and_test_sets#cite_note-14) even has a section reviewing this discrepancy. Pure conjecture but I think it most likely stems from this: [![enter image description here](https://i.stack.imgur.com/xTmSM.png)](https://i.stack.imgur.com/xTmSM.png) Where if you just have a simple split it is train/test and this split used to be a standard way to tune for simple models so the 'test' set was everything. And to add further to this, it seems if you only do 5 fold cross validation then you are doing 5 train sets and 5 test sets. BUT if you then add a third holdout set then you now have 5 train sets, 5 **validation** sets, and 1 test set.
525,735
I have a longitudinal outcome of two time points(2018 and 2020), the outcome is a quality of life score generated from a validated instrument, the score ranges from -0.158 to 1, a value of 1 indicate perfect health state, a values of 0 indicate a health state equal to death, negative values indicate a health state worse than death. I have a sample size of 457 longitudinal profile, the distribution of this outcome is heavily skewed to the left and multimodal, 55% of the scores lies in [0.8 ; 1 ]. [![Histogram of data](https://i.stack.imgur.com/RJRpE.png)](https://i.stack.imgur.com/RJRpE.png) I tried the linear mixed model using some covariates such as age gender region, the plot of the residuals looked like this : [![residuals](https://i.stack.imgur.com/FOcqx.png)](https://i.stack.imgur.com/FOcqx.png) It was clearly that the linear mixed model would not fit well, the log or square root transformations are not applicable since I have negative values, I tried this transformation : * transform into scale of 0-1 by a normal linear transformation. * apply the logit and transform to the whole real line. then the distribution looked like this [![hist](https://i.stack.imgur.com/I4Idd.png)](https://i.stack.imgur.com/I4Idd.png) and when i fitted a linear mixed model the residuals were like this : [![res](https://i.stack.imgur.com/3lWtO.png)](https://i.stack.imgur.com/3lWtO.png) both raw variable and the transformed one are not suitable for modelling. How to handle this type of data? > > A social preference valuations set for EQ-5D health states > in Flanders, Belgium > Irina Cleemput > > >
2021/05/24
[ "https://stats.stackexchange.com/questions/525735", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/320963/" ]
For machine learning, I've predominantly seen the usage OP describes, but I've also encountered *lots* of confusion coming from this usage. --- Historically, I guess what happened (at least in my field, analytical chemistry) is that as models became more complex, at some point people noticed that independent data is needed for verification and validation purposes (in our terminology, almost all testing that is routinely done with models would be considered part of verification which in turn is part of the much wider task of method validation). Enter the validation set and methods such as cross validation (with its original purpose of estimating generalization error). Later, people started to use generalization error estimates from what we call internal verification/validation such as cross validation or a random split to refine/optimize their models. Enter hyperparameter tuning. Again, it was realized that estimating generalization error of the refined model needs independent data. And a new name was needed as well, as the usage of "validation set" for the data used for refining/optimizing had already been established. Enter the test set. Thus we have the situation where a so-called *validation* set is used for model development/optimization/refining and is therefore *not* suitable any more for the purpose of model verification and validation. --- Someone with e.g. an analytical chemistry (or engineering) background will certainly refer to the data they use/acquire for method validation purposes as their validation data\* - and that is correct usage of the terms in these fields. \*(unless they know the different use of terminology in machine learning, in which case they'd usually explain what exactly they are talking about). --- Personally, in order to avoid the ongoing confusion that comes from this clash of terminology between fields, I've moved to using "optimization data/set" for the data used for hyperparameter tuning (Andrew Ng's development set is fine with me as well) and "verification data/set" for the final independent test data (the testing we typically do is actually verification rather than validation, so that avoids another common mistake: the testing we typically do is not even close to a full method validation in analytical chemistry, and it's good to be aware of that) Another strategy I find helpful to avoid confusion is moving from splitting into 3 data sets back to splitting into training and verification data, and then describing the hyperparameter tuning as part of the training procedure which happens to include another split into data used to fit the model parameters and data used to optimize the hyperparameters.
Apparently, the terms are used ambiguously, but I always seen them used as that there are three (or more) sets of data: *train* set used for training the model, *validation* set for assessing the performance of the model when tuning it, and held-out *test* set that you use at the very end to assess the performance of the model. These names are used in Google's [Machine Learning Crash Course](https://developers.google.com/machine-learning/crash-course/validation/another-partition), the [*Deep Learning with Python*](https://www.manning.com/books/deep-learning-with-python) book by François Chollet, the [*Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow*](https://www.goodreads.com/book/show/40363665-hands-on-machine-learning-with-scikit-learn-keras-and-tensorflow) book by Aurélien Géron, [*The Elements of Statistical Learning*](https://web.stanford.edu/%7Ehastie/ElemStatLearn/) by Trevor Hastie, Robert Tibshirani, and Jerome Friedman, and a number of other books. If you find this naming convention confusing, [you can, as Andrew Ng, use the train/dev/test](https://www.youtube.com/watch?v=1waHlpKiNyY) naming, where the *dev* set is used for *dev*elopment.
6,613,628
I've used this before but i've forgotten the name of the method. I'm guessing it must be exclusive to MVC3/Razor. Is there a method that allows you to include a JavaScript or CSS file and then specify that it should be in the head. I remember it as two different methods similar to the following ``` IncludeJS("my.js").AtHead(); IncludeCSS("my.css").AtHead(); ``` They might be HTML helpers but I can't find any reference to them anywhere. Am I going mad?
2011/07/07
[ "https://Stackoverflow.com/questions/6613628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/833910/" ]
Check this question, best answer supposed to do what you need: [ASP.Net MVC 3 Razor: Include js file in Head tag](https://stackoverflow.com/questions/4311783/asp-net-mvc-3-razor-include-js-file-in-head-tag)
What you're talking about sounds like a custom helper similar to: [Add CSS or JavaScript files to layout head from views or partial views](https://stackoverflow.com/questions/5110028/add-css-or-js-files-to-layout-head-from-views-or-partial-views)
15,227,926
I am trying to use rpy2 to let me use some r functionality in python. Here is a simple regression I want to do. I create a data frame, convert it to R data frame and then try using R's lm. But the R data frame cannot be found (see below). Where should I look to troubleshoot? FYI I am using python 2.7.3, rpy2-2.3.2, pandas version '0.10.1' and R2.15.3 ``` >>> import rpy2 >>> import pandas as pd >>> import pandas.rpy.common as com >>> datframe = pd.DataFrame({'a' : [1, 2, 3], 'b' : [3, 4, 5]}) >>> r_df = com.convert_to_r_dataframe(datframe) >>> r_df (DataFrame - Python:0x32547e8 / R:0x345d640) [IntVector, IntVector] a: (class 'rpy2.robjects.vectors.IntVector') (IntVector - Python:0x3254e18 / R:0x345d608) [ 1, 2, 3] b: (class 'rpy2.robjects.vectors.IntVector') (IntVector - Python:0x3254e60 / R:0x345d5d0) [ 3, 4, 5] >>> print type(r_df) (class 'rpy2.robjects.vectors.DataFrame') >>> from rpy2.robjects import r >>> r('lmout <- lm(r_df$a ~ r_df$b)') Error in eval(expr, envir, enclos) : object 'r_df' not found Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> r('lmout <- lm(r_df$a ~ r_df$b)') File "/usr/local/lib/python2.7/dist-packages/rpy2/robjects/__init__.py", line 236, in __call__ res = self.eval(p) File "/usr/local/lib/python2.7/dist-packages/rpy2/robjects/functions.py", line 86, in __call__ return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/rpy2/robjects/functions.py", line 35, in __call__ res = super(Function, self).__call__(*new_args, **new_kwargs) RRuntimeError: Error in eval(expr, envir, enclos) : object 'r_df' not found ```
2013/03/05
[ "https://Stackoverflow.com/questions/15227926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2133151/" ]
When calling ``` r('lmout <- lm(r_df$a ~ r_df$b)') ``` the embedded R will look for a variable `r_df`, and no such variable is made visible to R in your code example. When doing ``` r_df = com.convert_to_r_dataframe(datframe) ``` you are creating the variable `r_df` on the Python side but while the actual data in now in R, there is no symbol (name) associated with it known to R. That data structure remains anonymous. (btw, you may want to use the automagic conversion of pandas data frames shipping with rpy2-2.3.3). To create a variable name in R's "global environment", add this: ``` from rpy2.robjects import globalenv globalenv['r_df'] = r_df ``` Now your `lm()` call should work.
try this, (not sure which header do the magic, though....) ``` import rpy2.robjects as robjects from rpy2.robjects import DataFrame, Formula import rpy2.robjects.numpy2ri as npr import numpy as np from rpy2.robjects.packages import importr def my_linear_fit_using_r(X,Y,verbose=True): # ## FITTINGS: RPy implementation ### r_correlation = robjects.r('function(x,y) cor.test(x,y)') # r_quadfit = robjects.r('function(x,y) lm(y~I(x)+I(x^2))') r_linfit = robjects.r('function(x,y) lm(y~x)') r_get_r2=robjects.r('function(x) summary(x)$r.squared') lin=r_linfit(robjects.FloatVector(X),robjects.FloatVector(Y)) coef_lin=robjects.r.coef(lin) a=coef_lin[0] b=coef_lin[1] r2=r_get_r2(lin) ci=robjects.r.confint(lin) # confidence intervals lwr_a=ci[0] lwr_b=ci[1] upr_a=ci[2] upr_b=ci[3] if verbose: print robjects.r.summary(lin) # print robjects.r.summary(quad) return (a,b,r2[0],lwr_a,upr_a,lwr_b,upr_b) ```
15,227,926
I am trying to use rpy2 to let me use some r functionality in python. Here is a simple regression I want to do. I create a data frame, convert it to R data frame and then try using R's lm. But the R data frame cannot be found (see below). Where should I look to troubleshoot? FYI I am using python 2.7.3, rpy2-2.3.2, pandas version '0.10.1' and R2.15.3 ``` >>> import rpy2 >>> import pandas as pd >>> import pandas.rpy.common as com >>> datframe = pd.DataFrame({'a' : [1, 2, 3], 'b' : [3, 4, 5]}) >>> r_df = com.convert_to_r_dataframe(datframe) >>> r_df (DataFrame - Python:0x32547e8 / R:0x345d640) [IntVector, IntVector] a: (class 'rpy2.robjects.vectors.IntVector') (IntVector - Python:0x3254e18 / R:0x345d608) [ 1, 2, 3] b: (class 'rpy2.robjects.vectors.IntVector') (IntVector - Python:0x3254e60 / R:0x345d5d0) [ 3, 4, 5] >>> print type(r_df) (class 'rpy2.robjects.vectors.DataFrame') >>> from rpy2.robjects import r >>> r('lmout <- lm(r_df$a ~ r_df$b)') Error in eval(expr, envir, enclos) : object 'r_df' not found Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> r('lmout <- lm(r_df$a ~ r_df$b)') File "/usr/local/lib/python2.7/dist-packages/rpy2/robjects/__init__.py", line 236, in __call__ res = self.eval(p) File "/usr/local/lib/python2.7/dist-packages/rpy2/robjects/functions.py", line 86, in __call__ return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/rpy2/robjects/functions.py", line 35, in __call__ res = super(Function, self).__call__(*new_args, **new_kwargs) RRuntimeError: Error in eval(expr, envir, enclos) : object 'r_df' not found ```
2013/03/05
[ "https://Stackoverflow.com/questions/15227926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2133151/" ]
When calling ``` r('lmout <- lm(r_df$a ~ r_df$b)') ``` the embedded R will look for a variable `r_df`, and no such variable is made visible to R in your code example. When doing ``` r_df = com.convert_to_r_dataframe(datframe) ``` you are creating the variable `r_df` on the Python side but while the actual data in now in R, there is no symbol (name) associated with it known to R. That data structure remains anonymous. (btw, you may want to use the automagic conversion of pandas data frames shipping with rpy2-2.3.3). To create a variable name in R's "global environment", add this: ``` from rpy2.robjects import globalenv globalenv['r_df'] = r_df ``` Now your `lm()` call should work.
Just a remark, for simple regressions you can do it completely in Python, use `ols` from `statsmodels`: ``` from statsmodels.formula.api import ols lmout = ols('a ~ b', datframe).fit() lmout.summary() ```
57,079,481
I have multiple lists of the same size and need to sort one of them by all of the other lists. There is no limit to the number of lists that can be passed in and their order matters. In addition, the user may want to sort the lists ascending or descending. For example, someone may wish to sort a list of people by their age descending first, and if their ages are the same, then sort by their first name ascending. ``` List people = List.of("John Doe", "Jane Doe", "Abe Smith") List ages = List.of(20, 25, 20) List firstNames = List.of("John", "Jane", "Abe") sort(people, ages, "desc", firstNames, "asc") Result: ["Jane Doe", "Abe Smith", "John Doe"] ``` Edit: The user can sort any lists they want by any other lists they want, as long as they are all the same size. It is not just people. That's just one example of the type of data they may want to sort.
2019/07/17
[ "https://Stackoverflow.com/questions/57079481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1141313/" ]
* Create a generic function f(people, list1, desc, list2, asc ....) * take hashMap object and store, people as key and value list1, list2 and create myComprator class and sort by value.
Seems to me that what approach you have taken will not help you convert to class as People and take all property inside as #Michael mentioned
157,067
The Ozoa are a peculiar race. They are native to a large gas giant similar to Saturn and physically look similar to what we would call "jellyfish". Within their "head" the Ozoa contain a lifting gas their body naturally produces and regulates to keep the Ozoa afloat. The tentacles are used for propulsion and grasping. "Swimming" similar to how a squid moves through the water. But these traits are similar to many examples of gas giant species across the galaxy. The Ozoa are truly remarkable for being "naturally" spacefarring with elderly Ozoa able to escspe the atmosphere of their homeworld. Ozoa are born rather miniscule but throughout their lifespan the Ozoa grow to rather monstrous size with some reaching the sizes of zeplins. When Ozoa reach peak "ship size" their outer layer of skin begins to harden into a tough exoskeleton that's also airtight and to keep themselves afloat the Ozoa begin to process the hydrogen atmosphere into fuel. Which they use to eventually escape their planet. What I'm wondering is how they would make hydrogen into fuel. The two things I'm interested in is: how do they "process" hydrogen into a fuel they can store and second how do they effectively "burn" or "light" the hydrogen without, you know, exploding? Notes: Evolution of the species isn't overly important for the question they just did. They have a similar life cycle to a jellyfish, but past physical appearance are very different internally.
2019/09/26
[ "https://worldbuilding.stackexchange.com/questions/157067", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/51720/" ]
No. The resistance would be hilarious. -------------------------------------- The resistance of a wire is given (simply) by this equation: $R = \frac{\rho L}{CSA}$ where, $\rho$ is a material-dependent constant, $L$ is the length of the wire and $CSA$ is the cross-sectional area of the wire. As you stretch a wire (or indeed any material), **its cross sectional area decreases whilst its length increases**. For an example, let's take copper. This copper wire is $1m$ in length and has a radius of $1mm$, giving it a cross-sectional area of $\pi \* 10^{-6}m^2$. Given the $\rho$ of copper is $1.68\*10^{-8}\Omega/m$, the resistance of this wire is: $R = \frac{1.68\*10^{-8}}{\pi\*10^{-6}} = 5.35\*10^{-3}\Omega$ Now let's stretch it out to $2m$. We can use the Elastic Stretch Equation (found [here](https://blog.loosco.com/bid/42817/How-to-Calculate-Wire-Rope-and-Cable-Stretch)) to calculate the percentage change in wire length, and rearrange to find the new diameter and thus CSA (note I've changed imperial to metric, hence the ugly constant): $\%\,Change = \frac{293.25M}{D^2}$ $M = \delta\*v = 28.1g = 0.0281kg$ $100 = \frac{8.24}{D^2}$ $D^2 = 0.0824mm^2$ $D = 0.287mm$ $New\,CSA = 6.47\*10^{-8}$ $New\,Resistance = \frac{2 \* 1.68\*10^{-8}}{6.47\*10^{-8}} = 5.19 \* 10^{-1}\Omega$ As shown, **doubling the length of copper wire gives it 9,700% of its original electrical resistance** (or its resistance is 97 times bigger than before). Aside from heat generation alone, not many electrical signals are going to get through this. With all that being said, the field is a work in progress. Things like [conductive fabric](https://en.wikipedia.org/wiki/Conductive_textile) are using smart geometry, topology, wire shorting etc. to get better, and the field is showing more promise every day. Hope it helps!
Yes, and it's already commercially available. This stuff can apparently change length up to 40% with NO CHANGE in resistance. <https://mnwire.com/istretch/>
157,067
The Ozoa are a peculiar race. They are native to a large gas giant similar to Saturn and physically look similar to what we would call "jellyfish". Within their "head" the Ozoa contain a lifting gas their body naturally produces and regulates to keep the Ozoa afloat. The tentacles are used for propulsion and grasping. "Swimming" similar to how a squid moves through the water. But these traits are similar to many examples of gas giant species across the galaxy. The Ozoa are truly remarkable for being "naturally" spacefarring with elderly Ozoa able to escspe the atmosphere of their homeworld. Ozoa are born rather miniscule but throughout their lifespan the Ozoa grow to rather monstrous size with some reaching the sizes of zeplins. When Ozoa reach peak "ship size" their outer layer of skin begins to harden into a tough exoskeleton that's also airtight and to keep themselves afloat the Ozoa begin to process the hydrogen atmosphere into fuel. Which they use to eventually escape their planet. What I'm wondering is how they would make hydrogen into fuel. The two things I'm interested in is: how do they "process" hydrogen into a fuel they can store and second how do they effectively "burn" or "light" the hydrogen without, you know, exploding? Notes: Evolution of the species isn't overly important for the question they just did. They have a similar life cycle to a jellyfish, but past physical appearance are very different internally.
2019/09/26
[ "https://worldbuilding.stackexchange.com/questions/157067", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/51720/" ]
The answer to the question of advancing bandwidth to our portable devices, where a dedicated pre-selected length of wire would be undesirable, lies not in finding a better way to make a hardline wire to it, but making better use of wireless design. High bandwidth optical communications, such as what we use in fibre optics, can work surprisingly well as a wireless system. However the transmitters and receivers require direct line of sight, and may be interfered with due to weather conditions. [or someone/something stepping into the beam...] The other drawback of running open optical systems is that they can quickly reach a saturation point where sending-receiving pairs that are spaced too close together will risk cross talk as the receiver from Pair A begins to pick up parts of the signal from Pair B's transmitter. Along with removing the requirement of line of sight, routing optical signals through dedicated fibres means we can pack far more Sending-Receiving pairs into the same space. --- It is really this cross talk risk that is the heart of our bandwidth problems, whether dealing with Optical, Cellular Signals, or home WiFi, we will quickly saturate an area with competing signals if we use devices that blast data over a wide area without concern for where the other end is going to be. --- So, how do we resolve this? We begin limiting the wireless signals to more confined and better defined regions. This concept is seen all the way back with the original cellular networks [and is why they're called cellular...]. Rather than broadcasting *one* signal that can be seen *everywhere*, you split "everywhere" into smaller regions that are covered by weaker signals [such that signals don't overlap any more than needed], and you can then squeeze more data through the whole system. As such, we apply the same solution by adjusting the scale again. We use smaller cells that will cover fewer users, freeing up more of the max transmission bandwidth for each user. Have a Network Signal that covers an entire neighbourhood that is becoming overloaded? * Run hardline to each house, and give each house a smaller wireless network that doesn't spread much beyond each person's yard. Is the 'whole yard' system getting saturated? * Run hardline to each room in the house, and give each room an even smaller wireless signal network so that devices in different parts of the home aren't trying to 'talk over' each other. Need more bandwidth in the room? * Again go smaller and more focused. Rather than broadcasting a blanket signal across the whole room, use a different wireless style that focuses better and sends tighter beams aimed at individual devices. Need to go even smaller? * Cover the ceiling with an array of transceivers that can beam data directly at the device with laser like precision... [Just remember to design it in a way that avoids blinding people... Using actual lasers that can be misdirected off mirrors or something could be problematic, but there are totally ways around that sort of thing.]
Yes, and it's already commercially available. This stuff can apparently change length up to 40% with NO CHANGE in resistance. <https://mnwire.com/istretch/>
157,067
The Ozoa are a peculiar race. They are native to a large gas giant similar to Saturn and physically look similar to what we would call "jellyfish". Within their "head" the Ozoa contain a lifting gas their body naturally produces and regulates to keep the Ozoa afloat. The tentacles are used for propulsion and grasping. "Swimming" similar to how a squid moves through the water. But these traits are similar to many examples of gas giant species across the galaxy. The Ozoa are truly remarkable for being "naturally" spacefarring with elderly Ozoa able to escspe the atmosphere of their homeworld. Ozoa are born rather miniscule but throughout their lifespan the Ozoa grow to rather monstrous size with some reaching the sizes of zeplins. When Ozoa reach peak "ship size" their outer layer of skin begins to harden into a tough exoskeleton that's also airtight and to keep themselves afloat the Ozoa begin to process the hydrogen atmosphere into fuel. Which they use to eventually escape their planet. What I'm wondering is how they would make hydrogen into fuel. The two things I'm interested in is: how do they "process" hydrogen into a fuel they can store and second how do they effectively "burn" or "light" the hydrogen without, you know, exploding? Notes: Evolution of the species isn't overly important for the question they just did. They have a similar life cycle to a jellyfish, but past physical appearance are very different internally.
2019/09/26
[ "https://worldbuilding.stackexchange.com/questions/157067", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/51720/" ]
> > The difficulty with wires is their management, and they must either be rolled up somewhere (if the cable is too long) taking up space > > > Your assumption seems wrong to me. Rolling cables is every engineer's favorite way to **save** space. If the distance between two points you need to link is going to vary, the proper way to do things is to use a reel. These exist in many sizes, for practically every application you can think of. ![A cable reel](https://i.stack.imgur.com/6p1XP.jpg) And I mean every application. See some guys standing on a reel for submarine fiber optics cables: ![That's a lot of reel](https://i.stack.imgur.com/ShuY1.jpg) Using elastic cables would vary the conducivity of the wiring (see [mcRobusta's answer](https://worldbuilding.stackexchange.com/a/157057/21222)) and would add other hazards, such as the cable getting stretch-stuck on unwanted places due to someone or something moving it around. If instead you use proper reeling on strategic places, you keep things neat, easier to service and easier to pack up and move if need be.
The answer to the question of advancing bandwidth to our portable devices, where a dedicated pre-selected length of wire would be undesirable, lies not in finding a better way to make a hardline wire to it, but making better use of wireless design. High bandwidth optical communications, such as what we use in fibre optics, can work surprisingly well as a wireless system. However the transmitters and receivers require direct line of sight, and may be interfered with due to weather conditions. [or someone/something stepping into the beam...] The other drawback of running open optical systems is that they can quickly reach a saturation point where sending-receiving pairs that are spaced too close together will risk cross talk as the receiver from Pair A begins to pick up parts of the signal from Pair B's transmitter. Along with removing the requirement of line of sight, routing optical signals through dedicated fibres means we can pack far more Sending-Receiving pairs into the same space. --- It is really this cross talk risk that is the heart of our bandwidth problems, whether dealing with Optical, Cellular Signals, or home WiFi, we will quickly saturate an area with competing signals if we use devices that blast data over a wide area without concern for where the other end is going to be. --- So, how do we resolve this? We begin limiting the wireless signals to more confined and better defined regions. This concept is seen all the way back with the original cellular networks [and is why they're called cellular...]. Rather than broadcasting *one* signal that can be seen *everywhere*, you split "everywhere" into smaller regions that are covered by weaker signals [such that signals don't overlap any more than needed], and you can then squeeze more data through the whole system. As such, we apply the same solution by adjusting the scale again. We use smaller cells that will cover fewer users, freeing up more of the max transmission bandwidth for each user. Have a Network Signal that covers an entire neighbourhood that is becoming overloaded? * Run hardline to each house, and give each house a smaller wireless network that doesn't spread much beyond each person's yard. Is the 'whole yard' system getting saturated? * Run hardline to each room in the house, and give each room an even smaller wireless signal network so that devices in different parts of the home aren't trying to 'talk over' each other. Need more bandwidth in the room? * Again go smaller and more focused. Rather than broadcasting a blanket signal across the whole room, use a different wireless style that focuses better and sends tighter beams aimed at individual devices. Need to go even smaller? * Cover the ceiling with an array of transceivers that can beam data directly at the device with laser like precision... [Just remember to design it in a way that avoids blinding people... Using actual lasers that can be misdirected off mirrors or something could be problematic, but there are totally ways around that sort of thing.]
157,067
The Ozoa are a peculiar race. They are native to a large gas giant similar to Saturn and physically look similar to what we would call "jellyfish". Within their "head" the Ozoa contain a lifting gas their body naturally produces and regulates to keep the Ozoa afloat. The tentacles are used for propulsion and grasping. "Swimming" similar to how a squid moves through the water. But these traits are similar to many examples of gas giant species across the galaxy. The Ozoa are truly remarkable for being "naturally" spacefarring with elderly Ozoa able to escspe the atmosphere of their homeworld. Ozoa are born rather miniscule but throughout their lifespan the Ozoa grow to rather monstrous size with some reaching the sizes of zeplins. When Ozoa reach peak "ship size" their outer layer of skin begins to harden into a tough exoskeleton that's also airtight and to keep themselves afloat the Ozoa begin to process the hydrogen atmosphere into fuel. Which they use to eventually escape their planet. What I'm wondering is how they would make hydrogen into fuel. The two things I'm interested in is: how do they "process" hydrogen into a fuel they can store and second how do they effectively "burn" or "light" the hydrogen without, you know, exploding? Notes: Evolution of the species isn't overly important for the question they just did. They have a similar life cycle to a jellyfish, but past physical appearance are very different internally.
2019/09/26
[ "https://worldbuilding.stackexchange.com/questions/157067", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/51720/" ]
**Coiled wire** such as that used on old-fashioned telephone sets (as below) (I cannot for the life of me find a Wikipedia article mentioning this kind of cord) allow a limited amount of flexibility, but can easily be twisted incorrectly and over-stretched, damaging the wire. I do not know why this technology is no longer used and any pointers towards resources referring to it would be greatly appreciated. ![Old fashioned green telephone](https://live.staticflickr.com/6088/6088452082_c50679ea5d_k.jpg) [Old fashioned green telephone](https://flic.kr/p/ah1UFL) by [şaban uluca](https://www.flickr.com/photos/40266898@N04/) on Flickr --- Creating a more exotic **conductive chain** and covering it in a tight, elastic fabric could achieve the desired effect. Potential drawbacks could be: * Major friction on the internal chain links during usage * Limited flexibility * Cables containing multiple wires would be very difficult to achieve * Copper, aluminium and gold could be too soft, allowing the chain to tear if overstretched: alloys or other less conductive metals would have to be used * Incredibly arduous manufacturing of individual chain links * Possible loss of contact between chain links * And much, much more
No. The resistance would be hilarious. -------------------------------------- The resistance of a wire is given (simply) by this equation: $R = \frac{\rho L}{CSA}$ where, $\rho$ is a material-dependent constant, $L$ is the length of the wire and $CSA$ is the cross-sectional area of the wire. As you stretch a wire (or indeed any material), **its cross sectional area decreases whilst its length increases**. For an example, let's take copper. This copper wire is $1m$ in length and has a radius of $1mm$, giving it a cross-sectional area of $\pi \* 10^{-6}m^2$. Given the $\rho$ of copper is $1.68\*10^{-8}\Omega/m$, the resistance of this wire is: $R = \frac{1.68\*10^{-8}}{\pi\*10^{-6}} = 5.35\*10^{-3}\Omega$ Now let's stretch it out to $2m$. We can use the Elastic Stretch Equation (found [here](https://blog.loosco.com/bid/42817/How-to-Calculate-Wire-Rope-and-Cable-Stretch)) to calculate the percentage change in wire length, and rearrange to find the new diameter and thus CSA (note I've changed imperial to metric, hence the ugly constant): $\%\,Change = \frac{293.25M}{D^2}$ $M = \delta\*v = 28.1g = 0.0281kg$ $100 = \frac{8.24}{D^2}$ $D^2 = 0.0824mm^2$ $D = 0.287mm$ $New\,CSA = 6.47\*10^{-8}$ $New\,Resistance = \frac{2 \* 1.68\*10^{-8}}{6.47\*10^{-8}} = 5.19 \* 10^{-1}\Omega$ As shown, **doubling the length of copper wire gives it 9,700% of its original electrical resistance** (or its resistance is 97 times bigger than before). Aside from heat generation alone, not many electrical signals are going to get through this. With all that being said, the field is a work in progress. Things like [conductive fabric](https://en.wikipedia.org/wiki/Conductive_textile) are using smart geometry, topology, wire shorting etc. to get better, and the field is showing more promise every day. Hope it helps!
157,067
The Ozoa are a peculiar race. They are native to a large gas giant similar to Saturn and physically look similar to what we would call "jellyfish". Within their "head" the Ozoa contain a lifting gas their body naturally produces and regulates to keep the Ozoa afloat. The tentacles are used for propulsion and grasping. "Swimming" similar to how a squid moves through the water. But these traits are similar to many examples of gas giant species across the galaxy. The Ozoa are truly remarkable for being "naturally" spacefarring with elderly Ozoa able to escspe the atmosphere of their homeworld. Ozoa are born rather miniscule but throughout their lifespan the Ozoa grow to rather monstrous size with some reaching the sizes of zeplins. When Ozoa reach peak "ship size" their outer layer of skin begins to harden into a tough exoskeleton that's also airtight and to keep themselves afloat the Ozoa begin to process the hydrogen atmosphere into fuel. Which they use to eventually escape their planet. What I'm wondering is how they would make hydrogen into fuel. The two things I'm interested in is: how do they "process" hydrogen into a fuel they can store and second how do they effectively "burn" or "light" the hydrogen without, you know, exploding? Notes: Evolution of the species isn't overly important for the question they just did. They have a similar life cycle to a jellyfish, but past physical appearance are very different internally.
2019/09/26
[ "https://worldbuilding.stackexchange.com/questions/157067", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/51720/" ]
No. The resistance would be hilarious. -------------------------------------- The resistance of a wire is given (simply) by this equation: $R = \frac{\rho L}{CSA}$ where, $\rho$ is a material-dependent constant, $L$ is the length of the wire and $CSA$ is the cross-sectional area of the wire. As you stretch a wire (or indeed any material), **its cross sectional area decreases whilst its length increases**. For an example, let's take copper. This copper wire is $1m$ in length and has a radius of $1mm$, giving it a cross-sectional area of $\pi \* 10^{-6}m^2$. Given the $\rho$ of copper is $1.68\*10^{-8}\Omega/m$, the resistance of this wire is: $R = \frac{1.68\*10^{-8}}{\pi\*10^{-6}} = 5.35\*10^{-3}\Omega$ Now let's stretch it out to $2m$. We can use the Elastic Stretch Equation (found [here](https://blog.loosco.com/bid/42817/How-to-Calculate-Wire-Rope-and-Cable-Stretch)) to calculate the percentage change in wire length, and rearrange to find the new diameter and thus CSA (note I've changed imperial to metric, hence the ugly constant): $\%\,Change = \frac{293.25M}{D^2}$ $M = \delta\*v = 28.1g = 0.0281kg$ $100 = \frac{8.24}{D^2}$ $D^2 = 0.0824mm^2$ $D = 0.287mm$ $New\,CSA = 6.47\*10^{-8}$ $New\,Resistance = \frac{2 \* 1.68\*10^{-8}}{6.47\*10^{-8}} = 5.19 \* 10^{-1}\Omega$ As shown, **doubling the length of copper wire gives it 9,700% of its original electrical resistance** (or its resistance is 97 times bigger than before). Aside from heat generation alone, not many electrical signals are going to get through this. With all that being said, the field is a work in progress. Things like [conductive fabric](https://en.wikipedia.org/wiki/Conductive_textile) are using smart geometry, topology, wire shorting etc. to get better, and the field is showing more promise every day. Hope it helps!
The answer to the question of advancing bandwidth to our portable devices, where a dedicated pre-selected length of wire would be undesirable, lies not in finding a better way to make a hardline wire to it, but making better use of wireless design. High bandwidth optical communications, such as what we use in fibre optics, can work surprisingly well as a wireless system. However the transmitters and receivers require direct line of sight, and may be interfered with due to weather conditions. [or someone/something stepping into the beam...] The other drawback of running open optical systems is that they can quickly reach a saturation point where sending-receiving pairs that are spaced too close together will risk cross talk as the receiver from Pair A begins to pick up parts of the signal from Pair B's transmitter. Along with removing the requirement of line of sight, routing optical signals through dedicated fibres means we can pack far more Sending-Receiving pairs into the same space. --- It is really this cross talk risk that is the heart of our bandwidth problems, whether dealing with Optical, Cellular Signals, or home WiFi, we will quickly saturate an area with competing signals if we use devices that blast data over a wide area without concern for where the other end is going to be. --- So, how do we resolve this? We begin limiting the wireless signals to more confined and better defined regions. This concept is seen all the way back with the original cellular networks [and is why they're called cellular...]. Rather than broadcasting *one* signal that can be seen *everywhere*, you split "everywhere" into smaller regions that are covered by weaker signals [such that signals don't overlap any more than needed], and you can then squeeze more data through the whole system. As such, we apply the same solution by adjusting the scale again. We use smaller cells that will cover fewer users, freeing up more of the max transmission bandwidth for each user. Have a Network Signal that covers an entire neighbourhood that is becoming overloaded? * Run hardline to each house, and give each house a smaller wireless network that doesn't spread much beyond each person's yard. Is the 'whole yard' system getting saturated? * Run hardline to each room in the house, and give each room an even smaller wireless signal network so that devices in different parts of the home aren't trying to 'talk over' each other. Need more bandwidth in the room? * Again go smaller and more focused. Rather than broadcasting a blanket signal across the whole room, use a different wireless style that focuses better and sends tighter beams aimed at individual devices. Need to go even smaller? * Cover the ceiling with an array of transceivers that can beam data directly at the device with laser like precision... [Just remember to design it in a way that avoids blinding people... Using actual lasers that can be misdirected off mirrors or something could be problematic, but there are totally ways around that sort of thing.]
157,067
The Ozoa are a peculiar race. They are native to a large gas giant similar to Saturn and physically look similar to what we would call "jellyfish". Within their "head" the Ozoa contain a lifting gas their body naturally produces and regulates to keep the Ozoa afloat. The tentacles are used for propulsion and grasping. "Swimming" similar to how a squid moves through the water. But these traits are similar to many examples of gas giant species across the galaxy. The Ozoa are truly remarkable for being "naturally" spacefarring with elderly Ozoa able to escspe the atmosphere of their homeworld. Ozoa are born rather miniscule but throughout their lifespan the Ozoa grow to rather monstrous size with some reaching the sizes of zeplins. When Ozoa reach peak "ship size" their outer layer of skin begins to harden into a tough exoskeleton that's also airtight and to keep themselves afloat the Ozoa begin to process the hydrogen atmosphere into fuel. Which they use to eventually escape their planet. What I'm wondering is how they would make hydrogen into fuel. The two things I'm interested in is: how do they "process" hydrogen into a fuel they can store and second how do they effectively "burn" or "light" the hydrogen without, you know, exploding? Notes: Evolution of the species isn't overly important for the question they just did. They have a similar life cycle to a jellyfish, but past physical appearance are very different internally.
2019/09/26
[ "https://worldbuilding.stackexchange.com/questions/157067", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/51720/" ]
> > The difficulty with wires is their management, and they must either be rolled up somewhere (if the cable is too long) taking up space > > > Your assumption seems wrong to me. Rolling cables is every engineer's favorite way to **save** space. If the distance between two points you need to link is going to vary, the proper way to do things is to use a reel. These exist in many sizes, for practically every application you can think of. ![A cable reel](https://i.stack.imgur.com/6p1XP.jpg) And I mean every application. See some guys standing on a reel for submarine fiber optics cables: ![That's a lot of reel](https://i.stack.imgur.com/ShuY1.jpg) Using elastic cables would vary the conducivity of the wiring (see [mcRobusta's answer](https://worldbuilding.stackexchange.com/a/157057/21222)) and would add other hazards, such as the cable getting stretch-stuck on unwanted places due to someone or something moving it around. If instead you use proper reeling on strategic places, you keep things neat, easier to service and easier to pack up and move if need be.
Yes, and it's already commercially available. This stuff can apparently change length up to 40% with NO CHANGE in resistance. <https://mnwire.com/istretch/>
157,067
The Ozoa are a peculiar race. They are native to a large gas giant similar to Saturn and physically look similar to what we would call "jellyfish". Within their "head" the Ozoa contain a lifting gas their body naturally produces and regulates to keep the Ozoa afloat. The tentacles are used for propulsion and grasping. "Swimming" similar to how a squid moves through the water. But these traits are similar to many examples of gas giant species across the galaxy. The Ozoa are truly remarkable for being "naturally" spacefarring with elderly Ozoa able to escspe the atmosphere of their homeworld. Ozoa are born rather miniscule but throughout their lifespan the Ozoa grow to rather monstrous size with some reaching the sizes of zeplins. When Ozoa reach peak "ship size" their outer layer of skin begins to harden into a tough exoskeleton that's also airtight and to keep themselves afloat the Ozoa begin to process the hydrogen atmosphere into fuel. Which they use to eventually escape their planet. What I'm wondering is how they would make hydrogen into fuel. The two things I'm interested in is: how do they "process" hydrogen into a fuel they can store and second how do they effectively "burn" or "light" the hydrogen without, you know, exploding? Notes: Evolution of the species isn't overly important for the question they just did. They have a similar life cycle to a jellyfish, but past physical appearance are very different internally.
2019/09/26
[ "https://worldbuilding.stackexchange.com/questions/157067", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/51720/" ]
No. The resistance would be hilarious. -------------------------------------- The resistance of a wire is given (simply) by this equation: $R = \frac{\rho L}{CSA}$ where, $\rho$ is a material-dependent constant, $L$ is the length of the wire and $CSA$ is the cross-sectional area of the wire. As you stretch a wire (or indeed any material), **its cross sectional area decreases whilst its length increases**. For an example, let's take copper. This copper wire is $1m$ in length and has a radius of $1mm$, giving it a cross-sectional area of $\pi \* 10^{-6}m^2$. Given the $\rho$ of copper is $1.68\*10^{-8}\Omega/m$, the resistance of this wire is: $R = \frac{1.68\*10^{-8}}{\pi\*10^{-6}} = 5.35\*10^{-3}\Omega$ Now let's stretch it out to $2m$. We can use the Elastic Stretch Equation (found [here](https://blog.loosco.com/bid/42817/How-to-Calculate-Wire-Rope-and-Cable-Stretch)) to calculate the percentage change in wire length, and rearrange to find the new diameter and thus CSA (note I've changed imperial to metric, hence the ugly constant): $\%\,Change = \frac{293.25M}{D^2}$ $M = \delta\*v = 28.1g = 0.0281kg$ $100 = \frac{8.24}{D^2}$ $D^2 = 0.0824mm^2$ $D = 0.287mm$ $New\,CSA = 6.47\*10^{-8}$ $New\,Resistance = \frac{2 \* 1.68\*10^{-8}}{6.47\*10^{-8}} = 5.19 \* 10^{-1}\Omega$ As shown, **doubling the length of copper wire gives it 9,700% of its original electrical resistance** (or its resistance is 97 times bigger than before). Aside from heat generation alone, not many electrical signals are going to get through this. With all that being said, the field is a work in progress. Things like [conductive fabric](https://en.wikipedia.org/wiki/Conductive_textile) are using smart geometry, topology, wire shorting etc. to get better, and the field is showing more promise every day. Hope it helps!
I would have thought, given the availability of conductive lycra fabric (I've just googled it and had a fair few hits!), the answer to this is yes. So, quoting from <https://www.stem.org.uk/resources/elibrary/resource/31617/conductive-fabric> > > This fabric looks and feels like ordinary Lycra but is highly > conductive. It can be cut into narrow strips to form conducting > ‘wires’ or can be used as a soft compliant substitute for metal and > foil in switches and sensors > > > At the moment this fabric is predominantly used for wearable electronics. Possibly a better solution would be using electric nano-materials <https://aip.scitation.org/doi/10.1063/1.5083942>. This would allow wiring that acts pretty much like a rubber band. In the paper above it's using copper wires in a coil inside a substrate, but it also mentions using nanotubes or silver nanowires, and also structural folding such as origami to allow stretching.
157,067
The Ozoa are a peculiar race. They are native to a large gas giant similar to Saturn and physically look similar to what we would call "jellyfish". Within their "head" the Ozoa contain a lifting gas their body naturally produces and regulates to keep the Ozoa afloat. The tentacles are used for propulsion and grasping. "Swimming" similar to how a squid moves through the water. But these traits are similar to many examples of gas giant species across the galaxy. The Ozoa are truly remarkable for being "naturally" spacefarring with elderly Ozoa able to escspe the atmosphere of their homeworld. Ozoa are born rather miniscule but throughout their lifespan the Ozoa grow to rather monstrous size with some reaching the sizes of zeplins. When Ozoa reach peak "ship size" their outer layer of skin begins to harden into a tough exoskeleton that's also airtight and to keep themselves afloat the Ozoa begin to process the hydrogen atmosphere into fuel. Which they use to eventually escape their planet. What I'm wondering is how they would make hydrogen into fuel. The two things I'm interested in is: how do they "process" hydrogen into a fuel they can store and second how do they effectively "burn" or "light" the hydrogen without, you know, exploding? Notes: Evolution of the species isn't overly important for the question they just did. They have a similar life cycle to a jellyfish, but past physical appearance are very different internally.
2019/09/26
[ "https://worldbuilding.stackexchange.com/questions/157067", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/51720/" ]
**Coiled wire** such as that used on old-fashioned telephone sets (as below) (I cannot for the life of me find a Wikipedia article mentioning this kind of cord) allow a limited amount of flexibility, but can easily be twisted incorrectly and over-stretched, damaging the wire. I do not know why this technology is no longer used and any pointers towards resources referring to it would be greatly appreciated. ![Old fashioned green telephone](https://live.staticflickr.com/6088/6088452082_c50679ea5d_k.jpg) [Old fashioned green telephone](https://flic.kr/p/ah1UFL) by [şaban uluca](https://www.flickr.com/photos/40266898@N04/) on Flickr --- Creating a more exotic **conductive chain** and covering it in a tight, elastic fabric could achieve the desired effect. Potential drawbacks could be: * Major friction on the internal chain links during usage * Limited flexibility * Cables containing multiple wires would be very difficult to achieve * Copper, aluminium and gold could be too soft, allowing the chain to tear if overstretched: alloys or other less conductive metals would have to be used * Incredibly arduous manufacturing of individual chain links * Possible loss of contact between chain links * And much, much more
> > The difficulty with wires is their management, and they must either be rolled up somewhere (if the cable is too long) taking up space > > > Your assumption seems wrong to me. Rolling cables is every engineer's favorite way to **save** space. If the distance between two points you need to link is going to vary, the proper way to do things is to use a reel. These exist in many sizes, for practically every application you can think of. ![A cable reel](https://i.stack.imgur.com/6p1XP.jpg) And I mean every application. See some guys standing on a reel for submarine fiber optics cables: ![That's a lot of reel](https://i.stack.imgur.com/ShuY1.jpg) Using elastic cables would vary the conducivity of the wiring (see [mcRobusta's answer](https://worldbuilding.stackexchange.com/a/157057/21222)) and would add other hazards, such as the cable getting stretch-stuck on unwanted places due to someone or something moving it around. If instead you use proper reeling on strategic places, you keep things neat, easier to service and easier to pack up and move if need be.
157,067
The Ozoa are a peculiar race. They are native to a large gas giant similar to Saturn and physically look similar to what we would call "jellyfish". Within their "head" the Ozoa contain a lifting gas their body naturally produces and regulates to keep the Ozoa afloat. The tentacles are used for propulsion and grasping. "Swimming" similar to how a squid moves through the water. But these traits are similar to many examples of gas giant species across the galaxy. The Ozoa are truly remarkable for being "naturally" spacefarring with elderly Ozoa able to escspe the atmosphere of their homeworld. Ozoa are born rather miniscule but throughout their lifespan the Ozoa grow to rather monstrous size with some reaching the sizes of zeplins. When Ozoa reach peak "ship size" their outer layer of skin begins to harden into a tough exoskeleton that's also airtight and to keep themselves afloat the Ozoa begin to process the hydrogen atmosphere into fuel. Which they use to eventually escape their planet. What I'm wondering is how they would make hydrogen into fuel. The two things I'm interested in is: how do they "process" hydrogen into a fuel they can store and second how do they effectively "burn" or "light" the hydrogen without, you know, exploding? Notes: Evolution of the species isn't overly important for the question they just did. They have a similar life cycle to a jellyfish, but past physical appearance are very different internally.
2019/09/26
[ "https://worldbuilding.stackexchange.com/questions/157067", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/51720/" ]
> > The difficulty with wires is their management, and they must either be rolled up somewhere (if the cable is too long) taking up space > > > Your assumption seems wrong to me. Rolling cables is every engineer's favorite way to **save** space. If the distance between two points you need to link is going to vary, the proper way to do things is to use a reel. These exist in many sizes, for practically every application you can think of. ![A cable reel](https://i.stack.imgur.com/6p1XP.jpg) And I mean every application. See some guys standing on a reel for submarine fiber optics cables: ![That's a lot of reel](https://i.stack.imgur.com/ShuY1.jpg) Using elastic cables would vary the conducivity of the wiring (see [mcRobusta's answer](https://worldbuilding.stackexchange.com/a/157057/21222)) and would add other hazards, such as the cable getting stretch-stuck on unwanted places due to someone or something moving it around. If instead you use proper reeling on strategic places, you keep things neat, easier to service and easier to pack up and move if need be.
I would have thought, given the availability of conductive lycra fabric (I've just googled it and had a fair few hits!), the answer to this is yes. So, quoting from <https://www.stem.org.uk/resources/elibrary/resource/31617/conductive-fabric> > > This fabric looks and feels like ordinary Lycra but is highly > conductive. It can be cut into narrow strips to form conducting > ‘wires’ or can be used as a soft compliant substitute for metal and > foil in switches and sensors > > > At the moment this fabric is predominantly used for wearable electronics. Possibly a better solution would be using electric nano-materials <https://aip.scitation.org/doi/10.1063/1.5083942>. This would allow wiring that acts pretty much like a rubber band. In the paper above it's using copper wires in a coil inside a substrate, but it also mentions using nanotubes or silver nanowires, and also structural folding such as origami to allow stretching.
157,067
The Ozoa are a peculiar race. They are native to a large gas giant similar to Saturn and physically look similar to what we would call "jellyfish". Within their "head" the Ozoa contain a lifting gas their body naturally produces and regulates to keep the Ozoa afloat. The tentacles are used for propulsion and grasping. "Swimming" similar to how a squid moves through the water. But these traits are similar to many examples of gas giant species across the galaxy. The Ozoa are truly remarkable for being "naturally" spacefarring with elderly Ozoa able to escspe the atmosphere of their homeworld. Ozoa are born rather miniscule but throughout their lifespan the Ozoa grow to rather monstrous size with some reaching the sizes of zeplins. When Ozoa reach peak "ship size" their outer layer of skin begins to harden into a tough exoskeleton that's also airtight and to keep themselves afloat the Ozoa begin to process the hydrogen atmosphere into fuel. Which they use to eventually escape their planet. What I'm wondering is how they would make hydrogen into fuel. The two things I'm interested in is: how do they "process" hydrogen into a fuel they can store and second how do they effectively "burn" or "light" the hydrogen without, you know, exploding? Notes: Evolution of the species isn't overly important for the question they just did. They have a similar life cycle to a jellyfish, but past physical appearance are very different internally.
2019/09/26
[ "https://worldbuilding.stackexchange.com/questions/157067", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/51720/" ]
**Coiled wire** such as that used on old-fashioned telephone sets (as below) (I cannot for the life of me find a Wikipedia article mentioning this kind of cord) allow a limited amount of flexibility, but can easily be twisted incorrectly and over-stretched, damaging the wire. I do not know why this technology is no longer used and any pointers towards resources referring to it would be greatly appreciated. ![Old fashioned green telephone](https://live.staticflickr.com/6088/6088452082_c50679ea5d_k.jpg) [Old fashioned green telephone](https://flic.kr/p/ah1UFL) by [şaban uluca](https://www.flickr.com/photos/40266898@N04/) on Flickr --- Creating a more exotic **conductive chain** and covering it in a tight, elastic fabric could achieve the desired effect. Potential drawbacks could be: * Major friction on the internal chain links during usage * Limited flexibility * Cables containing multiple wires would be very difficult to achieve * Copper, aluminium and gold could be too soft, allowing the chain to tear if overstretched: alloys or other less conductive metals would have to be used * Incredibly arduous manufacturing of individual chain links * Possible loss of contact between chain links * And much, much more
I would have thought, given the availability of conductive lycra fabric (I've just googled it and had a fair few hits!), the answer to this is yes. So, quoting from <https://www.stem.org.uk/resources/elibrary/resource/31617/conductive-fabric> > > This fabric looks and feels like ordinary Lycra but is highly > conductive. It can be cut into narrow strips to form conducting > ‘wires’ or can be used as a soft compliant substitute for metal and > foil in switches and sensors > > > At the moment this fabric is predominantly used for wearable electronics. Possibly a better solution would be using electric nano-materials <https://aip.scitation.org/doi/10.1063/1.5083942>. This would allow wiring that acts pretty much like a rubber band. In the paper above it's using copper wires in a coil inside a substrate, but it also mentions using nanotubes or silver nanowires, and also structural folding such as origami to allow stretching.
33,814
I have trained several classifiers using Python's scikit-learn which are fairly accurate when applied on a test set at identifying different classes with a standardized set of input features. These different classifiers provide a certain probability for the classification. The input features are controllable physical parameters that I am measuring (e.g. temperature, volume) which intricately influence an output which can essentially be either 1 or 0 (and others in mutli-class cases). I can already do basic identification, but what I am curious about is: given an initial feature vector starting in class 0, are there known methods to find the optimal ways to change my input features so as to increase my probability of going into class 1? The input feature space has a high number of dimensions, and there may be certain constraints on the inputs (e.g. temperature cannot exceed a certain value if volume is kept at a particular value).
2018/06/29
[ "https://datascience.stackexchange.com/questions/33814", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/54277/" ]
This is a multivariate optimisation problem. You have a function f(X) that returns an output that you want to maximise - Maximising the probability of belonging to class. That function f(X) is just your model. You also mention "constraints", and again this is standard constrained optimisation territory. The problem itself may be hard to solve, but the framework seems to be that. Have a look at scipy optimise [here](https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html)
You have said in a comment that you use random forests and scikit-learn. The first step that you might take is to identify the features that have the greatest weight in deciding the outcome. As you can see [here](http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html) this is your classifier's property `feature_importances_` which ranks the inputs by their importance. From my experience their importance will usually follow the power-law and you could set a threshold that will reduce the number of dimensions you are looking at significantly. From here it depends on what approach you would rather take - you can train a classifier that takes these features and outputs the changes you need to switch the resulting class (use regularization to minimize the changes) or you can use an optimization black-box to solve the problem on a per-case basis. Specifically you could use the [scipy.optimize.minimize](https://docs.scipy.org/doc/scipy-0.13.0/reference/generated/scipy.optimize.minimize.html) method to minimize the `-(classifier confidence)` with constraints. For example if you want to find $\bar{x}$ s.t. $sample \* \bar{x}$ maximizes the classifier's confidence, you could do something on the lines of: ``` def min_func(x): return -cls.fit(sample*x) x0 = [1.3, 0.7, 0.8, 1.9, 1.2] minimizing_xs = minimize(min_func, x0, method='SLSQP', constraints=cons) ``` This optimization approach will naturally lend itself to a similar learning approach where you try to learn a generalized vector $\bar{x}$.
33,814
I have trained several classifiers using Python's scikit-learn which are fairly accurate when applied on a test set at identifying different classes with a standardized set of input features. These different classifiers provide a certain probability for the classification. The input features are controllable physical parameters that I am measuring (e.g. temperature, volume) which intricately influence an output which can essentially be either 1 or 0 (and others in mutli-class cases). I can already do basic identification, but what I am curious about is: given an initial feature vector starting in class 0, are there known methods to find the optimal ways to change my input features so as to increase my probability of going into class 1? The input feature space has a high number of dimensions, and there may be certain constraints on the inputs (e.g. temperature cannot exceed a certain value if volume is kept at a particular value).
2018/06/29
[ "https://datascience.stackexchange.com/questions/33814", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/54277/" ]
This is a multivariate optimisation problem. You have a function f(X) that returns an output that you want to maximise - Maximising the probability of belonging to class. That function f(X) is just your model. You also mention "constraints", and again this is standard constrained optimisation territory. The problem itself may be hard to solve, but the framework seems to be that. Have a look at scipy optimise [here](https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html)
Following your model choice, you could pick n observation labeled "0" and create **from each** m syinthetic new cases to feed to your best model in order to get predicitons. Basically you brute force-simulate new data changing the features starting from the input vector you already have. Say you have this feat. vector, you know is labeled zero: ``` x1 x2 x3 x4 x5 x6 y 20 5 1 0.5 6 10 0 ``` From this you simulate m new feature vector, using some prior knowledge about `x1-x6`. For example you start changing some inputs with higher values, and other with lower values (again it's best if you have some prior knowledge). After predicting the probability for each m new vector, you'll start seeing some pattern perhaps. To me, this is something worth trying and more interesting than simple importance measures obtained from RFs. Because they tend not to get the "big" picture, in other words the relationship conjoined between features. This are just some thoughts, hope it helps.
33,814
I have trained several classifiers using Python's scikit-learn which are fairly accurate when applied on a test set at identifying different classes with a standardized set of input features. These different classifiers provide a certain probability for the classification. The input features are controllable physical parameters that I am measuring (e.g. temperature, volume) which intricately influence an output which can essentially be either 1 or 0 (and others in mutli-class cases). I can already do basic identification, but what I am curious about is: given an initial feature vector starting in class 0, are there known methods to find the optimal ways to change my input features so as to increase my probability of going into class 1? The input feature space has a high number of dimensions, and there may be certain constraints on the inputs (e.g. temperature cannot exceed a certain value if volume is kept at a particular value).
2018/06/29
[ "https://datascience.stackexchange.com/questions/33814", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/54277/" ]
This is a multivariate optimisation problem. You have a function f(X) that returns an output that you want to maximise - Maximising the probability of belonging to class. That function f(X) is just your model. You also mention "constraints", and again this is standard constrained optimisation territory. The problem itself may be hard to solve, but the framework seems to be that. Have a look at scipy optimise [here](https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html)
This can be answered by performing [Sensitivity Analysis](https://en.wikipedia.org/wiki/Sensitivity_analysis) on your model (white or black box). This is a well-known technique in the field of Operations Research and it also applies to Machine Learning models. These are some helpful references: <https://ieeexplore.ieee.org/document/7600185/> <https://rd.springer.com/chapter/10.1007/978-3-319-43742-2_17> <http://www2.cs.uregina.ca/~jtyao/Papers/NAFIPS-E-178.pdf>
15,999,273
I do not understand why I am getting 404 error while trying to access my application my index.xhtml is in (Web Content) In my log I have no error I created my project using eclipse : web dynamic project : my url : ``` http://localhost:8080/jsf_getting_started/ ``` I tried with eclipse with tomcat (Run On Server). My web xml ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>jsf_getting_started</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>com.sun.faces.expressionFactory</param-name> <param-value>com.sun.el.ExpressionFactoryImpl</param-value> </context-param> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <context-param> <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <context-param> <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> <param-value>resources.application</param-value> </context-param> <listener> <listener-class>com.sun.faces.config.ConfigureListener</listener-class> </listener> ```
2013/04/14
[ "https://Stackoverflow.com/questions/15999273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2005176/" ]
The problem is that you have set the mapping of the Faces Servlet as `/faces/*` so in order to access to your page and be parsed by this servlet you must access to it like ``` http://localhost:8080/jsf_getting_started/faces/index.xhtml ``` But the problem with the `/faces/*` configuration is that the Faces Servlet will even process non-JSF resources like images, JS, CSS scripts, etc. The best solution would be to change the mapping to `*.xhtml` and remove all the pages in welcome file list to have only `index.xhtml`. Your web.xml file will look like this (note that I'm just posting the changes made on the parts described in this answer): ```xml <welcome-file-list> <welcome-file>index.xhtml</welcome-file> <!-- no need of the other files... --> </welcome-file-list> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <!-- The relevant URL mapping when using Facelets and JSF --> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> ``` After changing the web.xml file, rebuild your project, make sure to undeploy it from Tomcat Server and try again.
You need to add `index.xhtml` in the `welcome-file-list`.
367,295
As an amateur radio operator for 60 years now I have been aware that a major worry vis-a-vis lightning is not so much the very rare "direct hit" that blows up the house, but the far more common "near miss" in which a very large electromagnetic pulse will spread at the speed of light whenever lightning strikes nearby. I have been taught that this pulse (EMP) will induce a substantial voltage on antenna structures but also on power lines coming into the house. In this context, how does having the neutral wire (grounded at the home's AC service panel) provide ANY protection against a voltage surge on the AC supply going into the house? I am confused about this despite much reading on this great web site.
2018/04/08
[ "https://electronics.stackexchange.com/questions/367295", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/185083/" ]
The induced pulse from a nearby lightning strike is a *common-mode* signal with respect to the power line, which is a balanced (differential) connection to the pole transformer. (I'm assuming that you're in the USA, with the usual 120-0-120 "split phase" power connection.) The neutral is grounded at both ends — i.e., at the pole transformer and at your service entrance. At least one connection is required to keep this link from "floating" to arbitrary voltage levels with respect to ground. Two connections serves to short out the common-mode surge from lightning strikes. In other words, if the neutral (center tap) was grounded *only* at the pole transformer, the common-mode surge induced along the length of the cable would enter the house, rather than being shorted to ground. Similarly, if the only ground was at the service entrance, then the pole transformer would experience the surge, possibly exceeding its ratings and causing an internal breakdown.
![schematic](https://i.stack.imgur.com/4s9Ev.png) [simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f4s9Ev.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/) The best protection is an MOV and a good line filter.
30,290,881
I'm currently dealing with a generic Tree with this structure: ``` typedef struct NODE { //node's keys unsigned short *transboard; int depth; unsigned int i; unsigned int j; int player; int value; struct NODE *leftchild; //points to the first child from the left struct NODE *rightbrothers; //linked list of brothers from the current node }NODE; static NODE *GameTree = NULL; ``` While the function that allocates the different nodes is (don't bother too much at the keys' values, basically allocates the children-nodes. If there aren't any the new child goes to leftchild, otherwise it goes at the end of the list "node->leftchild->rightbrothers"): ``` static int AllocateChildren(NODE **T, int depth, unsigned int i, unsigned int j, int player, unsigned short *transboard) { NODE *tmp = NULL; if ((*T)->leftchild == NULL) { if( (tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX ) ? (tmp->value = 2 ): (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; (*T)->leftchild = tmp; } } else { NODE *scorri = (*T)->leftchild; while (scorri->rightbrothers != NULL) scorri = scorri->rightbrothers; if( ( tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX) ? (tmp->value = 2) : (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; } scorri->rightbrothers = tmp; } return 1; } ``` I need to come up with a function, possibly recursive, that deallocates the whole tree, so far I've come up with this: ``` void DeleteTree(NODE **T) { if((*T) != NULL) { NODE *tmp; for(tmp = (*T)->children; tmp->brother != NULL; tmp = tmp->brother) { DeleteTree(&tmp); } free(*T); } } ``` But it doesn't seem working, it doesn't even deallocate a single node of memory. Any ideas of where I am being wrong or how can it be implemented? P.s. I've gotten the idea of the recursive function from this pseudocode from my teacher. However I'm not sure I've translated it correctly in C with my kind of Tree. Pseudocode: ``` 1: function DeleteTree(T) 2: if T != NULL then 3: for c ∈ Children(T) do 4: DeleteTree(c) 5: end for 6: Delete(T) 7: end if 8: end function ```
2015/05/17
[ "https://Stackoverflow.com/questions/30290881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228382/" ]
In mysql your query should be like ``` ALTER TABLE table_name change column_1 column_2 Data_Type; ``` you have written the query in Oracle.
if you are using gui SQL SMS you can do db -> Tables -> Table -> columns -> column you want to rename right click and rename
30,290,881
I'm currently dealing with a generic Tree with this structure: ``` typedef struct NODE { //node's keys unsigned short *transboard; int depth; unsigned int i; unsigned int j; int player; int value; struct NODE *leftchild; //points to the first child from the left struct NODE *rightbrothers; //linked list of brothers from the current node }NODE; static NODE *GameTree = NULL; ``` While the function that allocates the different nodes is (don't bother too much at the keys' values, basically allocates the children-nodes. If there aren't any the new child goes to leftchild, otherwise it goes at the end of the list "node->leftchild->rightbrothers"): ``` static int AllocateChildren(NODE **T, int depth, unsigned int i, unsigned int j, int player, unsigned short *transboard) { NODE *tmp = NULL; if ((*T)->leftchild == NULL) { if( (tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX ) ? (tmp->value = 2 ): (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; (*T)->leftchild = tmp; } } else { NODE *scorri = (*T)->leftchild; while (scorri->rightbrothers != NULL) scorri = scorri->rightbrothers; if( ( tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX) ? (tmp->value = 2) : (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; } scorri->rightbrothers = tmp; } return 1; } ``` I need to come up with a function, possibly recursive, that deallocates the whole tree, so far I've come up with this: ``` void DeleteTree(NODE **T) { if((*T) != NULL) { NODE *tmp; for(tmp = (*T)->children; tmp->brother != NULL; tmp = tmp->brother) { DeleteTree(&tmp); } free(*T); } } ``` But it doesn't seem working, it doesn't even deallocate a single node of memory. Any ideas of where I am being wrong or how can it be implemented? P.s. I've gotten the idea of the recursive function from this pseudocode from my teacher. However I'm not sure I've translated it correctly in C with my kind of Tree. Pseudocode: ``` 1: function DeleteTree(T) 2: if T != NULL then 3: for c ∈ Children(T) do 4: DeleteTree(c) 5: end for 6: Delete(T) 7: end if 8: end function ```
2015/05/17
[ "https://Stackoverflow.com/questions/30290881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228382/" ]
``` ALTER TABLE `table_name` CHANGE `$old_column_name` `new_column_name` VARCHAR(40) ``` this is working for me
**Rename column name in mysql** ``` alter table categories change type category_type varchar(255); ```
30,290,881
I'm currently dealing with a generic Tree with this structure: ``` typedef struct NODE { //node's keys unsigned short *transboard; int depth; unsigned int i; unsigned int j; int player; int value; struct NODE *leftchild; //points to the first child from the left struct NODE *rightbrothers; //linked list of brothers from the current node }NODE; static NODE *GameTree = NULL; ``` While the function that allocates the different nodes is (don't bother too much at the keys' values, basically allocates the children-nodes. If there aren't any the new child goes to leftchild, otherwise it goes at the end of the list "node->leftchild->rightbrothers"): ``` static int AllocateChildren(NODE **T, int depth, unsigned int i, unsigned int j, int player, unsigned short *transboard) { NODE *tmp = NULL; if ((*T)->leftchild == NULL) { if( (tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX ) ? (tmp->value = 2 ): (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; (*T)->leftchild = tmp; } } else { NODE *scorri = (*T)->leftchild; while (scorri->rightbrothers != NULL) scorri = scorri->rightbrothers; if( ( tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX) ? (tmp->value = 2) : (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; } scorri->rightbrothers = tmp; } return 1; } ``` I need to come up with a function, possibly recursive, that deallocates the whole tree, so far I've come up with this: ``` void DeleteTree(NODE **T) { if((*T) != NULL) { NODE *tmp; for(tmp = (*T)->children; tmp->brother != NULL; tmp = tmp->brother) { DeleteTree(&tmp); } free(*T); } } ``` But it doesn't seem working, it doesn't even deallocate a single node of memory. Any ideas of where I am being wrong or how can it be implemented? P.s. I've gotten the idea of the recursive function from this pseudocode from my teacher. However I'm not sure I've translated it correctly in C with my kind of Tree. Pseudocode: ``` 1: function DeleteTree(T) 2: if T != NULL then 3: for c ∈ Children(T) do 4: DeleteTree(c) 5: end for 6: Delete(T) 7: end if 8: end function ```
2015/05/17
[ "https://Stackoverflow.com/questions/30290881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228382/" ]
``` ALTER TABLE `table_name` CHANGE `$old_column_name` `new_column_name` VARCHAR(40) ``` this is working for me
<https://dev.mysql.com/doc/refman/8.0/en/alter-table.html> For MySQL 8 ``` alter table creditReportXml_temp change column applicationID applicantID int(11); ```
30,290,881
I'm currently dealing with a generic Tree with this structure: ``` typedef struct NODE { //node's keys unsigned short *transboard; int depth; unsigned int i; unsigned int j; int player; int value; struct NODE *leftchild; //points to the first child from the left struct NODE *rightbrothers; //linked list of brothers from the current node }NODE; static NODE *GameTree = NULL; ``` While the function that allocates the different nodes is (don't bother too much at the keys' values, basically allocates the children-nodes. If there aren't any the new child goes to leftchild, otherwise it goes at the end of the list "node->leftchild->rightbrothers"): ``` static int AllocateChildren(NODE **T, int depth, unsigned int i, unsigned int j, int player, unsigned short *transboard) { NODE *tmp = NULL; if ((*T)->leftchild == NULL) { if( (tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX ) ? (tmp->value = 2 ): (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; (*T)->leftchild = tmp; } } else { NODE *scorri = (*T)->leftchild; while (scorri->rightbrothers != NULL) scorri = scorri->rightbrothers; if( ( tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX) ? (tmp->value = 2) : (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; } scorri->rightbrothers = tmp; } return 1; } ``` I need to come up with a function, possibly recursive, that deallocates the whole tree, so far I've come up with this: ``` void DeleteTree(NODE **T) { if((*T) != NULL) { NODE *tmp; for(tmp = (*T)->children; tmp->brother != NULL; tmp = tmp->brother) { DeleteTree(&tmp); } free(*T); } } ``` But it doesn't seem working, it doesn't even deallocate a single node of memory. Any ideas of where I am being wrong or how can it be implemented? P.s. I've gotten the idea of the recursive function from this pseudocode from my teacher. However I'm not sure I've translated it correctly in C with my kind of Tree. Pseudocode: ``` 1: function DeleteTree(T) 2: if T != NULL then 3: for c ∈ Children(T) do 4: DeleteTree(c) 5: end for 6: Delete(T) 7: end if 8: end function ```
2015/05/17
[ "https://Stackoverflow.com/questions/30290881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228382/" ]
Use the following query: ``` ALTER TABLE tableName CHANGE oldcolname newcolname datatype(length); ``` The `RENAME` function is used in Oracle databases. ``` ALTER TABLE tableName RENAME COLUMN oldcolname TO newcolname datatype(length); ``` --- [@lad2025](https://stackoverflow.com/a/49925232/4762528) mentions it below, but I thought it'd be nice to add what he said. Thank you @lad2025! You can use the `RENAME COLUMN` in MySQL 8.0 to rename any column you need renamed. ``` ALTER TABLE table_name RENAME COLUMN old_col_name TO new_col_name; ``` > > [ALTER TABLE Syntax](https://dev.mysql.com/doc/refman/8.0/en/alter-table.html): > **RENAME COLUMN:** > > > * Can change a column name but not its definition. > * More convenient than CHANGE to rename a column without changing its definition. > > >
From **MySQL 5.7 Reference [Manual](https://dev.mysql.com/doc/refman/5.7/en/alter-table.html)**. Syntax : > > ALTER TABLE t1 CHANGE a b DATATYPE; > > > e.g. : for **Customer** TABLE having COLUMN ***customer\_name***, ***customer\_street***, ***customercity***. And we want to change **customercity** TO **customer\_city** : ``` alter table customer change customercity customer_city VARCHAR(225); ```
30,290,881
I'm currently dealing with a generic Tree with this structure: ``` typedef struct NODE { //node's keys unsigned short *transboard; int depth; unsigned int i; unsigned int j; int player; int value; struct NODE *leftchild; //points to the first child from the left struct NODE *rightbrothers; //linked list of brothers from the current node }NODE; static NODE *GameTree = NULL; ``` While the function that allocates the different nodes is (don't bother too much at the keys' values, basically allocates the children-nodes. If there aren't any the new child goes to leftchild, otherwise it goes at the end of the list "node->leftchild->rightbrothers"): ``` static int AllocateChildren(NODE **T, int depth, unsigned int i, unsigned int j, int player, unsigned short *transboard) { NODE *tmp = NULL; if ((*T)->leftchild == NULL) { if( (tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX ) ? (tmp->value = 2 ): (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; (*T)->leftchild = tmp; } } else { NODE *scorri = (*T)->leftchild; while (scorri->rightbrothers != NULL) scorri = scorri->rightbrothers; if( ( tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX) ? (tmp->value = 2) : (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; } scorri->rightbrothers = tmp; } return 1; } ``` I need to come up with a function, possibly recursive, that deallocates the whole tree, so far I've come up with this: ``` void DeleteTree(NODE **T) { if((*T) != NULL) { NODE *tmp; for(tmp = (*T)->children; tmp->brother != NULL; tmp = tmp->brother) { DeleteTree(&tmp); } free(*T); } } ``` But it doesn't seem working, it doesn't even deallocate a single node of memory. Any ideas of where I am being wrong or how can it be implemented? P.s. I've gotten the idea of the recursive function from this pseudocode from my teacher. However I'm not sure I've translated it correctly in C with my kind of Tree. Pseudocode: ``` 1: function DeleteTree(T) 2: if T != NULL then 3: for c ∈ Children(T) do 4: DeleteTree(c) 5: end for 6: Delete(T) 7: end if 8: end function ```
2015/05/17
[ "https://Stackoverflow.com/questions/30290881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228382/" ]
``` ALTER TABLE table_name CHANGE old_column_name new_column_name columnDataType; ```
for mysql version 5 `alter table *table_name* change column *old_column_name* *new_column_name* datatype();`
30,290,881
I'm currently dealing with a generic Tree with this structure: ``` typedef struct NODE { //node's keys unsigned short *transboard; int depth; unsigned int i; unsigned int j; int player; int value; struct NODE *leftchild; //points to the first child from the left struct NODE *rightbrothers; //linked list of brothers from the current node }NODE; static NODE *GameTree = NULL; ``` While the function that allocates the different nodes is (don't bother too much at the keys' values, basically allocates the children-nodes. If there aren't any the new child goes to leftchild, otherwise it goes at the end of the list "node->leftchild->rightbrothers"): ``` static int AllocateChildren(NODE **T, int depth, unsigned int i, unsigned int j, int player, unsigned short *transboard) { NODE *tmp = NULL; if ((*T)->leftchild == NULL) { if( (tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX ) ? (tmp->value = 2 ): (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; (*T)->leftchild = tmp; } } else { NODE *scorri = (*T)->leftchild; while (scorri->rightbrothers != NULL) scorri = scorri->rightbrothers; if( ( tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX) ? (tmp->value = 2) : (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; } scorri->rightbrothers = tmp; } return 1; } ``` I need to come up with a function, possibly recursive, that deallocates the whole tree, so far I've come up with this: ``` void DeleteTree(NODE **T) { if((*T) != NULL) { NODE *tmp; for(tmp = (*T)->children; tmp->brother != NULL; tmp = tmp->brother) { DeleteTree(&tmp); } free(*T); } } ``` But it doesn't seem working, it doesn't even deallocate a single node of memory. Any ideas of where I am being wrong or how can it be implemented? P.s. I've gotten the idea of the recursive function from this pseudocode from my teacher. However I'm not sure I've translated it correctly in C with my kind of Tree. Pseudocode: ``` 1: function DeleteTree(T) 2: if T != NULL then 3: for c ∈ Children(T) do 4: DeleteTree(c) 5: end for 6: Delete(T) 7: end if 8: end function ```
2015/05/17
[ "https://Stackoverflow.com/questions/30290881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228382/" ]
``` ALTER TABLE table_name CHANGE old_column_name new_column_name columnDataType; ```
Posting it here, it helps helps else ignore it but when trying to use the Change Column and Rename column functions it is throwing me an error. So figured I would see what statement is generated when we go ahead and rename the column by going into table properties. Below is the command been generated. ``` EXEC DB.sys.sp_rename N'db.tablename.TrackingIDChargeDescription1' , N'ChargeDescription1', 'COLUMN'; ``` I used and renamed bunch of columns in table.
30,290,881
I'm currently dealing with a generic Tree with this structure: ``` typedef struct NODE { //node's keys unsigned short *transboard; int depth; unsigned int i; unsigned int j; int player; int value; struct NODE *leftchild; //points to the first child from the left struct NODE *rightbrothers; //linked list of brothers from the current node }NODE; static NODE *GameTree = NULL; ``` While the function that allocates the different nodes is (don't bother too much at the keys' values, basically allocates the children-nodes. If there aren't any the new child goes to leftchild, otherwise it goes at the end of the list "node->leftchild->rightbrothers"): ``` static int AllocateChildren(NODE **T, int depth, unsigned int i, unsigned int j, int player, unsigned short *transboard) { NODE *tmp = NULL; if ((*T)->leftchild == NULL) { if( (tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX ) ? (tmp->value = 2 ): (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; (*T)->leftchild = tmp; } } else { NODE *scorri = (*T)->leftchild; while (scorri->rightbrothers != NULL) scorri = scorri->rightbrothers; if( ( tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX) ? (tmp->value = 2) : (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; } scorri->rightbrothers = tmp; } return 1; } ``` I need to come up with a function, possibly recursive, that deallocates the whole tree, so far I've come up with this: ``` void DeleteTree(NODE **T) { if((*T) != NULL) { NODE *tmp; for(tmp = (*T)->children; tmp->brother != NULL; tmp = tmp->brother) { DeleteTree(&tmp); } free(*T); } } ``` But it doesn't seem working, it doesn't even deallocate a single node of memory. Any ideas of where I am being wrong or how can it be implemented? P.s. I've gotten the idea of the recursive function from this pseudocode from my teacher. However I'm not sure I've translated it correctly in C with my kind of Tree. Pseudocode: ``` 1: function DeleteTree(T) 2: if T != NULL then 3: for c ∈ Children(T) do 4: DeleteTree(c) 5: end for 6: Delete(T) 7: end if 8: end function ```
2015/05/17
[ "https://Stackoverflow.com/questions/30290881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228382/" ]
Use the following query: ``` ALTER TABLE tableName CHANGE oldcolname newcolname datatype(length); ``` The `RENAME` function is used in Oracle databases. ``` ALTER TABLE tableName RENAME COLUMN oldcolname TO newcolname datatype(length); ``` --- [@lad2025](https://stackoverflow.com/a/49925232/4762528) mentions it below, but I thought it'd be nice to add what he said. Thank you @lad2025! You can use the `RENAME COLUMN` in MySQL 8.0 to rename any column you need renamed. ``` ALTER TABLE table_name RENAME COLUMN old_col_name TO new_col_name; ``` > > [ALTER TABLE Syntax](https://dev.mysql.com/doc/refman/8.0/en/alter-table.html): > **RENAME COLUMN:** > > > * Can change a column name but not its definition. > * More convenient than CHANGE to rename a column without changing its definition. > > >
From MySQL 8.0 you could use ``` ALTER TABLE table_name RENAME COLUMN old_col_name TO new_col_name; ``` > > [ALTER TABLE Syntax](https://dev.mysql.com/doc/refman/8.0/en/alter-table.html): > > > **RENAME COLUMN:** > > > * Can change a column name but not its definition. > * More convenient than CHANGE to rename a column without changing its definition. > > > **[DBFiddle Demo](https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=dc21e8c179aa5325d9f337c54cb0e63f)**
30,290,881
I'm currently dealing with a generic Tree with this structure: ``` typedef struct NODE { //node's keys unsigned short *transboard; int depth; unsigned int i; unsigned int j; int player; int value; struct NODE *leftchild; //points to the first child from the left struct NODE *rightbrothers; //linked list of brothers from the current node }NODE; static NODE *GameTree = NULL; ``` While the function that allocates the different nodes is (don't bother too much at the keys' values, basically allocates the children-nodes. If there aren't any the new child goes to leftchild, otherwise it goes at the end of the list "node->leftchild->rightbrothers"): ``` static int AllocateChildren(NODE **T, int depth, unsigned int i, unsigned int j, int player, unsigned short *transboard) { NODE *tmp = NULL; if ((*T)->leftchild == NULL) { if( (tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX ) ? (tmp->value = 2 ): (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; (*T)->leftchild = tmp; } } else { NODE *scorri = (*T)->leftchild; while (scorri->rightbrothers != NULL) scorri = scorri->rightbrothers; if( ( tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX) ? (tmp->value = 2) : (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; } scorri->rightbrothers = tmp; } return 1; } ``` I need to come up with a function, possibly recursive, that deallocates the whole tree, so far I've come up with this: ``` void DeleteTree(NODE **T) { if((*T) != NULL) { NODE *tmp; for(tmp = (*T)->children; tmp->brother != NULL; tmp = tmp->brother) { DeleteTree(&tmp); } free(*T); } } ``` But it doesn't seem working, it doesn't even deallocate a single node of memory. Any ideas of where I am being wrong or how can it be implemented? P.s. I've gotten the idea of the recursive function from this pseudocode from my teacher. However I'm not sure I've translated it correctly in C with my kind of Tree. Pseudocode: ``` 1: function DeleteTree(T) 2: if T != NULL then 3: for c ∈ Children(T) do 4: DeleteTree(c) 5: end for 6: Delete(T) 7: end if 8: end function ```
2015/05/17
[ "https://Stackoverflow.com/questions/30290881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228382/" ]
You can use following code: ``` ALTER TABLE `dbName`.`tableName` CHANGE COLUMN `old_columnName` `new_columnName` VARCHAR(45) NULL DEFAULT NULL ; ```
None of the above worked when I had a column with parenthesis. Then I tried ` and the magic worked. So if you have a special character in your column by mistake and you want to rename it, use **`** for the name of the existing column. For example: ALTER TABLE table\_name RENAME COLUMN `column(old)` TO `new_column`;
30,290,881
I'm currently dealing with a generic Tree with this structure: ``` typedef struct NODE { //node's keys unsigned short *transboard; int depth; unsigned int i; unsigned int j; int player; int value; struct NODE *leftchild; //points to the first child from the left struct NODE *rightbrothers; //linked list of brothers from the current node }NODE; static NODE *GameTree = NULL; ``` While the function that allocates the different nodes is (don't bother too much at the keys' values, basically allocates the children-nodes. If there aren't any the new child goes to leftchild, otherwise it goes at the end of the list "node->leftchild->rightbrothers"): ``` static int AllocateChildren(NODE **T, int depth, unsigned int i, unsigned int j, int player, unsigned short *transboard) { NODE *tmp = NULL; if ((*T)->leftchild == NULL) { if( (tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX ) ? (tmp->value = 2 ): (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; (*T)->leftchild = tmp; } } else { NODE *scorri = (*T)->leftchild; while (scorri->rightbrothers != NULL) scorri = scorri->rightbrothers; if( ( tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX) ? (tmp->value = 2) : (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; } scorri->rightbrothers = tmp; } return 1; } ``` I need to come up with a function, possibly recursive, that deallocates the whole tree, so far I've come up with this: ``` void DeleteTree(NODE **T) { if((*T) != NULL) { NODE *tmp; for(tmp = (*T)->children; tmp->brother != NULL; tmp = tmp->brother) { DeleteTree(&tmp); } free(*T); } } ``` But it doesn't seem working, it doesn't even deallocate a single node of memory. Any ideas of where I am being wrong or how can it be implemented? P.s. I've gotten the idea of the recursive function from this pseudocode from my teacher. However I'm not sure I've translated it correctly in C with my kind of Tree. Pseudocode: ``` 1: function DeleteTree(T) 2: if T != NULL then 3: for c ∈ Children(T) do 4: DeleteTree(c) 5: end for 6: Delete(T) 7: end if 8: end function ```
2015/05/17
[ "https://Stackoverflow.com/questions/30290881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228382/" ]
From MySQL 8.0 you could use ``` ALTER TABLE table_name RENAME COLUMN old_col_name TO new_col_name; ``` > > [ALTER TABLE Syntax](https://dev.mysql.com/doc/refman/8.0/en/alter-table.html): > > > **RENAME COLUMN:** > > > * Can change a column name but not its definition. > * More convenient than CHANGE to rename a column without changing its definition. > > > **[DBFiddle Demo](https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=dc21e8c179aa5325d9f337c54cb0e63f)**
In mysql your query should be like ``` ALTER TABLE table_name change column_1 column_2 Data_Type; ``` you have written the query in Oracle.
30,290,881
I'm currently dealing with a generic Tree with this structure: ``` typedef struct NODE { //node's keys unsigned short *transboard; int depth; unsigned int i; unsigned int j; int player; int value; struct NODE *leftchild; //points to the first child from the left struct NODE *rightbrothers; //linked list of brothers from the current node }NODE; static NODE *GameTree = NULL; ``` While the function that allocates the different nodes is (don't bother too much at the keys' values, basically allocates the children-nodes. If there aren't any the new child goes to leftchild, otherwise it goes at the end of the list "node->leftchild->rightbrothers"): ``` static int AllocateChildren(NODE **T, int depth, unsigned int i, unsigned int j, int player, unsigned short *transboard) { NODE *tmp = NULL; if ((*T)->leftchild == NULL) { if( (tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX ) ? (tmp->value = 2 ): (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; (*T)->leftchild = tmp; } } else { NODE *scorri = (*T)->leftchild; while (scorri->rightbrothers != NULL) scorri = scorri->rightbrothers; if( ( tmp = (NODE*)malloc(sizeof(NODE)) )== NULL) return 0; else { tmp->i = i; tmp->j = j; tmp->depth = depth; (player == MAX) ? (tmp->value = 2) : (tmp->value = -2); tmp->player = player; tmp->transboard = transboard; tmp->leftchild = NULL; tmp->rightbrothers = NULL; } scorri->rightbrothers = tmp; } return 1; } ``` I need to come up with a function, possibly recursive, that deallocates the whole tree, so far I've come up with this: ``` void DeleteTree(NODE **T) { if((*T) != NULL) { NODE *tmp; for(tmp = (*T)->children; tmp->brother != NULL; tmp = tmp->brother) { DeleteTree(&tmp); } free(*T); } } ``` But it doesn't seem working, it doesn't even deallocate a single node of memory. Any ideas of where I am being wrong or how can it be implemented? P.s. I've gotten the idea of the recursive function from this pseudocode from my teacher. However I'm not sure I've translated it correctly in C with my kind of Tree. Pseudocode: ``` 1: function DeleteTree(T) 2: if T != NULL then 3: for c ∈ Children(T) do 4: DeleteTree(c) 5: end for 6: Delete(T) 7: end if 8: end function ```
2015/05/17
[ "https://Stackoverflow.com/questions/30290881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228382/" ]
You can use following code: ``` ALTER TABLE `dbName`.`tableName` CHANGE COLUMN `old_columnName` `new_columnName` VARCHAR(45) NULL DEFAULT NULL ; ```
**Rename column name in mysql** ``` alter table categories change type category_type varchar(255); ```
10,726
When we practice mindfulness we notice our mental habit and mental pattern. What makes us angry, jealous, greedy, etc.. My question is, when you notice them, do you change it to positive mental quality or just watch it? Someone angry for 'no reason', but actually there is a reason if one keeps the mindfulness. With mindfulness, we realize that the trigger of the anger is for example a certain situation happened yesterday. By realizing this we are no longer angry. Is this also a practice of mindfulness or analyzing? Which one is the correct practice? Thanks all.
2015/08/10
[ "https://buddhism.stackexchange.com/questions/10726", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/5229/" ]
In mindfulness, we try to stay in the present moment, being aware of what we are doing and experiencing right here and right now. For the most part, the things that upset us are things that happened in the past, even if the past was just 5 minutes ago. Dwelling on the past would be outside of mindfulness. A great dhamma talk I've read on this subject is from Ajahn Sumedo called [In the moment of mindfulness, there is no suffering.](http://buddhismnow.com/2014/09/18/in-the-moment-of-mindfulness-there-is-no-suffering-by-ajahn-sumedho/) > > In the moment of mindfulness, there is no suffering. I can’t find any suffering in mindfulness; it’s impossible; there’s absolutely none. But when there’s heedlessness, there is a lot of suffering in my mind. If I give in to grasping things, to wanting things, to following emotions or doubts and worries and being caught up in things like that—then there is suffering. It all begins from my grasping. But when there is mindfulness and right understanding, then I can’t find any suffering at all in this moment, now. This is about this moment here and now. > > > I encourage you to read the rest of the dhamma talk to be inspired to try to live in this present moment. Regarding realizing you are upset about something that occurred in the past, the simple technique of noting and observing your feeling, such as noting "angry...angry" or "disappointed...disappointed" without replaying in your mind the incident which made you angry or disappointed can help you see that feelings such as these are fleeting and impermanent. They come and go and we can help ourselves see their impermanent nature by not "feeding" them with overthinking them or dwelling in the past but remaining in the present moment and impartially observing that feelings arise and cease.
> > ... do you change it to positive mental quality ... > > > If any of the [Nīvaraṇa](https://en.wikipedia.org/wiki/Five_hindrances) arises you can apply the antidote to it. Also see: [Nīvarana,pahana Vagga](http://www.themindingcentre.org/dharmafarer/wp-content/uploads/2009/12/16.3-Nivarana-Pahana-Vagga-a1.2-piya.pdf) and [Nīvaraṇa](http://www.themindingcentre.org/dharmafarer/wp-content/uploads/2010/02/32.1-Nivarana.-piya.pdf) > > ... or just watch it? > > > You can do this also. There is always a sensation associated with the hindrances. If you are angry you get a burning sensation. If you have sloth or torpor you feel heavy. > > Someone angry for 'no reason', but actually there is a reason if one keeps the mindfulness. > > > This is some stimuli at the scene door which give an unpleasant sensation. > > ... By realizing this we are no longer angry. > > > These mental states are impermanent. When the cause, initial stimuli or / and the subsequent mental proliferation disappears then result (anger) disappears. Also see: [Dependent Arising](http://www.themindingcentre.org/dharmafarer/wp-content/uploads/2009/12/5.16-Dependent-arising-piya.pdf) > > Is this also a practice of mindfulness or analyzing? > > > This is a form of analysing the impermanence of feelings arising from this mental state. It can be taken as [Dhamma vicaya](https://en.wikipedia.org/wiki/Dhamma_vicaya) which is mindfulness. Basically you look at the arising and passing of sensations pertaining to the hindrance. > > Which one is the correct practice? > > > All he following you mentioned are correct: * apply antidote * being mindful of the impermanence or arising and passing of sensations (or phenomena what is felt) pertaining to the hindrance * analyse the impermanence or arising and passing of sensations (or phenomena what is felt) pertaining to the hindrance (same as above)
27,873,836
I have installed all three dependencies according to the document (Python 2.6, 2.7, 3.2 or higher. Django 1.2.7 or higher. django-classy-tags 0.3.1 or higher) But when I add ‘sekizai’ into my INSTALLED\_APPS setting, and execute "manage.py runserver", it will report "ImportError: No module named sekizai" to me. My contents in settings.py: ``` # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'mptt', 'hw', 'useraccess', 'proxy', 'compressor', 'sekizai', ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'useraccess.middleware.VisitCollectMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.i18n', 'django.core.context_processors.request', 'django.core.context_processors.media', 'django.core.context_processors.static', 'hw.context_processors.user_info', 'hw.context_processors.login_form', 'hw.context_processors.get_all_user', 'sekizai.context_processors.sekizai', ) ```
2015/01/10
[ "https://Stackoverflow.com/questions/27873836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4258041/" ]
just do ``` pip install https://pypi.python.org/packages/source/d/django-sekizai/django-sekizai-0.8.1.tar.gz ``` and you should be fine.
the answer updated 10 july 2021 ``` pip install django pip install django-cms pip install django-sekizai pip freeze asgiref==3.4.1 Django==3.2.5 django-classy-tags==2.0.0 django-cms==3.9.0 django-formtools==2.3 django-sekizai==2.0.0 django-treebeard==4.5.1 djangocms-admin-style==2.0.2 pytz==2021.1 sqlparse==0.4.1 ```
15,473,348
The goal of my code is to search on the API search string: So if you fill out the form you get the hits bij name. I used the following Knockout.js script: ``` var viewModel= { query : ko.observable("wis"), }; function EmployeesViewModel(query) { var self = this; self.employees = ko.observableArray(); self.query = ko.observable(query); self.baseUri = BASE + "/api/v1/search?resource=employees&field=achternaam&q="; self.apiurl = ko.computed(function() { return self.baseUri + self.query(); }, self); //$.getJSON(baseUri, self.employees); //$.getJSON(self.baseUri, self.employees); $.getJSON(self.apiurl(), self.employees); }; $(document).ready(function () { ko.applyBindings(new EmployeesViewModel(viewModel.query())); }); ``` The html binding is: ``` <input type="text" class="search-query" placeholder="Search" id="global-search" data-bind="value: query, valueUpdate: 'keyup'"/> ``` But if i fill the text box i onley get the default "wis" employees? What am I doing wrong?
2013/03/18
[ "https://Stackoverflow.com/questions/15473348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2181663/" ]
I remember somewhere in the kendo ui documentation (may be datasource > groups) it said that, if you define groups, the grouping requires the sorted data.. Remove all your groups and display the data in plain vanilla grid and see if some automatic sorting is applied.
This is a complete guess, but have you tried setting the ServerSorting property to true?
15,473,348
The goal of my code is to search on the API search string: So if you fill out the form you get the hits bij name. I used the following Knockout.js script: ``` var viewModel= { query : ko.observable("wis"), }; function EmployeesViewModel(query) { var self = this; self.employees = ko.observableArray(); self.query = ko.observable(query); self.baseUri = BASE + "/api/v1/search?resource=employees&field=achternaam&q="; self.apiurl = ko.computed(function() { return self.baseUri + self.query(); }, self); //$.getJSON(baseUri, self.employees); //$.getJSON(self.baseUri, self.employees); $.getJSON(self.apiurl(), self.employees); }; $(document).ready(function () { ko.applyBindings(new EmployeesViewModel(viewModel.query())); }); ``` The html binding is: ``` <input type="text" class="search-query" placeholder="Search" id="global-search" data-bind="value: query, valueUpdate: 'keyup'"/> ``` But if i fill the text box i onley get the default "wis" employees? What am I doing wrong?
2013/03/18
[ "https://Stackoverflow.com/questions/15473348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2181663/" ]
I remember somewhere in the kendo ui documentation (may be datasource > groups) it said that, if you define groups, the grouping requires the sorted data.. Remove all your groups and display the data in plain vanilla grid and see if some automatic sorting is applied.
Kendo UI Grid Grouping gives you `ListSortDirection.Ascending` sorting by default. If you want to do something else you have to set it. If you are using the WebApi interface and generating a kendoRequest for the `Kendo.mvc.dll` method `.ToDataSourceResult(kendoRequest);` then you may try something like this: ``` var sort = kendoRequest.Sorts.FirstOrDefault(); var group = kendoRequest.Groups.FirstOrDefault(); if(sort != null && group != null) { if(sort.Member == group.Member && sort.SortDirection == ListSortDirection.Descending) { kendoRequest.Groups[0].SortDirection = sort.SortDirection; } } ``` That way the Sort feature from the Grid affects the Group by column when they match.
11,571,977
``` $to = 'my@email.ca'; $subject = 'Receipt'; $repEmail = 'rep@sales.ca'; $fileName = 'receipt.pdf'; $fileatt = $pdf->Output($fileName, 'E'); $attachment = chunk_split($fileatt); $eol = PHP_EOL; $separator = md5(time()); $headers = 'From: Sender <'.$repEmail.'>'.$eol; $headers .= 'MIME-Version: 1.0' .$eol; $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\""; $message = "--".$separator.$eol; $message .= "Content-Transfer-Encoding: 7bit".$eol.$eol; $message .= "This is a MIME encoded message.".$eol; $message .= "--".$separator.$eol; $message .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol; $message .= "Content-Transfer-Encoding: 8bit".$eol.$eol; $message .= "--".$separator.$eol; $message .= "Content-Type: application/pdf; name=\"".$fileName."\"".$eol; $message .= "Content-Transfer-Encoding: base64".$eol; $message .= "Content-Disposition: attachment".$eol.$eol; $message .= $attachment.$eol; $message .= "--".$separator."--"; if (mail($to, $subject, $message, $headers)){ $action = 'action=Receipt%20Sent'; header('Location: ../index.php?'.$action); } else { $action = 'action=Send%20Failed'; header('Location: ../index.php?'.$action); } ``` I have been using TCPDF for a short amount of time now to generate PDF files from forms. It works quite well and that part of the PHP has not changed. Now I want to send those PDF files to my email account. The emailing is actually working with this coding and attaching a PDF. The issue is that it is simply a blank PDF at rough 100 bytes in size. Which of course is not a valid PDF nor does it have anything to do with the responses from the form. I am really not familiar with the attaching of files to an email in PHP and any help resolving this issue would be greatly appreciated. **Update** Since it seems like several people are looking at this still I will post my current solution. It involves downloading PHPMailer as suggested below. I have started at the output line for TCPDF. ``` $attachment = $makepdf->Output('filename.pdf', 'S'); SENDmail($attachment); function SENDmail($pdf) { require_once('phpmailer/class.phpmailer.php'); $mailer = new PHPMailer(); $mailer->AddReplyTo('reply@to.ca', 'Reply To'); $mailer->SetFrom('sent@from.ca', 'Sent From'); $mailer->AddReplyTo('reply@to.ca', 'Reply To'); $mailer->AddAddress('send@to.ca', 'Send To'); $mailer->Subject = 'Message with PDF'; $mailer->AltBody = "To view the message, please use an HTML compatible email viewer"; $mailer->MsgHTML('<p>Message contents</p>')); if ($pdf) {$mailer->AddStringAttachment($pdf, 'filename.pdf');} $mailer->Send(); } ```
2012/07/20
[ "https://Stackoverflow.com/questions/11571977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/896075/" ]
You have two choices. You can save the PDF to a file and attach the file or else output it as a string. I find the string output is preferable: ``` $pdfString = $pdf->Output('dummy.pdf', 'S'); ``` The file name is ignored since it just returns the encoded string. Now you can include the string in your email. I prefer to use PHPMailer when working with attachments like this. Use the AddStringAttachment method of PHPMailer to accomplish this: ``` $mailer->AddStringAttachment($pdfString, 'some_filename.pdf'); ```
I tried several alternatives. Only way that worked was when I saved the PDF to a folder and then email it. ``` $pdf->Output("folder/filename.pdf", "F"); //save the pdf to a folder require_once('phpmailer/class.phpmailer.php'); //where your phpmailer folder is $mail = new PHPMailer(); $mail->From = "email.com"; $mail->FromName = "Your name"; $mail->AddAddress("email@yahoo.com"); $mail->AddReplyTo("email@gmail.com", "Your name"); $mail->AddAttachment("folder/filename.pdf"); // attach pdf that was saved in a folder $mail->Subject = "Email Subject"; $mail->Body = "Email Body"; if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent"; } echo 'sent email and attachment'; ```
14,581,205
I am trying to read lines of text from the console. The number of lines is not known in advance. The BufferedReader.readLine() method reads a line but after the last line it waits for input from the console. What should be done in order to avoid this? Please see the code snippet below: ``` public static String[] getLinesFromConsole() { String strLine = ""; try { // Get the object of DataInputStream InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String line = ""; while ((line = br.readLine()) != null) strLine += line + "~"; //edited isr.close(); } catch (IOException ioe) { ioe.printStackTrace(); } return strLine.split("~"); } ```
2013/01/29
[ "https://Stackoverflow.com/questions/14581205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1376556/" ]
The below code might fix, replace text `exit` with your requirement specific string ``` public static String[] getLinesFromConsole() { String strLine = ""; try { // Get the object of DataInputStream InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String line = ""; while ((line = br.readLine()) != null && !line.equals("exit") ) strLine += br.readLine() + "~"; isr.close(); } catch (IOException ioe) { ioe.printStackTrace(); } return strLine.split("~"); } ```
When reading from the console, you need to define a "terminating" input since the console (unlike a file) doesn't ever "end" (it continues to run even after your program terminates). There are several solutions to your problem: 1. Put the input in a file and use IO redirection: `java ... < input-file` The shell will hook up your process with the input file and you will get an EOF. 2. Type the EOF-character for your console. On Linux and Mac, it's `Ctrl+D`, on Windows, it's `Ctrl+Z` + `Enter` 3. Stop when you read an empty line. That way, the user can simply type `Enter`. PS: there is a bug in your code. If you call `readLine()` twice, it will skip every second line.
29,555,006
I'm having a html form where i have 3 fields(ID, NAME, BLOOD GROUP). And below that I've 3 buttons(INSERT, UPDATE, DELETE). And then i want to enter the values in the fields and when click on the INSERT button these values should be entered into a table through a PHP script. Similar respective actions must happen with UPDATE and DELETE also. Can anyone help me out? ``` <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if (!$conn) { die("couldn't connect" . mysql_error()); } echo 'connected successfully'; mysql_select_db('DB'); $id = $_POST['Id']; $name = $_POST['Name']; $blood = $_POST['BloodGroup']; $order = "Insert into info(Id, name, BloodGroup) values ('$Id', '$Name', '$BloodGroup')"; $result = mysql_query($order); if (!$result) { die('Input data failed' . mysql_error()); } echo 'Input data entered successfully'; mysql_close($conn); ```
2015/04/10
[ "https://Stackoverflow.com/questions/29555006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4767213/" ]
Firstly make sure your form is submitting to the PHP script. For this the INSERT button should be of `type="submit"`. Then you can debug your PHP script line by line. For UPDATE and DELETE you can use the same PHP script with the query strings. Ex - `?id=xx&action=update` OR `?id=zz&action=delete`. Then you can apply the code in your PHP script corresponding to the action.
Use `mysql_select_db('DB')` or `die(mysql_error());` once. and also your variable names are wrong. Please Use `$order = "Insert into info(Id, name, BloodGroup) values ('$id', '$name', '$blood')";`
1,898,825
Playing with a pencil and paper notebook I noticed the following: $x=1$ $x^3=1$ --- $x=2$ $x^3=8$ --- $x=3$ $x^3=27$ --- $x=4$ $x^3=64$ --- $64-27 = 37$ $27-8 = 19$ $8-1 = 7$ --- $19-7=12$ $37-19=18$ --- $18-12=6$ --- I noticed a pattern for first 1..10 (in the above example I just compute the first 3 exponents) exponent values, where the difference is always 6 for increasing exponentials. So to compute $x^3$ for $x=5$, instead of $5\times 5\times 5$, use $(18+6)+37+64 = 125$. I doubt I've discovered something new, but is there a name for calculating exponents in this way? Is there a proof that it works for all numbers? There is a similar less complicated pattern for computing $x^2$ values.
2016/08/21
[ "https://math.stackexchange.com/questions/1898825", "https://math.stackexchange.com", "https://math.stackexchange.com/users/29320/" ]
It's not something new, but for your discovery I applaud. This procedure is called the method of successive differences, and you can show that for every power the successive difference appears. Let us say you have a sequence: $$ 1^3 \quad2^3\quad 3^3\quad 4^3\quad \ldots $$ Note that $x^3-(x-1)^3 = 3x^2-3x+1$. So we'll get a new sequence at the bottom: $$ 7 \quad 19\quad 37\quad 61\quad \ldots $$ Now, note that $3x^2-3x+1-(3(x-1)^2-3(x-1)+1) = 6(x-1)$. Hence, we'll get another series: $$ 0 \quad6\quad 12\quad 18\quad\ldots $$ Now, note that $6(x-1)-6((x-1)-1) = 6$! Now, the new sequence is: $$ 6\quad 6\quad 6\quad 6\quad 6\quad ... $$ So $6$ appears as the final difference! This shows the power of algebra. As an exercise, do this for $x^4$. See the pattern of the number at the end, and if you can say something for $x^n$. The reason, as you can see, is that at each line above, the degree of the polynomial $f(x)-f(x-1)$ decreases by $1$. Hence, at the end of three lines, you are only going to get a constant polynomial.
What you have discovered is a [finite difference](https://en.wikipedia.org/wiki/Finite_difference) calculation. For any function $f$, in this case the third-power function $$ f(n) = n^3 $$ we can define the *forward difference*, or *forward discrete derivative*: $$ \Delta f(n) = f(n+1) - f(n) = 3n^2 + 3n + 1 $$ Likewise, \begin{align\*} \Delta \Delta f(n) = \Delta^2 f(n) &= 6n+ 6 \\ \Delta^3 f(n) &= 6 \\ \Delta^4 f(n) &= 0. \end{align\*} Your computation, $$ 5^3 = 64 + 37 + 18 + 6 $$ is the statement $$ f(5) = f(4) + \Delta f(3) + \Delta^2 f(2) + \Delta^3 f(1), $$ or more generally $$ f(n) = f(n-1) + \Delta f(n-2) + \Delta^2 f(n-3) + \Delta^3 f(n-4). $$ This is one discrete analogue of Taylor series (the more common analogue is [Newton's series](https://en.wikipedia.org/wiki/Finite_difference#Newton.27s_series)). The reason it works is that, for $f(n) = n^3$, $\Delta^4$ and beyond are all zero. So the summation stops once we get to $\Delta^3$. --- **EDIT:** Let me add that there is yet another identity here which resembles Taylor series, namely, $$ f(n-1) = f(n) - \Delta f(n) + \Delta^2 f(n) - \Delta^3 f(n). $$ Altogether, at least when $f$ is a polynomial, we thus have the following Taylor series-like formulas: \begin{align\*} f(n-1) &= \sum\_{i = 0}^\infty (-1)^i [\Delta^i f](n) \\ f(n+1) &= \sum\_{i = 0}^\infty [\Delta^i f](n - i) \\ f(n+x) &= \sum\_{i=0}^\infty \binom{x}{i} [\Delta^i f](n). \end{align\*}
1,898,825
Playing with a pencil and paper notebook I noticed the following: $x=1$ $x^3=1$ --- $x=2$ $x^3=8$ --- $x=3$ $x^3=27$ --- $x=4$ $x^3=64$ --- $64-27 = 37$ $27-8 = 19$ $8-1 = 7$ --- $19-7=12$ $37-19=18$ --- $18-12=6$ --- I noticed a pattern for first 1..10 (in the above example I just compute the first 3 exponents) exponent values, where the difference is always 6 for increasing exponentials. So to compute $x^3$ for $x=5$, instead of $5\times 5\times 5$, use $(18+6)+37+64 = 125$. I doubt I've discovered something new, but is there a name for calculating exponents in this way? Is there a proof that it works for all numbers? There is a similar less complicated pattern for computing $x^2$ values.
2016/08/21
[ "https://math.stackexchange.com/questions/1898825", "https://math.stackexchange.com", "https://math.stackexchange.com/users/29320/" ]
It's not something new, but for your discovery I applaud. This procedure is called the method of successive differences, and you can show that for every power the successive difference appears. Let us say you have a sequence: $$ 1^3 \quad2^3\quad 3^3\quad 4^3\quad \ldots $$ Note that $x^3-(x-1)^3 = 3x^2-3x+1$. So we'll get a new sequence at the bottom: $$ 7 \quad 19\quad 37\quad 61\quad \ldots $$ Now, note that $3x^2-3x+1-(3(x-1)^2-3(x-1)+1) = 6(x-1)$. Hence, we'll get another series: $$ 0 \quad6\quad 12\quad 18\quad\ldots $$ Now, note that $6(x-1)-6((x-1)-1) = 6$! Now, the new sequence is: $$ 6\quad 6\quad 6\quad 6\quad 6\quad ... $$ So $6$ appears as the final difference! This shows the power of algebra. As an exercise, do this for $x^4$. See the pattern of the number at the end, and if you can say something for $x^n$. The reason, as you can see, is that at each line above, the degree of the polynomial $f(x)-f(x-1)$ decreases by $1$. Hence, at the end of three lines, you are only going to get a constant polynomial.
For a little bit more, see the answer "[General method for indefinite summation](/a/1353749)" which explains how exactly this representation using forward differences allows you to easily find the formula for indefinite summation of powers. Applied to your case you get: ``` 0, 1, 8, 27 1, 7, 19 6, 12 6 ``` and hence: > > $n^3 = 0 \binom{n}{0} + 1 \binom{n}{1} + 6 \binom{n}{2} + 6 \binom{n}{3}$. > > > which immediately gives: $ \newcommand\lfrac[2]{{\large\frac{#1}{#2}}} $ > > $\sum\_{k=0}^{n-1} k^3 = 0 \binom{n}{1} + 1 \binom{n}{2} + 6 \binom{n}{3} + 6 \binom{n}{4} = n\lfrac{n-1}{2}(1+\lfrac{n-2}{3}(6+\lfrac{n-3}{4}(6)))$ > > > > > $\ = \lfrac{n^2 (n-1)^2}{4}$. > > > and then, if you prefer the indices to end at $n$: > > $\sum\_{k=1}^n k^3 = \lfrac{(n+1)^2 n^2}{4}$. > > > As you can see, hardly any computation was necessary to get this result!
1,898,825
Playing with a pencil and paper notebook I noticed the following: $x=1$ $x^3=1$ --- $x=2$ $x^3=8$ --- $x=3$ $x^3=27$ --- $x=4$ $x^3=64$ --- $64-27 = 37$ $27-8 = 19$ $8-1 = 7$ --- $19-7=12$ $37-19=18$ --- $18-12=6$ --- I noticed a pattern for first 1..10 (in the above example I just compute the first 3 exponents) exponent values, where the difference is always 6 for increasing exponentials. So to compute $x^3$ for $x=5$, instead of $5\times 5\times 5$, use $(18+6)+37+64 = 125$. I doubt I've discovered something new, but is there a name for calculating exponents in this way? Is there a proof that it works for all numbers? There is a similar less complicated pattern for computing $x^2$ values.
2016/08/21
[ "https://math.stackexchange.com/questions/1898825", "https://math.stackexchange.com", "https://math.stackexchange.com/users/29320/" ]
It's not something new, but for your discovery I applaud. This procedure is called the method of successive differences, and you can show that for every power the successive difference appears. Let us say you have a sequence: $$ 1^3 \quad2^3\quad 3^3\quad 4^3\quad \ldots $$ Note that $x^3-(x-1)^3 = 3x^2-3x+1$. So we'll get a new sequence at the bottom: $$ 7 \quad 19\quad 37\quad 61\quad \ldots $$ Now, note that $3x^2-3x+1-(3(x-1)^2-3(x-1)+1) = 6(x-1)$. Hence, we'll get another series: $$ 0 \quad6\quad 12\quad 18\quad\ldots $$ Now, note that $6(x-1)-6((x-1)-1) = 6$! Now, the new sequence is: $$ 6\quad 6\quad 6\quad 6\quad 6\quad ... $$ So $6$ appears as the final difference! This shows the power of algebra. As an exercise, do this for $x^4$. See the pattern of the number at the end, and if you can say something for $x^n$. The reason, as you can see, is that at each line above, the degree of the polynomial $f(x)-f(x-1)$ decreases by $1$. Hence, at the end of three lines, you are only going to get a constant polynomial.
To test your hypothesis you could work out the form of the differences from the first few cases. \begin{align\*} 1^{3}-0^{3}&=1\\ 2^{3}-1^{3}&=7\\ 3^{3}-2^{3}&=19\\ 4^{3}-3^{3}&=37 \end{align\*} For example rewrite out $(37-19)-(19-7)=18-6=6$ as: \begin{align\*} \{(4^{3}-3^{3})-(3^{3}-2^{3})\}&-\{(3^{3}-2^{3})-(2^{3}-1^{3})\}\\ &=(4^{3}-2\cdot3^{3}+2^3)-(3^{3}-2\cdot2^{3}+1^{3})\\ &=4^{3}-3\cdot3^{3}+3\cdot2^3-1^{3}\qquad (\star)\\ &=6 \end{align\*} So you have to find the difference of two differences to get to $6$ (this is called a finite difference pattern, and you have to iterate twice to get the result of $6$ for all such differences, any further iteration ending in a $0$). Now check that pattern $(\star)$ holds in general for some integer $k\ge3$: \begin{align\*} k^{3}&-3\cdot(k-1)^{3}+3\cdot(k-2)^3-(k-3)^{3}\\ &=k^{3}-3(k^2-3k^2+3k-1) +3(k^3-2\cdot3k^2+2^2\cdot3k-2^3) -(k^3-3\cdot3k^2+3^2\cdot3k-3^3)\\ &=\ \ k^3\\ &\ -3k^3\ +\ 9k^2\ -\ 9k\ +\ 3\\ &\ +3k^3-18k^2+36k-24\\ &\ \ -k^3\ +\ \ 9k^2-27k+27\\ &=6 \end{align\*}
1,898,825
Playing with a pencil and paper notebook I noticed the following: $x=1$ $x^3=1$ --- $x=2$ $x^3=8$ --- $x=3$ $x^3=27$ --- $x=4$ $x^3=64$ --- $64-27 = 37$ $27-8 = 19$ $8-1 = 7$ --- $19-7=12$ $37-19=18$ --- $18-12=6$ --- I noticed a pattern for first 1..10 (in the above example I just compute the first 3 exponents) exponent values, where the difference is always 6 for increasing exponentials. So to compute $x^3$ for $x=5$, instead of $5\times 5\times 5$, use $(18+6)+37+64 = 125$. I doubt I've discovered something new, but is there a name for calculating exponents in this way? Is there a proof that it works for all numbers? There is a similar less complicated pattern for computing $x^2$ values.
2016/08/21
[ "https://math.stackexchange.com/questions/1898825", "https://math.stackexchange.com", "https://math.stackexchange.com/users/29320/" ]
What you have discovered is a [finite difference](https://en.wikipedia.org/wiki/Finite_difference) calculation. For any function $f$, in this case the third-power function $$ f(n) = n^3 $$ we can define the *forward difference*, or *forward discrete derivative*: $$ \Delta f(n) = f(n+1) - f(n) = 3n^2 + 3n + 1 $$ Likewise, \begin{align\*} \Delta \Delta f(n) = \Delta^2 f(n) &= 6n+ 6 \\ \Delta^3 f(n) &= 6 \\ \Delta^4 f(n) &= 0. \end{align\*} Your computation, $$ 5^3 = 64 + 37 + 18 + 6 $$ is the statement $$ f(5) = f(4) + \Delta f(3) + \Delta^2 f(2) + \Delta^3 f(1), $$ or more generally $$ f(n) = f(n-1) + \Delta f(n-2) + \Delta^2 f(n-3) + \Delta^3 f(n-4). $$ This is one discrete analogue of Taylor series (the more common analogue is [Newton's series](https://en.wikipedia.org/wiki/Finite_difference#Newton.27s_series)). The reason it works is that, for $f(n) = n^3$, $\Delta^4$ and beyond are all zero. So the summation stops once we get to $\Delta^3$. --- **EDIT:** Let me add that there is yet another identity here which resembles Taylor series, namely, $$ f(n-1) = f(n) - \Delta f(n) + \Delta^2 f(n) - \Delta^3 f(n). $$ Altogether, at least when $f$ is a polynomial, we thus have the following Taylor series-like formulas: \begin{align\*} f(n-1) &= \sum\_{i = 0}^\infty (-1)^i [\Delta^i f](n) \\ f(n+1) &= \sum\_{i = 0}^\infty [\Delta^i f](n - i) \\ f(n+x) &= \sum\_{i=0}^\infty \binom{x}{i} [\Delta^i f](n). \end{align\*}
For a little bit more, see the answer "[General method for indefinite summation](/a/1353749)" which explains how exactly this representation using forward differences allows you to easily find the formula for indefinite summation of powers. Applied to your case you get: ``` 0, 1, 8, 27 1, 7, 19 6, 12 6 ``` and hence: > > $n^3 = 0 \binom{n}{0} + 1 \binom{n}{1} + 6 \binom{n}{2} + 6 \binom{n}{3}$. > > > which immediately gives: $ \newcommand\lfrac[2]{{\large\frac{#1}{#2}}} $ > > $\sum\_{k=0}^{n-1} k^3 = 0 \binom{n}{1} + 1 \binom{n}{2} + 6 \binom{n}{3} + 6 \binom{n}{4} = n\lfrac{n-1}{2}(1+\lfrac{n-2}{3}(6+\lfrac{n-3}{4}(6)))$ > > > > > $\ = \lfrac{n^2 (n-1)^2}{4}$. > > > and then, if you prefer the indices to end at $n$: > > $\sum\_{k=1}^n k^3 = \lfrac{(n+1)^2 n^2}{4}$. > > > As you can see, hardly any computation was necessary to get this result!
1,898,825
Playing with a pencil and paper notebook I noticed the following: $x=1$ $x^3=1$ --- $x=2$ $x^3=8$ --- $x=3$ $x^3=27$ --- $x=4$ $x^3=64$ --- $64-27 = 37$ $27-8 = 19$ $8-1 = 7$ --- $19-7=12$ $37-19=18$ --- $18-12=6$ --- I noticed a pattern for first 1..10 (in the above example I just compute the first 3 exponents) exponent values, where the difference is always 6 for increasing exponentials. So to compute $x^3$ for $x=5$, instead of $5\times 5\times 5$, use $(18+6)+37+64 = 125$. I doubt I've discovered something new, but is there a name for calculating exponents in this way? Is there a proof that it works for all numbers? There is a similar less complicated pattern for computing $x^2$ values.
2016/08/21
[ "https://math.stackexchange.com/questions/1898825", "https://math.stackexchange.com", "https://math.stackexchange.com/users/29320/" ]
What you have discovered is a [finite difference](https://en.wikipedia.org/wiki/Finite_difference) calculation. For any function $f$, in this case the third-power function $$ f(n) = n^3 $$ we can define the *forward difference*, or *forward discrete derivative*: $$ \Delta f(n) = f(n+1) - f(n) = 3n^2 + 3n + 1 $$ Likewise, \begin{align\*} \Delta \Delta f(n) = \Delta^2 f(n) &= 6n+ 6 \\ \Delta^3 f(n) &= 6 \\ \Delta^4 f(n) &= 0. \end{align\*} Your computation, $$ 5^3 = 64 + 37 + 18 + 6 $$ is the statement $$ f(5) = f(4) + \Delta f(3) + \Delta^2 f(2) + \Delta^3 f(1), $$ or more generally $$ f(n) = f(n-1) + \Delta f(n-2) + \Delta^2 f(n-3) + \Delta^3 f(n-4). $$ This is one discrete analogue of Taylor series (the more common analogue is [Newton's series](https://en.wikipedia.org/wiki/Finite_difference#Newton.27s_series)). The reason it works is that, for $f(n) = n^3$, $\Delta^4$ and beyond are all zero. So the summation stops once we get to $\Delta^3$. --- **EDIT:** Let me add that there is yet another identity here which resembles Taylor series, namely, $$ f(n-1) = f(n) - \Delta f(n) + \Delta^2 f(n) - \Delta^3 f(n). $$ Altogether, at least when $f$ is a polynomial, we thus have the following Taylor series-like formulas: \begin{align\*} f(n-1) &= \sum\_{i = 0}^\infty (-1)^i [\Delta^i f](n) \\ f(n+1) &= \sum\_{i = 0}^\infty [\Delta^i f](n - i) \\ f(n+x) &= \sum\_{i=0}^\infty \binom{x}{i} [\Delta^i f](n). \end{align\*}
To test your hypothesis you could work out the form of the differences from the first few cases. \begin{align\*} 1^{3}-0^{3}&=1\\ 2^{3}-1^{3}&=7\\ 3^{3}-2^{3}&=19\\ 4^{3}-3^{3}&=37 \end{align\*} For example rewrite out $(37-19)-(19-7)=18-6=6$ as: \begin{align\*} \{(4^{3}-3^{3})-(3^{3}-2^{3})\}&-\{(3^{3}-2^{3})-(2^{3}-1^{3})\}\\ &=(4^{3}-2\cdot3^{3}+2^3)-(3^{3}-2\cdot2^{3}+1^{3})\\ &=4^{3}-3\cdot3^{3}+3\cdot2^3-1^{3}\qquad (\star)\\ &=6 \end{align\*} So you have to find the difference of two differences to get to $6$ (this is called a finite difference pattern, and you have to iterate twice to get the result of $6$ for all such differences, any further iteration ending in a $0$). Now check that pattern $(\star)$ holds in general for some integer $k\ge3$: \begin{align\*} k^{3}&-3\cdot(k-1)^{3}+3\cdot(k-2)^3-(k-3)^{3}\\ &=k^{3}-3(k^2-3k^2+3k-1) +3(k^3-2\cdot3k^2+2^2\cdot3k-2^3) -(k^3-3\cdot3k^2+3^2\cdot3k-3^3)\\ &=\ \ k^3\\ &\ -3k^3\ +\ 9k^2\ -\ 9k\ +\ 3\\ &\ +3k^3-18k^2+36k-24\\ &\ \ -k^3\ +\ \ 9k^2-27k+27\\ &=6 \end{align\*}
1,898,825
Playing with a pencil and paper notebook I noticed the following: $x=1$ $x^3=1$ --- $x=2$ $x^3=8$ --- $x=3$ $x^3=27$ --- $x=4$ $x^3=64$ --- $64-27 = 37$ $27-8 = 19$ $8-1 = 7$ --- $19-7=12$ $37-19=18$ --- $18-12=6$ --- I noticed a pattern for first 1..10 (in the above example I just compute the first 3 exponents) exponent values, where the difference is always 6 for increasing exponentials. So to compute $x^3$ for $x=5$, instead of $5\times 5\times 5$, use $(18+6)+37+64 = 125$. I doubt I've discovered something new, but is there a name for calculating exponents in this way? Is there a proof that it works for all numbers? There is a similar less complicated pattern for computing $x^2$ values.
2016/08/21
[ "https://math.stackexchange.com/questions/1898825", "https://math.stackexchange.com", "https://math.stackexchange.com/users/29320/" ]
For a little bit more, see the answer "[General method for indefinite summation](/a/1353749)" which explains how exactly this representation using forward differences allows you to easily find the formula for indefinite summation of powers. Applied to your case you get: ``` 0, 1, 8, 27 1, 7, 19 6, 12 6 ``` and hence: > > $n^3 = 0 \binom{n}{0} + 1 \binom{n}{1} + 6 \binom{n}{2} + 6 \binom{n}{3}$. > > > which immediately gives: $ \newcommand\lfrac[2]{{\large\frac{#1}{#2}}} $ > > $\sum\_{k=0}^{n-1} k^3 = 0 \binom{n}{1} + 1 \binom{n}{2} + 6 \binom{n}{3} + 6 \binom{n}{4} = n\lfrac{n-1}{2}(1+\lfrac{n-2}{3}(6+\lfrac{n-3}{4}(6)))$ > > > > > $\ = \lfrac{n^2 (n-1)^2}{4}$. > > > and then, if you prefer the indices to end at $n$: > > $\sum\_{k=1}^n k^3 = \lfrac{(n+1)^2 n^2}{4}$. > > > As you can see, hardly any computation was necessary to get this result!
To test your hypothesis you could work out the form of the differences from the first few cases. \begin{align\*} 1^{3}-0^{3}&=1\\ 2^{3}-1^{3}&=7\\ 3^{3}-2^{3}&=19\\ 4^{3}-3^{3}&=37 \end{align\*} For example rewrite out $(37-19)-(19-7)=18-6=6$ as: \begin{align\*} \{(4^{3}-3^{3})-(3^{3}-2^{3})\}&-\{(3^{3}-2^{3})-(2^{3}-1^{3})\}\\ &=(4^{3}-2\cdot3^{3}+2^3)-(3^{3}-2\cdot2^{3}+1^{3})\\ &=4^{3}-3\cdot3^{3}+3\cdot2^3-1^{3}\qquad (\star)\\ &=6 \end{align\*} So you have to find the difference of two differences to get to $6$ (this is called a finite difference pattern, and you have to iterate twice to get the result of $6$ for all such differences, any further iteration ending in a $0$). Now check that pattern $(\star)$ holds in general for some integer $k\ge3$: \begin{align\*} k^{3}&-3\cdot(k-1)^{3}+3\cdot(k-2)^3-(k-3)^{3}\\ &=k^{3}-3(k^2-3k^2+3k-1) +3(k^3-2\cdot3k^2+2^2\cdot3k-2^3) -(k^3-3\cdot3k^2+3^2\cdot3k-3^3)\\ &=\ \ k^3\\ &\ -3k^3\ +\ 9k^2\ -\ 9k\ +\ 3\\ &\ +3k^3-18k^2+36k-24\\ &\ \ -k^3\ +\ \ 9k^2-27k+27\\ &=6 \end{align\*}
5,125,771
I have development experience in C++, but I know there are some different aspects between C and C++. Now I am going to work on Objective-C. Is there any need to learn the book `C Primer Plus` before starting to write Objective-C code? In addition, I have read the Objective-C programming book by Dave Mark. Now I plan to learn Cocoa on Mac and iOS development.
2011/02/26
[ "https://Stackoverflow.com/questions/5125771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/635317/" ]
It is necessary to set environment variables first. You just need to add the location of the bin class to the directory path.(just add a semicolon and paste the path ). Then after creating a visual c++ console project you have to include needed include directories path to specific location.(If you need more explanation on that just add a comment)
You need to set the environment variables, and then set the projects properties (C++ and Linker) according to your OpenCV version and directories. See my step-bystep guide with instructions and a video: <http://devel-open.blogspot.com.ar/2012/12/opencv-visual-studio-2008.html>
47,045,800
Im looking for a best way to select all rows where at least one of these column ``` job_start, title, visit_hours, name, leave_start and leave_end ``` has a value, and at least one uniq first\_name row must be selected from below table The result should exclude row 1 and 7 [![enter image description here](https://i.stack.imgur.com/ODa1N.png)](https://i.stack.imgur.com/ODa1N.png)
2017/10/31
[ "https://Stackoverflow.com/questions/47045800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1883793/" ]
Before the loop initialize `ary[0]` for example the following way (otherwise uninitialized value of `ary[0]` is used in the program) ``` ary[0] = 1; ``` then substitute these if statements ``` if(ary[x]%2==0) { if(ary[0]<ary[x]) ``` for ``` if( ary[x]%2==0 && ( x == 1 || ary[0]<ary[x] ) ) ``` And at last write ``` if ( ary[0] != 1 ) printf("%d",ary[0]); ``` Take into account that this call ``` fflush(stdin); ``` has undefined behavior and should be removed. In fact there is no need to declare an array. Without the array the program can look like ``` #include <stdio.h> int main( void ) { unsigned int n; int max_even = 1; printf("How many numbers are you going to enter: "); scanf("%u", &n); int x; for (unsigned int i = 0; i < n && scanf( "%d", &x ) == 1; i++) { if ((x % 2) == 0 && (max_even == 1 || max_even < x)) { max_even = x; } } if (max_even != 1) { printf("maximum entered even number is %d\n", max_even); } else { puts("None even number was enetered"); } return 0; } ``` Its output might look like ``` How many numbers are you going to enter: 10 0 1 2 3 4 5 6 7 8 9 maximum entered even number is 8 ```
Your code does not work because `ary[0]` is not yet initialized the first time you compare its value to the value read, furthermore it might not be even for the other comparisons. You should use an indicator telling you whether an even value has been seen. Here is a solution: ``` #include <stdio.h> #include <stdlib.h> int main(void) { int has_even = 0, max_even = 0, value, amount, x; if (scanf("%d", &amount) != 1) return 1; for (x = 0; x < amount; x++) { if (scanf("%d", &value) != 1) break; if (!has_even || value > max) { max_even = value; has_even = 1; } } if (has_even) printf("%d\n", max_even); else printf("no even value\n"); getchar(); return 0; } ```
47,045,800
Im looking for a best way to select all rows where at least one of these column ``` job_start, title, visit_hours, name, leave_start and leave_end ``` has a value, and at least one uniq first\_name row must be selected from below table The result should exclude row 1 and 7 [![enter image description here](https://i.stack.imgur.com/ODa1N.png)](https://i.stack.imgur.com/ODa1N.png)
2017/10/31
[ "https://Stackoverflow.com/questions/47045800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1883793/" ]
Before the loop initialize `ary[0]` for example the following way (otherwise uninitialized value of `ary[0]` is used in the program) ``` ary[0] = 1; ``` then substitute these if statements ``` if(ary[x]%2==0) { if(ary[0]<ary[x]) ``` for ``` if( ary[x]%2==0 && ( x == 1 || ary[0]<ary[x] ) ) ``` And at last write ``` if ( ary[0] != 1 ) printf("%d",ary[0]); ``` Take into account that this call ``` fflush(stdin); ``` has undefined behavior and should be removed. In fact there is no need to declare an array. Without the array the program can look like ``` #include <stdio.h> int main( void ) { unsigned int n; int max_even = 1; printf("How many numbers are you going to enter: "); scanf("%u", &n); int x; for (unsigned int i = 0; i < n && scanf( "%d", &x ) == 1; i++) { if ((x % 2) == 0 && (max_even == 1 || max_even < x)) { max_even = x; } } if (max_even != 1) { printf("maximum entered even number is %d\n", max_even); } else { puts("None even number was enetered"); } return 0; } ``` Its output might look like ``` How many numbers are you going to enter: 10 0 1 2 3 4 5 6 7 8 9 maximum entered even number is 8 ```
``` #include <stdio.h> #include <stdlib.h> int main() { int ary[100]; int ary[0 = 0; int x, y = 0; int amount; scanf("%d", &amount); fflush(stdin); for (x = 1; x <= amount; x++) { scanf("%d", &ary[x]); if (ary[x] % 2 == 0) { if (ary[0] < ary[x]) { ary[0] = ary[x]; } } } printf("%d", ary[0]); getchar(); return 0; ``` }
2,506,536
> > Can anyone help me find all pairs of two digit numbers such that the sum is $83$ > > >
2017/11/05
[ "https://math.stackexchange.com/questions/2506536", "https://math.stackexchange.com", "https://math.stackexchange.com/users/446286/" ]
$(10,\; 73),\; (11,\; 72),\; (12,\; 71),\; (13,\; 70),\; (14,\; 69),\; (15,\; 68),\; (16,\; 67),\; (17,\; 66),\; (18,\; 65),\; (19,\; 64),\; (20,\; 63),\; (21,\; 62),\; (22,\; 61),\; (23,\; 60),\; (24,\; 59),\; (25,\; 58),\; (26,\; 57),\; (27,\; 56),\; (28,\; 55),\; (29,\; 54),\; (30,\; 53),\; (31,\; 52),\; (32,\; 51),\; (33,\; 50),\; (34,\; 49),\; (35,\; 48),\; (36,\; 47),\; (37,\; 46),\; (38,\; 45),\; (39,\; 44),\; (40,\; 43),\; (41,\; 42),\; (42,\; 41),\; (43,\; 40),\; (44,\; 39),\; (45,\; 38),\; (46,\; 37),\; (47,\; 36),\; (48,\; 35),\; (49,\; 34),\; (50,\; 33),\; (51,\; 32),\; (52,\; 31),\; (53,\; 30),\; (54,\; 29),\; (55,\; 28),\; (56,\; 27),\; (57,\; 26),\; (58,\; 25),\; (59,\; 24),\; (60,\; 23),\; (61,\; 22),\; (62,\; 21),\; (63,\; 20),\; (64,\; 19),\; (65,\; 18),\; (66,\; 17),\; (67,\; 16),\; (68,\; 15),\; (69,\; 14),\; (70,\; 13),\; (71,\; 12),\; (72,\; 11),\; (73,\; 10)$ ``` (10, 73), (11, 72), (12, 71), (13, 70), (14, 69), (15, 68), (16, 67), (17, 66), (18, 65), (19, 64), (20, 63), (21, 62), (22, 61), (23, 60), (24, 59), (25, 58), (26, 57), (27, 56), (28, 55), (29, 54), (30, 53), (31, 52), (32, 51), (33, 50), (34, 49), (35, 48), (36, 47), (37, 46), (38, 45), (39, 44), (40, 43), (41, 42), (42, 41), (43, 40), (44, 39), (45, 38), (46, 37), (47, 36), (48, 35), (49, 34), (50, 33), (51, 32), (52, 31), (53, 30), (54, 29), (55, 28), (56, 27), (57, 26), (58, 25), (59, 24), (60, 23), (61, 22), (62, 21), (63, 20), (64, 19), (65, 18), (66, 17), (67, 16), (68, 15), (69, 14), (70, 13), (71, 12), (72, 11), (73, 10) ```
Just ... do them. $a + b = 83$ so $b = 83 - a$ and $a \ge 10$ So $a = 10,11,12,.........,71,72,73$ and $b = 73,72,71,.........,12,11,10$.
2,506,536
> > Can anyone help me find all pairs of two digit numbers such that the sum is $83$ > > >
2017/11/05
[ "https://math.stackexchange.com/questions/2506536", "https://math.stackexchange.com", "https://math.stackexchange.com/users/446286/" ]
Just ... do them. $a + b = 83$ so $b = 83 - a$ and $a \ge 10$ So $a = 10,11,12,.........,71,72,73$ and $b = 73,72,71,.........,12,11,10$.
Im bored $ \\10, 73 \\11, 72 \\12, 71 \\13, 70 \\14, 69 \\15, 68 \\16, 67 \\17, 66 \\18, 65 \\19, 64 \\20, 63 \\21, 63 \\22, 61 \\23, 60 \\24, 59 \\25, 58 \\26, 57 \\27, 56 \\28, 55 \\29, 54 \\30, 53 \\31, 52 \\32, 51 \\33, 50 \\34, 49 \\35, 48 \\36, 47 \\37, 46 \\38, 45 \\39, 44 \\40, 43 \\41, 42 \\ 93, -10 \\ 94, -11 \\ 95, -12 \\96, -13 \\97, -14 \\98, -15 \\99, -16 $
2,506,536
> > Can anyone help me find all pairs of two digit numbers such that the sum is $83$ > > >
2017/11/05
[ "https://math.stackexchange.com/questions/2506536", "https://math.stackexchange.com", "https://math.stackexchange.com/users/446286/" ]
$(10,\; 73),\; (11,\; 72),\; (12,\; 71),\; (13,\; 70),\; (14,\; 69),\; (15,\; 68),\; (16,\; 67),\; (17,\; 66),\; (18,\; 65),\; (19,\; 64),\; (20,\; 63),\; (21,\; 62),\; (22,\; 61),\; (23,\; 60),\; (24,\; 59),\; (25,\; 58),\; (26,\; 57),\; (27,\; 56),\; (28,\; 55),\; (29,\; 54),\; (30,\; 53),\; (31,\; 52),\; (32,\; 51),\; (33,\; 50),\; (34,\; 49),\; (35,\; 48),\; (36,\; 47),\; (37,\; 46),\; (38,\; 45),\; (39,\; 44),\; (40,\; 43),\; (41,\; 42),\; (42,\; 41),\; (43,\; 40),\; (44,\; 39),\; (45,\; 38),\; (46,\; 37),\; (47,\; 36),\; (48,\; 35),\; (49,\; 34),\; (50,\; 33),\; (51,\; 32),\; (52,\; 31),\; (53,\; 30),\; (54,\; 29),\; (55,\; 28),\; (56,\; 27),\; (57,\; 26),\; (58,\; 25),\; (59,\; 24),\; (60,\; 23),\; (61,\; 22),\; (62,\; 21),\; (63,\; 20),\; (64,\; 19),\; (65,\; 18),\; (66,\; 17),\; (67,\; 16),\; (68,\; 15),\; (69,\; 14),\; (70,\; 13),\; (71,\; 12),\; (72,\; 11),\; (73,\; 10)$ ``` (10, 73), (11, 72), (12, 71), (13, 70), (14, 69), (15, 68), (16, 67), (17, 66), (18, 65), (19, 64), (20, 63), (21, 62), (22, 61), (23, 60), (24, 59), (25, 58), (26, 57), (27, 56), (28, 55), (29, 54), (30, 53), (31, 52), (32, 51), (33, 50), (34, 49), (35, 48), (36, 47), (37, 46), (38, 45), (39, 44), (40, 43), (41, 42), (42, 41), (43, 40), (44, 39), (45, 38), (46, 37), (47, 36), (48, 35), (49, 34), (50, 33), (51, 32), (52, 31), (53, 30), (54, 29), (55, 28), (56, 27), (57, 26), (58, 25), (59, 24), (60, 23), (61, 22), (62, 21), (63, 20), (64, 19), (65, 18), (66, 17), (67, 16), (68, 15), (69, 14), (70, 13), (71, 12), (72, 11), (73, 10) ```
Im bored $ \\10, 73 \\11, 72 \\12, 71 \\13, 70 \\14, 69 \\15, 68 \\16, 67 \\17, 66 \\18, 65 \\19, 64 \\20, 63 \\21, 63 \\22, 61 \\23, 60 \\24, 59 \\25, 58 \\26, 57 \\27, 56 \\28, 55 \\29, 54 \\30, 53 \\31, 52 \\32, 51 \\33, 50 \\34, 49 \\35, 48 \\36, 47 \\37, 46 \\38, 45 \\39, 44 \\40, 43 \\41, 42 \\ 93, -10 \\ 94, -11 \\ 95, -12 \\96, -13 \\97, -14 \\98, -15 \\99, -16 $
571,504
This is what I have so far: ``` for f in 'svn ls repository_dir'; do svn checkout repository_dir/$f/trunk/dir1/dir2/dir3/dir4/needed_dir done ``` This works great for the projects (100's of them) that have the needed\_dir in the correct place. But some projects ($f) have their directory structure a little different. So "needed\_dir" might be in a different location. **In the do loop**, how can I tell my bash script to: "Find "needed\_dir". If found, check it out." Or "Find "needed\_file.txt". If found, check it out." Thank you for any help
2013/03/26
[ "https://superuser.com/questions/571504", "https://superuser.com", "https://superuser.com/users/210421/" ]
This will probably be easiest with [find](http://unixhelp.ed.ac.uk/CGI/man-cgi?find). To execute `svn checkout` or every directory named `needed_dir` in the directory tree of `repository_dir/$f/trunk`, use this command: ``` find repository_dir/$f/trunk/ -type d -name needed_dir -exec svn checkout {} \; ``` Find substitutes `{}` with the name of the found directory. The switch `-type d` only finds directories, while `-type f` finds only files.
Sorry I don't have enough reputation to comment, so I have to create a new answer. The `find` command is not going to work here because it can only search a directory on disk. (So it would work only if you first svn checkout the entirety of "repository\_dir".) See [the following link on StackOverflow](https://stackoverflow.com/questions/704901/search-in-svn-repository-for-a-file-name) for a similar question. Something similar to the answer given there is more appropriate: ``` for f in 'svn ls -R repository_dir | grep "needed_dir"'; do svn checkout repository_dir/$f done ``` The -R option to svn makes svn list everything at URL recursively. Grep searches for the directory you need. For what it is worth, you can make this somewhat more terse by using the `xargs` command instead of a for loop. ``` svn list -R <URL> | grep "needed_dir" | xargs --max-args=1 -I'{}' svn co <URL>'{}' ``` Xargs runs "svn co (path-in-url)" for each white-space delimited word discovered by svn list and grep. (The weird -I'{}' is necessary otherwise xargs puts a space between the URL and the subdirectory name.)
56,949,235
I'm trying to run some tasks in the background while running a django server. To do this, I'm using background-tasks library. I've followed the following steps: 1. `pip install django-background-tasks` 2. Added `'background_task'`, in `INSTALLED_APPS` in `settings.py` 3. `python manage.py makemigrations background_task` The problem arises in the 3rd step giving an error stating: > > django.db.utils.ProgrammingError: relation "background\_task" does not > exist LINE 1: INSERT INTO "background\_task" ("task\_name", > "task\_params", "... > > > I've tried looking for other solutions but every one of them was the 3rd line. How should I proceed ?
2019/07/09
[ "https://Stackoverflow.com/questions/56949235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11679327/" ]
I don't know if this is still valid question but what helped me was to revert all changes in code related to `background_task` module and then applying migrations. After that reapply your changes in code and it should all work.
After the 2nd step go to command line and do following : 1. python manage.py showmigrations (check if it works fine) 2. python manage.py migrate (check if the background task file is added to the show migrations list eg: background\_task [X] 0001\_initial [X] 0002\_auto\_20170927\_1109) 3. Now make modifications in your views in which ever way you want to use the backgroundtasks.
41,725,136
I am using `UIDocumentPickerViewController` in Import mode and it shows PDFs on iCloud and Dropbox. However they are all greyed out and I cannot select them. What am I doing wrong?
2017/01/18
[ "https://Stackoverflow.com/questions/41725136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560653/" ]
**First** ``` import MobileCoreServices ``` now you're eable to access new values such as `String(kUTTypePDF)` **Finally**, in your Document View Controller ``` let importMenu = UIDocumentMenuViewController(documentTypes: [String(kUTTypePDF)], in: .import) ``` enjoy
You need to provide the types of documents that the user is allowed to select. ``` let docTypes = [ "com.adobe.pdf" ] let docViewCtlr = UIDocumentMenuViewController(documentTypes: docTypes, in: .import) ```
41,725,136
I am using `UIDocumentPickerViewController` in Import mode and it shows PDFs on iCloud and Dropbox. However they are all greyed out and I cannot select them. What am I doing wrong?
2017/01/18
[ "https://Stackoverflow.com/questions/41725136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560653/" ]
You need to provide the types of documents that the user is allowed to select. ``` let docTypes = [ "com.adobe.pdf" ] let docViewCtlr = UIDocumentMenuViewController(documentTypes: docTypes, in: .import) ```
Try the following ``` @IBAction func PdfBtn(_ sender: Any) { let importMenu = UIDocumentMenuViewController(documentTypes: ["public.composite-content"], in: .import) importMenu.delegate = self present(importMenu, animated: true, completion: nil) } ```
41,725,136
I am using `UIDocumentPickerViewController` in Import mode and it shows PDFs on iCloud and Dropbox. However they are all greyed out and I cannot select them. What am I doing wrong?
2017/01/18
[ "https://Stackoverflow.com/questions/41725136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560653/" ]
You need to provide the types of documents that the user is allowed to select. ``` let docTypes = [ "com.adobe.pdf" ] let docViewCtlr = UIDocumentMenuViewController(documentTypes: docTypes, in: .import) ```
For iOS 14 or later, use [`init(forOpeningContentTypes:)`](https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller/3566732-init) ```swift import UniformTypeIdentifiers let pickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: [ UTType.pdf ]) pickerViewController.delegate = self present(pickerViewController, animated: true, completion: nil) ```
41,725,136
I am using `UIDocumentPickerViewController` in Import mode and it shows PDFs on iCloud and Dropbox. However they are all greyed out and I cannot select them. What am I doing wrong?
2017/01/18
[ "https://Stackoverflow.com/questions/41725136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560653/" ]
**First** ``` import MobileCoreServices ``` now you're eable to access new values such as `String(kUTTypePDF)` **Finally**, in your Document View Controller ``` let importMenu = UIDocumentMenuViewController(documentTypes: [String(kUTTypePDF)], in: .import) ``` enjoy
Try the following ``` @IBAction func PdfBtn(_ sender: Any) { let importMenu = UIDocumentMenuViewController(documentTypes: ["public.composite-content"], in: .import) importMenu.delegate = self present(importMenu, animated: true, completion: nil) } ```
41,725,136
I am using `UIDocumentPickerViewController` in Import mode and it shows PDFs on iCloud and Dropbox. However they are all greyed out and I cannot select them. What am I doing wrong?
2017/01/18
[ "https://Stackoverflow.com/questions/41725136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560653/" ]
**First** ``` import MobileCoreServices ``` now you're eable to access new values such as `String(kUTTypePDF)` **Finally**, in your Document View Controller ``` let importMenu = UIDocumentMenuViewController(documentTypes: [String(kUTTypePDF)], in: .import) ``` enjoy
For iOS 14 or later, use [`init(forOpeningContentTypes:)`](https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller/3566732-init) ```swift import UniformTypeIdentifiers let pickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: [ UTType.pdf ]) pickerViewController.delegate = self present(pickerViewController, animated: true, completion: nil) ```
41,725,136
I am using `UIDocumentPickerViewController` in Import mode and it shows PDFs on iCloud and Dropbox. However they are all greyed out and I cannot select them. What am I doing wrong?
2017/01/18
[ "https://Stackoverflow.com/questions/41725136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560653/" ]
Try the following ``` @IBAction func PdfBtn(_ sender: Any) { let importMenu = UIDocumentMenuViewController(documentTypes: ["public.composite-content"], in: .import) importMenu.delegate = self present(importMenu, animated: true, completion: nil) } ```
For iOS 14 or later, use [`init(forOpeningContentTypes:)`](https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller/3566732-init) ```swift import UniformTypeIdentifiers let pickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: [ UTType.pdf ]) pickerViewController.delegate = self present(pickerViewController, animated: true, completion: nil) ```
57,420,989
I want to execute a select statement against each row of a set returned by a subquery/table. I then want to combine the results and view it as a single set. I have a table tbl1 - ``` city|zip|contractor|budget ========================== LA |010| A | 100 LA |010| A | 200 LA |010| B | 50 LA |010| D | 25 LA |020| A | 400 LA |020| C | 200 LA |020| C | 350 ``` The first statement that I am executing is - ``` select group,city,sum(budget) from tbl1 group by city,zip ``` This results in a table like this (tbl2) - ``` city|zip||budget ========================== LA |010|375 LA |020|950 ``` On this table I then want to run a query to rank the TOP 2 contractors. So I want the following statement to run for every row in tbl2 and then combine(union) the results - ``` select TOP 2 contractor,sum(budget) as budget_sum from tbl1 where city = <city_value_for_row> and zip = <zip_value_for_row> group by contractor order by budget_sum desc ``` My final desired table is this: ``` city|zip|contractor|budget_sum ========================== LA |010| A | 300 LA |010| B | 50 LA |020| C | 550 LA |020| A | 400 ``` ^^The first two lines I will get from executing the select against row 1 on tbl2. The second two lines are a result of the executing select against row 2 from tbl2. In other words I want to be able to rank contractors based on a group of city and zip and I want to do this for every possible combination of city and zip. Is there a set based way to do this? Or would I have to iterate over each row in tbl2, execute select, insert into a temp table and then get the results?
2019/08/08
[ "https://Stackoverflow.com/questions/57420989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6173517/" ]
You can do this: ``` G <- substitute(post == 1) E <- substitute(D$G, list(G = G)) #D$post == 1 ``` That expression looks like what you want, right? Well, it isn't, as you can see when you try to evaluate it: ``` eval(E) #Error in D$post == 1 : invalid subscript type 'language' ``` Let's inspect the expression in more detail: ``` as.list(E) #[[1]] #`$` # #[[2]] #D # #[[3]] #post == 1 ``` OK, we have one function call (to `$`) with two arguments (`D` and `post == 1`). The second argument is an expression whereas `$` expects a name. Let's compare this with how it should look like: ``` as.list(quote(D$post == 1)) #[[1]] #`==` # #[[2]] #D$post # #[[3]] #[1] 1 as.list(quote(D$post == 1)[[2]]) #[[1]] #`$` # #[[2]] #D # #[[3]] #post ``` So, `D$post == 1` is actually a call to two nested functions and get's parsed to this: ``` `==`(`$`(D, post), 1) ``` I hope this clarifies why "[w]orking with substitute after $ sign" is not so simple. Just to show that is still possible, if you understand how the expression is parsed: ``` E <- quote(D$x) E[[3]] <- G[[2]] G[[2]] <- E eval(G) #[1] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE ``` However, such code is really hard to maintain and debug. Don't do this. As @joran shows, you can use functions like `with` that evaluate the expression `post == 1` within the data.frame, which is basically just a wrapper for `eval(G, D, parent.frame())`. However, that's a dangerous and slippery path that can lead to dragons. Let me quote the relevant warning from `help("subset")` here: > > This is a convenience function intended for use interactively. For > programming it is better to use the standard subsetting functions like > [, and in particular the non-standard evaluation of argument subset > can have unanticipated consequences. > > >
Maybe you want something more like this: ``` q <- quote(post == 1) with(D,eval(q)) ```
57,774,876
I have been trying to load array inside fragment but i could not able list the array binded value in dropdown. Initially, i have stored values into empty array and then passed array into json model to list array values into dropdown. Here is the code for storing array values and passed to json model: ``` var value = oEvent.getSource().getParent().getBindingContext().getPath(); var valueind = value.split("/"); this.indexj = valueind[2]; var tabley = this.getView().byId("tablez"); var count = tabley.getItems().length; for (var i = 0; i < count; i++) { this.ops1 = tabley.getItems()[i].getCells()[0].getValue(); this.objy= { "Opeartion": this.ops1, }; console.log("this.objy", this.objy); empOper.push(this.objy); }//For Loop Closed console.log("empOper", empOper); this.objy = sap.ui.core.Fragment.byId("Operationsfragment", "operations"); var seamoModelccd80 = new sap.ui.model.json.JSONModel(); seamoModelccd80.setData({ empOper: empOper }); this.objy.setModel(seamoModelccd80); console.log("this.objy", this.objy); console.log("seamoModelccd80", seamoModelccd80); ``` Here is the code for fragments view: ``` <ComboBox id="operations" value="{path='/empOper'}" editable="true" enabled="true" visible="true" width="auto" valueState="None" change="ChangOpera"> <!--<core:Item text="{Name}"/>--> </ComboBox> ``` Here is the srceenshot which i am trying to achieve: [![enter image description here](https://i.stack.imgur.com/C0xTS.png)](https://i.stack.imgur.com/C0xTS.png) Any help much appreciated pls... According to @Voyager answer: ``` var sValue = ""; for (var i = 0; i < count; i++) { sValue = tabley.getItems()[i].getCells()[0].getValue(); empOper.push({ "Opeartion": sValue }); } var seamoModelccd80 = new sap.ui.model.json.JSONModel(); // created a JSON model seamoModelccd80.setData({ // Set the data to the model using the JSON object defined already empOper: empOper }); var oView = this.getView(); Fragment.load({ name: "fragments.Operationsfragment.Operations", id: oView.getId(), controller: this }).then( function(oComboBox) { oView.addDependent(oComboBox); oComboBox.setModel(seamoModelccd80); } ); <ComboBox id="operations" items="{path: '/empOper', templateShareable: 'false'}"> <items> <core:ListItem key="{Name}" text="{Name}"/> </items> </ComboBox> ``` [![my console log](https://i.stack.imgur.com/sv5rp.png)](https://i.stack.imgur.com/sv5rp.png)
2019/09/03
[ "https://Stackoverflow.com/questions/57774876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8842890/" ]
You have to bind the items aggregation of the combobox properly and give the aggregation a template. Since "items" is not the default aggregation of ComboBox, you have to write the aggregation tag (items) specifically. [Aggregation Binding](https://sapui5.hana.ondemand.com/#/topic/91f057786f4d1014b6dd926db0e91070) ``` <ComboBox id="operations" items="{path: '/empOper', templateShareable: 'false'}"> <items> <core:ListItem key="{key}" text="{Operation}"/> </items> </ComboBox> ``` --- Objects are saved by reference. This means, when you push the object into you array, you are actually just pushing the reference to the same object inside your loop. You have to push new objects every time. Otherwise, you simply have the same objects just in different positions inside you array multiple times. ``` var sValue = ""; for (var i = 0; i < count; i++) { sValue = tabley.getItems()[i].getCells()[0].getValue(); empOper.push({ "key": i, "Operation": sValue }); } ``` --- You have to load the fragment properly. Require the module (sap/ui/core/Fragment) at the top of your file. [Fragment Instantiation](https://sapui5.hana.ondemand.com/#/topic/d6af195124cf430599530668ddea7425) ``` var oView = this.getView(); Fragment.load({ name: "NAMESPACE.PATH.TO.Operationsfragment", id: oView.getId(), controller: this }).then( function(oComboBox) { oView.addDependent(oComboBox); oComboBox.setModel(seamoModelccd80); } ); ``` --- I think/hope this addresses all your issues.
Declare the JSON Model in the manifest without datasource then set data in the controller and bind your ComboBox.
29,765,626
This public class `TestInterviewquestion` has these methods and all parameters are unique. But I get the compile time error *"The method fun(String) is ambiguous for the type TestInterviewquestion class"*. Can someone see the problem? ``` public static void fun(String s) { System.out.println("String"); } public static void fun(Object o) { System.out.println("Object"); } public static void fun(Integer i) { System.out.println("Integer"); } public static void main(String arg[]) { fun(null); } ```
2015/04/21
[ "https://Stackoverflow.com/questions/29765626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4311404/" ]
If the question is why `fun(null)` is ambiguous, the reason is that both `public static void fun(Integer i)` and `public static void fun(String s)` can accept a `null`, but since neither of String and Integer is more specific than the other, the compiler can't choose between the two.
Compilation of this code gives ambiguous call because ``` fun(null) ``` is applicable to all the overloaded method since string,Integer and Object variables can hold null reference and java doesn't know which overloaded method to call .
809,986
I want to access my home machine from internet. Since I don't have a static IP I am trying to use DDNS. For that, I've registered a free domain(alihammad.ddns.net) with Noip.com, it binds my external IP (101.50.xx.x) with the domain name. I've also configured my router DDNS settings Router: TP-Link TL-WR740N Routeer Firmware: DD-WRT v24-sp2 (11/21/10) std ![enter image description here](https://i.stack.imgur.com/6qQpe.png) I am also forwarding two ports, 80 for web and 22 for ssh. ![enter image description here](https://i.stack.imgur.com/kHTB2.png) Now if I ping my domain (alihammad.ddns.net) from LAN, it works. But, if I ping the same domain from another network, it doesn't work. Please guide?
2014/09/10
[ "https://superuser.com/questions/809986", "https://superuser.com", "https://superuser.com/users/252835/" ]
The reason you're seeing failed pings is that DD-WRT blocks anonymous ping requests by default (any competent router should do this as well). It helps to prevent people from "seeing" you on the internet, therefore improving your security a little bit. You'll likely need to open and forward ports, depending on what you're planning on doing.
I hope you found your solution, but for people looking for an answer: When you forward a port on your router, you need to specify the IP of the device which host the service. In your forwarding table you use 192.168.53.1 which is the router IP. So if your Web server is on 192.168.53.10, you should use this address. Also to be sure that the device keeps the same IP address, you should use the MAC/IP binding. In order to know your IP address/ MAC address: Windows: Win + R, execute "cmd" (or "cmd.exe"), and type "ipconfig" press enter. Mac/Linux: launch a terminal, and type "ifconfig" press enter.
44,672
I have seen a couple software implementations of the Advanced Encryption Standard. They are pretty much straight forward, i.e. they are implemented exactly the same way as the AES is described. This makes an implementation of AES very easy to achieve. Nevertheless I was wondering if there are other ways of implementing it? Other algorithms for achieving a faster or more secure implementation? For example, with ECC I know that there are different algorithms for implementing the point multiplication (double-and-add, double-and-add-always, Montgomery Algorithm). So, are there different algorithms for implementing AES?
2017/03/13
[ "https://crypto.stackexchange.com/questions/44672", "https://crypto.stackexchange.com", "https://crypto.stackexchange.com/users/44984/" ]
To my knowledge there are at least 4 ways to implement AES. ### I. lookup tables For simple blocs, lookup tables are fast but they are sensible to timings attacks. Here is an example of lookup table implementation: ``` b0 = T0[ a0 >> 24 ] ^ T1[(a1 >> 16) & 0xff] ^ T2[(a2 >> 8) & 0xff] ^ T3[ a3 & 0xff] ^ rk[4]; b1 = T0[ a1 >> 24 ] ^ T1[(a2 >> 16) & 0xff] ^ T2[(a3 >> 8) & 0xff] ^ T3[ a0 & 0xff] ^ rk[5]; b2 = T0[ a2 >> 24 ] ^ T1[(a3 >> 16) & 0xff] ^ T2[(a0 >> 8) & 0xff] ^ T3[ a1 & 0xff] ^ rk[6]; b3 = T0[ a3 >> 24 ] ^ T1[(a0 >> 16) & 0xff] ^ T2[(a1 >> 8) & 0xff] ^ T3[ a2 & 0xff] ^ rk[7]; ``` ### II. With Inversion in $GF(2)[X]$ One can represent a polynomial of degree 7 in $GF(2)[X]$ by a number in $GF(2^8)$. ([2.1.4 Polynomials over a Field, p. 13, The Design of Rinjdael](http://jda.noekeon.org/JDA_VRI_Rijndael_2002.pdf)) or in other word a byte. By going back to the initial definition, one can implement `subBytes` is such way and have it potentially protected against timing attacks. ### III. Bit sliced Wait! This is slow as hell! In order to gain speed, we can have a look at a bit sliced version. Bit slicing is basically writing an hardware implementation in software, considering that each bit is a different input and operations as gates applied at the same time. In 2007 Matsui and Nakajima propose a bit-sliced implementation of AES-CTR, about 30% faster than the table lookup version. It uses 128 bits vector registers and computes 128 blocs of AES at the same time. The only draw back is that you need 2kB of data to encrypt to benefit from the speed up. But that is still useful in the case of HDD encryption ... Two years later P. Schwabe and E. Käsper implement another version 20% faster and that does not have this 2kB requirement. ### IV. But I need more SPEED ! In 2010, Intel provides a hardware AES instruction. ``` aesenc xmm1, xmm3 % xmm1 - data, xmm3 - key ``` Which leads to: ``` # Encrypt the block. pxor %xmm5, %xmm0 aesenc %xmm6, %xmm0 aesenc %xmm7, %xmm0 aesenc %xmm8, %xmm0 aesenc %xmm9, %xmm0 aesenc %xmm10, %xmm0 aesenc %xmm11, %xmm0 aesenc %xmm12, %xmm0 aesenc %xmm13, %xmm0 aesenc %xmm14, %xmm0 aesenclast %xmm15, %xmm0 ``` [source](https://github.com/kmcallister/aesni-examples/blob/master/encrypt.s) ### V. More readings: [Implementing AES 2000-2010: performance and security challenges by Emilia Käsper](https://www.hyperelliptic.org/SPEED/slides09/kasper-aes_speedcc09_slides.pdf) [How can bit slicing be constant time, when Mix Columns is in the cipher](https://crypto.stackexchange.com/questions/35132/how-can-bit-slicing-be-constant-time-when-mix-columns-is-in-the-cipher)
There are mainly differences if and how lookup tables are used. This is mainly a balancing act between protection against timing attacks, performance and code size: For instance, Bouncy Castle has three engines: * [a "normal" engine](https://www.bouncycastle.org/docs/docs1.5on/org/bouncycastle/crypto/engines/AESEngine.html) that uses a table of 256 entries * [a fast one with an 8K table](https://www.bouncycastle.org/docs/docs1.5on/org/bouncycastle/crypto/engines/AESFastEngine.html) and finally * [one without a table](https://www.bouncycastle.org/docs/docs1.5on/org/bouncycastle/crypto/engines/AESLightEngine.html), which is less susceptible to timing attacks and has a small code size) They are all based on Brian Gladman's implementation of the Rijndael - now hosted on GitHub (<https://github.com/BrianGladman/AES/blob/master/aes.txt>). AES is a subset of that cipher. --- There are of course also implementations for GPU's, coprocessors, processors (Intel's AES-NI), FPGA's etc. etc. etc. but above are the main configuration options for implementing the cipher in software you'll see.
54,642,209
I have a shopify store and i want to add a form on product page the problem is when i want to submit a from using ajax with an external link but i want to stay on the same page it goes to the external link ``` <form method="post" id="fastform"action="http://website.fun/bianca/doc.php" class="form" enctype="multipart/form-data"> <label class="label" style="color: rgb(0, 0, 0);">Nom : </label> <input placeholder="Nom" class="input" width="100%" type="text" name="nom" id="nom"> <label class="label" style="color: rgb(0, 0, 0);">Télephone* : </label> <input placeholder="Telephone" class="input" width="100%" type="text" name="phone" id="phone"> <input placeholder="Adresse" class="input" width="100%" type="text" name="adresse" id="adresse"> <div id="form-messages"></div> <button type="submit" class="button-input btn btn-default" name="btn"style="margin-top: 20px;" id="btn">Commander</button> ``` and this is the js en ajax part ``` <script> $(function () { // Get the form. var form = $('#fastform'); // Get the messages div. var formMessages = $('#form-messages'); // Set up an event listener for the contact form. $(form).submit(function (event) { // Stop the browser from submitting the form. event.preventDefault(); // Serialize the form data. var formData = $(form).serialize(); $.ajax({ type: 'POST', url: $(form).attr('action'), data: formData }.done(function(response) { // Make sure that the formMessages div has the 'success' class. $(formMessages).removeClass('error'); $(formMessages).addClass('success'); // Set the message text. $(formMessages).text("votre commande et bien traiter"); // Clear the form. $('#name').val(''); $('#email').val(''); $('#message').val(''); })).fail(function(data) { // Make sure that the formMessages div has the 'error' class. $(formMessages).removeClass('success'); $(formMessages).addClass('error'); // Set the message text. if (data.responseText !== '') { $(formMessages).text(data.responseText); } else { $(formMessages).text('Oops! il\'ya un problem'); } }); }); ``` i want the page to stay without refreshing and get the results on the same page
2019/02/12
[ "https://Stackoverflow.com/questions/54642209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6501928/" ]
try this, ``` $( "#your_form_id" ).submit(function(event) { event.preventDefault(); $.ajax({ beforeSend: function () { //something to do before ajax call }, complete: function () { //something to do after ajax call }, type:"POST", data:$(this).serialize(), url:"<?php echo $url;?>", success:function(data){ $('#divId').html(data); // id where you want to retrive and show your data } }); }); ``` Please review your action URL again
**Try This** Change the form like this. ``` <form method="post" id="fastform" onsubmit='return submitForm()' action="http://website.fun/bianca/doc.php" class="form" enctype="multipart/form-data"> ``` And change the function like this, ``` function submitForm(){ var formData = $('#fastform').serialize(); $.ajax({ type: 'POST', url: $('#fastform').attr('action'), data: formData }.done(function(response) { // Make sure that the formMessages div has the 'success' class. $(formMessages).removeClass('error'); $(formMessages).addClass('success'); // Set the message text. $(formMessages).text("votre commande et bien traiter"); // Clear the form. $('#name').val(''); $('#email').val(''); $('#message').val(''); })).fail(function(data) { // Make sure that the formMessages div has the 'error' class. $(formMessages).removeClass('success'); $(formMessages).addClass('error'); // Set the message text. if (data.responseText !== '') { $(formMessages).text(data.responseText); } else { $(formMessages).text('Oops! il\'ya un problem'); } }); return false; } ```
54,642,209
I have a shopify store and i want to add a form on product page the problem is when i want to submit a from using ajax with an external link but i want to stay on the same page it goes to the external link ``` <form method="post" id="fastform"action="http://website.fun/bianca/doc.php" class="form" enctype="multipart/form-data"> <label class="label" style="color: rgb(0, 0, 0);">Nom : </label> <input placeholder="Nom" class="input" width="100%" type="text" name="nom" id="nom"> <label class="label" style="color: rgb(0, 0, 0);">Télephone* : </label> <input placeholder="Telephone" class="input" width="100%" type="text" name="phone" id="phone"> <input placeholder="Adresse" class="input" width="100%" type="text" name="adresse" id="adresse"> <div id="form-messages"></div> <button type="submit" class="button-input btn btn-default" name="btn"style="margin-top: 20px;" id="btn">Commander</button> ``` and this is the js en ajax part ``` <script> $(function () { // Get the form. var form = $('#fastform'); // Get the messages div. var formMessages = $('#form-messages'); // Set up an event listener for the contact form. $(form).submit(function (event) { // Stop the browser from submitting the form. event.preventDefault(); // Serialize the form data. var formData = $(form).serialize(); $.ajax({ type: 'POST', url: $(form).attr('action'), data: formData }.done(function(response) { // Make sure that the formMessages div has the 'success' class. $(formMessages).removeClass('error'); $(formMessages).addClass('success'); // Set the message text. $(formMessages).text("votre commande et bien traiter"); // Clear the form. $('#name').val(''); $('#email').val(''); $('#message').val(''); })).fail(function(data) { // Make sure that the formMessages div has the 'error' class. $(formMessages).removeClass('success'); $(formMessages).addClass('error'); // Set the message text. if (data.responseText !== '') { $(formMessages).text(data.responseText); } else { $(formMessages).text('Oops! il\'ya un problem'); } }); }); ``` i want the page to stay without refreshing and get the results on the same page
2019/02/12
[ "https://Stackoverflow.com/questions/54642209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6501928/" ]
try this, ``` $( "#your_form_id" ).submit(function(event) { event.preventDefault(); $.ajax({ beforeSend: function () { //something to do before ajax call }, complete: function () { //something to do after ajax call }, type:"POST", data:$(this).serialize(), url:"<?php echo $url;?>", success:function(data){ $('#divId').html(data); // id where you want to retrive and show your data } }); }); ``` Please review your action URL again
Try this code: ``` $(function (){ $('form').bind('submit', function () { $.ajax({ type: 'post', url: 'libs/send.php', data: new FormData($('form')[0]), cache: false, contentType: false, processData: false, success: function () { alert("Data has been successfully inserted"); } }); return false; }); }); ```
16,418,955
**--> IP address of Android Application end user** I have searched allot over internet about how to capture the **IP ADDRESS** of user who is actually using my ANDROID APPLICATION, but did not get the correct code which will work for me. I am developing this android app on Eclipse. on most of the forums i get this link which is not reachable at all: <http://www.droidnova.com/get-the-ip-address-of-your-device,304.html> Need your support guys. Thanks
2013/05/07
[ "https://Stackoverflow.com/questions/16418955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2301232/" ]
You can try the following code. ``` public String getLocalIpAddress() { try { for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress()) { String ip = Formatter.formatIpAddress(inetAddress.hashCode()); return ip; } } } } catch (SocketException ex) { // } return null; } ``` Don't forget to add the following permission in order to allow your application to open network sockets: ``` <uses-permission android:name="android.permission.INTERNET" /> ```
1. try to open a connection to <http://www.whatismyip.com> and fetch the result. 2. Make a HTTP POST ( or GET) to your app host and check there from which IP is coming the request. 3. use SDK. Edit: based on comment: that is the server side role to get the client IP, not the Android job. Here is a sample how can you do it with PHP: `$_SERVER['REMOTE_ADDR']`
16,418,955
**--> IP address of Android Application end user** I have searched allot over internet about how to capture the **IP ADDRESS** of user who is actually using my ANDROID APPLICATION, but did not get the correct code which will work for me. I am developing this android app on Eclipse. on most of the forums i get this link which is not reachable at all: <http://www.droidnova.com/get-the-ip-address-of-your-device,304.html> Need your support guys. Thanks
2013/05/07
[ "https://Stackoverflow.com/questions/16418955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2301232/" ]
1. try to open a connection to <http://www.whatismyip.com> and fetch the result. 2. Make a HTTP POST ( or GET) to your app host and check there from which IP is coming the request. 3. use SDK. Edit: based on comment: that is the server side role to get the client IP, not the Android job. Here is a sample how can you do it with PHP: `$_SERVER['REMOTE_ADDR']`
Or instead of requesting the IP from the Server, you can tell your phone to send the IP. You can get the IP adress with the following code. ``` public String getLocalIpAddress() { try { for (Enumeration<NetworkInterface> en = NetworkInterface .getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf .getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress()) { return inetAddress.getHostAddress().toString(); } } } } catch (SocketException ex) { Log.e(tag, ex.toString()); } return ""; } ```
16,418,955
**--> IP address of Android Application end user** I have searched allot over internet about how to capture the **IP ADDRESS** of user who is actually using my ANDROID APPLICATION, but did not get the correct code which will work for me. I am developing this android app on Eclipse. on most of the forums i get this link which is not reachable at all: <http://www.droidnova.com/get-the-ip-address-of-your-device,304.html> Need your support guys. Thanks
2013/05/07
[ "https://Stackoverflow.com/questions/16418955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2301232/" ]
You can try the following code. ``` public String getLocalIpAddress() { try { for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress()) { String ip = Formatter.formatIpAddress(inetAddress.hashCode()); return ip; } } } } catch (SocketException ex) { // } return null; } ``` Don't forget to add the following permission in order to allow your application to open network sockets: ``` <uses-permission android:name="android.permission.INTERNET" /> ```
Or instead of requesting the IP from the Server, you can tell your phone to send the IP. You can get the IP adress with the following code. ``` public String getLocalIpAddress() { try { for (Enumeration<NetworkInterface> en = NetworkInterface .getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf .getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress()) { return inetAddress.getHostAddress().toString(); } } } } catch (SocketException ex) { Log.e(tag, ex.toString()); } return ""; } ```
262,753
Today, my PostgreSQL doesn't start anymore on my windows machine... I've tried to start the service in windows services and got the following error: ``` Windows could not start the PostgreSQL Database Server 8.3 service on Local Computer. Error 1053: The service did not respond to the start or control request in a timely fashion. ``` Then I went to the command line to manually start C:/Program Files (x86)/PostgreSQL/8.3/bin/psql.exe, and then I got this error: ``` psql: Could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "???" and accepting TCP/IP connections on port 5432? ``` Edit: I found this in the logs: ``` 2011-04-22 13:13:16 CEST LOG: could not receive data from client: No connection could be made because the target machine actively refused it. 2011-04-22 13:13:16 CEST LOG: unexpected EOF on client connection ```
2011/04/23
[ "https://serverfault.com/questions/262753", "https://serverfault.com", "https://serverfault.com/users/79339/" ]
PostgreSQL is having an error on startup and to find out what it is you will have to start PostgreSQL manually. PostgreSQL does not log its startup failures as often as you would hope and how i find out what is going on is by starting a cmd.exe window under the postgres user and manually starting PostgreSQL. Run this to start a CMD.exe under the postgres user ``` runas /user:postgres cmd.exe ``` Enter in the postgres password. And then in that new CMD window start PostgreSQL ``` "C:/Program Files (x86)/PostgreSQL/8.3/bin/postgres.exe" -D "C:/Program Files (x86)/PostgreSQL/8.3/data" ``` And let us know the output...
That log data is from a running server! Is that the end of the newest log if so it not even seems to create new log files anymore. When postgresql is started it is passed the path to the data folder using the -D option. If you go to the windows services manager you should be able to check that path there. See if that matches with the actual path. If it contains forward slashes instead of backslashes that's normal in this case. If the path is wrong you will have to dive into the registry to correct it as the service manager doesn't give you a method to change it. While you are in the service manager also check the postgres service runs under the postgres user account. Also check the postgres user has all rights on the data folder. Other users shouldn't have rights on the folder. If this doesn't help maybe you better try making a backup of your data folder. Uninstall postgres reinstall the same version. DON'T put back your backup, first check if it is working. Then stop the server put the backup back start the server and keep your fingers crossed.
262,753
Today, my PostgreSQL doesn't start anymore on my windows machine... I've tried to start the service in windows services and got the following error: ``` Windows could not start the PostgreSQL Database Server 8.3 service on Local Computer. Error 1053: The service did not respond to the start or control request in a timely fashion. ``` Then I went to the command line to manually start C:/Program Files (x86)/PostgreSQL/8.3/bin/psql.exe, and then I got this error: ``` psql: Could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "???" and accepting TCP/IP connections on port 5432? ``` Edit: I found this in the logs: ``` 2011-04-22 13:13:16 CEST LOG: could not receive data from client: No connection could be made because the target machine actively refused it. 2011-04-22 13:13:16 CEST LOG: unexpected EOF on client connection ```
2011/04/23
[ "https://serverfault.com/questions/262753", "https://serverfault.com", "https://serverfault.com/users/79339/" ]
That log data is from a running server! Is that the end of the newest log if so it not even seems to create new log files anymore. When postgresql is started it is passed the path to the data folder using the -D option. If you go to the windows services manager you should be able to check that path there. See if that matches with the actual path. If it contains forward slashes instead of backslashes that's normal in this case. If the path is wrong you will have to dive into the registry to correct it as the service manager doesn't give you a method to change it. While you are in the service manager also check the postgres service runs under the postgres user account. Also check the postgres user has all rights on the data folder. Other users shouldn't have rights on the folder. If this doesn't help maybe you better try making a backup of your data folder. Uninstall postgres reinstall the same version. DON'T put back your backup, first check if it is working. Then stop the server put the backup back start the server and keep your fingers crossed.
had similar problem on windows 10. coudln't start postgres service in windows services, so I decided just to reinstall it and it did resolve the issue.