qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
4,069,054
I cannot seem to find an answer for this anywhere. Superuser *root* has a crontab with a couple of jobs that send the resultant output to *root's* mailbox addressed **from** my non-superuser account *foo*. It is my understanding that the owner of the cron job is supposed to be the sender of the resultant cron job output. Account *foo* does not have a crontab, and in-fact I have even tried explicitly removing *foo's* crontab, but still *root* receives *root's* cron job output from user *foo*. When I edit *root's* crontab, I log into the system as *foo*, and then `su -` to *root*. Does this have anything to do with it? When I `ls -alF /var/spool/cron/crontabs` there is no file for user *foo*. Does anyone know why my non-superuser account *foo*, that does not have a crontab file, seems to be sending mail to superuser *root*? It also seems that for some of *root's* cron jobs, that it executes as *root* **and** as *foo* which both send email to *root's* mailbox. Example: From foo Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000027883; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: foo Message-Id: <201010302301.TAA0000027883@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands. From root Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000025999; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: system privileged account Message-Id: <201010302301.TAA0000025999@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands.
2010/11/01
[ "https://Stackoverflow.com/questions/4069054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493585/" ]
Why do you need to make a duplication of the form? Try to find some refactoring that can help you, e.g. create some base form and extract common logic there. Every time you make a duplication kitten dies!
You can just add a new blank form and then select all items on the original aform and paste them onto the new form. This will not copy the code behind though. But that can also be solved with copy paste. This will not cause any renaming conflicts.
4,069,054
I cannot seem to find an answer for this anywhere. Superuser *root* has a crontab with a couple of jobs that send the resultant output to *root's* mailbox addressed **from** my non-superuser account *foo*. It is my understanding that the owner of the cron job is supposed to be the sender of the resultant cron job output. Account *foo* does not have a crontab, and in-fact I have even tried explicitly removing *foo's* crontab, but still *root* receives *root's* cron job output from user *foo*. When I edit *root's* crontab, I log into the system as *foo*, and then `su -` to *root*. Does this have anything to do with it? When I `ls -alF /var/spool/cron/crontabs` there is no file for user *foo*. Does anyone know why my non-superuser account *foo*, that does not have a crontab file, seems to be sending mail to superuser *root*? It also seems that for some of *root's* cron jobs, that it executes as *root* **and** as *foo* which both send email to *root's* mailbox. Example: From foo Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000027883; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: foo Message-Id: <201010302301.TAA0000027883@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands. From root Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000025999; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: system privileged account Message-Id: <201010302301.TAA0000025999@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands.
2010/11/01
[ "https://Stackoverflow.com/questions/4069054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493585/" ]
Copy the form in visual studio solution explorer. Rename it. And **change the class name manually both in .cs and .Designer.cs files**. Do not use VS refactoring feature as it blows away references to the original class.
You can just add a new blank form and then select all items on the original aform and paste them onto the new form. This will not copy the code behind though. But that can also be solved with copy paste. This will not cause any renaming conflicts.
4,069,054
I cannot seem to find an answer for this anywhere. Superuser *root* has a crontab with a couple of jobs that send the resultant output to *root's* mailbox addressed **from** my non-superuser account *foo*. It is my understanding that the owner of the cron job is supposed to be the sender of the resultant cron job output. Account *foo* does not have a crontab, and in-fact I have even tried explicitly removing *foo's* crontab, but still *root* receives *root's* cron job output from user *foo*. When I edit *root's* crontab, I log into the system as *foo*, and then `su -` to *root*. Does this have anything to do with it? When I `ls -alF /var/spool/cron/crontabs` there is no file for user *foo*. Does anyone know why my non-superuser account *foo*, that does not have a crontab file, seems to be sending mail to superuser *root*? It also seems that for some of *root's* cron jobs, that it executes as *root* **and** as *foo* which both send email to *root's* mailbox. Example: From foo Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000027883; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: foo Message-Id: <201010302301.TAA0000027883@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands. From root Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000025999; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: system privileged account Message-Id: <201010302301.TAA0000025999@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands.
2010/11/01
[ "https://Stackoverflow.com/questions/4069054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493585/" ]
To duplicate a form (in the same project): 1. Right click on the source form --> Copy 2. Right click on the destination folder/project --> Paste 3. Right click on the new form --> Rename 4. Change manually the class name in .cs 5. Change manually the constructor name in .cs 6. Change manually the class name in .Designer.cs Enjoy!
You can just add a new blank form and then select all items on the original aform and paste them onto the new form. This will not copy the code behind though. But that can also be solved with copy paste. This will not cause any renaming conflicts.
4,069,054
I cannot seem to find an answer for this anywhere. Superuser *root* has a crontab with a couple of jobs that send the resultant output to *root's* mailbox addressed **from** my non-superuser account *foo*. It is my understanding that the owner of the cron job is supposed to be the sender of the resultant cron job output. Account *foo* does not have a crontab, and in-fact I have even tried explicitly removing *foo's* crontab, but still *root* receives *root's* cron job output from user *foo*. When I edit *root's* crontab, I log into the system as *foo*, and then `su -` to *root*. Does this have anything to do with it? When I `ls -alF /var/spool/cron/crontabs` there is no file for user *foo*. Does anyone know why my non-superuser account *foo*, that does not have a crontab file, seems to be sending mail to superuser *root*? It also seems that for some of *root's* cron jobs, that it executes as *root* **and** as *foo* which both send email to *root's* mailbox. Example: From foo Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000027883; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: foo Message-Id: <201010302301.TAA0000027883@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands. From root Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000025999; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: system privileged account Message-Id: <201010302301.TAA0000025999@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands.
2010/11/01
[ "https://Stackoverflow.com/questions/4069054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493585/" ]
Copy the form in visual studio solution explorer. Rename it. And **change the class name manually both in .cs and .Designer.cs files**. Do not use VS refactoring feature as it blows away references to the original class.
Why do you need to make a duplication of the form? Try to find some refactoring that can help you, e.g. create some base form and extract common logic there. Every time you make a duplication kitten dies!
4,069,054
I cannot seem to find an answer for this anywhere. Superuser *root* has a crontab with a couple of jobs that send the resultant output to *root's* mailbox addressed **from** my non-superuser account *foo*. It is my understanding that the owner of the cron job is supposed to be the sender of the resultant cron job output. Account *foo* does not have a crontab, and in-fact I have even tried explicitly removing *foo's* crontab, but still *root* receives *root's* cron job output from user *foo*. When I edit *root's* crontab, I log into the system as *foo*, and then `su -` to *root*. Does this have anything to do with it? When I `ls -alF /var/spool/cron/crontabs` there is no file for user *foo*. Does anyone know why my non-superuser account *foo*, that does not have a crontab file, seems to be sending mail to superuser *root*? It also seems that for some of *root's* cron jobs, that it executes as *root* **and** as *foo* which both send email to *root's* mailbox. Example: From foo Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000027883; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: foo Message-Id: <201010302301.TAA0000027883@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands. From root Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000025999; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: system privileged account Message-Id: <201010302301.TAA0000025999@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands.
2010/11/01
[ "https://Stackoverflow.com/questions/4069054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493585/" ]
To duplicate a form (in the same project): 1. Right click on the source form --> Copy 2. Right click on the destination folder/project --> Paste 3. Right click on the new form --> Rename 4. Change manually the class name in .cs 5. Change manually the constructor name in .cs 6. Change manually the class name in .Designer.cs Enjoy!
Why do you need to make a duplication of the form? Try to find some refactoring that can help you, e.g. create some base form and extract common logic there. Every time you make a duplication kitten dies!
4,069,054
I cannot seem to find an answer for this anywhere. Superuser *root* has a crontab with a couple of jobs that send the resultant output to *root's* mailbox addressed **from** my non-superuser account *foo*. It is my understanding that the owner of the cron job is supposed to be the sender of the resultant cron job output. Account *foo* does not have a crontab, and in-fact I have even tried explicitly removing *foo's* crontab, but still *root* receives *root's* cron job output from user *foo*. When I edit *root's* crontab, I log into the system as *foo*, and then `su -` to *root*. Does this have anything to do with it? When I `ls -alF /var/spool/cron/crontabs` there is no file for user *foo*. Does anyone know why my non-superuser account *foo*, that does not have a crontab file, seems to be sending mail to superuser *root*? It also seems that for some of *root's* cron jobs, that it executes as *root* **and** as *foo* which both send email to *root's* mailbox. Example: From foo Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000027883; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: foo Message-Id: <201010302301.TAA0000027883@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands. From root Sat Oct 30 19:01:01 2010 Received: by XXXXXX (8.8.8/1.1.22.3/15Jan03-1152AM) id TAA0000025999; Sat, 30 Oct 2010 19:01:01 -0400 (EDT) Date: Sat, 30 Oct 2010 19:01:01 -0400 (EDT) From: system privileged account Message-Id: <201010302301.TAA0000025999@XXXXXX> *redacted* --- Cron: The previous message is the standard output and standard error of one of your cron commands.
2010/11/01
[ "https://Stackoverflow.com/questions/4069054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493585/" ]
Copy the form in visual studio solution explorer. Rename it. And **change the class name manually both in .cs and .Designer.cs files**. Do not use VS refactoring feature as it blows away references to the original class.
To duplicate a form (in the same project): 1. Right click on the source form --> Copy 2. Right click on the destination folder/project --> Paste 3. Right click on the new form --> Rename 4. Change manually the class name in .cs 5. Change manually the constructor name in .cs 6. Change manually the class name in .Designer.cs Enjoy!
9,354,945
I'm trying to to resize my image (from URL) to full screen in my iPhone. However, the size 320x480 which is supposed to be full size is not full screen. ``` -(IBAction)changeFullSize{ urlImage.contentMode = UIViewContentModeScaleAspectFit; urlImage.frame = CGRectMake(0,0,320,480); } ``` I'm using a `UIButton` here, so when the user clicks on the opaque button, it changes to a full sized image. However, there is an empty space between the tab bar at the top and the start of the picture. What is the correct size for full screen? Is there a way for it to automatically resize to full screen without me specifying the width and height? Thanks.
2012/02/20
[ "https://Stackoverflow.com/questions/9354945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1210581/" ]
You could try and get it from `self.view.frame.size` but for the entire screen you can use `[[UIScreen mainScreen] bounds]`. Hope this helps.
If you have status bar then don't forget to reduce its size from the height. And also aspect-fit would keep the image in its correct ratio, then consider filling it. Aspect-fill would keep the image in correct ration + will try to make full screen, no void spaces, chances are some part of image wont be shown. Scale to fill will keep the image full screen, ratio doesn't matter there.
9,354,945
I'm trying to to resize my image (from URL) to full screen in my iPhone. However, the size 320x480 which is supposed to be full size is not full screen. ``` -(IBAction)changeFullSize{ urlImage.contentMode = UIViewContentModeScaleAspectFit; urlImage.frame = CGRectMake(0,0,320,480); } ``` I'm using a `UIButton` here, so when the user clicks on the opaque button, it changes to a full sized image. However, there is an empty space between the tab bar at the top and the start of the picture. What is the correct size for full screen? Is there a way for it to automatically resize to full screen without me specifying the width and height? Thanks.
2012/02/20
[ "https://Stackoverflow.com/questions/9354945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1210581/" ]
you cant just resize your image by changing its frame, since you are using aspect fit, the image will keep its original aspect, depending on your needs a simple way would be to change to UIViewContentModeScaleToFill if scaling to fill does not produce your intended results, you may want to check out trevor's blog post on uiimage categories [here](http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/) once the UIImage categories are added you can just perform ``` [youruiimage resizedImage:CGSizeMake(320, 480) interpolationQuality:kCGInterpolationHigh] ``` using this you can use either UIViewContentModeScaleToFill or UIViewContentModeScaleAspectFit and it should turn out nicely =)
If you have status bar then don't forget to reduce its size from the height. And also aspect-fit would keep the image in its correct ratio, then consider filling it. Aspect-fill would keep the image in correct ration + will try to make full screen, no void spaces, chances are some part of image wont be shown. Scale to fill will keep the image full screen, ratio doesn't matter there.
91,001
I'm an ardent physicalist with a belief in the importance of the partial reduction of theories to physicalism. I have on occasion had discussions with philosophers here who challenge the existence of the natural/supernatural dichotomy, or in some way endorse supernaturalism. My question is directed at those who know something about theology and supernaturalism. Thus, despite ontologically rejecting supernaturalism and magic myself, I'm curious about the metaphysical presuppositions of others that entail belief. EDIT <<< (In response to comments: Naturalism for me is everything conveyed by an athiestic conception of a pluralism of sciences with partial reduction of theory with pragmatic criteria for the distinction of pseudoscience that takes a middle ground between realism and instrumentalism. Supernaturalism is therefore any ontological category outside of this.) <<< **Simply put, for philosophical positions (even of non-Western schools) that accept supernaturalism, does acceptance metaphysically necessitate 'magic' as a category?** My sense is modern theologians accept 'miracles', but reject 'magic' based on my own discussions with those who profess the [Book of Concord](https://en.wikipedia.org/wiki/Book_of_Concord) as a faithful characterization of Christian doctrine. But theology and supernaturalism is much broader than being a confessional Lutheran, so any relevant perspective, including historical philosophy such as the text of [Mauro Allegranza's link](https://en.wikipedia.org/wiki/Renaissance_magic) is of interest.
2022/05/03
[ "https://philosophy.stackexchange.com/questions/91001", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/40730/" ]
The range of supernaturalism is much broader and more general than the religious doctrines contained in the Book of Concord. Taking the definitions from [wikipedia](https://en.wikipedia.org/wiki/Supernatural#Magic) (emphasis J.W.): * The **supernatural** is phenomena or entities that are not subject to the laws of nature. […] The term is attributed to non-physical entities, such as angels, demons, gods, and spirits. It also includes claimed abilities embodied in or provided by such beings, including magic, telekinesis, levitation, precognition, and extrasensory perception. * The philosophy of **naturalism** contends that nothing exists beyond the natural world, and as such approaches supernatural claims with skepticism. * **Magic** or sorcery is the use of rituals, symbols, actions, gestures, or language with the aim of utilizing supernatural forces. Hence Magic presupposes the existence of supernatural entities and forces. From a logical point of view the opposite relation does not hold. Because one may believe in the existence of supernatural entities but assume that we cannot influence them.
There is no such thing as supernatural. Everything that exists is natural. Magic comes in two flavours: * Entertainment magic creates an *illusion* of something impossible. * "Real" magic is nothing but advanced technology that only looks impossible to an uneducated observer.
91,001
I'm an ardent physicalist with a belief in the importance of the partial reduction of theories to physicalism. I have on occasion had discussions with philosophers here who challenge the existence of the natural/supernatural dichotomy, or in some way endorse supernaturalism. My question is directed at those who know something about theology and supernaturalism. Thus, despite ontologically rejecting supernaturalism and magic myself, I'm curious about the metaphysical presuppositions of others that entail belief. EDIT <<< (In response to comments: Naturalism for me is everything conveyed by an athiestic conception of a pluralism of sciences with partial reduction of theory with pragmatic criteria for the distinction of pseudoscience that takes a middle ground between realism and instrumentalism. Supernaturalism is therefore any ontological category outside of this.) <<< **Simply put, for philosophical positions (even of non-Western schools) that accept supernaturalism, does acceptance metaphysically necessitate 'magic' as a category?** My sense is modern theologians accept 'miracles', but reject 'magic' based on my own discussions with those who profess the [Book of Concord](https://en.wikipedia.org/wiki/Book_of_Concord) as a faithful characterization of Christian doctrine. But theology and supernaturalism is much broader than being a confessional Lutheran, so any relevant perspective, including historical philosophy such as the text of [Mauro Allegranza's link](https://en.wikipedia.org/wiki/Renaissance_magic) is of interest.
2022/05/03
[ "https://philosophy.stackexchange.com/questions/91001", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/40730/" ]
The range of supernaturalism is much broader and more general than the religious doctrines contained in the Book of Concord. Taking the definitions from [wikipedia](https://en.wikipedia.org/wiki/Supernatural#Magic) (emphasis J.W.): * The **supernatural** is phenomena or entities that are not subject to the laws of nature. […] The term is attributed to non-physical entities, such as angels, demons, gods, and spirits. It also includes claimed abilities embodied in or provided by such beings, including magic, telekinesis, levitation, precognition, and extrasensory perception. * The philosophy of **naturalism** contends that nothing exists beyond the natural world, and as such approaches supernatural claims with skepticism. * **Magic** or sorcery is the use of rituals, symbols, actions, gestures, or language with the aim of utilizing supernatural forces. Hence Magic presupposes the existence of supernatural entities and forces. From a logical point of view the opposite relation does not hold. Because one may believe in the existence of supernatural entities but assume that we cannot influence them.
There are technical philosophical glosses of the concept of *magic* in modern fantasy writing. The problematique starts at the narrative level: "Is the guiding problem of the story a problem posed by magic? And how much magic is involved in the solution?" Then *magic* is formally read back into "the conditions of magical problems and solutions," so perhaps impredicatively, although then the [two](https://www.stephenrdonaldson.com/) [authors](https://faq.brandonsanderson.com/knowledge-base/what-are-sandersons-laws-of-magic/) who have developed this theory the most (to my knowledge, and separately) do go on to structure the use of magic in their stories in a pretty "rigorous" manner. So the stronger of the two embeds the ontology of magic, in his broadest work, into the matter/energy dichotomy, posing the counterfactual question, "If matter and energy are two species under an even more elementary genus, then what if there was a third term under the same genus?" Voila, presto, abracadabra, here you go: this third term, locally designated *investiture*, plays the narrative role of magic. Aleister Crowley defined magic like so: > > Magick is the Science and Art of causing Change to occur in conformity with Will. ... Every intentional act is a Magical act.... Magick is the Science of understanding oneself and one's conditions. It is the Art of applying that understanding in action. > > > And the narrative role of magic, in general, seems to be to give characters a way to cause highly distinct physical effects using pure free will (emotionally and/or intellectually interpreted). In a related historical vein, then, Hume portrayed the naive theory of promises as magical thinking ["at its finest"](https://plato.stanford.edu/entries/promises/#ProProObl): > > ... promissory obligations aren't just contingent upon acts of the will, like the obligations we might incur by deliberately damaging someone's property, but (at least it seems on first reflection) they are immediately created by acts of the will. When I promise to do something, it seems that *by so doing* I have created the obligation to do it. This feature makes promissory obligations a special puzzle for naturalistic ethical theories that hope to explain moral obligations without recourse to super-natural entities. The idea that we simply manufacture promissory obligations by speaking them, like an incantation, is decidedly mysterious. As Hume acidly remarked in the *Treatise*: > > > > > > > I shall further observe, that, since every new promise imposes a new obligation of morality on the person who promises, and since this new obligation arises from his will; it is one of the most mysterious and incomprehensible operations that can possibly be imagined, and may even be compared to *transubstantiation* or *holy orders*, where a certain form of words, along with a certain intention, changes entirely the nature of an external object, and even of a human creature. (*Treatise*, 3.2.5–14/15–524; emphasis in the original) > > > > > > > > > If, as with Kant, we try to locate free will "proper" in an eternal realm where God possibly exists, we will be hard-pressed to avoid the appearance of talking about magic, then; and what Hume mocked respecting obligations from promises becomes the manifold of all our responsibilities whatsoever instead, i.e. again the pure will. So for all that, narrative will-theoretic magic tropes might represent their content as embedded in what is otherwise a physical/natural world. What do we say to Clarke's "lemma," that sufficiently advanced technology is indistinguishable from magic? If God's nature is Its will (in some way that our mortal nature is not completely simultaneous with our will), then if God does something by magic, this is actually to do it by nature too, as well as supernaturally all at once. A feat worthy of an omnipotent paradox, perhaps.
91,001
I'm an ardent physicalist with a belief in the importance of the partial reduction of theories to physicalism. I have on occasion had discussions with philosophers here who challenge the existence of the natural/supernatural dichotomy, or in some way endorse supernaturalism. My question is directed at those who know something about theology and supernaturalism. Thus, despite ontologically rejecting supernaturalism and magic myself, I'm curious about the metaphysical presuppositions of others that entail belief. EDIT <<< (In response to comments: Naturalism for me is everything conveyed by an athiestic conception of a pluralism of sciences with partial reduction of theory with pragmatic criteria for the distinction of pseudoscience that takes a middle ground between realism and instrumentalism. Supernaturalism is therefore any ontological category outside of this.) <<< **Simply put, for philosophical positions (even of non-Western schools) that accept supernaturalism, does acceptance metaphysically necessitate 'magic' as a category?** My sense is modern theologians accept 'miracles', but reject 'magic' based on my own discussions with those who profess the [Book of Concord](https://en.wikipedia.org/wiki/Book_of_Concord) as a faithful characterization of Christian doctrine. But theology and supernaturalism is much broader than being a confessional Lutheran, so any relevant perspective, including historical philosophy such as the text of [Mauro Allegranza's link](https://en.wikipedia.org/wiki/Renaissance_magic) is of interest.
2022/05/03
[ "https://philosophy.stackexchange.com/questions/91001", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/40730/" ]
The range of supernaturalism is much broader and more general than the religious doctrines contained in the Book of Concord. Taking the definitions from [wikipedia](https://en.wikipedia.org/wiki/Supernatural#Magic) (emphasis J.W.): * The **supernatural** is phenomena or entities that are not subject to the laws of nature. […] The term is attributed to non-physical entities, such as angels, demons, gods, and spirits. It also includes claimed abilities embodied in or provided by such beings, including magic, telekinesis, levitation, precognition, and extrasensory perception. * The philosophy of **naturalism** contends that nothing exists beyond the natural world, and as such approaches supernatural claims with skepticism. * **Magic** or sorcery is the use of rituals, symbols, actions, gestures, or language with the aim of utilizing supernatural forces. Hence Magic presupposes the existence of supernatural entities and forces. From a logical point of view the opposite relation does not hold. Because one may believe in the existence of supernatural entities but assume that we cannot influence them.
As a preamble, I consider it to be poor practice to use the term "supernatural" for the non-physical. "Natural" has a very clear meaning in epistemology -- it describes the items/events/forces which are subject to the tools of methodological naturalism -- IE empiricism and reasoning. Super-naturalism, from an epistemological perspective, are those things which one *cannot* apply reasoning and empiricism to. Use of "supernatural" for the ontologic category "spiritual" or for *any* non-physical thing, which are different but common uses, leads almost immediately into equivocation errors relative to epistemological meanings of natural and supernatural. Note, there are many ontologically supernatural categories which are not epistemologically supernatural. All of Thomist philosophy and metaphysics, for instance, is purely rationalistic -- IE methodologically natural. And vitalism was a specialty within the science of biology at the start of the 20th century. And mathematics, logic, and ethics, do not appear to be physical fields, yet they are very much subject to methodological naturalism. With that preamble, I will try to answer your question. There are two questions at issue. The first has to do with the ontology of our universe. Are there multiple fundamentally different types of things in it, or only one? And further, you are assuming that the existence of matter is beyond question, so the one is assumed to be material. What you are describing as "supernaturalism" would encompass a diverse set of ontologies, ranging from Platonic Idealism, Tegmark/Pythagorean math as source of everything, thru the Mind-centric idealist-leaning Perennial Philosophy, any concept of interactive spiritual dualism, Popper's strongly emergent consciousness, and probably Russellian Monism as well. Your "supernatural" just appears to be the postulate that there are non physical things or planes in our universe. All of the above ontologic views assume that non-material things can be causal on the material -- IE that physics is not causally closed. This interaction, from outside physics, is generally described as "magic" by physicalists. "Magic" is the method by which the ontic supernatural interacts with the physical. Physicalism is committed to the presumption that physics is causally closed, hence magic is impossible. Physics is *not* causally closed, and cannot be for multiple reasons. 1. Physics is underdetermined, hence an outside influence can influence an outcome within that suite of options, entirely consistently with physics 2. Physics, so long as it is an actual science, is by definition incomplete, as well as uncertain, so cannot exclude any phenomenon or outcomes (both ontic "supernatural" and "magic" are consistent with physics, so long as physics is not complete). 3. No space within our universe, nor the universe itself, can ever be isolated from outside influence. Both entanglement and cosmology assume that no physical system can ever be completely isolated from outside influences. 4. There are no absolute "laws" in science, only occasionally violated regularities, so causal closure, applied as a "law" is contrary to science. Some principles of "magic", by which Platonic Forms influence their shadows in this world, or by which the Will to Power creates life events, or how Consciousness and Neurons both are reflections of the Russelian monod, are postulated or assumed in each of these differing ontologies. But most of the details are currently not filled it. Provided these "supernatural" ontologies are not epistemologically supernatural, than the application of methodological naturalism should allow the details to gradually get filled in as to how magic works in that ontology. Or else identify sufficient problems and/or contradictions that could lead to the abandonment of that ontology by most of its holders. Note philosophy over the millenia has been subject to methodological naturalism, and subject areas and sciences have emerged from it to become their own science or academic specialty, as progress is made in characterizing how to evaluate that subject. "Magic" based "supernatural" ontologies are generally committed to this as a future path for their assumed ontology. For an example of training a skill of "magic", IE applying methodological naturalism to refine a magic methodology, look a the methods developed by the CIA to perform remote viewing. Here is an example site that offers this training today: <https://remoteviewingtraining.com/> For an example of a work that presumes the Perennial Philosophy as a starting point for doing science, and intrinsically accepts magic see Beyond Physicalism: Toward Reconciliation of Science and Spirituality <https://www.amazon.com/gp/customer-reviews/RZY1A4EL2JOZ4?ref=pf_vv_at_pdctrvw_srp>. This work treats "magic" as able to potentially operate through all 4 of the exceptions to causal closure of the physical I noted. For one that takes a far more restrictive view of magic, and assumes that it will only act within the indeterminism of physics of the first exception, see Swinburne: Mind, Brain, and Free Will <https://www.amazon.com/gp/customer-reviews/R18J8OJA7QPLKX?ref=pf_vv_at_pdctrvw_srp>. Eccles also limits his magic to the indeterminate parts of physics: How the SELF Controls Its BRAIN [https://www.amazon.com/How-SELF-Controls-Its-BRAIN/dp/3642492266/ref=sr\_1\_1?crid=XBJGKN0G1Q5X&keywords=eccles+how+the+brain&qid=1651905829&sprefix=eccles+how+the+brain%2Caps%2C214&sr=8-1](https://rads.stackoverflow.com/amzn/click/com/3642492266) For an effort to understand how energy conservation could or could not apply to "magic" see this question and answer: 'The Zero Energy Hypothesis and its consequences for particle creation and dualist interactionism' <https://physics.stackexchange.com/q/494408/181964> As to whether one must accept magic if one accepts "supernatural" ontology -- that one need not do so is the position of epiphenomenalism. Epiphenomenalism has a challenge to explain its own coherence, as asserting the truth of epiphenomenalism appears to be intrinsically a refutation of its own premise (assertions are physical, and presumably asserting the reality of consciousness as a non-physical item is a consequence of the reality of consciousness, hence is an examples of consciousness being causal on the physical). Despite the coherence difficulties, there are epiphenomenalists among current active philosophers. Both Chalmers and Jackson are "supernaturalists" relative to consciousness, and anti-magic epiphenomenalists relative to the effect of consciousness on the physical.
91,001
I'm an ardent physicalist with a belief in the importance of the partial reduction of theories to physicalism. I have on occasion had discussions with philosophers here who challenge the existence of the natural/supernatural dichotomy, or in some way endorse supernaturalism. My question is directed at those who know something about theology and supernaturalism. Thus, despite ontologically rejecting supernaturalism and magic myself, I'm curious about the metaphysical presuppositions of others that entail belief. EDIT <<< (In response to comments: Naturalism for me is everything conveyed by an athiestic conception of a pluralism of sciences with partial reduction of theory with pragmatic criteria for the distinction of pseudoscience that takes a middle ground between realism and instrumentalism. Supernaturalism is therefore any ontological category outside of this.) <<< **Simply put, for philosophical positions (even of non-Western schools) that accept supernaturalism, does acceptance metaphysically necessitate 'magic' as a category?** My sense is modern theologians accept 'miracles', but reject 'magic' based on my own discussions with those who profess the [Book of Concord](https://en.wikipedia.org/wiki/Book_of_Concord) as a faithful characterization of Christian doctrine. But theology and supernaturalism is much broader than being a confessional Lutheran, so any relevant perspective, including historical philosophy such as the text of [Mauro Allegranza's link](https://en.wikipedia.org/wiki/Renaissance_magic) is of interest.
2022/05/03
[ "https://philosophy.stackexchange.com/questions/91001", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/40730/" ]
The range of supernaturalism is much broader and more general than the religious doctrines contained in the Book of Concord. Taking the definitions from [wikipedia](https://en.wikipedia.org/wiki/Supernatural#Magic) (emphasis J.W.): * The **supernatural** is phenomena or entities that are not subject to the laws of nature. […] The term is attributed to non-physical entities, such as angels, demons, gods, and spirits. It also includes claimed abilities embodied in or provided by such beings, including magic, telekinesis, levitation, precognition, and extrasensory perception. * The philosophy of **naturalism** contends that nothing exists beyond the natural world, and as such approaches supernatural claims with skepticism. * **Magic** or sorcery is the use of rituals, symbols, actions, gestures, or language with the aim of utilizing supernatural forces. Hence Magic presupposes the existence of supernatural entities and forces. From a logical point of view the opposite relation does not hold. Because one may believe in the existence of supernatural entities but assume that we cannot influence them.
It seems to me that magic is referring to the intervention of someone in the (accepted) laws of a system in order to attain something that otherwise cound not be attained, metaphorically speaking "bending" the laws. On the other hand supernatural refers to something that is happening that is considered outside of the (accepted) laws, either because of ignorance of the (real) laws or because of someone's magic. So magic is from the point of doing something and supernatural from the point of viewing. (It's like energy and information!).
91,001
I'm an ardent physicalist with a belief in the importance of the partial reduction of theories to physicalism. I have on occasion had discussions with philosophers here who challenge the existence of the natural/supernatural dichotomy, or in some way endorse supernaturalism. My question is directed at those who know something about theology and supernaturalism. Thus, despite ontologically rejecting supernaturalism and magic myself, I'm curious about the metaphysical presuppositions of others that entail belief. EDIT <<< (In response to comments: Naturalism for me is everything conveyed by an athiestic conception of a pluralism of sciences with partial reduction of theory with pragmatic criteria for the distinction of pseudoscience that takes a middle ground between realism and instrumentalism. Supernaturalism is therefore any ontological category outside of this.) <<< **Simply put, for philosophical positions (even of non-Western schools) that accept supernaturalism, does acceptance metaphysically necessitate 'magic' as a category?** My sense is modern theologians accept 'miracles', but reject 'magic' based on my own discussions with those who profess the [Book of Concord](https://en.wikipedia.org/wiki/Book_of_Concord) as a faithful characterization of Christian doctrine. But theology and supernaturalism is much broader than being a confessional Lutheran, so any relevant perspective, including historical philosophy such as the text of [Mauro Allegranza's link](https://en.wikipedia.org/wiki/Renaissance_magic) is of interest.
2022/05/03
[ "https://philosophy.stackexchange.com/questions/91001", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/40730/" ]
There are technical philosophical glosses of the concept of *magic* in modern fantasy writing. The problematique starts at the narrative level: "Is the guiding problem of the story a problem posed by magic? And how much magic is involved in the solution?" Then *magic* is formally read back into "the conditions of magical problems and solutions," so perhaps impredicatively, although then the [two](https://www.stephenrdonaldson.com/) [authors](https://faq.brandonsanderson.com/knowledge-base/what-are-sandersons-laws-of-magic/) who have developed this theory the most (to my knowledge, and separately) do go on to structure the use of magic in their stories in a pretty "rigorous" manner. So the stronger of the two embeds the ontology of magic, in his broadest work, into the matter/energy dichotomy, posing the counterfactual question, "If matter and energy are two species under an even more elementary genus, then what if there was a third term under the same genus?" Voila, presto, abracadabra, here you go: this third term, locally designated *investiture*, plays the narrative role of magic. Aleister Crowley defined magic like so: > > Magick is the Science and Art of causing Change to occur in conformity with Will. ... Every intentional act is a Magical act.... Magick is the Science of understanding oneself and one's conditions. It is the Art of applying that understanding in action. > > > And the narrative role of magic, in general, seems to be to give characters a way to cause highly distinct physical effects using pure free will (emotionally and/or intellectually interpreted). In a related historical vein, then, Hume portrayed the naive theory of promises as magical thinking ["at its finest"](https://plato.stanford.edu/entries/promises/#ProProObl): > > ... promissory obligations aren't just contingent upon acts of the will, like the obligations we might incur by deliberately damaging someone's property, but (at least it seems on first reflection) they are immediately created by acts of the will. When I promise to do something, it seems that *by so doing* I have created the obligation to do it. This feature makes promissory obligations a special puzzle for naturalistic ethical theories that hope to explain moral obligations without recourse to super-natural entities. The idea that we simply manufacture promissory obligations by speaking them, like an incantation, is decidedly mysterious. As Hume acidly remarked in the *Treatise*: > > > > > > > I shall further observe, that, since every new promise imposes a new obligation of morality on the person who promises, and since this new obligation arises from his will; it is one of the most mysterious and incomprehensible operations that can possibly be imagined, and may even be compared to *transubstantiation* or *holy orders*, where a certain form of words, along with a certain intention, changes entirely the nature of an external object, and even of a human creature. (*Treatise*, 3.2.5–14/15–524; emphasis in the original) > > > > > > > > > If, as with Kant, we try to locate free will "proper" in an eternal realm where God possibly exists, we will be hard-pressed to avoid the appearance of talking about magic, then; and what Hume mocked respecting obligations from promises becomes the manifold of all our responsibilities whatsoever instead, i.e. again the pure will. So for all that, narrative will-theoretic magic tropes might represent their content as embedded in what is otherwise a physical/natural world. What do we say to Clarke's "lemma," that sufficiently advanced technology is indistinguishable from magic? If God's nature is Its will (in some way that our mortal nature is not completely simultaneous with our will), then if God does something by magic, this is actually to do it by nature too, as well as supernaturally all at once. A feat worthy of an omnipotent paradox, perhaps.
There is no such thing as supernatural. Everything that exists is natural. Magic comes in two flavours: * Entertainment magic creates an *illusion* of something impossible. * "Real" magic is nothing but advanced technology that only looks impossible to an uneducated observer.
91,001
I'm an ardent physicalist with a belief in the importance of the partial reduction of theories to physicalism. I have on occasion had discussions with philosophers here who challenge the existence of the natural/supernatural dichotomy, or in some way endorse supernaturalism. My question is directed at those who know something about theology and supernaturalism. Thus, despite ontologically rejecting supernaturalism and magic myself, I'm curious about the metaphysical presuppositions of others that entail belief. EDIT <<< (In response to comments: Naturalism for me is everything conveyed by an athiestic conception of a pluralism of sciences with partial reduction of theory with pragmatic criteria for the distinction of pseudoscience that takes a middle ground between realism and instrumentalism. Supernaturalism is therefore any ontological category outside of this.) <<< **Simply put, for philosophical positions (even of non-Western schools) that accept supernaturalism, does acceptance metaphysically necessitate 'magic' as a category?** My sense is modern theologians accept 'miracles', but reject 'magic' based on my own discussions with those who profess the [Book of Concord](https://en.wikipedia.org/wiki/Book_of_Concord) as a faithful characterization of Christian doctrine. But theology and supernaturalism is much broader than being a confessional Lutheran, so any relevant perspective, including historical philosophy such as the text of [Mauro Allegranza's link](https://en.wikipedia.org/wiki/Renaissance_magic) is of interest.
2022/05/03
[ "https://philosophy.stackexchange.com/questions/91001", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/40730/" ]
As a preamble, I consider it to be poor practice to use the term "supernatural" for the non-physical. "Natural" has a very clear meaning in epistemology -- it describes the items/events/forces which are subject to the tools of methodological naturalism -- IE empiricism and reasoning. Super-naturalism, from an epistemological perspective, are those things which one *cannot* apply reasoning and empiricism to. Use of "supernatural" for the ontologic category "spiritual" or for *any* non-physical thing, which are different but common uses, leads almost immediately into equivocation errors relative to epistemological meanings of natural and supernatural. Note, there are many ontologically supernatural categories which are not epistemologically supernatural. All of Thomist philosophy and metaphysics, for instance, is purely rationalistic -- IE methodologically natural. And vitalism was a specialty within the science of biology at the start of the 20th century. And mathematics, logic, and ethics, do not appear to be physical fields, yet they are very much subject to methodological naturalism. With that preamble, I will try to answer your question. There are two questions at issue. The first has to do with the ontology of our universe. Are there multiple fundamentally different types of things in it, or only one? And further, you are assuming that the existence of matter is beyond question, so the one is assumed to be material. What you are describing as "supernaturalism" would encompass a diverse set of ontologies, ranging from Platonic Idealism, Tegmark/Pythagorean math as source of everything, thru the Mind-centric idealist-leaning Perennial Philosophy, any concept of interactive spiritual dualism, Popper's strongly emergent consciousness, and probably Russellian Monism as well. Your "supernatural" just appears to be the postulate that there are non physical things or planes in our universe. All of the above ontologic views assume that non-material things can be causal on the material -- IE that physics is not causally closed. This interaction, from outside physics, is generally described as "magic" by physicalists. "Magic" is the method by which the ontic supernatural interacts with the physical. Physicalism is committed to the presumption that physics is causally closed, hence magic is impossible. Physics is *not* causally closed, and cannot be for multiple reasons. 1. Physics is underdetermined, hence an outside influence can influence an outcome within that suite of options, entirely consistently with physics 2. Physics, so long as it is an actual science, is by definition incomplete, as well as uncertain, so cannot exclude any phenomenon or outcomes (both ontic "supernatural" and "magic" are consistent with physics, so long as physics is not complete). 3. No space within our universe, nor the universe itself, can ever be isolated from outside influence. Both entanglement and cosmology assume that no physical system can ever be completely isolated from outside influences. 4. There are no absolute "laws" in science, only occasionally violated regularities, so causal closure, applied as a "law" is contrary to science. Some principles of "magic", by which Platonic Forms influence their shadows in this world, or by which the Will to Power creates life events, or how Consciousness and Neurons both are reflections of the Russelian monod, are postulated or assumed in each of these differing ontologies. But most of the details are currently not filled it. Provided these "supernatural" ontologies are not epistemologically supernatural, than the application of methodological naturalism should allow the details to gradually get filled in as to how magic works in that ontology. Or else identify sufficient problems and/or contradictions that could lead to the abandonment of that ontology by most of its holders. Note philosophy over the millenia has been subject to methodological naturalism, and subject areas and sciences have emerged from it to become their own science or academic specialty, as progress is made in characterizing how to evaluate that subject. "Magic" based "supernatural" ontologies are generally committed to this as a future path for their assumed ontology. For an example of training a skill of "magic", IE applying methodological naturalism to refine a magic methodology, look a the methods developed by the CIA to perform remote viewing. Here is an example site that offers this training today: <https://remoteviewingtraining.com/> For an example of a work that presumes the Perennial Philosophy as a starting point for doing science, and intrinsically accepts magic see Beyond Physicalism: Toward Reconciliation of Science and Spirituality <https://www.amazon.com/gp/customer-reviews/RZY1A4EL2JOZ4?ref=pf_vv_at_pdctrvw_srp>. This work treats "magic" as able to potentially operate through all 4 of the exceptions to causal closure of the physical I noted. For one that takes a far more restrictive view of magic, and assumes that it will only act within the indeterminism of physics of the first exception, see Swinburne: Mind, Brain, and Free Will <https://www.amazon.com/gp/customer-reviews/R18J8OJA7QPLKX?ref=pf_vv_at_pdctrvw_srp>. Eccles also limits his magic to the indeterminate parts of physics: How the SELF Controls Its BRAIN [https://www.amazon.com/How-SELF-Controls-Its-BRAIN/dp/3642492266/ref=sr\_1\_1?crid=XBJGKN0G1Q5X&keywords=eccles+how+the+brain&qid=1651905829&sprefix=eccles+how+the+brain%2Caps%2C214&sr=8-1](https://rads.stackoverflow.com/amzn/click/com/3642492266) For an effort to understand how energy conservation could or could not apply to "magic" see this question and answer: 'The Zero Energy Hypothesis and its consequences for particle creation and dualist interactionism' <https://physics.stackexchange.com/q/494408/181964> As to whether one must accept magic if one accepts "supernatural" ontology -- that one need not do so is the position of epiphenomenalism. Epiphenomenalism has a challenge to explain its own coherence, as asserting the truth of epiphenomenalism appears to be intrinsically a refutation of its own premise (assertions are physical, and presumably asserting the reality of consciousness as a non-physical item is a consequence of the reality of consciousness, hence is an examples of consciousness being causal on the physical). Despite the coherence difficulties, there are epiphenomenalists among current active philosophers. Both Chalmers and Jackson are "supernaturalists" relative to consciousness, and anti-magic epiphenomenalists relative to the effect of consciousness on the physical.
There is no such thing as supernatural. Everything that exists is natural. Magic comes in two flavours: * Entertainment magic creates an *illusion* of something impossible. * "Real" magic is nothing but advanced technology that only looks impossible to an uneducated observer.
91,001
I'm an ardent physicalist with a belief in the importance of the partial reduction of theories to physicalism. I have on occasion had discussions with philosophers here who challenge the existence of the natural/supernatural dichotomy, or in some way endorse supernaturalism. My question is directed at those who know something about theology and supernaturalism. Thus, despite ontologically rejecting supernaturalism and magic myself, I'm curious about the metaphysical presuppositions of others that entail belief. EDIT <<< (In response to comments: Naturalism for me is everything conveyed by an athiestic conception of a pluralism of sciences with partial reduction of theory with pragmatic criteria for the distinction of pseudoscience that takes a middle ground between realism and instrumentalism. Supernaturalism is therefore any ontological category outside of this.) <<< **Simply put, for philosophical positions (even of non-Western schools) that accept supernaturalism, does acceptance metaphysically necessitate 'magic' as a category?** My sense is modern theologians accept 'miracles', but reject 'magic' based on my own discussions with those who profess the [Book of Concord](https://en.wikipedia.org/wiki/Book_of_Concord) as a faithful characterization of Christian doctrine. But theology and supernaturalism is much broader than being a confessional Lutheran, so any relevant perspective, including historical philosophy such as the text of [Mauro Allegranza's link](https://en.wikipedia.org/wiki/Renaissance_magic) is of interest.
2022/05/03
[ "https://philosophy.stackexchange.com/questions/91001", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/40730/" ]
It seems to me that magic is referring to the intervention of someone in the (accepted) laws of a system in order to attain something that otherwise cound not be attained, metaphorically speaking "bending" the laws. On the other hand supernatural refers to something that is happening that is considered outside of the (accepted) laws, either because of ignorance of the (real) laws or because of someone's magic. So magic is from the point of doing something and supernatural from the point of viewing. (It's like energy and information!).
There is no such thing as supernatural. Everything that exists is natural. Magic comes in two flavours: * Entertainment magic creates an *illusion* of something impossible. * "Real" magic is nothing but advanced technology that only looks impossible to an uneducated observer.
91,001
I'm an ardent physicalist with a belief in the importance of the partial reduction of theories to physicalism. I have on occasion had discussions with philosophers here who challenge the existence of the natural/supernatural dichotomy, or in some way endorse supernaturalism. My question is directed at those who know something about theology and supernaturalism. Thus, despite ontologically rejecting supernaturalism and magic myself, I'm curious about the metaphysical presuppositions of others that entail belief. EDIT <<< (In response to comments: Naturalism for me is everything conveyed by an athiestic conception of a pluralism of sciences with partial reduction of theory with pragmatic criteria for the distinction of pseudoscience that takes a middle ground between realism and instrumentalism. Supernaturalism is therefore any ontological category outside of this.) <<< **Simply put, for philosophical positions (even of non-Western schools) that accept supernaturalism, does acceptance metaphysically necessitate 'magic' as a category?** My sense is modern theologians accept 'miracles', but reject 'magic' based on my own discussions with those who profess the [Book of Concord](https://en.wikipedia.org/wiki/Book_of_Concord) as a faithful characterization of Christian doctrine. But theology and supernaturalism is much broader than being a confessional Lutheran, so any relevant perspective, including historical philosophy such as the text of [Mauro Allegranza's link](https://en.wikipedia.org/wiki/Renaissance_magic) is of interest.
2022/05/03
[ "https://philosophy.stackexchange.com/questions/91001", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/40730/" ]
There are technical philosophical glosses of the concept of *magic* in modern fantasy writing. The problematique starts at the narrative level: "Is the guiding problem of the story a problem posed by magic? And how much magic is involved in the solution?" Then *magic* is formally read back into "the conditions of magical problems and solutions," so perhaps impredicatively, although then the [two](https://www.stephenrdonaldson.com/) [authors](https://faq.brandonsanderson.com/knowledge-base/what-are-sandersons-laws-of-magic/) who have developed this theory the most (to my knowledge, and separately) do go on to structure the use of magic in their stories in a pretty "rigorous" manner. So the stronger of the two embeds the ontology of magic, in his broadest work, into the matter/energy dichotomy, posing the counterfactual question, "If matter and energy are two species under an even more elementary genus, then what if there was a third term under the same genus?" Voila, presto, abracadabra, here you go: this third term, locally designated *investiture*, plays the narrative role of magic. Aleister Crowley defined magic like so: > > Magick is the Science and Art of causing Change to occur in conformity with Will. ... Every intentional act is a Magical act.... Magick is the Science of understanding oneself and one's conditions. It is the Art of applying that understanding in action. > > > And the narrative role of magic, in general, seems to be to give characters a way to cause highly distinct physical effects using pure free will (emotionally and/or intellectually interpreted). In a related historical vein, then, Hume portrayed the naive theory of promises as magical thinking ["at its finest"](https://plato.stanford.edu/entries/promises/#ProProObl): > > ... promissory obligations aren't just contingent upon acts of the will, like the obligations we might incur by deliberately damaging someone's property, but (at least it seems on first reflection) they are immediately created by acts of the will. When I promise to do something, it seems that *by so doing* I have created the obligation to do it. This feature makes promissory obligations a special puzzle for naturalistic ethical theories that hope to explain moral obligations without recourse to super-natural entities. The idea that we simply manufacture promissory obligations by speaking them, like an incantation, is decidedly mysterious. As Hume acidly remarked in the *Treatise*: > > > > > > > I shall further observe, that, since every new promise imposes a new obligation of morality on the person who promises, and since this new obligation arises from his will; it is one of the most mysterious and incomprehensible operations that can possibly be imagined, and may even be compared to *transubstantiation* or *holy orders*, where a certain form of words, along with a certain intention, changes entirely the nature of an external object, and even of a human creature. (*Treatise*, 3.2.5–14/15–524; emphasis in the original) > > > > > > > > > If, as with Kant, we try to locate free will "proper" in an eternal realm where God possibly exists, we will be hard-pressed to avoid the appearance of talking about magic, then; and what Hume mocked respecting obligations from promises becomes the manifold of all our responsibilities whatsoever instead, i.e. again the pure will. So for all that, narrative will-theoretic magic tropes might represent their content as embedded in what is otherwise a physical/natural world. What do we say to Clarke's "lemma," that sufficiently advanced technology is indistinguishable from magic? If God's nature is Its will (in some way that our mortal nature is not completely simultaneous with our will), then if God does something by magic, this is actually to do it by nature too, as well as supernaturally all at once. A feat worthy of an omnipotent paradox, perhaps.
As a preamble, I consider it to be poor practice to use the term "supernatural" for the non-physical. "Natural" has a very clear meaning in epistemology -- it describes the items/events/forces which are subject to the tools of methodological naturalism -- IE empiricism and reasoning. Super-naturalism, from an epistemological perspective, are those things which one *cannot* apply reasoning and empiricism to. Use of "supernatural" for the ontologic category "spiritual" or for *any* non-physical thing, which are different but common uses, leads almost immediately into equivocation errors relative to epistemological meanings of natural and supernatural. Note, there are many ontologically supernatural categories which are not epistemologically supernatural. All of Thomist philosophy and metaphysics, for instance, is purely rationalistic -- IE methodologically natural. And vitalism was a specialty within the science of biology at the start of the 20th century. And mathematics, logic, and ethics, do not appear to be physical fields, yet they are very much subject to methodological naturalism. With that preamble, I will try to answer your question. There are two questions at issue. The first has to do with the ontology of our universe. Are there multiple fundamentally different types of things in it, or only one? And further, you are assuming that the existence of matter is beyond question, so the one is assumed to be material. What you are describing as "supernaturalism" would encompass a diverse set of ontologies, ranging from Platonic Idealism, Tegmark/Pythagorean math as source of everything, thru the Mind-centric idealist-leaning Perennial Philosophy, any concept of interactive spiritual dualism, Popper's strongly emergent consciousness, and probably Russellian Monism as well. Your "supernatural" just appears to be the postulate that there are non physical things or planes in our universe. All of the above ontologic views assume that non-material things can be causal on the material -- IE that physics is not causally closed. This interaction, from outside physics, is generally described as "magic" by physicalists. "Magic" is the method by which the ontic supernatural interacts with the physical. Physicalism is committed to the presumption that physics is causally closed, hence magic is impossible. Physics is *not* causally closed, and cannot be for multiple reasons. 1. Physics is underdetermined, hence an outside influence can influence an outcome within that suite of options, entirely consistently with physics 2. Physics, so long as it is an actual science, is by definition incomplete, as well as uncertain, so cannot exclude any phenomenon or outcomes (both ontic "supernatural" and "magic" are consistent with physics, so long as physics is not complete). 3. No space within our universe, nor the universe itself, can ever be isolated from outside influence. Both entanglement and cosmology assume that no physical system can ever be completely isolated from outside influences. 4. There are no absolute "laws" in science, only occasionally violated regularities, so causal closure, applied as a "law" is contrary to science. Some principles of "magic", by which Platonic Forms influence their shadows in this world, or by which the Will to Power creates life events, or how Consciousness and Neurons both are reflections of the Russelian monod, are postulated or assumed in each of these differing ontologies. But most of the details are currently not filled it. Provided these "supernatural" ontologies are not epistemologically supernatural, than the application of methodological naturalism should allow the details to gradually get filled in as to how magic works in that ontology. Or else identify sufficient problems and/or contradictions that could lead to the abandonment of that ontology by most of its holders. Note philosophy over the millenia has been subject to methodological naturalism, and subject areas and sciences have emerged from it to become their own science or academic specialty, as progress is made in characterizing how to evaluate that subject. "Magic" based "supernatural" ontologies are generally committed to this as a future path for their assumed ontology. For an example of training a skill of "magic", IE applying methodological naturalism to refine a magic methodology, look a the methods developed by the CIA to perform remote viewing. Here is an example site that offers this training today: <https://remoteviewingtraining.com/> For an example of a work that presumes the Perennial Philosophy as a starting point for doing science, and intrinsically accepts magic see Beyond Physicalism: Toward Reconciliation of Science and Spirituality <https://www.amazon.com/gp/customer-reviews/RZY1A4EL2JOZ4?ref=pf_vv_at_pdctrvw_srp>. This work treats "magic" as able to potentially operate through all 4 of the exceptions to causal closure of the physical I noted. For one that takes a far more restrictive view of magic, and assumes that it will only act within the indeterminism of physics of the first exception, see Swinburne: Mind, Brain, and Free Will <https://www.amazon.com/gp/customer-reviews/R18J8OJA7QPLKX?ref=pf_vv_at_pdctrvw_srp>. Eccles also limits his magic to the indeterminate parts of physics: How the SELF Controls Its BRAIN [https://www.amazon.com/How-SELF-Controls-Its-BRAIN/dp/3642492266/ref=sr\_1\_1?crid=XBJGKN0G1Q5X&keywords=eccles+how+the+brain&qid=1651905829&sprefix=eccles+how+the+brain%2Caps%2C214&sr=8-1](https://rads.stackoverflow.com/amzn/click/com/3642492266) For an effort to understand how energy conservation could or could not apply to "magic" see this question and answer: 'The Zero Energy Hypothesis and its consequences for particle creation and dualist interactionism' <https://physics.stackexchange.com/q/494408/181964> As to whether one must accept magic if one accepts "supernatural" ontology -- that one need not do so is the position of epiphenomenalism. Epiphenomenalism has a challenge to explain its own coherence, as asserting the truth of epiphenomenalism appears to be intrinsically a refutation of its own premise (assertions are physical, and presumably asserting the reality of consciousness as a non-physical item is a consequence of the reality of consciousness, hence is an examples of consciousness being causal on the physical). Despite the coherence difficulties, there are epiphenomenalists among current active philosophers. Both Chalmers and Jackson are "supernaturalists" relative to consciousness, and anti-magic epiphenomenalists relative to the effect of consciousness on the physical.
91,001
I'm an ardent physicalist with a belief in the importance of the partial reduction of theories to physicalism. I have on occasion had discussions with philosophers here who challenge the existence of the natural/supernatural dichotomy, or in some way endorse supernaturalism. My question is directed at those who know something about theology and supernaturalism. Thus, despite ontologically rejecting supernaturalism and magic myself, I'm curious about the metaphysical presuppositions of others that entail belief. EDIT <<< (In response to comments: Naturalism for me is everything conveyed by an athiestic conception of a pluralism of sciences with partial reduction of theory with pragmatic criteria for the distinction of pseudoscience that takes a middle ground between realism and instrumentalism. Supernaturalism is therefore any ontological category outside of this.) <<< **Simply put, for philosophical positions (even of non-Western schools) that accept supernaturalism, does acceptance metaphysically necessitate 'magic' as a category?** My sense is modern theologians accept 'miracles', but reject 'magic' based on my own discussions with those who profess the [Book of Concord](https://en.wikipedia.org/wiki/Book_of_Concord) as a faithful characterization of Christian doctrine. But theology and supernaturalism is much broader than being a confessional Lutheran, so any relevant perspective, including historical philosophy such as the text of [Mauro Allegranza's link](https://en.wikipedia.org/wiki/Renaissance_magic) is of interest.
2022/05/03
[ "https://philosophy.stackexchange.com/questions/91001", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/40730/" ]
It seems to me that magic is referring to the intervention of someone in the (accepted) laws of a system in order to attain something that otherwise cound not be attained, metaphorically speaking "bending" the laws. On the other hand supernatural refers to something that is happening that is considered outside of the (accepted) laws, either because of ignorance of the (real) laws or because of someone's magic. So magic is from the point of doing something and supernatural from the point of viewing. (It's like energy and information!).
As a preamble, I consider it to be poor practice to use the term "supernatural" for the non-physical. "Natural" has a very clear meaning in epistemology -- it describes the items/events/forces which are subject to the tools of methodological naturalism -- IE empiricism and reasoning. Super-naturalism, from an epistemological perspective, are those things which one *cannot* apply reasoning and empiricism to. Use of "supernatural" for the ontologic category "spiritual" or for *any* non-physical thing, which are different but common uses, leads almost immediately into equivocation errors relative to epistemological meanings of natural and supernatural. Note, there are many ontologically supernatural categories which are not epistemologically supernatural. All of Thomist philosophy and metaphysics, for instance, is purely rationalistic -- IE methodologically natural. And vitalism was a specialty within the science of biology at the start of the 20th century. And mathematics, logic, and ethics, do not appear to be physical fields, yet they are very much subject to methodological naturalism. With that preamble, I will try to answer your question. There are two questions at issue. The first has to do with the ontology of our universe. Are there multiple fundamentally different types of things in it, or only one? And further, you are assuming that the existence of matter is beyond question, so the one is assumed to be material. What you are describing as "supernaturalism" would encompass a diverse set of ontologies, ranging from Platonic Idealism, Tegmark/Pythagorean math as source of everything, thru the Mind-centric idealist-leaning Perennial Philosophy, any concept of interactive spiritual dualism, Popper's strongly emergent consciousness, and probably Russellian Monism as well. Your "supernatural" just appears to be the postulate that there are non physical things or planes in our universe. All of the above ontologic views assume that non-material things can be causal on the material -- IE that physics is not causally closed. This interaction, from outside physics, is generally described as "magic" by physicalists. "Magic" is the method by which the ontic supernatural interacts with the physical. Physicalism is committed to the presumption that physics is causally closed, hence magic is impossible. Physics is *not* causally closed, and cannot be for multiple reasons. 1. Physics is underdetermined, hence an outside influence can influence an outcome within that suite of options, entirely consistently with physics 2. Physics, so long as it is an actual science, is by definition incomplete, as well as uncertain, so cannot exclude any phenomenon or outcomes (both ontic "supernatural" and "magic" are consistent with physics, so long as physics is not complete). 3. No space within our universe, nor the universe itself, can ever be isolated from outside influence. Both entanglement and cosmology assume that no physical system can ever be completely isolated from outside influences. 4. There are no absolute "laws" in science, only occasionally violated regularities, so causal closure, applied as a "law" is contrary to science. Some principles of "magic", by which Platonic Forms influence their shadows in this world, or by which the Will to Power creates life events, or how Consciousness and Neurons both are reflections of the Russelian monod, are postulated or assumed in each of these differing ontologies. But most of the details are currently not filled it. Provided these "supernatural" ontologies are not epistemologically supernatural, than the application of methodological naturalism should allow the details to gradually get filled in as to how magic works in that ontology. Or else identify sufficient problems and/or contradictions that could lead to the abandonment of that ontology by most of its holders. Note philosophy over the millenia has been subject to methodological naturalism, and subject areas and sciences have emerged from it to become their own science or academic specialty, as progress is made in characterizing how to evaluate that subject. "Magic" based "supernatural" ontologies are generally committed to this as a future path for their assumed ontology. For an example of training a skill of "magic", IE applying methodological naturalism to refine a magic methodology, look a the methods developed by the CIA to perform remote viewing. Here is an example site that offers this training today: <https://remoteviewingtraining.com/> For an example of a work that presumes the Perennial Philosophy as a starting point for doing science, and intrinsically accepts magic see Beyond Physicalism: Toward Reconciliation of Science and Spirituality <https://www.amazon.com/gp/customer-reviews/RZY1A4EL2JOZ4?ref=pf_vv_at_pdctrvw_srp>. This work treats "magic" as able to potentially operate through all 4 of the exceptions to causal closure of the physical I noted. For one that takes a far more restrictive view of magic, and assumes that it will only act within the indeterminism of physics of the first exception, see Swinburne: Mind, Brain, and Free Will <https://www.amazon.com/gp/customer-reviews/R18J8OJA7QPLKX?ref=pf_vv_at_pdctrvw_srp>. Eccles also limits his magic to the indeterminate parts of physics: How the SELF Controls Its BRAIN [https://www.amazon.com/How-SELF-Controls-Its-BRAIN/dp/3642492266/ref=sr\_1\_1?crid=XBJGKN0G1Q5X&keywords=eccles+how+the+brain&qid=1651905829&sprefix=eccles+how+the+brain%2Caps%2C214&sr=8-1](https://rads.stackoverflow.com/amzn/click/com/3642492266) For an effort to understand how energy conservation could or could not apply to "magic" see this question and answer: 'The Zero Energy Hypothesis and its consequences for particle creation and dualist interactionism' <https://physics.stackexchange.com/q/494408/181964> As to whether one must accept magic if one accepts "supernatural" ontology -- that one need not do so is the position of epiphenomenalism. Epiphenomenalism has a challenge to explain its own coherence, as asserting the truth of epiphenomenalism appears to be intrinsically a refutation of its own premise (assertions are physical, and presumably asserting the reality of consciousness as a non-physical item is a consequence of the reality of consciousness, hence is an examples of consciousness being causal on the physical). Despite the coherence difficulties, there are epiphenomenalists among current active philosophers. Both Chalmers and Jackson are "supernaturalists" relative to consciousness, and anti-magic epiphenomenalists relative to the effect of consciousness on the physical.
45,968,642
I am wondering how to get the width of a `th` and set all of the `td` under this header to be the same width. Next `th` would be a different width and all of the `td` under this `th` would be that appropriate width, different from the first. Essentially trying to line up my `thead` and `tbody` columns relative to eachother. The structure of my table is: ``` <table id="my_table"> <thead> <tr> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td></td> </tr> </tbody> </table> ``` The CSS is as follows for a scroll able table: ``` #my_table thead, #my_table tbody { display: inline-block; overflow: auto; width: 100%; } #my_table thead{ height: 100px; } #my_table tbody{ height: 300px; } ``` The data that goes into th is dynamic and makes the width of the cell different every time. Using jQuery, I am stuck with this not sure how to iterate through each `th` and assign the width to its corresponding `td`: ``` var table = document.getElementById('#my_table'); table.find('th').each(function() { var header_width = this.width(); $table.width(header_width); }); ``` Although this is not working. I feel as if I am using the `each()` function incorrectly. Any ideas?
2017/08/30
[ "https://Stackoverflow.com/questions/45968642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7163580/" ]
Try this, is ugly and is not efficient but should do what you want to do: ``` var table = document.getElementById('#my_table'); table.find('th').each(function(index) { var header_width = this.width(); table.find('tr').each(function() { $(this).find('td:nth-child('+index+')').width(header_width); }); }); ``` Note: I didn't check the syntax, so it may contain a bug.
1st. sum the `th` length first (by letter length), then update the width by `%` of `th` length, see example below: 2nd. wrap your content with `<div class="scrollable">` and css: ``` .scrollable{ height: 200px; overflow: scroll; } ``` This allowed you to control the height of the `td` without set tbody to inline block which breaks the layout. ```js $(window).resize(function() { var total_len = $('thead tr th').text().length; $('thead tr th').each(function() { pct = $(this).text().length / total_len * 100; $(this).width(pct + '%'); }) }).trigger('resize'); ``` ```css table * { border: 1px solid black; } table { width: 100%; display: table; } table * { border: 1px solid red; text-align: center; } #my_table thead tr { height: 100px; } .scrollable{ height: 200px; overflow: scroll; } ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table id="my_table"> <thead> <tr> <th>111 121312312 21 1211 31123121</th> <th>2222 2 22 22</th> <th>3333 </th> </tr> </thead> <tbody> <tr> <td><div class="scrollable">tests 11 1 1 1 1 1 111 1 1 1 1 1</div></td> <td><div class="scrollable">2 2 2 22 2</div></td> <td><div class="scrollable">I am wondering how to get the width of a th and set all of the td under this header to be the same width. Next th would be a different width and all of the td under this th would be that appropriate width, different from the first. Essentially trying to line up my thead and tbody columns relative to eachother.</div></td> </tr> <tbody> </table> ```
45,968,642
I am wondering how to get the width of a `th` and set all of the `td` under this header to be the same width. Next `th` would be a different width and all of the `td` under this `th` would be that appropriate width, different from the first. Essentially trying to line up my `thead` and `tbody` columns relative to eachother. The structure of my table is: ``` <table id="my_table"> <thead> <tr> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td></td> </tr> </tbody> </table> ``` The CSS is as follows for a scroll able table: ``` #my_table thead, #my_table tbody { display: inline-block; overflow: auto; width: 100%; } #my_table thead{ height: 100px; } #my_table tbody{ height: 300px; } ``` The data that goes into th is dynamic and makes the width of the cell different every time. Using jQuery, I am stuck with this not sure how to iterate through each `th` and assign the width to its corresponding `td`: ``` var table = document.getElementById('#my_table'); table.find('th').each(function() { var header_width = this.width(); $table.width(header_width); }); ``` Although this is not working. I feel as if I am using the `each()` function incorrectly. Any ideas?
2017/08/30
[ "https://Stackoverflow.com/questions/45968642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7163580/" ]
1st. sum the `th` length first (by letter length), then update the width by `%` of `th` length, see example below: 2nd. wrap your content with `<div class="scrollable">` and css: ``` .scrollable{ height: 200px; overflow: scroll; } ``` This allowed you to control the height of the `td` without set tbody to inline block which breaks the layout. ```js $(window).resize(function() { var total_len = $('thead tr th').text().length; $('thead tr th').each(function() { pct = $(this).text().length / total_len * 100; $(this).width(pct + '%'); }) }).trigger('resize'); ``` ```css table * { border: 1px solid black; } table { width: 100%; display: table; } table * { border: 1px solid red; text-align: center; } #my_table thead tr { height: 100px; } .scrollable{ height: 200px; overflow: scroll; } ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table id="my_table"> <thead> <tr> <th>111 121312312 21 1211 31123121</th> <th>2222 2 22 22</th> <th>3333 </th> </tr> </thead> <tbody> <tr> <td><div class="scrollable">tests 11 1 1 1 1 1 111 1 1 1 1 1</div></td> <td><div class="scrollable">2 2 2 22 2</div></td> <td><div class="scrollable">I am wondering how to get the width of a th and set all of the td under this header to be the same width. Next th would be a different width and all of the td under this th would be that appropriate width, different from the first. Essentially trying to line up my thead and tbody columns relative to eachother.</div></td> </tr> <tbody> </table> ```
Just change each th width to a fixed width with css: ```css #my-table th, #my-table tbody td { border-width: 0 1px 0 1px; border-style: solid; border-color: black; } #my-table th:first-child { width: 20%; } #my-table th:nth-child(2) { width: 30%; } #my-table th:nth-child(3) { width: 30%; } ``` ```html <table id="my-table"> <thead> <tr> <th>COLUMN 1 Title</th> <th>COLUMN 2 Title</th> <th>COLUMN 3 Title</th> </tr> </thead> <tbody> <tr> <td>Lorem ipsum</td> <td>Dolor sit ames</td> <td>Random Text</td> </tr> <tr> <td>More random text</td> <td>Lorem ipsum</td> <td>Dolor sit ames</td> </tr> </tbody> </table> ``` P.S. Add max-width instead of width to allow them to expand (as much as possible)
45,968,642
I am wondering how to get the width of a `th` and set all of the `td` under this header to be the same width. Next `th` would be a different width and all of the `td` under this `th` would be that appropriate width, different from the first. Essentially trying to line up my `thead` and `tbody` columns relative to eachother. The structure of my table is: ``` <table id="my_table"> <thead> <tr> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td></td> </tr> </tbody> </table> ``` The CSS is as follows for a scroll able table: ``` #my_table thead, #my_table tbody { display: inline-block; overflow: auto; width: 100%; } #my_table thead{ height: 100px; } #my_table tbody{ height: 300px; } ``` The data that goes into th is dynamic and makes the width of the cell different every time. Using jQuery, I am stuck with this not sure how to iterate through each `th` and assign the width to its corresponding `td`: ``` var table = document.getElementById('#my_table'); table.find('th').each(function() { var header_width = this.width(); $table.width(header_width); }); ``` Although this is not working. I feel as if I am using the `each()` function incorrectly. Any ideas?
2017/08/30
[ "https://Stackoverflow.com/questions/45968642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7163580/" ]
Try this, is ugly and is not efficient but should do what you want to do: ``` var table = document.getElementById('#my_table'); table.find('th').each(function(index) { var header_width = this.width(); table.find('tr').each(function() { $(this).find('td:nth-child('+index+')').width(header_width); }); }); ``` Note: I didn't check the syntax, so it may contain a bug.
Just change each th width to a fixed width with css: ```css #my-table th, #my-table tbody td { border-width: 0 1px 0 1px; border-style: solid; border-color: black; } #my-table th:first-child { width: 20%; } #my-table th:nth-child(2) { width: 30%; } #my-table th:nth-child(3) { width: 30%; } ``` ```html <table id="my-table"> <thead> <tr> <th>COLUMN 1 Title</th> <th>COLUMN 2 Title</th> <th>COLUMN 3 Title</th> </tr> </thead> <tbody> <tr> <td>Lorem ipsum</td> <td>Dolor sit ames</td> <td>Random Text</td> </tr> <tr> <td>More random text</td> <td>Lorem ipsum</td> <td>Dolor sit ames</td> </tr> </tbody> </table> ``` P.S. Add max-width instead of width to allow them to expand (as much as possible)
143,675
My Windows 7 setup uses around 16GB while Windows XP only needs around 4GB hard disk space. Seems weird. I use Windows only for gaming so I don't need a lot of stuff they have to offer. What is the best way to reduce the size of Windows 7? What can I delete / uninstall and how? I'd also like to reduce the CPU and memory usage as much as possible (as long as it doesnt hurt game performance) - turning off all that fancy stuff and so on. What can I turn off and how?
2010/05/21
[ "https://superuser.com/questions/143675", "https://superuser.com", "https://superuser.com/users/25345/" ]
You can [turn off Aero](http://www.howtogeek.com/howto/windows-vista/disable-aero-on-windows-vista/) by selecting one of the basic themes. This will reduce the load on your graphics card as Aero uses DirectX, which should improve performance while in Windows. It won't affect gaming performance as that uses full screen mode which bypasses Windows. To reduce the disk space Windows takes up look at removing some components. On XP this was "Control Panel > Add/Remove Windows Components" - I don't have Windows 7 on this machine to double check if it's in the same place. As to what you could remove, I couldn't say. You'll know what you do and don't use. Also, I've just checked in XP and there's not a lot you can remove and those items such as the games won't take up that much space.
One idea would be to create a slipstream install cd for windows 7. This involves removing all the stuff you dont want installed and adding additional files (like drivers) Simply google slipstream windows 7 installation and there are so many sites who can help you with this
143,675
My Windows 7 setup uses around 16GB while Windows XP only needs around 4GB hard disk space. Seems weird. I use Windows only for gaming so I don't need a lot of stuff they have to offer. What is the best way to reduce the size of Windows 7? What can I delete / uninstall and how? I'd also like to reduce the CPU and memory usage as much as possible (as long as it doesnt hurt game performance) - turning off all that fancy stuff and so on. What can I turn off and how?
2010/05/21
[ "https://superuser.com/questions/143675", "https://superuser.com", "https://superuser.com/users/25345/" ]
You can [turn off Aero](http://www.howtogeek.com/howto/windows-vista/disable-aero-on-windows-vista/) by selecting one of the basic themes. This will reduce the load on your graphics card as Aero uses DirectX, which should improve performance while in Windows. It won't affect gaming performance as that uses full screen mode which bypasses Windows. To reduce the disk space Windows takes up look at removing some components. On XP this was "Control Panel > Add/Remove Windows Components" - I don't have Windows 7 on this machine to double check if it's in the same place. As to what you could remove, I couldn't say. You'll know what you do and don't use. Also, I've just checked in XP and there's not a lot you can remove and those items such as the games won't take up that much space.
1. Use [Disk Cleanup](http://en.wikipedia.org/wiki/Disk_Cleanup) frequently to clean out temporary things. 2. See where data is being spent with [WinDirStat](http://windirstat.info/) and look if you can clean something. 3. Remove programs and windows components you don't need from the Control Panel. 4. [Resource Monitor](http://edge.technet.com/Media/Windows-7-Screencast-Resource-Monitor-resmon/) is great for checking out what things are happening when your PC is idle, see it as an improved version of Task Manager that is meant for power users instead of system admins. 5. If you want to know more about a folder, you can Google for it, back-up if you don't know...
143,675
My Windows 7 setup uses around 16GB while Windows XP only needs around 4GB hard disk space. Seems weird. I use Windows only for gaming so I don't need a lot of stuff they have to offer. What is the best way to reduce the size of Windows 7? What can I delete / uninstall and how? I'd also like to reduce the CPU and memory usage as much as possible (as long as it doesnt hurt game performance) - turning off all that fancy stuff and so on. What can I turn off and how?
2010/05/21
[ "https://superuser.com/questions/143675", "https://superuser.com", "https://superuser.com/users/25345/" ]
4GB XP? 16GB Win7? That seems an awful lot. My vanilla win7 install on VirtualBox was around 5GB, and you can certainly get XP down to 700MB or so. Use a visualisation tool such as [WinDirStat](http://windirstat.info/) to find out what's taking up all that disc. Stuff to target, if you don't need it and you really know what you're doing: * unused Windows components (Control Panel -> Add/Remove -> Windows components, or in Vista+, All Control Panel -> Programs and Features -> Turn Windows features on or off) * System Restore * \Windows\System32\dllcache on XP * \Windows\System32\DriverStore\FileRepository on Vista+, if you're sure you're not going to need any more drivers out of it * \Windows\SoftwareDistribution\Download * %TEMP%, the IE cache, the trash * patch rollbacks (hidden $ folders in \Windows on XP) * example shared media and \Windows\Web * disable virtual memory to get rid of the pagefile (assuming you have enough memory to run swapless) * disable hibernation to get read of hiberfil * delete the large Chinese/Japanese/Korean fonts, if you don't use them * all vendor crapware (if an OEM install) must be destroyed as a matter of course For some of these on Win7 you have to take ownership of the files back from SYSTEM before you can delete them.
You can [turn off Aero](http://www.howtogeek.com/howto/windows-vista/disable-aero-on-windows-vista/) by selecting one of the basic themes. This will reduce the load on your graphics card as Aero uses DirectX, which should improve performance while in Windows. It won't affect gaming performance as that uses full screen mode which bypasses Windows. To reduce the disk space Windows takes up look at removing some components. On XP this was "Control Panel > Add/Remove Windows Components" - I don't have Windows 7 on this machine to double check if it's in the same place. As to what you could remove, I couldn't say. You'll know what you do and don't use. Also, I've just checked in XP and there's not a lot you can remove and those items such as the games won't take up that much space.
143,675
My Windows 7 setup uses around 16GB while Windows XP only needs around 4GB hard disk space. Seems weird. I use Windows only for gaming so I don't need a lot of stuff they have to offer. What is the best way to reduce the size of Windows 7? What can I delete / uninstall and how? I'd also like to reduce the CPU and memory usage as much as possible (as long as it doesnt hurt game performance) - turning off all that fancy stuff and so on. What can I turn off and how?
2010/05/21
[ "https://superuser.com/questions/143675", "https://superuser.com", "https://superuser.com/users/25345/" ]
You can [turn off Aero](http://www.howtogeek.com/howto/windows-vista/disable-aero-on-windows-vista/) by selecting one of the basic themes. This will reduce the load on your graphics card as Aero uses DirectX, which should improve performance while in Windows. It won't affect gaming performance as that uses full screen mode which bypasses Windows. To reduce the disk space Windows takes up look at removing some components. On XP this was "Control Panel > Add/Remove Windows Components" - I don't have Windows 7 on this machine to double check if it's in the same place. As to what you could remove, I couldn't say. You'll know what you do and don't use. Also, I've just checked in XP and there's not a lot you can remove and those items such as the games won't take up that much space.
Windows Vista/7 doesn't provide explicit way to disable hibernation. (I don't know why) You can make this with following steps : * Open command prompt with administrator privilege. * Type this : powercfg -h off If c:\hiberfil.sys file disappear, it has worked.
143,675
My Windows 7 setup uses around 16GB while Windows XP only needs around 4GB hard disk space. Seems weird. I use Windows only for gaming so I don't need a lot of stuff they have to offer. What is the best way to reduce the size of Windows 7? What can I delete / uninstall and how? I'd also like to reduce the CPU and memory usage as much as possible (as long as it doesnt hurt game performance) - turning off all that fancy stuff and so on. What can I turn off and how?
2010/05/21
[ "https://superuser.com/questions/143675", "https://superuser.com", "https://superuser.com/users/25345/" ]
4GB XP? 16GB Win7? That seems an awful lot. My vanilla win7 install on VirtualBox was around 5GB, and you can certainly get XP down to 700MB or so. Use a visualisation tool such as [WinDirStat](http://windirstat.info/) to find out what's taking up all that disc. Stuff to target, if you don't need it and you really know what you're doing: * unused Windows components (Control Panel -> Add/Remove -> Windows components, or in Vista+, All Control Panel -> Programs and Features -> Turn Windows features on or off) * System Restore * \Windows\System32\dllcache on XP * \Windows\System32\DriverStore\FileRepository on Vista+, if you're sure you're not going to need any more drivers out of it * \Windows\SoftwareDistribution\Download * %TEMP%, the IE cache, the trash * patch rollbacks (hidden $ folders in \Windows on XP) * example shared media and \Windows\Web * disable virtual memory to get rid of the pagefile (assuming you have enough memory to run swapless) * disable hibernation to get read of hiberfil * delete the large Chinese/Japanese/Korean fonts, if you don't use them * all vendor crapware (if an OEM install) must be destroyed as a matter of course For some of these on Win7 you have to take ownership of the files back from SYSTEM before you can delete them.
One idea would be to create a slipstream install cd for windows 7. This involves removing all the stuff you dont want installed and adding additional files (like drivers) Simply google slipstream windows 7 installation and there are so many sites who can help you with this
143,675
My Windows 7 setup uses around 16GB while Windows XP only needs around 4GB hard disk space. Seems weird. I use Windows only for gaming so I don't need a lot of stuff they have to offer. What is the best way to reduce the size of Windows 7? What can I delete / uninstall and how? I'd also like to reduce the CPU and memory usage as much as possible (as long as it doesnt hurt game performance) - turning off all that fancy stuff and so on. What can I turn off and how?
2010/05/21
[ "https://superuser.com/questions/143675", "https://superuser.com", "https://superuser.com/users/25345/" ]
Windows Vista/7 doesn't provide explicit way to disable hibernation. (I don't know why) You can make this with following steps : * Open command prompt with administrator privilege. * Type this : powercfg -h off If c:\hiberfil.sys file disappear, it has worked.
One idea would be to create a slipstream install cd for windows 7. This involves removing all the stuff you dont want installed and adding additional files (like drivers) Simply google slipstream windows 7 installation and there are so many sites who can help you with this
143,675
My Windows 7 setup uses around 16GB while Windows XP only needs around 4GB hard disk space. Seems weird. I use Windows only for gaming so I don't need a lot of stuff they have to offer. What is the best way to reduce the size of Windows 7? What can I delete / uninstall and how? I'd also like to reduce the CPU and memory usage as much as possible (as long as it doesnt hurt game performance) - turning off all that fancy stuff and so on. What can I turn off and how?
2010/05/21
[ "https://superuser.com/questions/143675", "https://superuser.com", "https://superuser.com/users/25345/" ]
4GB XP? 16GB Win7? That seems an awful lot. My vanilla win7 install on VirtualBox was around 5GB, and you can certainly get XP down to 700MB or so. Use a visualisation tool such as [WinDirStat](http://windirstat.info/) to find out what's taking up all that disc. Stuff to target, if you don't need it and you really know what you're doing: * unused Windows components (Control Panel -> Add/Remove -> Windows components, or in Vista+, All Control Panel -> Programs and Features -> Turn Windows features on or off) * System Restore * \Windows\System32\dllcache on XP * \Windows\System32\DriverStore\FileRepository on Vista+, if you're sure you're not going to need any more drivers out of it * \Windows\SoftwareDistribution\Download * %TEMP%, the IE cache, the trash * patch rollbacks (hidden $ folders in \Windows on XP) * example shared media and \Windows\Web * disable virtual memory to get rid of the pagefile (assuming you have enough memory to run swapless) * disable hibernation to get read of hiberfil * delete the large Chinese/Japanese/Korean fonts, if you don't use them * all vendor crapware (if an OEM install) must be destroyed as a matter of course For some of these on Win7 you have to take ownership of the files back from SYSTEM before you can delete them.
1. Use [Disk Cleanup](http://en.wikipedia.org/wiki/Disk_Cleanup) frequently to clean out temporary things. 2. See where data is being spent with [WinDirStat](http://windirstat.info/) and look if you can clean something. 3. Remove programs and windows components you don't need from the Control Panel. 4. [Resource Monitor](http://edge.technet.com/Media/Windows-7-Screencast-Resource-Monitor-resmon/) is great for checking out what things are happening when your PC is idle, see it as an improved version of Task Manager that is meant for power users instead of system admins. 5. If you want to know more about a folder, you can Google for it, back-up if you don't know...
143,675
My Windows 7 setup uses around 16GB while Windows XP only needs around 4GB hard disk space. Seems weird. I use Windows only for gaming so I don't need a lot of stuff they have to offer. What is the best way to reduce the size of Windows 7? What can I delete / uninstall and how? I'd also like to reduce the CPU and memory usage as much as possible (as long as it doesnt hurt game performance) - turning off all that fancy stuff and so on. What can I turn off and how?
2010/05/21
[ "https://superuser.com/questions/143675", "https://superuser.com", "https://superuser.com/users/25345/" ]
Windows Vista/7 doesn't provide explicit way to disable hibernation. (I don't know why) You can make this with following steps : * Open command prompt with administrator privilege. * Type this : powercfg -h off If c:\hiberfil.sys file disappear, it has worked.
1. Use [Disk Cleanup](http://en.wikipedia.org/wiki/Disk_Cleanup) frequently to clean out temporary things. 2. See where data is being spent with [WinDirStat](http://windirstat.info/) and look if you can clean something. 3. Remove programs and windows components you don't need from the Control Panel. 4. [Resource Monitor](http://edge.technet.com/Media/Windows-7-Screencast-Resource-Monitor-resmon/) is great for checking out what things are happening when your PC is idle, see it as an improved version of Task Manager that is meant for power users instead of system admins. 5. If you want to know more about a folder, you can Google for it, back-up if you don't know...
143,675
My Windows 7 setup uses around 16GB while Windows XP only needs around 4GB hard disk space. Seems weird. I use Windows only for gaming so I don't need a lot of stuff they have to offer. What is the best way to reduce the size of Windows 7? What can I delete / uninstall and how? I'd also like to reduce the CPU and memory usage as much as possible (as long as it doesnt hurt game performance) - turning off all that fancy stuff and so on. What can I turn off and how?
2010/05/21
[ "https://superuser.com/questions/143675", "https://superuser.com", "https://superuser.com/users/25345/" ]
4GB XP? 16GB Win7? That seems an awful lot. My vanilla win7 install on VirtualBox was around 5GB, and you can certainly get XP down to 700MB or so. Use a visualisation tool such as [WinDirStat](http://windirstat.info/) to find out what's taking up all that disc. Stuff to target, if you don't need it and you really know what you're doing: * unused Windows components (Control Panel -> Add/Remove -> Windows components, or in Vista+, All Control Panel -> Programs and Features -> Turn Windows features on or off) * System Restore * \Windows\System32\dllcache on XP * \Windows\System32\DriverStore\FileRepository on Vista+, if you're sure you're not going to need any more drivers out of it * \Windows\SoftwareDistribution\Download * %TEMP%, the IE cache, the trash * patch rollbacks (hidden $ folders in \Windows on XP) * example shared media and \Windows\Web * disable virtual memory to get rid of the pagefile (assuming you have enough memory to run swapless) * disable hibernation to get read of hiberfil * delete the large Chinese/Japanese/Korean fonts, if you don't use them * all vendor crapware (if an OEM install) must be destroyed as a matter of course For some of these on Win7 you have to take ownership of the files back from SYSTEM before you can delete them.
Windows Vista/7 doesn't provide explicit way to disable hibernation. (I don't know why) You can make this with following steps : * Open command prompt with administrator privilege. * Type this : powercfg -h off If c:\hiberfil.sys file disappear, it has worked.
55,652,352
I have a problem. The concept of Object Oriented Programming in C got homework. I need to use variadic functions. But I get a mistake. I'd appreciate it if you could help me. I'm new to encoding. RastgeleKarakter.h : ``` #ifndef RASTGELEKARAKTER_H #define RASTGELEKARAKTER_H struct RASTGELEKARAKTER{ // code }; RastgeleKarakter SKarakterOlustur(int...); // prototype void Print(const RastgeleKarakter); #endif ``` RastgeleKarakter.c : ``` #include "RastgeleKarakter.h" #include "stdarg.h RastgeleKarakter SKarakterOlustur(int... characters){ //code } ``` Error : ``` make gcc -I ./include/ -o ./lib/test.o -c ./src/Test.c In file included from ./src/Test.c:3:0: ./include/RastgeleKarakter.h:17:38: error: expected ';', ',' or ')' before '...' token RastgeleKarakter SKarakterOlustur(int...); ``` I don't know how many parameters there are. I want to solve this with the variable function.
2019/04/12
[ "https://Stackoverflow.com/questions/55652352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9409166/" ]
So my solution was to simply check if the user was already authenticated in my `[HttpGet]` login controller as opposed to my `[HttpPost]` login controller. ``` [HttpGet] public ActionResult Login() { if (User.Identity.IsAuthenticated) return RedirectToAction("Index", "Dashboard"); return View(); } [HttpPost] public async Task<IActionResult> Login(LoginViewModel req) { return View(req); } ```
Implement Authentication. And make Dashboard default controller. Magic will happen, out of the box. In Startup.cs ``` public void ConfigureServices(IServiceCollection services) { ... services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie("user_by_cookie", options => { options.LoginPath = "/Login/Index/"; }) ... } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { ... app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Dashboard}/{action=Index}/{id?}"); }); ... } ``` Login Controller ``` [Authorize(AuthenticationSchemes = "user_by_cookie")] public class LoginController : Controller { [HttpGet] [AllowAnonymous] public IActionResult Index() { return View(); } [HttpPost] [AllowAnonymous] public IActionResult Index() { ... //authenticate(); ... return View(); } [HttpGet] public IActionResult Logout() { .. // logout(); -> .. return RedirectToAction("Index"); } } ``` in Dashboard Controller ``` [Authorize(AuthenticationSchemes = "user_by_cookie")] public class DashboardController : Controller { [HttpGet] public IActionResult Index() { return View(); } } ```
15,289,765
I'm searching an userpicker that looks like Gmail, that when you add a "To" address, it becomes a label, or like StackOverflow when you add tags I've found this plugin: <http://htmlpreview.github.com/?https://github.com/ErikNoren/entitypicker/blob/master/entitypickerdemo.html> but I would like to find more plugins to compare... In my case, In my case, I need to convert two values (mail and phone) in one label...How can I do it?? Thank you very much!
2013/03/08
[ "https://Stackoverflow.com/questions/15289765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My current autocomplete plugin of choice is Select2. You can find it here <http://ivaynberg.github.io/select2/>
I found this plugin to meet the requirement. Enjoy. [UserPicker input element like GMAIL](http://tagedit.webwork-albrecht.de/)
15,289,765
I'm searching an userpicker that looks like Gmail, that when you add a "To" address, it becomes a label, or like StackOverflow when you add tags I've found this plugin: <http://htmlpreview.github.com/?https://github.com/ErikNoren/entitypicker/blob/master/entitypickerdemo.html> but I would like to find more plugins to compare... In my case, In my case, I need to convert two values (mail and phone) in one label...How can I do it?? Thank you very much!
2013/03/08
[ "https://Stackoverflow.com/questions/15289765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My current autocomplete plugin of choice is Select2. You can find it here <http://ivaynberg.github.io/select2/>
I have created a fiddle using typeahead.js and jquery. Please have a look. <https://jsfiddle.net/Rohith_KP/k73msa47/> ``` ! function(source) { function extractor(query) { var result = /([^,]+)$/.exec(query); if (result && result[1]) return result[1].trim(); return ''; } function tagTmpl(item) { return '<div class="selected">' + '<span class="value-wrapper">' + '<div class="value">' + item + '</div>' + '<div class="value-close"></div>' + '</span>' + '</div>' } <!--init --> var initData = ["Alabama", "Alaska", "Arizona", "Arkansas"], tagTmpls = ''; $.each(initData, function(index, item) { tagTmpls += tagTmpl(item); }) $('.multiselect').before(tagTmpls); $('.multiselect-display').text(initData.join(', ')); $('.multiselect').data({ "selectedValues": initData }); <!-- end init --> $('.multiselect').typeahead({ source: source, updater: function(item) { var tmpl = tagTmpl(item); this.$element.before(tmpl); var dataToSend = this.$element.data("selectedValues"); dataToSend = dataToSend ? dataToSend : []; dataToSend.push(item); this.$element.data({ "selectedValues": dataToSend }) return ''; }, matcher: function(item) { var tquery = extractor(this.query); if (!tquery) return false; return ~item.toLowerCase().indexOf(tquery) }, highlighter: function(item) { var query = extractor(this.query).replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&') return item.replace(new RegExp('(' + query + ')', 'ig'), function($1, match) { return '<strong>' + match + '</strong>' }) } }); $('.multiselect-wrapper').off('click').on('click', '.value-close', function() { $this = $(this); var text = $this.siblings('.value').text(); var selectedValues = $(event.currentTarget).find('.multiselect').data("selectedValues"); removeStringFromArray(selectedValues, text); $this.parents('.selected').hide(); window.setTimeout(function() { $this.parents('.selected').remove(); }, 0) }) $('.multiselect-wrapper').off('click', multislctWrprClickHndlr).on('click', multislctWrprClickHndlr) function multislctWrprClickHndlr(e) { $("body").off('click', bodyClickHandler).on('click', bodyClickHandler); if (!$(e.target).is('.selected')) { $('.multiselect').focus() } }; $('.multiselect-display').off('click', multislctDsplyClickHndlr).on('click', multislctDsplyClickHndlr) function multislctDsplyClickHndlr() { $(this).hide() $('.multiselect-wrapper').trigger('click').show(); }; function bodyClickHandler(e) { debugger; if ($(e.target).is('.multiselect-wrapper') || $(e.target).parents('.multiselect-wrapper').length || $(e.target).is('.multiselect-display') || $(e.target).parents('.multiselect-display').length) { e.preventDefault(); return; } $("body").off('click', bodyClickHandler); $('.multiselect-wrapper').hide(); $('.multiselect-display').text($('.multiselect').data("selectedValues").join(', ')).show() } function removeStringFromArray(array, search_term) { for (var i = array.length - 1; i >= 0; i--) { if (array[i] === search_term) { array.splice(i, 1); break; } } } }(["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut"]); ```
15,289,765
I'm searching an userpicker that looks like Gmail, that when you add a "To" address, it becomes a label, or like StackOverflow when you add tags I've found this plugin: <http://htmlpreview.github.com/?https://github.com/ErikNoren/entitypicker/blob/master/entitypickerdemo.html> but I would like to find more plugins to compare... In my case, In my case, I need to convert two values (mail and phone) in one label...How can I do it?? Thank you very much!
2013/03/08
[ "https://Stackoverflow.com/questions/15289765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My current autocomplete plugin of choice is Select2. You can find it here <http://ivaynberg.github.io/select2/>
Try this one. A jQuery plugin designed for Email related apps that allow the visitor to add/remove multiple comma-separated email addresses in a single text field. With a basic Email address validation functionality using regular expressions. <https://github.com/pierresh/multiple-emails.js>
15,289,765
I'm searching an userpicker that looks like Gmail, that when you add a "To" address, it becomes a label, or like StackOverflow when you add tags I've found this plugin: <http://htmlpreview.github.com/?https://github.com/ErikNoren/entitypicker/blob/master/entitypickerdemo.html> but I would like to find more plugins to compare... In my case, In my case, I need to convert two values (mail and phone) in one label...How can I do it?? Thank you very much!
2013/03/08
[ "https://Stackoverflow.com/questions/15289765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My current autocomplete plugin of choice is Select2. You can find it here <http://ivaynberg.github.io/select2/>
Things have gotten easier with plugins Nowadays. Checkout the <https://github.com/jshjohnson/Choices> The plugin works with `text input`, `select` and `multiple select` With this JS plugin, you can even validate items before you add to a list. ``` For example: 1. You can write your own validation rules 2. You can use Regex among other awesome things ``` Its quite easier to initialize: ``` var choice = new Choices(document.getElementById('itemID'), { option1:option, option2: option } ``` It even has several callBacks like; `removingItems`, `addingItems` etc Example Implementation: [![enter image description here](https://i.stack.imgur.com/TzJn1.png)](https://i.stack.imgur.com/TzJn1.png)
15,289,765
I'm searching an userpicker that looks like Gmail, that when you add a "To" address, it becomes a label, or like StackOverflow when you add tags I've found this plugin: <http://htmlpreview.github.com/?https://github.com/ErikNoren/entitypicker/blob/master/entitypickerdemo.html> but I would like to find more plugins to compare... In my case, In my case, I need to convert two values (mail and phone) in one label...How can I do it?? Thank you very much!
2013/03/08
[ "https://Stackoverflow.com/questions/15289765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have created a fiddle using typeahead.js and jquery. Please have a look. <https://jsfiddle.net/Rohith_KP/k73msa47/> ``` ! function(source) { function extractor(query) { var result = /([^,]+)$/.exec(query); if (result && result[1]) return result[1].trim(); return ''; } function tagTmpl(item) { return '<div class="selected">' + '<span class="value-wrapper">' + '<div class="value">' + item + '</div>' + '<div class="value-close"></div>' + '</span>' + '</div>' } <!--init --> var initData = ["Alabama", "Alaska", "Arizona", "Arkansas"], tagTmpls = ''; $.each(initData, function(index, item) { tagTmpls += tagTmpl(item); }) $('.multiselect').before(tagTmpls); $('.multiselect-display').text(initData.join(', ')); $('.multiselect').data({ "selectedValues": initData }); <!-- end init --> $('.multiselect').typeahead({ source: source, updater: function(item) { var tmpl = tagTmpl(item); this.$element.before(tmpl); var dataToSend = this.$element.data("selectedValues"); dataToSend = dataToSend ? dataToSend : []; dataToSend.push(item); this.$element.data({ "selectedValues": dataToSend }) return ''; }, matcher: function(item) { var tquery = extractor(this.query); if (!tquery) return false; return ~item.toLowerCase().indexOf(tquery) }, highlighter: function(item) { var query = extractor(this.query).replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&') return item.replace(new RegExp('(' + query + ')', 'ig'), function($1, match) { return '<strong>' + match + '</strong>' }) } }); $('.multiselect-wrapper').off('click').on('click', '.value-close', function() { $this = $(this); var text = $this.siblings('.value').text(); var selectedValues = $(event.currentTarget).find('.multiselect').data("selectedValues"); removeStringFromArray(selectedValues, text); $this.parents('.selected').hide(); window.setTimeout(function() { $this.parents('.selected').remove(); }, 0) }) $('.multiselect-wrapper').off('click', multislctWrprClickHndlr).on('click', multislctWrprClickHndlr) function multislctWrprClickHndlr(e) { $("body").off('click', bodyClickHandler).on('click', bodyClickHandler); if (!$(e.target).is('.selected')) { $('.multiselect').focus() } }; $('.multiselect-display').off('click', multislctDsplyClickHndlr).on('click', multislctDsplyClickHndlr) function multislctDsplyClickHndlr() { $(this).hide() $('.multiselect-wrapper').trigger('click').show(); }; function bodyClickHandler(e) { debugger; if ($(e.target).is('.multiselect-wrapper') || $(e.target).parents('.multiselect-wrapper').length || $(e.target).is('.multiselect-display') || $(e.target).parents('.multiselect-display').length) { e.preventDefault(); return; } $("body").off('click', bodyClickHandler); $('.multiselect-wrapper').hide(); $('.multiselect-display').text($('.multiselect').data("selectedValues").join(', ')).show() } function removeStringFromArray(array, search_term) { for (var i = array.length - 1; i >= 0; i--) { if (array[i] === search_term) { array.splice(i, 1); break; } } } }(["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut"]); ```
I found this plugin to meet the requirement. Enjoy. [UserPicker input element like GMAIL](http://tagedit.webwork-albrecht.de/)
15,289,765
I'm searching an userpicker that looks like Gmail, that when you add a "To" address, it becomes a label, or like StackOverflow when you add tags I've found this plugin: <http://htmlpreview.github.com/?https://github.com/ErikNoren/entitypicker/blob/master/entitypickerdemo.html> but I would like to find more plugins to compare... In my case, In my case, I need to convert two values (mail and phone) in one label...How can I do it?? Thank you very much!
2013/03/08
[ "https://Stackoverflow.com/questions/15289765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I found this plugin to meet the requirement. Enjoy. [UserPicker input element like GMAIL](http://tagedit.webwork-albrecht.de/)
Try this one. A jQuery plugin designed for Email related apps that allow the visitor to add/remove multiple comma-separated email addresses in a single text field. With a basic Email address validation functionality using regular expressions. <https://github.com/pierresh/multiple-emails.js>
15,289,765
I'm searching an userpicker that looks like Gmail, that when you add a "To" address, it becomes a label, or like StackOverflow when you add tags I've found this plugin: <http://htmlpreview.github.com/?https://github.com/ErikNoren/entitypicker/blob/master/entitypickerdemo.html> but I would like to find more plugins to compare... In my case, In my case, I need to convert two values (mail and phone) in one label...How can I do it?? Thank you very much!
2013/03/08
[ "https://Stackoverflow.com/questions/15289765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I found this plugin to meet the requirement. Enjoy. [UserPicker input element like GMAIL](http://tagedit.webwork-albrecht.de/)
Things have gotten easier with plugins Nowadays. Checkout the <https://github.com/jshjohnson/Choices> The plugin works with `text input`, `select` and `multiple select` With this JS plugin, you can even validate items before you add to a list. ``` For example: 1. You can write your own validation rules 2. You can use Regex among other awesome things ``` Its quite easier to initialize: ``` var choice = new Choices(document.getElementById('itemID'), { option1:option, option2: option } ``` It even has several callBacks like; `removingItems`, `addingItems` etc Example Implementation: [![enter image description here](https://i.stack.imgur.com/TzJn1.png)](https://i.stack.imgur.com/TzJn1.png)
15,289,765
I'm searching an userpicker that looks like Gmail, that when you add a "To" address, it becomes a label, or like StackOverflow when you add tags I've found this plugin: <http://htmlpreview.github.com/?https://github.com/ErikNoren/entitypicker/blob/master/entitypickerdemo.html> but I would like to find more plugins to compare... In my case, In my case, I need to convert two values (mail and phone) in one label...How can I do it?? Thank you very much!
2013/03/08
[ "https://Stackoverflow.com/questions/15289765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have created a fiddle using typeahead.js and jquery. Please have a look. <https://jsfiddle.net/Rohith_KP/k73msa47/> ``` ! function(source) { function extractor(query) { var result = /([^,]+)$/.exec(query); if (result && result[1]) return result[1].trim(); return ''; } function tagTmpl(item) { return '<div class="selected">' + '<span class="value-wrapper">' + '<div class="value">' + item + '</div>' + '<div class="value-close"></div>' + '</span>' + '</div>' } <!--init --> var initData = ["Alabama", "Alaska", "Arizona", "Arkansas"], tagTmpls = ''; $.each(initData, function(index, item) { tagTmpls += tagTmpl(item); }) $('.multiselect').before(tagTmpls); $('.multiselect-display').text(initData.join(', ')); $('.multiselect').data({ "selectedValues": initData }); <!-- end init --> $('.multiselect').typeahead({ source: source, updater: function(item) { var tmpl = tagTmpl(item); this.$element.before(tmpl); var dataToSend = this.$element.data("selectedValues"); dataToSend = dataToSend ? dataToSend : []; dataToSend.push(item); this.$element.data({ "selectedValues": dataToSend }) return ''; }, matcher: function(item) { var tquery = extractor(this.query); if (!tquery) return false; return ~item.toLowerCase().indexOf(tquery) }, highlighter: function(item) { var query = extractor(this.query).replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&') return item.replace(new RegExp('(' + query + ')', 'ig'), function($1, match) { return '<strong>' + match + '</strong>' }) } }); $('.multiselect-wrapper').off('click').on('click', '.value-close', function() { $this = $(this); var text = $this.siblings('.value').text(); var selectedValues = $(event.currentTarget).find('.multiselect').data("selectedValues"); removeStringFromArray(selectedValues, text); $this.parents('.selected').hide(); window.setTimeout(function() { $this.parents('.selected').remove(); }, 0) }) $('.multiselect-wrapper').off('click', multislctWrprClickHndlr).on('click', multislctWrprClickHndlr) function multislctWrprClickHndlr(e) { $("body").off('click', bodyClickHandler).on('click', bodyClickHandler); if (!$(e.target).is('.selected')) { $('.multiselect').focus() } }; $('.multiselect-display').off('click', multislctDsplyClickHndlr).on('click', multislctDsplyClickHndlr) function multislctDsplyClickHndlr() { $(this).hide() $('.multiselect-wrapper').trigger('click').show(); }; function bodyClickHandler(e) { debugger; if ($(e.target).is('.multiselect-wrapper') || $(e.target).parents('.multiselect-wrapper').length || $(e.target).is('.multiselect-display') || $(e.target).parents('.multiselect-display').length) { e.preventDefault(); return; } $("body").off('click', bodyClickHandler); $('.multiselect-wrapper').hide(); $('.multiselect-display').text($('.multiselect').data("selectedValues").join(', ')).show() } function removeStringFromArray(array, search_term) { for (var i = array.length - 1; i >= 0; i--) { if (array[i] === search_term) { array.splice(i, 1); break; } } } }(["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut"]); ```
Try this one. A jQuery plugin designed for Email related apps that allow the visitor to add/remove multiple comma-separated email addresses in a single text field. With a basic Email address validation functionality using regular expressions. <https://github.com/pierresh/multiple-emails.js>
15,289,765
I'm searching an userpicker that looks like Gmail, that when you add a "To" address, it becomes a label, or like StackOverflow when you add tags I've found this plugin: <http://htmlpreview.github.com/?https://github.com/ErikNoren/entitypicker/blob/master/entitypickerdemo.html> but I would like to find more plugins to compare... In my case, In my case, I need to convert two values (mail and phone) in one label...How can I do it?? Thank you very much!
2013/03/08
[ "https://Stackoverflow.com/questions/15289765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have created a fiddle using typeahead.js and jquery. Please have a look. <https://jsfiddle.net/Rohith_KP/k73msa47/> ``` ! function(source) { function extractor(query) { var result = /([^,]+)$/.exec(query); if (result && result[1]) return result[1].trim(); return ''; } function tagTmpl(item) { return '<div class="selected">' + '<span class="value-wrapper">' + '<div class="value">' + item + '</div>' + '<div class="value-close"></div>' + '</span>' + '</div>' } <!--init --> var initData = ["Alabama", "Alaska", "Arizona", "Arkansas"], tagTmpls = ''; $.each(initData, function(index, item) { tagTmpls += tagTmpl(item); }) $('.multiselect').before(tagTmpls); $('.multiselect-display').text(initData.join(', ')); $('.multiselect').data({ "selectedValues": initData }); <!-- end init --> $('.multiselect').typeahead({ source: source, updater: function(item) { var tmpl = tagTmpl(item); this.$element.before(tmpl); var dataToSend = this.$element.data("selectedValues"); dataToSend = dataToSend ? dataToSend : []; dataToSend.push(item); this.$element.data({ "selectedValues": dataToSend }) return ''; }, matcher: function(item) { var tquery = extractor(this.query); if (!tquery) return false; return ~item.toLowerCase().indexOf(tquery) }, highlighter: function(item) { var query = extractor(this.query).replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&') return item.replace(new RegExp('(' + query + ')', 'ig'), function($1, match) { return '<strong>' + match + '</strong>' }) } }); $('.multiselect-wrapper').off('click').on('click', '.value-close', function() { $this = $(this); var text = $this.siblings('.value').text(); var selectedValues = $(event.currentTarget).find('.multiselect').data("selectedValues"); removeStringFromArray(selectedValues, text); $this.parents('.selected').hide(); window.setTimeout(function() { $this.parents('.selected').remove(); }, 0) }) $('.multiselect-wrapper').off('click', multislctWrprClickHndlr).on('click', multislctWrprClickHndlr) function multislctWrprClickHndlr(e) { $("body").off('click', bodyClickHandler).on('click', bodyClickHandler); if (!$(e.target).is('.selected')) { $('.multiselect').focus() } }; $('.multiselect-display').off('click', multislctDsplyClickHndlr).on('click', multislctDsplyClickHndlr) function multislctDsplyClickHndlr() { $(this).hide() $('.multiselect-wrapper').trigger('click').show(); }; function bodyClickHandler(e) { debugger; if ($(e.target).is('.multiselect-wrapper') || $(e.target).parents('.multiselect-wrapper').length || $(e.target).is('.multiselect-display') || $(e.target).parents('.multiselect-display').length) { e.preventDefault(); return; } $("body").off('click', bodyClickHandler); $('.multiselect-wrapper').hide(); $('.multiselect-display').text($('.multiselect').data("selectedValues").join(', ')).show() } function removeStringFromArray(array, search_term) { for (var i = array.length - 1; i >= 0; i--) { if (array[i] === search_term) { array.splice(i, 1); break; } } } }(["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut"]); ```
Things have gotten easier with plugins Nowadays. Checkout the <https://github.com/jshjohnson/Choices> The plugin works with `text input`, `select` and `multiple select` With this JS plugin, you can even validate items before you add to a list. ``` For example: 1. You can write your own validation rules 2. You can use Regex among other awesome things ``` Its quite easier to initialize: ``` var choice = new Choices(document.getElementById('itemID'), { option1:option, option2: option } ``` It even has several callBacks like; `removingItems`, `addingItems` etc Example Implementation: [![enter image description here](https://i.stack.imgur.com/TzJn1.png)](https://i.stack.imgur.com/TzJn1.png)
53,116,703
I've got a class using two generic parameters in its constructor. I would like to implement a method to compare two instances of this class, as done in the code below. It works quite well except when one of the parameter is an arrays. I've read different topics about how to compare arrays with `java.util.Arrays.equals(Object[] a, Object[] a2)` but as my parameters are not defined as arrays, I can't use this method. How could return "true" in the content of my array is the same? Or is it possible to cast my parameters to use `java.util.Arrays.equals(Object[] a, Object[] a2)`? ``` public class Pair<U, V> { public final U first; public final V second; public Pair(U first, V second) { this.first = first; this.second = second; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> myPair= (Pair<?, ?>) o; if (!first.equals(myPair.first) || !second.equals(myPair.second)) return false; return true; } } ```
2018/11/02
[ "https://Stackoverflow.com/questions/53116703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6061004/" ]
You can do this: * use the guidance given [here](https://stackoverflow.com/questions/2725533/how-to-see-if-an-object-is-an-array-without-using-reflection) to determine whether both objects (this and the "other") contain arrays. Of course, detecting the actual member type means even more work. * utilize [Array.equals()](https://stackoverflow.com/questions/8777257/equals-vs-arrays-equals-in-java) to write specific comparison code when the fields are in fact arrays. But make no mistake: getting your `equals()` implementation to be correct, and work with inheritance and what not ... will be a major challenge! For example: do you consider an array of int to be equal to a list of Integer values (assuming the values are all in fact the same)? Or what about nested arrays? The real point here: Java doesn't have deep equality for arrays, and it is close to impossible to cover all potential cases yourself!
It's worth noting that no collection in Java that I'm aware of - pairs, lists, sets... - makes a concession for this case. As an example: ``` List<Integer[]> one = Arrays.asList( new Integer[]{1}, new Integer[]{2} ); List<Integer[]> two = Arrays.asList( new Integer[]{1}, new Integer[]{2} ); System.out.println(one.equals(two)); ``` Output: **false** Equality of two collections should only be determined by the equality of its elements. Anything other than that just makes the contract of your class increasingly vague. Arrays in Java do not override equals. That's a design decision that's already been made. It's not your job to try to correct what you must perceive as the wrong decision by hacking your implementation. So, in short, you don't.
53,116,703
I've got a class using two generic parameters in its constructor. I would like to implement a method to compare two instances of this class, as done in the code below. It works quite well except when one of the parameter is an arrays. I've read different topics about how to compare arrays with `java.util.Arrays.equals(Object[] a, Object[] a2)` but as my parameters are not defined as arrays, I can't use this method. How could return "true" in the content of my array is the same? Or is it possible to cast my parameters to use `java.util.Arrays.equals(Object[] a, Object[] a2)`? ``` public class Pair<U, V> { public final U first; public final V second; public Pair(U first, V second) { this.first = first; this.second = second; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> myPair= (Pair<?, ?>) o; if (!first.equals(myPair.first) || !second.equals(myPair.second)) return false; return true; } } ```
2018/11/02
[ "https://Stackoverflow.com/questions/53116703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6061004/" ]
``` @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> myPair = (Pair<?, ?>)o; if (first.getClass().isArray() ^ first.getClass().isArray() || second.getClass().isArray() ^ second.getClass().isArray()) return false; return deepEquals(first, myPair.first) && deepEquals(second, myPair.second); } private static boolean deepEquals(Object one, Object two) { if (one instanceof byte[]) return Arrays.equals((byte[])one, (byte[])two); if (one instanceof char[]) return Arrays.equals((char[])one, (char[])two); if (one instanceof short[]) return Arrays.equals((short[])one, (short[])two); if (one instanceof int[]) return Arrays.equals((int[])one, (int[])two); if (one instanceof long[]) return Arrays.equals((long[])one, (long[])two); if (one instanceof boolean[]) return Arrays.equals((boolean[])one, (boolean[])two); if (one instanceof float[]) return Arrays.equals((float[])one, (float[])two); if (one instanceof double[]) return Arrays.equals((double[])one, (double[])two); if (one instanceof Object[]) return Arrays.equals((Object[])one, (Object[])two); return one.equals(two); } ```
You can do this: * use the guidance given [here](https://stackoverflow.com/questions/2725533/how-to-see-if-an-object-is-an-array-without-using-reflection) to determine whether both objects (this and the "other") contain arrays. Of course, detecting the actual member type means even more work. * utilize [Array.equals()](https://stackoverflow.com/questions/8777257/equals-vs-arrays-equals-in-java) to write specific comparison code when the fields are in fact arrays. But make no mistake: getting your `equals()` implementation to be correct, and work with inheritance and what not ... will be a major challenge! For example: do you consider an array of int to be equal to a list of Integer values (assuming the values are all in fact the same)? Or what about nested arrays? The real point here: Java doesn't have deep equality for arrays, and it is close to impossible to cover all potential cases yourself!
53,116,703
I've got a class using two generic parameters in its constructor. I would like to implement a method to compare two instances of this class, as done in the code below. It works quite well except when one of the parameter is an arrays. I've read different topics about how to compare arrays with `java.util.Arrays.equals(Object[] a, Object[] a2)` but as my parameters are not defined as arrays, I can't use this method. How could return "true" in the content of my array is the same? Or is it possible to cast my parameters to use `java.util.Arrays.equals(Object[] a, Object[] a2)`? ``` public class Pair<U, V> { public final U first; public final V second; public Pair(U first, V second) { this.first = first; this.second = second; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> myPair= (Pair<?, ?>) o; if (!first.equals(myPair.first) || !second.equals(myPair.second)) return false; return true; } } ```
2018/11/02
[ "https://Stackoverflow.com/questions/53116703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6061004/" ]
``` @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> myPair = (Pair<?, ?>)o; if (first.getClass().isArray() ^ first.getClass().isArray() || second.getClass().isArray() ^ second.getClass().isArray()) return false; return deepEquals(first, myPair.first) && deepEquals(second, myPair.second); } private static boolean deepEquals(Object one, Object two) { if (one instanceof byte[]) return Arrays.equals((byte[])one, (byte[])two); if (one instanceof char[]) return Arrays.equals((char[])one, (char[])two); if (one instanceof short[]) return Arrays.equals((short[])one, (short[])two); if (one instanceof int[]) return Arrays.equals((int[])one, (int[])two); if (one instanceof long[]) return Arrays.equals((long[])one, (long[])two); if (one instanceof boolean[]) return Arrays.equals((boolean[])one, (boolean[])two); if (one instanceof float[]) return Arrays.equals((float[])one, (float[])two); if (one instanceof double[]) return Arrays.equals((double[])one, (double[])two); if (one instanceof Object[]) return Arrays.equals((Object[])one, (Object[])two); return one.equals(two); } ```
It's worth noting that no collection in Java that I'm aware of - pairs, lists, sets... - makes a concession for this case. As an example: ``` List<Integer[]> one = Arrays.asList( new Integer[]{1}, new Integer[]{2} ); List<Integer[]> two = Arrays.asList( new Integer[]{1}, new Integer[]{2} ); System.out.println(one.equals(two)); ``` Output: **false** Equality of two collections should only be determined by the equality of its elements. Anything other than that just makes the contract of your class increasingly vague. Arrays in Java do not override equals. That's a design decision that's already been made. It's not your job to try to correct what you must perceive as the wrong decision by hacking your implementation. So, in short, you don't.
53,116,703
I've got a class using two generic parameters in its constructor. I would like to implement a method to compare two instances of this class, as done in the code below. It works quite well except when one of the parameter is an arrays. I've read different topics about how to compare arrays with `java.util.Arrays.equals(Object[] a, Object[] a2)` but as my parameters are not defined as arrays, I can't use this method. How could return "true" in the content of my array is the same? Or is it possible to cast my parameters to use `java.util.Arrays.equals(Object[] a, Object[] a2)`? ``` public class Pair<U, V> { public final U first; public final V second; public Pair(U first, V second) { this.first = first; this.second = second; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> myPair= (Pair<?, ?>) o; if (!first.equals(myPair.first) || !second.equals(myPair.second)) return false; return true; } } ```
2018/11/02
[ "https://Stackoverflow.com/questions/53116703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6061004/" ]
``` public class Fourth { public static void main(String[] args) { Integer a[] = {1,2,3,4,5}; Integer b[] = {1,2,3,4,6,7}; CompareArrays<Integer, Integer> comp = new CompareArrays<Integer, Integer>(a,b); comp.compareArrays(); } } class CompareArrays<One extends Number, Two extends Number> { One[] array1; Two[] array2; CompareArrays(One[] ob1, Two[] ob2){ array1 = ob1; array2 = ob2; } void compareArrays() { if(array1.length != array2.length) { System.out.println("Two arrays are not equal"); }else { int flag = 0; for (int i = 0; i < array1.length; i++) { if(array1[i] != array2[i]) { flag =1; } } if(flag == 0) { System.out.println("Two arrays are equal"); }else { System.out.println("Two arrays are not equal"); } } } } ```
It's worth noting that no collection in Java that I'm aware of - pairs, lists, sets... - makes a concession for this case. As an example: ``` List<Integer[]> one = Arrays.asList( new Integer[]{1}, new Integer[]{2} ); List<Integer[]> two = Arrays.asList( new Integer[]{1}, new Integer[]{2} ); System.out.println(one.equals(two)); ``` Output: **false** Equality of two collections should only be determined by the equality of its elements. Anything other than that just makes the contract of your class increasingly vague. Arrays in Java do not override equals. That's a design decision that's already been made. It's not your job to try to correct what you must perceive as the wrong decision by hacking your implementation. So, in short, you don't.
53,116,703
I've got a class using two generic parameters in its constructor. I would like to implement a method to compare two instances of this class, as done in the code below. It works quite well except when one of the parameter is an arrays. I've read different topics about how to compare arrays with `java.util.Arrays.equals(Object[] a, Object[] a2)` but as my parameters are not defined as arrays, I can't use this method. How could return "true" in the content of my array is the same? Or is it possible to cast my parameters to use `java.util.Arrays.equals(Object[] a, Object[] a2)`? ``` public class Pair<U, V> { public final U first; public final V second; public Pair(U first, V second) { this.first = first; this.second = second; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> myPair= (Pair<?, ?>) o; if (!first.equals(myPair.first) || !second.equals(myPair.second)) return false; return true; } } ```
2018/11/02
[ "https://Stackoverflow.com/questions/53116703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6061004/" ]
``` @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> myPair = (Pair<?, ?>)o; if (first.getClass().isArray() ^ first.getClass().isArray() || second.getClass().isArray() ^ second.getClass().isArray()) return false; return deepEquals(first, myPair.first) && deepEquals(second, myPair.second); } private static boolean deepEquals(Object one, Object two) { if (one instanceof byte[]) return Arrays.equals((byte[])one, (byte[])two); if (one instanceof char[]) return Arrays.equals((char[])one, (char[])two); if (one instanceof short[]) return Arrays.equals((short[])one, (short[])two); if (one instanceof int[]) return Arrays.equals((int[])one, (int[])two); if (one instanceof long[]) return Arrays.equals((long[])one, (long[])two); if (one instanceof boolean[]) return Arrays.equals((boolean[])one, (boolean[])two); if (one instanceof float[]) return Arrays.equals((float[])one, (float[])two); if (one instanceof double[]) return Arrays.equals((double[])one, (double[])two); if (one instanceof Object[]) return Arrays.equals((Object[])one, (Object[])two); return one.equals(two); } ```
``` public class Fourth { public static void main(String[] args) { Integer a[] = {1,2,3,4,5}; Integer b[] = {1,2,3,4,6,7}; CompareArrays<Integer, Integer> comp = new CompareArrays<Integer, Integer>(a,b); comp.compareArrays(); } } class CompareArrays<One extends Number, Two extends Number> { One[] array1; Two[] array2; CompareArrays(One[] ob1, Two[] ob2){ array1 = ob1; array2 = ob2; } void compareArrays() { if(array1.length != array2.length) { System.out.println("Two arrays are not equal"); }else { int flag = 0; for (int i = 0; i < array1.length; i++) { if(array1[i] != array2[i]) { flag =1; } } if(flag == 0) { System.out.println("Two arrays are equal"); }else { System.out.println("Two arrays are not equal"); } } } } ```
5,629,495
im a newbie in android. I would like to ask if anybody knows why i'm getting this "connection refused" IOException when i try to establish a TCP/IP connection between two android device. I tried to ping both device and they are responding. Anybody please... Thanks in advance... ``` E/TCP_IP connect thread( 7466): java.net.ConnectException: /192.168.4.100:8080 - Connection refused E/TCP_IP connect thread( 7466): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:254) E/TCP_IP connect thread( 7466): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:219) E/TCP_IP connect thread( 7466): at java.net.Socket.startupSocket(Socket.java:781) E/TCP_IP connect thread( 7466): at java.net.Socket.<init>(Socket.java:316) E/TCP_IP connect thread( 7466): at com.neugent.WIFI.TCP_IP$ConnectThread.run(TCP_IP.java:291) ```
2011/04/12
[ "https://Stackoverflow.com/questions/5629495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/692101/" ]
If it's the missing INTERNET permission, add this line to your `Android.manifest` file just above the `<application>` tag. `<uses-permission android:name="android.permission.INTERNET/>`
You don't have the INTERNET permission? That, or your Wifi isn't turned on or the other IP isn't accessible (like you're trying to connect to a LAN IP via WAN).
5,629,495
im a newbie in android. I would like to ask if anybody knows why i'm getting this "connection refused" IOException when i try to establish a TCP/IP connection between two android device. I tried to ping both device and they are responding. Anybody please... Thanks in advance... ``` E/TCP_IP connect thread( 7466): java.net.ConnectException: /192.168.4.100:8080 - Connection refused E/TCP_IP connect thread( 7466): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:254) E/TCP_IP connect thread( 7466): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:219) E/TCP_IP connect thread( 7466): at java.net.Socket.startupSocket(Socket.java:781) E/TCP_IP connect thread( 7466): at java.net.Socket.<init>(Socket.java:316) E/TCP_IP connect thread( 7466): at com.neugent.WIFI.TCP_IP$ConnectThread.run(TCP_IP.java:291) ```
2011/04/12
[ "https://Stackoverflow.com/questions/5629495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/692101/" ]
You don't have the INTERNET permission? That, or your Wifi isn't turned on or the other IP isn't accessible (like you're trying to connect to a LAN IP via WAN).
For me restarting my WIFI worked....
5,629,495
im a newbie in android. I would like to ask if anybody knows why i'm getting this "connection refused" IOException when i try to establish a TCP/IP connection between two android device. I tried to ping both device and they are responding. Anybody please... Thanks in advance... ``` E/TCP_IP connect thread( 7466): java.net.ConnectException: /192.168.4.100:8080 - Connection refused E/TCP_IP connect thread( 7466): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:254) E/TCP_IP connect thread( 7466): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:219) E/TCP_IP connect thread( 7466): at java.net.Socket.startupSocket(Socket.java:781) E/TCP_IP connect thread( 7466): at java.net.Socket.<init>(Socket.java:316) E/TCP_IP connect thread( 7466): at com.neugent.WIFI.TCP_IP$ConnectThread.run(TCP_IP.java:291) ```
2011/04/12
[ "https://Stackoverflow.com/questions/5629495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/692101/" ]
If it's the missing INTERNET permission, add this line to your `Android.manifest` file just above the `<application>` tag. `<uses-permission android:name="android.permission.INTERNET/>`
For me restarting my WIFI worked....
45,631,132
The flag `CF` is set when we compare two digits and one number is less than another: ``` mov eax,1 cmp eax,2 jb truWay ``` In binary form: ``` 1=00000001 2=00000010=11111101+1(add. code)=11111110и 00000001+11111110=11111111(no carry) ``` Why does instruction `cmp eax,2` set the `CF` flag? There was no carry, or I'm wrong.
2017/08/11
[ "https://Stackoverflow.com/questions/45631132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2667757/" ]
You can refer to [these slides](http://web.cse.ohio-state.edu/~teodorescu.1/download/teaching/cse675.au08/Cse675.02.F.ALUDesign_part1.pdf) to understand how subtraction is performed in an ALU. While it is true that A - B = A + (-B) and that in two's complement this is A + ¬B + 1, this consideration accounts for the result only. A subtracter implemented with half-adders takes the form               [![A subtracter implemented with half-adders, note the inverted output carry](https://i.stack.imgur.com/0C4Ni.png)](https://i.stack.imgur.com/0C4Ni.png) Note that the *CarryOut* bit is inverted. You can check that this is necessary and correct by taking your example (limiting the size to 4 bits): 1 - 2 = 1 + (-2) = 0001b + 1110b = 0|1111b since ¬0 = 1 we have a borrow while for 2 - 1 one has 2 - 1 = 2 + (-1) = 0010b + 1111b = 1|0001b since ¬1 = 0 we have no borrow So in your example, there is a borrow, and thus CF is set, exactly because 0001b + 1110b produces no carry. For a more formal proof of the correctness of the inverted carry out flag, once can use induction on the number of bits. *Base case* *n = 1* This can be proven with a truth table ``` a b a-b (a+¬b+1) ¬carryOut Expected borrow 0 0 0+1+1 = 1|0 0 0 0 1 0+0+1 = 0|1 1 1 1 0 1+1+1 = 1|1 0 0 1 1 1+0+1 = 1|0 0 0 ``` *Induction case* When subtracting two n-bit numbers A = an an-1 ... a0 and B = bn bn-1 ... b0 we can have A > B, A < B or A = B. In the first case there is a *k* such that ak < bk and aj = bj for all *j* > *k* up to *n*. The condition ak < bk implies ak = 0 and bk = 1. Thus A and ¬B are equal down to the *k-1*-th bit so only this many bits influence the carry out. But by the induction hypothesis, the carry out is correct, so it is correct in this case too. The same process goes for the case A > B. The case A = B is easier as the whole operation is reduced to A + ¬A + 1 which reduces to 111...1 + 1 that always produces a carry out and thus no borrow.
There is **borrow out** indeed. `CF` is set by the `cmp` instruction if there is *borrow out*. Your instruction `cmp` performs the following subtraction: ``` 1 = 0001 - 2 = 0010 -------------- 1111 ``` For the the first rightmost column there is nothing special: `1 - 0 = 1`. For the second rightmost column there is a *borrow* (i.e.: a `1` is "borrowed" from one of the next columns). The borrow is needed because `0 < 1`. The result of this column is then `10 - 1 = 1`. Note however, that for the first operand there is not a single column on the left with a `1` to borrow from, therefore a *borrow out* occurs: a borrow is coming out for the most significant bit, which actually sets `CF`. Your subtraction operation would actually be like setting `CF` (i.e.: "borrowing" or "getting" a `1` for the MSB of the first operand) and performing the following subtraction: ``` 10001 - 0010 ------- 1111 ``` Note that the first operand has a `1` on the left side of its true MSB. This `1` was not there before and it represents the *borrow*.
45,631,132
The flag `CF` is set when we compare two digits and one number is less than another: ``` mov eax,1 cmp eax,2 jb truWay ``` In binary form: ``` 1=00000001 2=00000010=11111101+1(add. code)=11111110и 00000001+11111110=11111111(no carry) ``` Why does instruction `cmp eax,2` set the `CF` flag? There was no carry, or I'm wrong.
2017/08/11
[ "https://Stackoverflow.com/questions/45631132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2667757/" ]
You can refer to [these slides](http://web.cse.ohio-state.edu/~teodorescu.1/download/teaching/cse675.au08/Cse675.02.F.ALUDesign_part1.pdf) to understand how subtraction is performed in an ALU. While it is true that A - B = A + (-B) and that in two's complement this is A + ¬B + 1, this consideration accounts for the result only. A subtracter implemented with half-adders takes the form               [![A subtracter implemented with half-adders, note the inverted output carry](https://i.stack.imgur.com/0C4Ni.png)](https://i.stack.imgur.com/0C4Ni.png) Note that the *CarryOut* bit is inverted. You can check that this is necessary and correct by taking your example (limiting the size to 4 bits): 1 - 2 = 1 + (-2) = 0001b + 1110b = 0|1111b since ¬0 = 1 we have a borrow while for 2 - 1 one has 2 - 1 = 2 + (-1) = 0010b + 1111b = 1|0001b since ¬1 = 0 we have no borrow So in your example, there is a borrow, and thus CF is set, exactly because 0001b + 1110b produces no carry. For a more formal proof of the correctness of the inverted carry out flag, once can use induction on the number of bits. *Base case* *n = 1* This can be proven with a truth table ``` a b a-b (a+¬b+1) ¬carryOut Expected borrow 0 0 0+1+1 = 1|0 0 0 0 1 0+0+1 = 0|1 1 1 1 0 1+1+1 = 1|1 0 0 1 1 1+0+1 = 1|0 0 0 ``` *Induction case* When subtracting two n-bit numbers A = an an-1 ... a0 and B = bn bn-1 ... b0 we can have A > B, A < B or A = B. In the first case there is a *k* such that ak < bk and aj = bj for all *j* > *k* up to *n*. The condition ak < bk implies ak = 0 and bk = 1. Thus A and ¬B are equal down to the *k-1*-th bit so only this many bits influence the carry out. But by the induction hypothesis, the carry out is correct, so it is correct in this case too. The same process goes for the case A > B. The case A = B is easier as the whole operation is reduced to A + ¬A + 1 which reduces to 111...1 + 1 that always produces a carry out and thus no borrow.
**First:** The result of `a-b` is the same as the result of `a+(-b)`. However the **flags** set by the operation `a-b` are **NOT** (at least not always) the same flags as the flags set by the operation `a+(-b)`! This can be seen by comparing different CPU types (e.g. a modern x86 CPU and the historic 6502): The values of the flags after the operation `a+b` are the same on the x86 and the 6502 while the "carry flag" has exactly the opposite meaning on both CPUs after the operation `a-b`. This means that the "carry flag" has the same value after the operation `a+(-b)` on both CPUs while the value after `a-b` always differs on both CPUs. **Second:** On the x86 the "carry flag" is defined as "borrow out" for subtractions. You could emulate this by * extending both numbers to a number with more bits - for example 9 instead of 8 bits * then making the "extended" number negative * then doing the addition * ignoring the carry in the addition * instead using the highest bit of the result as carry Example: ``` 1 = 00000001 (8 bit) = 0 00000001 (9 bit) 2 = 00000010 (8 bit) = 0 00000010 (9 bit) 3 = 00000011 (8 bit) = 0 00000011 (9 bit) => -2 = 1 11111110 (9 bit!) Do the addition: 3 + (-2) = 1000000001 (9 bit plus carry) 1 + (-2) = 111111111 (9 bit) Ignore carry: 3 + (-2) = 000000001 (9 bit) 1 + (-2) = 111111111 (9 bit) Use the highest bit as carry: 3 + (-2) = 000000001 = 0 00000001 = (no carry) 00000001 1 + (-2) = 111111111 = 1 11111111 = (carry) 11111111 ```
55,935,015
i was trying to convert from a char array to integers and the atoi function is working properly except when i put a zero in the first index...it didn't print it ``` #include<iostream> using namespace std; int main() { char arr[]= "0150234"; int num; num=atoi(arr); cout << num; return 0; } ``` I expect the output of 0150234 but the actual output is 150234
2019/05/01
[ "https://Stackoverflow.com/questions/55935015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9560780/" ]
I think inside the atoi function you have typecasted the string to integer because of which the 0 gets removed. You can never get a 0 printed before a number since it doesn't make sense. 000001 will always be represented as 1. I hope this clears your doubt.
Binary number representations (such as `int`) do not store leading 0s because there is an infinite number of them. Rather they store a fixed number of bits which may have some leading 0 bits. You can still print the leading 0s if necessary: ``` std::cout << std::setw(4) << std::setfill('0') << 1 << '\n'; ``` Output: ``` 0001 ```
55,935,015
i was trying to convert from a char array to integers and the atoi function is working properly except when i put a zero in the first index...it didn't print it ``` #include<iostream> using namespace std; int main() { char arr[]= "0150234"; int num; num=atoi(arr); cout << num; return 0; } ``` I expect the output of 0150234 but the actual output is 150234
2019/05/01
[ "https://Stackoverflow.com/questions/55935015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9560780/" ]
I think inside the atoi function you have typecasted the string to integer because of which the 0 gets removed. You can never get a 0 printed before a number since it doesn't make sense. 000001 will always be represented as 1. I hope this clears your doubt.
You're confusing two ideas: **Numbers:** These are abstract things. They're quantities. Your computer stores the number in a manner that you should not care about (though it's probably binary). **Representations:** These are ways we display numbers to humans, like *"150234"*, or *"0x24ADA"*, or *"one hundred and fifty thousand, two hundred and thirty four"*. You pick a representation when you convert to a string. When streaming to `std::cout` a representation is picked for you by default, but you can choose your own representation using I/O manipulators, as [Maxim shows](https://stackoverflow.com/a/55935150/560648). The variable `num` is a *number*, not a representation of a number. It does not contain the information *«display this as "0150234"»*. That's what `arr` provides, because it is a string, containing a representation of a number. So, if that leading zero in the original representation is important to you, when you print `num`, you have to reproduce that representation yourself. --- ### By the way… *Usually*, in the programming world, and particularly in C-like source code: * When we see a string like *"150234"* we assume that it is the decimal (base-10) representation of a number; * When we see a string like *"0x24ADA"* (with a leading `0x`) we assume that it is the hexadecimal (base-16) representation of a number; * When we see a string like *"0150234"* (with a leading `0`) we assume that it is the octal (base-8) representation of a number. So, if you do add a leading zero, you may confuse your users. FYI the conventional base-8 representation of your number is *"0445332"*.
55,935,015
i was trying to convert from a char array to integers and the atoi function is working properly except when i put a zero in the first index...it didn't print it ``` #include<iostream> using namespace std; int main() { char arr[]= "0150234"; int num; num=atoi(arr); cout << num; return 0; } ``` I expect the output of 0150234 but the actual output is 150234
2019/05/01
[ "https://Stackoverflow.com/questions/55935015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9560780/" ]
Binary number representations (such as `int`) do not store leading 0s because there is an infinite number of them. Rather they store a fixed number of bits which may have some leading 0 bits. You can still print the leading 0s if necessary: ``` std::cout << std::setw(4) << std::setfill('0') << 1 << '\n'; ``` Output: ``` 0001 ```
You're confusing two ideas: **Numbers:** These are abstract things. They're quantities. Your computer stores the number in a manner that you should not care about (though it's probably binary). **Representations:** These are ways we display numbers to humans, like *"150234"*, or *"0x24ADA"*, or *"one hundred and fifty thousand, two hundred and thirty four"*. You pick a representation when you convert to a string. When streaming to `std::cout` a representation is picked for you by default, but you can choose your own representation using I/O manipulators, as [Maxim shows](https://stackoverflow.com/a/55935150/560648). The variable `num` is a *number*, not a representation of a number. It does not contain the information *«display this as "0150234"»*. That's what `arr` provides, because it is a string, containing a representation of a number. So, if that leading zero in the original representation is important to you, when you print `num`, you have to reproduce that representation yourself. --- ### By the way… *Usually*, in the programming world, and particularly in C-like source code: * When we see a string like *"150234"* we assume that it is the decimal (base-10) representation of a number; * When we see a string like *"0x24ADA"* (with a leading `0x`) we assume that it is the hexadecimal (base-16) representation of a number; * When we see a string like *"0150234"* (with a leading `0`) we assume that it is the octal (base-8) representation of a number. So, if you do add a leading zero, you may confuse your users. FYI the conventional base-8 representation of your number is *"0445332"*.
5,020,203
I am attempting to add a new record to a table similar to the example listed below. When I run the query I get the following error: QODBC3: Unable to bind variable. What do I need to do to correct the error? ``` QSqlQuery query; query.prepare("INSERT INTO Table (id, val, time) VALUES (:id, :val, :time)"); query.bindValue(":id", 1); query.bindValue(":val", "23"); query.bindValue(":time", QTime(8, 0)); query.exec(); ```
2011/02/16
[ "https://Stackoverflow.com/questions/5020203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/241060/" ]
I would guess it doesn't know how to bind the QTime object. Should you be using the toString method?
1. turned on ODBC tracing 2. Double check your parameters!
2,301,474
Is there $A \subset \mathbb{R}^n$, such that $A$ is compact, contains the origin and has measure zero? I know that the finite set A, of the form $A=\{ x\_{1},...,x\_{n} \}$, is a set of measure zero, but I don't know about its compactness nor if one can include the element zero amoung its elements.
2017/05/29
[ "https://math.stackexchange.com/questions/2301474", "https://math.stackexchange.com", "https://math.stackexchange.com/users/443436/" ]
Don't worry. Finite sets are always compact.
Whatever definition you use of compactness and of *measure zero*, the easiest example of $A \subset \mathbb{R}^n$ with all the properties you like is $A = \{0\}$. No matter if you use sequential compactness or compactness via open coverings, a singleton is trivially compact and of null Lebesgue measure.
2,301,474
Is there $A \subset \mathbb{R}^n$, such that $A$ is compact, contains the origin and has measure zero? I know that the finite set A, of the form $A=\{ x\_{1},...,x\_{n} \}$, is a set of measure zero, but I don't know about its compactness nor if one can include the element zero amoung its elements.
2017/05/29
[ "https://math.stackexchange.com/questions/2301474", "https://math.stackexchange.com", "https://math.stackexchange.com/users/443436/" ]
A non-trivial one would be the standard Cantor set in $\mathbb{R}^n$. It's closed, bounded (contained in the unit rectangle $[0,1]^n$, thus compact. It also contains the origin and is of measure zero.
Don't worry. Finite sets are always compact.
2,301,474
Is there $A \subset \mathbb{R}^n$, such that $A$ is compact, contains the origin and has measure zero? I know that the finite set A, of the form $A=\{ x\_{1},...,x\_{n} \}$, is a set of measure zero, but I don't know about its compactness nor if one can include the element zero amoung its elements.
2017/05/29
[ "https://math.stackexchange.com/questions/2301474", "https://math.stackexchange.com", "https://math.stackexchange.com/users/443436/" ]
A non-trivial one would be the standard Cantor set in $\mathbb{R}^n$. It's closed, bounded (contained in the unit rectangle $[0,1]^n$, thus compact. It also contains the origin and is of measure zero.
Whatever definition you use of compactness and of *measure zero*, the easiest example of $A \subset \mathbb{R}^n$ with all the properties you like is $A = \{0\}$. No matter if you use sequential compactness or compactness via open coverings, a singleton is trivially compact and of null Lebesgue measure.
2,301,474
Is there $A \subset \mathbb{R}^n$, such that $A$ is compact, contains the origin and has measure zero? I know that the finite set A, of the form $A=\{ x\_{1},...,x\_{n} \}$, is a set of measure zero, but I don't know about its compactness nor if one can include the element zero amoung its elements.
2017/05/29
[ "https://math.stackexchange.com/questions/2301474", "https://math.stackexchange.com", "https://math.stackexchange.com/users/443436/" ]
Any compact subset of a subspace of lower dimension will have measure $0$ in the full space. The unit sphere (not the unit ball) is a compact set with measure $0$. You can translate it so that it contains the origin.
Whatever definition you use of compactness and of *measure zero*, the easiest example of $A \subset \mathbb{R}^n$ with all the properties you like is $A = \{0\}$. No matter if you use sequential compactness or compactness via open coverings, a singleton is trivially compact and of null Lebesgue measure.
2,301,474
Is there $A \subset \mathbb{R}^n$, such that $A$ is compact, contains the origin and has measure zero? I know that the finite set A, of the form $A=\{ x\_{1},...,x\_{n} \}$, is a set of measure zero, but I don't know about its compactness nor if one can include the element zero amoung its elements.
2017/05/29
[ "https://math.stackexchange.com/questions/2301474", "https://math.stackexchange.com", "https://math.stackexchange.com/users/443436/" ]
A non-trivial one would be the standard Cantor set in $\mathbb{R}^n$. It's closed, bounded (contained in the unit rectangle $[0,1]^n$, thus compact. It also contains the origin and is of measure zero.
Any compact subset of a subspace of lower dimension will have measure $0$ in the full space. The unit sphere (not the unit ball) is a compact set with measure $0$. You can translate it so that it contains the origin.
52,468
Recently I watched a documentary film from "Star Media" (a Russian film) called "The First World War". Up to this moment, I thought that the February Revolution happened because there was a huge economic problem and people were living in very poor conditions. Now I understand that the world war contributed to this problem (but I hadn't thought about it before). According to the film (and I believe it's true), the Bolsheviks signed a peace treaty with very bad terms for the Russian Empire (the Russian Empire had to pay reparations and lost some territories). So now I'm confused: How did the Bolshevik leader become so popular in Russia and have a lot of monuments?
2019/05/05
[ "https://history.stackexchange.com/questions/52468", "https://history.stackexchange.com", "https://history.stackexchange.com/users/37707/" ]
This contains several questions. First, why was Lenin (more exactly, his party) popular in 1918-1922. The short answer is "because they distributed landowners land among peasants" (Only to seize it back after 15 years of dictatorship). They also stopped the unpopular war (by surrender) and declared the right of nations for self-determination (only to conquer most of them back within 2 years). Second, why was he popular after his death, and until now. Because his successors who established a dictatorship in the country with total control and huge propaganda apparatus created a cult of Lenin. They, the ruling party, not the people, erected all those monuments. For several generations the population was intensively brainwashed (and the part of it which resisted brainwashing was physically exterminated). These rulers maintained the cult of Lenin which exists (to a smaller extent) even now. In the independent Ukraine people destroyed all monuments to Lenin in a short period since 2014. But another revolution (of 2014) was necessary to make this possible. You may compare this with the cult of Mao. His rule led to death of more people than Stalin and Hitler combined, and completely ruined the economy. Still his cult exists. Because the party created by Mao still rules in China.
End of war promise and skillful organization -------------------------------------------- First we must address the issues of Russian Empire at the begging of 20th entry. Social and economic changes have long ago outgrown political institutions of that country. You had masses of recently freed serfs, but with little land ownership. You had growing industrial working class, also living in poverty and permeable to various socialist ideas. You had rising middle class of (university) educated people, but with little political power. You had various nationalities with little loyalty to Empire, dreaming their own ethnic states (Poles, Finns, Jews, even Ukrainians and various Central Asian ethnic states) . At the top of that you had autocratic Emperor surrounded with his entourage where real power in the country lay It was clear that such situation would lead to unrest at first opportunity. And this happened in [1905](https://en.wikipedia.org/wiki/1905_Russian_Revolution), when bad economic situation, defeat in [Russo-Japanese war](https://en.wikipedia.org/wiki/Russo-Japanese_War) and above all events surrounding [Bloody Sunday](https://en.wikipedia.org/wiki/Bloody_Sunday_(1905)) undermined faith in the empire, and led to strikes, demonstrations and even open rebellion in some military units (especially navy). Anyway, as a revolution, events in 1905 were failure but did force the government to enact [Russian Constitution of 1906](https://en.wikipedia.org/wiki/Russian_Constitution_of_1906). Constitution was work of compromise: Emperor retained lot of power, but this was limited by newly established Duma (parliament). Some political liberties were given to citizens and the press. However, little was done to improve economic situation, except perhaps insurance for factory workers. Peasants practically got nothing. More moderate and affluent among "revolutionaries" were satisfied and ready to move political battle from streets to legislature and institutions. More radical (socialists and communists) were not, but they did not have strength at that time for complete revolution. Instead, radical left groups that would become [Bolsheviks](https://en.wikipedia.org/wiki/Bolsheviks) in few years later, started organizing themselves in a firm, underground structure with centralized hierarchy and harsh, almost military, discipline. They were preparing themselves for violent takeover of power at opportune moment. That moment came when WW1 started. [Russia did not fare well](https://alphahistory.com/russianrevolution/world-war-i/) in that war. Huge losses, relatively incompetent leadership that used soldiers like pawns but still suffered defeats, general underequipment plus huge economic problems (i.e. hunger) on home front due to the lack of male workers (which were conscripted). It must me noted that average ethnically Russian soldier did not see this war as "patriotic" - Russia proper was not invaded, fighting was mostly limited to border regions of the Empire which were inhabited by non-Russian people that did not want to be in Russia anyway. Germans themselves did not show much inclination to let's say capture Moscow or St Petersburg (Petrograd). All of that fit well into Bolshevik's propaganda that this was not their (soldier's) war . Of course, the fact that [Lenin collaborated with Germans](https://spartacus-educational.com/Lenin_Sealed_Train.htm), and that they actually paid and organized his return to Russia to undermine the empire was not known to public at this time. Idea that we should "stop war" even with concessions to Germans (that later became [Treaty of Brest-Litovsk](https://en.wikipedia.org/wiki/Treaty_of_Brest-Litovsk)) was not outlandish to average Russian soldier at that time. This became increasingly important when Kerensky government after [February Revolution](https://en.wikipedia.org/wiki/February_Revolution) continued with Russian participation in the war. Luckily for the Bolsheviks, their cooperation with Germans was swept under the rug by German defeat in November of 1918. They didn't have to pay Brest-Litovsk agreed reparations, and control of territories was determined by force of arms as everywhere else in former Russian Empire. As for Lenin himself, he was also "lucky" to die relatively quickly after the success of revolution (in 1924). Possibility that his death was caused by failed assassination attempt by [Fanny Kaplan](https://en.wikipedia.org/wiki/Fanny_Kaplan) increased aura of martyrdom. Since Fanny Kaplan was Jewish, in later years Stalinist propaganda portrayed her as a foreign agent, or Trotskyist, although she likely was more inclined to [Socialist Revolutionary Party](https://en.wikipedia.org/wiki/Socialist_Revolutionary_Party) . In any case, Lenin could not be blamed for later "excesses" of Socialism, but as "founding father" of USSR always had prominent role in iconography. He remained romanticized figure, always ["so young"](https://www.youtube.com/watch?v=bnz-g8jt0zU) as his time was identified with early revolutionary hope and zeal. Dissatisfied people often discussed "what if" scenarios, i.e. what would have been if he stayed alive for few more years. In reality, we know now that [Red Terror](https://en.wikipedia.org/wiki/Red_Terror) actually started when he was still alive, and under his direct command. It is unlikely he would be more merciful than Stalin. But, as things went as they went, he remained relatively "clean" figure for communists to create cult of personality that remains to this day.
60,511,619
here is my code ``` ArrayList <String> arr = new ArrayList<String>(); arr.add("123 456"); String []arr2 = arr.get(0).split(" "); char[]x=arr2[0].toCharArray(); char[]y=arr2[1].toCharArray(); System.out.println(x[0]); System.out.println(y[0]); int z = x[0]+y[0]; System.out.println(z); ``` i get a result of 1 6 but the z is 103 how is that possible when ``` char xx=1; char yy=6; int zz = xx+yy; System.out.println(zz); ``` results to 7
2020/03/03
[ "https://Stackoverflow.com/questions/60511619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12379338/" ]
Why are you adding char primitives? If you're trying to concatenate, it works only within String objects, or between String and primitives. <https://docs.oracle.com/javase/tutorial/java/data/strings.html> In case you're wondering why you get those results, char is sort of a compatible primitive with int, so they can be sum (they will return the sum of the ascii values corresponding to the characters). <http://www.asciitable.com/> Here you can check the values for your chars, but I don't think this is what you want to do.
As others in the comments have pointed out, in your second example you are adding `int xx = 1` and `int yy = 6` thus `xx + yy` returns `7`. However, in your first example, you are adding `cx = '1'` and `cy = '6'` so `int value = cx + cy` evaluates to `48 + 54`
60,511,619
here is my code ``` ArrayList <String> arr = new ArrayList<String>(); arr.add("123 456"); String []arr2 = arr.get(0).split(" "); char[]x=arr2[0].toCharArray(); char[]y=arr2[1].toCharArray(); System.out.println(x[0]); System.out.println(y[0]); int z = x[0]+y[0]; System.out.println(z); ``` i get a result of 1 6 but the z is 103 how is that possible when ``` char xx=1; char yy=6; int zz = xx+yy; System.out.println(zz); ``` results to 7
2020/03/03
[ "https://Stackoverflow.com/questions/60511619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12379338/" ]
Why are you adding char primitives? If you're trying to concatenate, it works only within String objects, or between String and primitives. <https://docs.oracle.com/javase/tutorial/java/data/strings.html> In case you're wondering why you get those results, char is sort of a compatible primitive with int, so they can be sum (they will return the sum of the ascii values corresponding to the characters). <http://www.asciitable.com/> Here you can check the values for your chars, but I don't think this is what you want to do.
I guess you mess up a bit between array, string and integers... The main problem is `int z = x[0]+y[0];` you getting X and Y as Char, so they concate the String, so `"1" + "1" = "11"`, and than converting the string to int... so "1" + "6" = "16" converting to int, they tried to get number representation to it, that looks like be 103 What you could do if you trying to reach 7, is convert the Char to Int right here `int z = x[0]+y[0];` will be this way `int z = Integer.parseInt(x[0])+Integer.parseInt(y[0]);` so now will be `1 + 6 = 7`
60,511,619
here is my code ``` ArrayList <String> arr = new ArrayList<String>(); arr.add("123 456"); String []arr2 = arr.get(0).split(" "); char[]x=arr2[0].toCharArray(); char[]y=arr2[1].toCharArray(); System.out.println(x[0]); System.out.println(y[0]); int z = x[0]+y[0]; System.out.println(z); ``` i get a result of 1 6 but the z is 103 how is that possible when ``` char xx=1; char yy=6; int zz = xx+yy; System.out.println(zz); ``` results to 7
2020/03/03
[ "https://Stackoverflow.com/questions/60511619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12379338/" ]
I guess you mess up a bit between array, string and integers... The main problem is `int z = x[0]+y[0];` you getting X and Y as Char, so they concate the String, so `"1" + "1" = "11"`, and than converting the string to int... so "1" + "6" = "16" converting to int, they tried to get number representation to it, that looks like be 103 What you could do if you trying to reach 7, is convert the Char to Int right here `int z = x[0]+y[0];` will be this way `int z = Integer.parseInt(x[0])+Integer.parseInt(y[0]);` so now will be `1 + 6 = 7`
As others in the comments have pointed out, in your second example you are adding `int xx = 1` and `int yy = 6` thus `xx + yy` returns `7`. However, in your first example, you are adding `cx = '1'` and `cy = '6'` so `int value = cx + cy` evaluates to `48 + 54`
34,931,506
I have the following strings: One Rule : Get all consecutive Square bracket strings : for example, > > string 1 : [hello][qwqwe:]sdsdfsdf [note2] > string 2 : > [somethingelse]sdfsdf [note 1] > string 3 : aasdad[note 3] > > > I would like to get the substrings : > > output 1 : [hello][qwqwe:] > output 2 : [somethingelse] > output > 3 : > > > If the string doesn't have square brackets, I do not want an output. If the string has a square bracket delimited string which is not consecutive, it should not match aswell. I tried using the regex expression > > ([.\*])\* > > > But it matches everything between two square brackets. If you notice the first string, I do not need the part of the string that violates my rule.
2016/01/21
[ "https://Stackoverflow.com/questions/34931506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488682/" ]
Approach 1: Matching multiple consecutive `[...]`s at string start *as a single string* ======================================================================================= You need to use the following regex: ``` ^(\[[^]]*])+ ``` See [regex demo](http://regexstorm.net/tester?p=%5e(%5c%5b%5b%5e%5d%5d*%5d)%2b&i=%5bhel%5b%5b%5blo%5d%5bqwq%5b%5b%5bwe%3a%5dsdsdfsdf+%5bnote2%5d+%0d%0a%5bsomethingelse%5dsdfsdf+%5bnote+1%5d+%0d%0aaasdad%5bnote+3%5d&o=nm) The `^(\[[^]]*])+` matches: * `^` - start of string (in the demo, it matches at line start due to the multiline modifier) * `(\[[^]]*])+` - captured into Group 1 (you can access all of those values via `.Groups[1].Captures` collection) one or more occurrences of... + `\[` - a literal `[` + `[^]]*` - zero or more characters other than `]` + `]` - a literal `]`. [C# code demo](http://ideone.com/fYxnE4): ``` var txt = "[hello][qwqwe:]sdsdfsdf [note2]"; var res = Regex.Match(txt, @"^(\[[^]]*])+"); // Run the single search Console.WriteLine(res.Value); // Display the match var captures = res.Groups[1].Captures.Cast<Capture>().Select(p => p.Value).ToList(); Console.WriteLine(string.Join(", ", captures)); // Display captures ``` Approach 2: Matching multiple consecutive `[...]`s at string start *separately* =============================================================================== You can use `\G` operator: ``` \G\[[^]]*] ``` See [regex demo](http://regexstorm.net/tester?p=%5cG%5c%5b%5b%5e%5d%5d*%5d&i=%5bhel%5b%5blo%5d%5bqwq%5b%5bwe%3a%5dsdsdfsdf+%5bnote2%5d+) It will match the `[...]` substrings at the start of the string and then after each successful match. **Regex explanation**: * `\G` - a zero-width assertion (anchor) matching the location at the beginning of a string, or after each successful match * `\[[^]]*]` - a literal `[` (`\[`) followed by zero more (`*`) characters other than a `]`, followed by a closing `]`. If you need to return a single string of all `[...]`s found at the beginning of the string, you need to concatenate the matches: ``` var txt = "[hello][qwqwe:]sdsdfsdf [note2]"; var res = Regex.Matches(txt, @"\G\[[^]]*]").Cast<Match>().Select(p => p.Value).ToList(); Console.WriteLine(string.Join("", res)); ``` See [IDEONE demo](http://ideone.com/WnrVKZ)
you can use this regular expression. ``` ^(\[(.*?)\])* ``` C# code for matching: ``` var regex = new Regex(@"^(\[(.*?)\])*"); var inputTexts = new string [] {"[abcd]xyz[pqrst]","abcd[xyz][pqr]","[asdf][abcd][qwer]sds[qwert]" }; foreach (var match in inputTexts.Select(inputText => regex.Match(inputText))) { Console.WriteLine(match.Value); } //result1 - [abcd] //result2 - //result3 - [asdf][abcd][qwer] ```
34,931,506
I have the following strings: One Rule : Get all consecutive Square bracket strings : for example, > > string 1 : [hello][qwqwe:]sdsdfsdf [note2] > string 2 : > [somethingelse]sdfsdf [note 1] > string 3 : aasdad[note 3] > > > I would like to get the substrings : > > output 1 : [hello][qwqwe:] > output 2 : [somethingelse] > output > 3 : > > > If the string doesn't have square brackets, I do not want an output. If the string has a square bracket delimited string which is not consecutive, it should not match aswell. I tried using the regex expression > > ([.\*])\* > > > But it matches everything between two square brackets. If you notice the first string, I do not need the part of the string that violates my rule.
2016/01/21
[ "https://Stackoverflow.com/questions/34931506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488682/" ]
Approach 1: Matching multiple consecutive `[...]`s at string start *as a single string* ======================================================================================= You need to use the following regex: ``` ^(\[[^]]*])+ ``` See [regex demo](http://regexstorm.net/tester?p=%5e(%5c%5b%5b%5e%5d%5d*%5d)%2b&i=%5bhel%5b%5b%5blo%5d%5bqwq%5b%5b%5bwe%3a%5dsdsdfsdf+%5bnote2%5d+%0d%0a%5bsomethingelse%5dsdfsdf+%5bnote+1%5d+%0d%0aaasdad%5bnote+3%5d&o=nm) The `^(\[[^]]*])+` matches: * `^` - start of string (in the demo, it matches at line start due to the multiline modifier) * `(\[[^]]*])+` - captured into Group 1 (you can access all of those values via `.Groups[1].Captures` collection) one or more occurrences of... + `\[` - a literal `[` + `[^]]*` - zero or more characters other than `]` + `]` - a literal `]`. [C# code demo](http://ideone.com/fYxnE4): ``` var txt = "[hello][qwqwe:]sdsdfsdf [note2]"; var res = Regex.Match(txt, @"^(\[[^]]*])+"); // Run the single search Console.WriteLine(res.Value); // Display the match var captures = res.Groups[1].Captures.Cast<Capture>().Select(p => p.Value).ToList(); Console.WriteLine(string.Join(", ", captures)); // Display captures ``` Approach 2: Matching multiple consecutive `[...]`s at string start *separately* =============================================================================== You can use `\G` operator: ``` \G\[[^]]*] ``` See [regex demo](http://regexstorm.net/tester?p=%5cG%5c%5b%5b%5e%5d%5d*%5d&i=%5bhel%5b%5blo%5d%5bqwq%5b%5bwe%3a%5dsdsdfsdf+%5bnote2%5d+) It will match the `[...]` substrings at the start of the string and then after each successful match. **Regex explanation**: * `\G` - a zero-width assertion (anchor) matching the location at the beginning of a string, or after each successful match * `\[[^]]*]` - a literal `[` (`\[`) followed by zero more (`*`) characters other than a `]`, followed by a closing `]`. If you need to return a single string of all `[...]`s found at the beginning of the string, you need to concatenate the matches: ``` var txt = "[hello][qwqwe:]sdsdfsdf [note2]"; var res = Regex.Matches(txt, @"\G\[[^]]*]").Cast<Match>().Select(p => p.Value).ToList(); Console.WriteLine(string.Join("", res)); ``` See [IDEONE demo](http://ideone.com/WnrVKZ)
Try this, it works for me with your test strings. ``` ^(\[[^\]]*(\]|\]\[))* ``` Explanation generated by <https://regex101.com/> : ``` 1st Capturing group (\[[^\]]*(\]|\]\[))* Quantifier: * Between zero and unlimited times, as many times as possible, giving back as needed [greedy] Note: A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data \[ matches the character [ literally [^\]]* match a single character not present in the list below Quantifier: * Between zero and unlimited times, as many times as possible, giving back as needed [greedy] \] matches the character ] literally 2nd Capturing group (\]|\]\[) 1st Alternative: \] \] matches the character ] literally 2nd Alternative: \]\[ \] matches the character ] literally \[ matches the character [ literally ```
34,931,506
I have the following strings: One Rule : Get all consecutive Square bracket strings : for example, > > string 1 : [hello][qwqwe:]sdsdfsdf [note2] > string 2 : > [somethingelse]sdfsdf [note 1] > string 3 : aasdad[note 3] > > > I would like to get the substrings : > > output 1 : [hello][qwqwe:] > output 2 : [somethingelse] > output > 3 : > > > If the string doesn't have square brackets, I do not want an output. If the string has a square bracket delimited string which is not consecutive, it should not match aswell. I tried using the regex expression > > ([.\*])\* > > > But it matches everything between two square brackets. If you notice the first string, I do not need the part of the string that violates my rule.
2016/01/21
[ "https://Stackoverflow.com/questions/34931506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488682/" ]
Approach 1: Matching multiple consecutive `[...]`s at string start *as a single string* ======================================================================================= You need to use the following regex: ``` ^(\[[^]]*])+ ``` See [regex demo](http://regexstorm.net/tester?p=%5e(%5c%5b%5b%5e%5d%5d*%5d)%2b&i=%5bhel%5b%5b%5blo%5d%5bqwq%5b%5b%5bwe%3a%5dsdsdfsdf+%5bnote2%5d+%0d%0a%5bsomethingelse%5dsdfsdf+%5bnote+1%5d+%0d%0aaasdad%5bnote+3%5d&o=nm) The `^(\[[^]]*])+` matches: * `^` - start of string (in the demo, it matches at line start due to the multiline modifier) * `(\[[^]]*])+` - captured into Group 1 (you can access all of those values via `.Groups[1].Captures` collection) one or more occurrences of... + `\[` - a literal `[` + `[^]]*` - zero or more characters other than `]` + `]` - a literal `]`. [C# code demo](http://ideone.com/fYxnE4): ``` var txt = "[hello][qwqwe:]sdsdfsdf [note2]"; var res = Regex.Match(txt, @"^(\[[^]]*])+"); // Run the single search Console.WriteLine(res.Value); // Display the match var captures = res.Groups[1].Captures.Cast<Capture>().Select(p => p.Value).ToList(); Console.WriteLine(string.Join(", ", captures)); // Display captures ``` Approach 2: Matching multiple consecutive `[...]`s at string start *separately* =============================================================================== You can use `\G` operator: ``` \G\[[^]]*] ``` See [regex demo](http://regexstorm.net/tester?p=%5cG%5c%5b%5b%5e%5d%5d*%5d&i=%5bhel%5b%5blo%5d%5bqwq%5b%5bwe%3a%5dsdsdfsdf+%5bnote2%5d+) It will match the `[...]` substrings at the start of the string and then after each successful match. **Regex explanation**: * `\G` - a zero-width assertion (anchor) matching the location at the beginning of a string, or after each successful match * `\[[^]]*]` - a literal `[` (`\[`) followed by zero more (`*`) characters other than a `]`, followed by a closing `]`. If you need to return a single string of all `[...]`s found at the beginning of the string, you need to concatenate the matches: ``` var txt = "[hello][qwqwe:]sdsdfsdf [note2]"; var res = Regex.Matches(txt, @"\G\[[^]]*]").Cast<Match>().Select(p => p.Value).ToList(); Console.WriteLine(string.Join("", res)); ``` See [IDEONE demo](http://ideone.com/WnrVKZ)
You can adjust four things from you original regex to make it work: 1) use non-greedy match `.*?`, 2) add `^` to match from beginning of string, 3) escape the square brackets, and 4) change final `*` to `+` to require at least one group of square brackets: ``` ^(\[.*?\])+ ```
34,931,506
I have the following strings: One Rule : Get all consecutive Square bracket strings : for example, > > string 1 : [hello][qwqwe:]sdsdfsdf [note2] > string 2 : > [somethingelse]sdfsdf [note 1] > string 3 : aasdad[note 3] > > > I would like to get the substrings : > > output 1 : [hello][qwqwe:] > output 2 : [somethingelse] > output > 3 : > > > If the string doesn't have square brackets, I do not want an output. If the string has a square bracket delimited string which is not consecutive, it should not match aswell. I tried using the regex expression > > ([.\*])\* > > > But it matches everything between two square brackets. If you notice the first string, I do not need the part of the string that violates my rule.
2016/01/21
[ "https://Stackoverflow.com/questions/34931506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488682/" ]
you can use this regular expression. ``` ^(\[(.*?)\])* ``` C# code for matching: ``` var regex = new Regex(@"^(\[(.*?)\])*"); var inputTexts = new string [] {"[abcd]xyz[pqrst]","abcd[xyz][pqr]","[asdf][abcd][qwer]sds[qwert]" }; foreach (var match in inputTexts.Select(inputText => regex.Match(inputText))) { Console.WriteLine(match.Value); } //result1 - [abcd] //result2 - //result3 - [asdf][abcd][qwer] ```
Try this, it works for me with your test strings. ``` ^(\[[^\]]*(\]|\]\[))* ``` Explanation generated by <https://regex101.com/> : ``` 1st Capturing group (\[[^\]]*(\]|\]\[))* Quantifier: * Between zero and unlimited times, as many times as possible, giving back as needed [greedy] Note: A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data \[ matches the character [ literally [^\]]* match a single character not present in the list below Quantifier: * Between zero and unlimited times, as many times as possible, giving back as needed [greedy] \] matches the character ] literally 2nd Capturing group (\]|\]\[) 1st Alternative: \] \] matches the character ] literally 2nd Alternative: \]\[ \] matches the character ] literally \[ matches the character [ literally ```
34,931,506
I have the following strings: One Rule : Get all consecutive Square bracket strings : for example, > > string 1 : [hello][qwqwe:]sdsdfsdf [note2] > string 2 : > [somethingelse]sdfsdf [note 1] > string 3 : aasdad[note 3] > > > I would like to get the substrings : > > output 1 : [hello][qwqwe:] > output 2 : [somethingelse] > output > 3 : > > > If the string doesn't have square brackets, I do not want an output. If the string has a square bracket delimited string which is not consecutive, it should not match aswell. I tried using the regex expression > > ([.\*])\* > > > But it matches everything between two square brackets. If you notice the first string, I do not need the part of the string that violates my rule.
2016/01/21
[ "https://Stackoverflow.com/questions/34931506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488682/" ]
you can use this regular expression. ``` ^(\[(.*?)\])* ``` C# code for matching: ``` var regex = new Regex(@"^(\[(.*?)\])*"); var inputTexts = new string [] {"[abcd]xyz[pqrst]","abcd[xyz][pqr]","[asdf][abcd][qwer]sds[qwert]" }; foreach (var match in inputTexts.Select(inputText => regex.Match(inputText))) { Console.WriteLine(match.Value); } //result1 - [abcd] //result2 - //result3 - [asdf][abcd][qwer] ```
You can adjust four things from you original regex to make it work: 1) use non-greedy match `.*?`, 2) add `^` to match from beginning of string, 3) escape the square brackets, and 4) change final `*` to `+` to require at least one group of square brackets: ``` ^(\[.*?\])+ ```
34,931,506
I have the following strings: One Rule : Get all consecutive Square bracket strings : for example, > > string 1 : [hello][qwqwe:]sdsdfsdf [note2] > string 2 : > [somethingelse]sdfsdf [note 1] > string 3 : aasdad[note 3] > > > I would like to get the substrings : > > output 1 : [hello][qwqwe:] > output 2 : [somethingelse] > output > 3 : > > > If the string doesn't have square brackets, I do not want an output. If the string has a square bracket delimited string which is not consecutive, it should not match aswell. I tried using the regex expression > > ([.\*])\* > > > But it matches everything between two square brackets. If you notice the first string, I do not need the part of the string that violates my rule.
2016/01/21
[ "https://Stackoverflow.com/questions/34931506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488682/" ]
You can adjust four things from you original regex to make it work: 1) use non-greedy match `.*?`, 2) add `^` to match from beginning of string, 3) escape the square brackets, and 4) change final `*` to `+` to require at least one group of square brackets: ``` ^(\[.*?\])+ ```
Try this, it works for me with your test strings. ``` ^(\[[^\]]*(\]|\]\[))* ``` Explanation generated by <https://regex101.com/> : ``` 1st Capturing group (\[[^\]]*(\]|\]\[))* Quantifier: * Between zero and unlimited times, as many times as possible, giving back as needed [greedy] Note: A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data \[ matches the character [ literally [^\]]* match a single character not present in the list below Quantifier: * Between zero and unlimited times, as many times as possible, giving back as needed [greedy] \] matches the character ] literally 2nd Capturing group (\]|\]\[) 1st Alternative: \] \] matches the character ] literally 2nd Alternative: \]\[ \] matches the character ] literally \[ matches the character [ literally ```
13,004,202
I am using [PyContract](http://pypi.python.org/pypi/contract/1.4) (not [PyContracts](http://pypi.python.org/pypi/PyContracts/1.4.0)) to implement design-by-contracts for my genetic algorithms framework. The main module is `GA.py`, which calls a function from `crossover.py` (let's call it `foocross`). I have written precondition and postcondition expressions for `foocross`. Now, I would like those conditions to be checked when I run the `main` in GA.py. I introduced a false precondition in `foocross` just to test if the contracts were being checked, but it seems that they are not. How do I make sure that the contracts are being checked? Here's a minimal section of my code: ``` # GA.py def main(): # some code crossover.foocross(params) # some more code if __name__ == "__main__": main() #crossover.py def injectionco(p1, p2, chrom): """ pre: isinstance(p1, int) # this should raise an error. p1 is never an int isinstance(p2, list) isinstance(chrom, int) forall(p1, lambda elem: any(isinstance(elem, i.__class__) for i in p2)) forall(p2, lambda elem: any(isinstance(elem, i.__class__) for i in p1)) len(p1) == len(p2) post: p1 is __old__.p1 p2 is __old__.p2 p1 == __old__.p1 p2 == __old__.p2 isinstance(__return__, p1.__class__) # returns an individual len(__return__) == len(p1) id(__return__) not in [id(p1), id(p2)] forall(__return__, lambda elem: __return__.count(elem) == 1) """ #code return #something ``` PS: this was a pretty difficult question for me to write because I had to strip out a LOT of my code (since the framework is pretty complex) and I'm new to design-by-contract. So if I've missed out on some information that would help answer this question, please ask and I'll happily provide more info :)
2012/10/22
[ "https://Stackoverflow.com/questions/13004202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198633/" ]
It's a very simple mechanism that was introduced sometime around iBooks 1.5+, and finally made available to use all with the addition of the `+[UIScreen brightness]` API in iOS 5. Because it accepts a simple float from 0.0-1.0, storing it is a no-brainer, and restoring it can be done in any of the UIApplication delegate methods trivially. In fact, I wrote a sample app (OOH, [Shiny](http://dl.dropbox.com/u/54072935/Shiny.zip)) which restores screen brightness on launch, and saves it on exit.
``` static CGFloat s_brightness = 0.5f; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { s_brightness = [[UIScreen mainScreen] brightness]; return YES; } - (void)applicationWillResignActive:(UIApplication *)application { [[UIScreen mainScreen] setBrightness:s_brightness]; } ```
13,004,202
I am using [PyContract](http://pypi.python.org/pypi/contract/1.4) (not [PyContracts](http://pypi.python.org/pypi/PyContracts/1.4.0)) to implement design-by-contracts for my genetic algorithms framework. The main module is `GA.py`, which calls a function from `crossover.py` (let's call it `foocross`). I have written precondition and postcondition expressions for `foocross`. Now, I would like those conditions to be checked when I run the `main` in GA.py. I introduced a false precondition in `foocross` just to test if the contracts were being checked, but it seems that they are not. How do I make sure that the contracts are being checked? Here's a minimal section of my code: ``` # GA.py def main(): # some code crossover.foocross(params) # some more code if __name__ == "__main__": main() #crossover.py def injectionco(p1, p2, chrom): """ pre: isinstance(p1, int) # this should raise an error. p1 is never an int isinstance(p2, list) isinstance(chrom, int) forall(p1, lambda elem: any(isinstance(elem, i.__class__) for i in p2)) forall(p2, lambda elem: any(isinstance(elem, i.__class__) for i in p1)) len(p1) == len(p2) post: p1 is __old__.p1 p2 is __old__.p2 p1 == __old__.p1 p2 == __old__.p2 isinstance(__return__, p1.__class__) # returns an individual len(__return__) == len(p1) id(__return__) not in [id(p1), id(p2)] forall(__return__, lambda elem: __return__.count(elem) == 1) """ #code return #something ``` PS: this was a pretty difficult question for me to write because I had to strip out a LOT of my code (since the framework is pretty complex) and I'm new to design-by-contract. So if I've missed out on some information that would help answer this question, please ask and I'll happily provide more info :)
2012/10/22
[ "https://Stackoverflow.com/questions/13004202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198633/" ]
It's a very simple mechanism that was introduced sometime around iBooks 1.5+, and finally made available to use all with the addition of the `+[UIScreen brightness]` API in iOS 5. Because it accepts a simple float from 0.0-1.0, storing it is a no-brainer, and restoring it can be done in any of the UIApplication delegate methods trivially. In fact, I wrote a sample app (OOH, [Shiny](http://dl.dropbox.com/u/54072935/Shiny.zip)) which restores screen brightness on launch, and saves it on exit.
In Swift ``` static var defaultBrightNess:CGFloat = 0.5; func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { AppDelegate.defaultBrightNess = UIScreen.main.brightness; UIScreen.main.brightness = 1.0; return true } func applicationWillEnterForeground(_ application: UIApplication) { UIScreen.main.brightness = 1.0 } func applicationWillResignActive(_ application: UIApplication) { UIScreen.main.brightness = CGFloat(AppDelegate.defaultBrightNess) } ```
13,004,202
I am using [PyContract](http://pypi.python.org/pypi/contract/1.4) (not [PyContracts](http://pypi.python.org/pypi/PyContracts/1.4.0)) to implement design-by-contracts for my genetic algorithms framework. The main module is `GA.py`, which calls a function from `crossover.py` (let's call it `foocross`). I have written precondition and postcondition expressions for `foocross`. Now, I would like those conditions to be checked when I run the `main` in GA.py. I introduced a false precondition in `foocross` just to test if the contracts were being checked, but it seems that they are not. How do I make sure that the contracts are being checked? Here's a minimal section of my code: ``` # GA.py def main(): # some code crossover.foocross(params) # some more code if __name__ == "__main__": main() #crossover.py def injectionco(p1, p2, chrom): """ pre: isinstance(p1, int) # this should raise an error. p1 is never an int isinstance(p2, list) isinstance(chrom, int) forall(p1, lambda elem: any(isinstance(elem, i.__class__) for i in p2)) forall(p2, lambda elem: any(isinstance(elem, i.__class__) for i in p1)) len(p1) == len(p2) post: p1 is __old__.p1 p2 is __old__.p2 p1 == __old__.p1 p2 == __old__.p2 isinstance(__return__, p1.__class__) # returns an individual len(__return__) == len(p1) id(__return__) not in [id(p1), id(p2)] forall(__return__, lambda elem: __return__.count(elem) == 1) """ #code return #something ``` PS: this was a pretty difficult question for me to write because I had to strip out a LOT of my code (since the framework is pretty complex) and I'm new to design-by-contract. So if I've missed out on some information that would help answer this question, please ask and I'll happily provide more info :)
2012/10/22
[ "https://Stackoverflow.com/questions/13004202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198633/" ]
``` static CGFloat s_brightness = 0.5f; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { s_brightness = [[UIScreen mainScreen] brightness]; return YES; } - (void)applicationWillResignActive:(UIApplication *)application { [[UIScreen mainScreen] setBrightness:s_brightness]; } ```
In Swift ``` static var defaultBrightNess:CGFloat = 0.5; func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { AppDelegate.defaultBrightNess = UIScreen.main.brightness; UIScreen.main.brightness = 1.0; return true } func applicationWillEnterForeground(_ application: UIApplication) { UIScreen.main.brightness = 1.0 } func applicationWillResignActive(_ application: UIApplication) { UIScreen.main.brightness = CGFloat(AppDelegate.defaultBrightNess) } ```
38,729,273
I'm looking for a way to colorize the output from `./configure` so that all instances of `yes` at the end of a check show in one color and `no` in another. I think there may be a way of creating the echo message using `AS_IF` to test the check result and then set the output using the usual bash color commands. I'd obviously prefer to not have to spend time doing this if it's already been done.
2016/08/02
[ "https://Stackoverflow.com/questions/38729273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1825933/" ]
Lucky for you, Autoconf is basically one giant C-preprocessor-abuse, so its internals are all exposed and it's easy to do something hacky that, fair warning, might not carry over from one Autoconf version to the next. The definition of `AC_MSG_RESULT` (which prints most of those yes/no messages) is found in `/usr/share/autoconf/autoconf/general.m4`, and is quite simply defined as printing a given message to the log file as well as to the terminal: ``` m4_define([AC_MSG_RESULT], [{ _AS_ECHO_LOG([result: $1]) _AS_ECHO([$1]); }dnl ]) ``` Since the Autoconf internals called in that macro are exposed to your configure.ac, you can just override `AC_MSG_RESULT` with your own macro that calls them. Here's one that worked for me, printing "yes" in green, "no" in red, and all other results in blue. Include it before any other macro calls in your configure.ac: ``` m4_pushdef([AC_MSG_RESULT], [ { result="$1" _AS_ECHO_LOG([result: $result]) AS_CASE(["x$result"], [xnone\ needed], _AS_ECHO([$(tput setaf 4)$result$(tput sgr0)]), [xyes*], _AS_ECHO([$(tput setaf 2)$result$(tput sgr0)]), [xno*], _AS_ECHO([$(tput setaf 1)$result$(tput sgr0)]), _AS_ECHO([$(tput setaf 4)$result$(tput sgr0)])); }dnl ]) ``` But seriously, don't do this.
This is probably a dumb ask. I wrote one for the package check: ``` AC_DEFUN([COLOR_PKG_CHECK],[ red=$(tput setaf 1) grn=$(tput setaf 2) clr=$(tput sgr0) PKG_CHECK_EXISTS([$1],[$2],[found=yes],[found=no]) AS_IF([test "x$found" = "xyes"],[ msg="checking for $1... ${grn}yes${clr}" AC_MSG_RESULT($msg) $3 ],[ msg="checking for $1... ${red}no${clr}" AC_MSG_RESULT($msg) $4 ]) ]) ``` This works but it kind of pointed out that the only way to do this would be to wrap any calls of interest the same way. I don't want to do that.
58,811,959
I have been using the code below to send sms to customers telling them their account balances after a given period. so far the code is able to send sms to one person at a time. Can i modify the code to send the message to all customers. ``` <?php function sendsms($sms_username,$sms_password,$sender_ID,$number,$message) { if(isset($sms_username) && isset($sms_password)) { $username = trim($sms_username);//your sms user account $password = trim($sms_password);//your sms password $type = '0';//FOR FLASH MESSAGES SET type to 1 $dlr = '1';//request for delivery report $destination = $number;;//phone number $source = urlencode($sender_ID);//This is the sender or label that will be received by client/user. MAXIMUM 11 CHARACTERS $message = urlencode("$message");//message content to be sent to user/client //Form url api $url = "https://api.sendingthesms/bulksms/?username=" .$username."&password=".$password."&type=0&dlr=1&destination=".$destination."&source=".$source."&message=" . $message; $scc = stream_context_create(array('http' => array('protocol_version' => 1.1)));//enforce http 1.1 $response = file_get_contents("$url",0,$scc);//fire/call nalo sms api return $response; }else { return "username cannot be empty"; } } echo sendsms("username","mypassword","$session_username",$mainphone3, $mysms); header("location:index.php"); exit; ?> ```
2019/11/12
[ "https://Stackoverflow.com/questions/58811959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12358842/" ]
-First, you can change your if statement with the condition if your loop at the first character in the phrase and meets a space. -Second, you can change how the way you swap from this : ``` phrase[i] = temp; phrase[i] = phrase[j]; phrase[j] = temp; ``` with this : ``` temp = phrase[i]; phrase[i] = phrase[j]; phrase[j] = temp; ```
Here's the proper C++ way of doing it. ``` #include <iostream> #include <string> #include <sstream> int main() { std::string phrase; std::cout << "Enter a phrase" << std::endl; getline(std::cin, phrase); std::stringstream ss{phrase}; std::string reversedPhrase; std::string word; while (ss >> word) { std::swap(word[0], word[word.length() - 1]); reversedPhrase += word + " "; } std::cout << "Original phrase: " << phrase << std::endl; std::cout << "Reversed phrase: " << reversedPhrase << std::endl; } ``` You can play around with the code live [here](https://wandbox.org/permlink/1Mjb46YY3uVbKCPk)
58,811,959
I have been using the code below to send sms to customers telling them their account balances after a given period. so far the code is able to send sms to one person at a time. Can i modify the code to send the message to all customers. ``` <?php function sendsms($sms_username,$sms_password,$sender_ID,$number,$message) { if(isset($sms_username) && isset($sms_password)) { $username = trim($sms_username);//your sms user account $password = trim($sms_password);//your sms password $type = '0';//FOR FLASH MESSAGES SET type to 1 $dlr = '1';//request for delivery report $destination = $number;;//phone number $source = urlencode($sender_ID);//This is the sender or label that will be received by client/user. MAXIMUM 11 CHARACTERS $message = urlencode("$message");//message content to be sent to user/client //Form url api $url = "https://api.sendingthesms/bulksms/?username=" .$username."&password=".$password."&type=0&dlr=1&destination=".$destination."&source=".$source."&message=" . $message; $scc = stream_context_create(array('http' => array('protocol_version' => 1.1)));//enforce http 1.1 $response = file_get_contents("$url",0,$scc);//fire/call nalo sms api return $response; }else { return "username cannot be empty"; } } echo sendsms("username","mypassword","$session_username",$mainphone3, $mysms); header("location:index.php"); exit; ?> ```
2019/11/12
[ "https://Stackoverflow.com/questions/58811959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12358842/" ]
-First, you can change your if statement with the condition if your loop at the first character in the phrase and meets a space. -Second, you can change how the way you swap from this : ``` phrase[i] = temp; phrase[i] = phrase[j]; phrase[j] = temp; ``` with this : ``` temp = phrase[i]; phrase[i] = phrase[j]; phrase[j] = temp; ```
This one is pretty easy! You're on the right track. When you cin your phrase, you can immediately switch the 1st index with the 2nd. Then, you for loop thru the rest. Something like this: [1]: <https://i.stack.imgur.com/M1ntj.png>
58,811,959
I have been using the code below to send sms to customers telling them their account balances after a given period. so far the code is able to send sms to one person at a time. Can i modify the code to send the message to all customers. ``` <?php function sendsms($sms_username,$sms_password,$sender_ID,$number,$message) { if(isset($sms_username) && isset($sms_password)) { $username = trim($sms_username);//your sms user account $password = trim($sms_password);//your sms password $type = '0';//FOR FLASH MESSAGES SET type to 1 $dlr = '1';//request for delivery report $destination = $number;;//phone number $source = urlencode($sender_ID);//This is the sender or label that will be received by client/user. MAXIMUM 11 CHARACTERS $message = urlencode("$message");//message content to be sent to user/client //Form url api $url = "https://api.sendingthesms/bulksms/?username=" .$username."&password=".$password."&type=0&dlr=1&destination=".$destination."&source=".$source."&message=" . $message; $scc = stream_context_create(array('http' => array('protocol_version' => 1.1)));//enforce http 1.1 $response = file_get_contents("$url",0,$scc);//fire/call nalo sms api return $response; }else { return "username cannot be empty"; } } echo sendsms("username","mypassword","$session_username",$mainphone3, $mysms); header("location:index.php"); exit; ?> ```
2019/11/12
[ "https://Stackoverflow.com/questions/58811959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12358842/" ]
This one is pretty easy! You're on the right track. When you cin your phrase, you can immediately switch the 1st index with the 2nd. Then, you for loop thru the rest. Something like this: [1]: <https://i.stack.imgur.com/M1ntj.png>
Here's the proper C++ way of doing it. ``` #include <iostream> #include <string> #include <sstream> int main() { std::string phrase; std::cout << "Enter a phrase" << std::endl; getline(std::cin, phrase); std::stringstream ss{phrase}; std::string reversedPhrase; std::string word; while (ss >> word) { std::swap(word[0], word[word.length() - 1]); reversedPhrase += word + " "; } std::cout << "Original phrase: " << phrase << std::endl; std::cout << "Reversed phrase: " << reversedPhrase << std::endl; } ``` You can play around with the code live [here](https://wandbox.org/permlink/1Mjb46YY3uVbKCPk)
15,384,108
I have a SSIS package where1 record (hard coded) flow through. ![enter image description here](https://i.stack.imgur.com/pPzEg.png) I have variable in DFT scope. ![enter image description here](https://i.stack.imgur.com/dw2of.png) I assign value to variable using Row Count Transaformation. ![enter image description here](https://i.stack.imgur.com/Azv3P.png) The value should be 1 i verify it by using script component. ``` public override void PostExecute() { System.Windows.Forms.MessageBox.Show(ReadWriteVariables[0].Value.ToString()); base.PostExecute(); /* Add your code here for postprocessing or remove if not needed You can set read/write variables here, for example: Variables.MyIntVar = 100 */ } ``` I look for zero condition through condition in Conditional split transformation. ![enter image description here](https://i.stack.imgur.com/EUP2H.png) Strangely it satisfies equal to zero condition whrease I think it should have value 1. Even Messagebox through script component shows value 1. ![enter image description here](https://i.stack.imgur.com/trIke.png) what could be the reason? Are value in varible realize only towards end of DFT or Conditional Split has some problem reading correct value or something else which i am not able to think up?
2013/03/13
[ "https://Stackoverflow.com/questions/15384108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1318701/" ]
The value for `variable` being assigned inside a `data flow task` can't be used in the `split transformation` or later in the Data Flow task . The values generally get `populated` once DFT gets `completed` . ``` Variable values does not update during the execution of Data Flow task ``` Even though you are able to see `value 1` or set some other value to `Variable` from script transformation in post or pre execution events ,these values gets effected only after the execution of `DFT` Hence the updated value can be used in precedence constraint or other tasks in control flow . Read [this](http://microsoft-ssis.blogspot.in/2011/02/how-to-skip-trailer-records.html) article .
Alternatively you can use RANK Function as one of the columns, latter use Conditional split with max function to get the number of rows selected (in directly row count). Next you can use Copy column and remove RANK column before inserting into final destination. Hope this helps!
21,816,052
How can I have the same effect in iOS `UITextView` like below image. Blur effect from the bottom of `UITextView` ![Gradient at the bottom of UItextView](https://i.stack.imgur.com/udcaL.png) Thanks in Advance :)
2014/02/16
[ "https://Stackoverflow.com/questions/21816052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1520570/" ]
Try the following: I tried the following with image but not UITextView ``` UIView *vwTest = [[UIView alloc] initWithFrame:_textView.frame]; [vwTest setBackgroundColor:[UIColor whiteColor]]; [vwTest setUserInteractionEnabled:NO]; [self.view addSubview:vwTest]; NSArray *colors = [NSArray arrayWithObjects: (id)[[UIColor colorWithWhite:0 alpha:1] CGColor], (id)[[UIColor colorWithWhite:0 alpha:0] CGColor], nil]; CAGradientLayer *layer = [CAGradientLayer layer]; [layer setFrame:vwTest.bounds]; [layer setColors:colors]; [layer setStartPoint:CGPointMake(0.0f, 1.0f)]; [layer setEndPoint:CGPointMake(0.0f, 0.6f)]; [vwTest.layer setMask:layer]; ```
Just place an UIImageView which contains a gradient image from clear to white on top of the bottom of the text view. That's the easiest way I guess.
21,816,052
How can I have the same effect in iOS `UITextView` like below image. Blur effect from the bottom of `UITextView` ![Gradient at the bottom of UItextView](https://i.stack.imgur.com/udcaL.png) Thanks in Advance :)
2014/02/16
[ "https://Stackoverflow.com/questions/21816052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1520570/" ]
Try the following: I tried the following with image but not UITextView ``` UIView *vwTest = [[UIView alloc] initWithFrame:_textView.frame]; [vwTest setBackgroundColor:[UIColor whiteColor]]; [vwTest setUserInteractionEnabled:NO]; [self.view addSubview:vwTest]; NSArray *colors = [NSArray arrayWithObjects: (id)[[UIColor colorWithWhite:0 alpha:1] CGColor], (id)[[UIColor colorWithWhite:0 alpha:0] CGColor], nil]; CAGradientLayer *layer = [CAGradientLayer layer]; [layer setFrame:vwTest.bounds]; [layer setColors:colors]; [layer setStartPoint:CGPointMake(0.0f, 1.0f)]; [layer setEndPoint:CGPointMake(0.0f, 0.6f)]; [vwTest.layer setMask:layer]; ```
``` let gradientLayer: CAGradientLayer = CAGradientLayer() gradientLayer.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(textView.frame), CGRectGetHeight(textView.frame)) gradientLayer.colors = [UIColor.init(white: 1, alpha: 0).CGColor, UIColor.whiteColor().CGColor] gradientLayer.startPoint = CGPointMake(0, 0.6) gradientLayer.endPoint = CGPointMake(0.0, 1) self.textview.layer.addSublayer(gradientLayer) ```
21,816,052
How can I have the same effect in iOS `UITextView` like below image. Blur effect from the bottom of `UITextView` ![Gradient at the bottom of UItextView](https://i.stack.imgur.com/udcaL.png) Thanks in Advance :)
2014/02/16
[ "https://Stackoverflow.com/questions/21816052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1520570/" ]
Try the following: I tried the following with image but not UITextView ``` UIView *vwTest = [[UIView alloc] initWithFrame:_textView.frame]; [vwTest setBackgroundColor:[UIColor whiteColor]]; [vwTest setUserInteractionEnabled:NO]; [self.view addSubview:vwTest]; NSArray *colors = [NSArray arrayWithObjects: (id)[[UIColor colorWithWhite:0 alpha:1] CGColor], (id)[[UIColor colorWithWhite:0 alpha:0] CGColor], nil]; CAGradientLayer *layer = [CAGradientLayer layer]; [layer setFrame:vwTest.bounds]; [layer setColors:colors]; [layer setStartPoint:CGPointMake(0.0f, 1.0f)]; [layer setEndPoint:CGPointMake(0.0f, 0.6f)]; [vwTest.layer setMask:layer]; ```
The answer of @Charlie above did not work as is for me on Swift 5.x, I had to make some changes. First add an UIView with an UITextView on it. Then I did apply the calare like this: ``` let gradientLayer: CAGradientLayer = CAGradientLayer() gradientLayer.frame = CGRect.init(x: 0.0, y: 0.0, width: textView.frame.width, height: textView.frame.height) gradientLayer.colors = [UIColor.init(white: 1, alpha: 0).cgColor, UIColor.white.cgColor] gradientLayer.startPoint = CGPoint.init(x: 0.0, y: 0.6) gradientLayer.endPoint = CGPoint.init(x: 0.0, y: 1.0) self.contentTextView.layer.addSublayer(gradientLayer) ```
476,176
I want to ask what is the little numbers on top/over any random number? For example, 75 in² and 125 ft3. What is it called and what does it mean is my question. I couldn't find anything online since I don't know what it is called.
2018/12/08
[ "https://english.stackexchange.com/questions/476176", "https://english.stackexchange.com", "https://english.stackexchange.com/users/318987/" ]
In terms of formatting, numbers and letters that appear in the top half of a line are in *superscript*. Similarly, numbers in the bottom half of a line would be called *subscript*. "Super" and "sub" describe their position over or under the main text. In your examples, these superscript numbers stand for a mathematical exponent or power as applied to a unit of measurement. If I were reading it out loud, I might say "seventy-five inches squared," or (more clearly) "seventy-five square inches." It means that I am talking about a unit of distance extending in two dimensions. It's a measurement of surface area, just like houses can be measured in square feet (ft2) and land can be measured in square miles (mi2). The cubic version (in3) would refer to a measurement across three dimensions, or a measurement of volume. Other measurements can also be squared or cubed, especially when doing calculations in STEM fields, but square inches/feet/miles are the most common examples of this in the US.
The general term for a number (or other text) written like this is **[superscript](https://en.wikipedia.org/wiki/Subscript_and_superscript)**. The term in2 refers to [square inches](https://en.wikipedia.org/wiki/Square_inch), which is the amount of area in a square with sides an inch in length. Likewise, if it were in3, it would be referring to [cubic inches](https://en.wikipedia.org/wiki/Cubic_inch), which is the amount of volume in a cube with side lengths of an inch.
476,176
I want to ask what is the little numbers on top/over any random number? For example, 75 in² and 125 ft3. What is it called and what does it mean is my question. I couldn't find anything online since I don't know what it is called.
2018/12/08
[ "https://english.stackexchange.com/questions/476176", "https://english.stackexchange.com", "https://english.stackexchange.com/users/318987/" ]
The general term for a number (or other text) written like this is **[superscript](https://en.wikipedia.org/wiki/Subscript_and_superscript)**. The term in2 refers to [square inches](https://en.wikipedia.org/wiki/Square_inch), which is the amount of area in a square with sides an inch in length. Likewise, if it were in3, it would be referring to [cubic inches](https://en.wikipedia.org/wiki/Cubic_inch), which is the amount of volume in a cube with side lengths of an inch.
**Exponent** > > 3.6 Derived Units— Derived units are formed by combining base units according to the algebraic relations linking > the corresponding quantities. Symbols for derived units are obtained by means of mathematical signs for > multiplication, division, and the use of **exponents**. For example, the SI unit for speed is the meter per second > (m/s or m·s–1 and that for density is kilogram per cubic meter kg/m3 > or kg·m–3). Most derived units have only > their composite names, such as meter per second for speed or velocity. Others have special names, such as > newton (N), joule (J), watt (W), and pascal (Pa), given to SI units of force, energy, power, and pressure (or > stress), respectively. > > > SAE Technical Standards Board: Rules for SAE Use of SI (Metric) Units, Rev May 1999. <https://www.sae.org/standardsdev/tsb/tsb003.pdf>
476,176
I want to ask what is the little numbers on top/over any random number? For example, 75 in² and 125 ft3. What is it called and what does it mean is my question. I couldn't find anything online since I don't know what it is called.
2018/12/08
[ "https://english.stackexchange.com/questions/476176", "https://english.stackexchange.com", "https://english.stackexchange.com/users/318987/" ]
In terms of formatting, numbers and letters that appear in the top half of a line are in *superscript*. Similarly, numbers in the bottom half of a line would be called *subscript*. "Super" and "sub" describe their position over or under the main text. In your examples, these superscript numbers stand for a mathematical exponent or power as applied to a unit of measurement. If I were reading it out loud, I might say "seventy-five inches squared," or (more clearly) "seventy-five square inches." It means that I am talking about a unit of distance extending in two dimensions. It's a measurement of surface area, just like houses can be measured in square feet (ft2) and land can be measured in square miles (mi2). The cubic version (in3) would refer to a measurement across three dimensions, or a measurement of volume. Other measurements can also be squared or cubed, especially when doing calculations in STEM fields, but square inches/feet/miles are the most common examples of this in the US.
**Exponent** > > 3.6 Derived Units— Derived units are formed by combining base units according to the algebraic relations linking > the corresponding quantities. Symbols for derived units are obtained by means of mathematical signs for > multiplication, division, and the use of **exponents**. For example, the SI unit for speed is the meter per second > (m/s or m·s–1 and that for density is kilogram per cubic meter kg/m3 > or kg·m–3). Most derived units have only > their composite names, such as meter per second for speed or velocity. Others have special names, such as > newton (N), joule (J), watt (W), and pascal (Pa), given to SI units of force, energy, power, and pressure (or > stress), respectively. > > > SAE Technical Standards Board: Rules for SAE Use of SI (Metric) Units, Rev May 1999. <https://www.sae.org/standardsdev/tsb/tsb003.pdf>
38,237
For example, we always assumed that the data or signal error is a Gaussian distribution? why? I have asked this question on stackoverflow, the link: <https://stackoverflow.com/questions/12616406/anyone-can-tell-me-why-we-always-use-the-gaussian-distribution-in-machine-learni>
2012/09/29
[ "https://stats.stackexchange.com/questions/38237", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/14477/" ]
I looked at the answers on SO. I don't think they are satisfactory. People often argue for the normal distribution because of the central limit theorem. That may be okay in large samples when the problem involves averages. But machine learning problems can be more complex and sample sizes are not always large enough for normal approximations to apply. Some argue for mathematical convenience. That is no justification especially when computers can easily handle added complexity and computer-intensive resampling approaches. But I think the question should be challenged. Who says the Guassian distribution is "always" used or even just predominantly used in machine learning. Taleb claimed that statistics is dominated by the Gaussian distribution especially when applied to finance. He was very wrong about that! In machine learning aren't kernel density classification approaches, tree classifiers and other nonparametric methods sometimes used? Aren't nearest neighbor methods used for clustering and classification? I think they are and I know statisticians use these methods very frequently.
Machine learning (and statistics as well) treats data as the mix of deterministic (causal) and random parts. The random part of data usually has normal distribution. (Really, the causal relation is reverse: the distribution of random part of variable is called normal). Central limit theorem says that the sum of large number of varibles each having a small influence on the result approximate normal distribution. 1. Why data is treated as normally distributed? In machine learning we want to express dependent variable as some function of a number of independent variables. If this function is sum (or expressed as a sum of some other funstions) and we are suggesting that the number of independent variables is really high, then the dependent variable should have normal distribution (due to central limit theorem). 2. Why errors are looked to be normally distributed? The dependent variable ($Y$) consists of deterministic and random parts. In machine learning we are trying to express deterministic part as a sum of deterministic independent variables: $$deterministic + random = func(deterministic(1))+...+func(deterministic(n))+model\\_error$$ If the whole deterministic part of $Y$ is explained by $X$ then the $model\\_error$ depicts only $random$ part, and thus should have normal distribution. So if error distribution is normal, then we may suggest that the model is successful. Else there are some other features that are absent in model, but have large enough influence on $Y$ (the model is incomplete) or the model is incorrect.
38,237
For example, we always assumed that the data or signal error is a Gaussian distribution? why? I have asked this question on stackoverflow, the link: <https://stackoverflow.com/questions/12616406/anyone-can-tell-me-why-we-always-use-the-gaussian-distribution-in-machine-learni>
2012/09/29
[ "https://stats.stackexchange.com/questions/38237", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/14477/" ]
I looked at the answers on SO. I don't think they are satisfactory. People often argue for the normal distribution because of the central limit theorem. That may be okay in large samples when the problem involves averages. But machine learning problems can be more complex and sample sizes are not always large enough for normal approximations to apply. Some argue for mathematical convenience. That is no justification especially when computers can easily handle added complexity and computer-intensive resampling approaches. But I think the question should be challenged. Who says the Guassian distribution is "always" used or even just predominantly used in machine learning. Taleb claimed that statistics is dominated by the Gaussian distribution especially when applied to finance. He was very wrong about that! In machine learning aren't kernel density classification approaches, tree classifiers and other nonparametric methods sometimes used? Aren't nearest neighbor methods used for clustering and classification? I think they are and I know statisticians use these methods very frequently.
i'm currently studying machine learning and the same question popped to my mind. What I think the reason should be is that in every machine learning problem we assume we have abundant observational data available and whenever data tends to infinity it gets normally distributed around its mean and thats what Normal distribution(Gaussian Distribution) says. Although its not necessary that Gaussian DIstribution will always be a perfect fit to any data that tends to infinity like take a case when your data is always positive then you can easily see if you try to fit gaussian dist to it it will give some weight to negative values of x also(although negligible but still some weight is given) so in such case distribution like Zeta is more suited.
38,237
For example, we always assumed that the data or signal error is a Gaussian distribution? why? I have asked this question on stackoverflow, the link: <https://stackoverflow.com/questions/12616406/anyone-can-tell-me-why-we-always-use-the-gaussian-distribution-in-machine-learni>
2012/09/29
[ "https://stats.stackexchange.com/questions/38237", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/14477/" ]
I looked at the answers on SO. I don't think they are satisfactory. People often argue for the normal distribution because of the central limit theorem. That may be okay in large samples when the problem involves averages. But machine learning problems can be more complex and sample sizes are not always large enough for normal approximations to apply. Some argue for mathematical convenience. That is no justification especially when computers can easily handle added complexity and computer-intensive resampling approaches. But I think the question should be challenged. Who says the Guassian distribution is "always" used or even just predominantly used in machine learning. Taleb claimed that statistics is dominated by the Gaussian distribution especially when applied to finance. He was very wrong about that! In machine learning aren't kernel density classification approaches, tree classifiers and other nonparametric methods sometimes used? Aren't nearest neighbor methods used for clustering and classification? I think they are and I know statisticians use these methods very frequently.
One reason that normal distributions are often (but not always!) assumed: the nature of the distribution often leads to extremely efficient computation. For example, in generalized linear regression, the solution is technically in closed form when your distribution is Gaussian: $\hat \beta = (X^T X)^{-1} X^T Y$ where as for other distributions, iterative algorithms must be used. Technical note: using this direct computation to find $\hat \beta$ is both inefficient and unstable. Quite often, both the theoretical math and numerical methods required are *substaintially* easier if the distribution is a linear transformation of normal variables. Because of this, methods are frequently first developed under the assumption that the data is normal, as the problem is considerably more tractable. Later, the more difficult problem of addressing non-normality is addressed by statistical/machine learning researchers.
38,237
For example, we always assumed that the data or signal error is a Gaussian distribution? why? I have asked this question on stackoverflow, the link: <https://stackoverflow.com/questions/12616406/anyone-can-tell-me-why-we-always-use-the-gaussian-distribution-in-machine-learni>
2012/09/29
[ "https://stats.stackexchange.com/questions/38237", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/14477/" ]
I looked at the answers on SO. I don't think they are satisfactory. People often argue for the normal distribution because of the central limit theorem. That may be okay in large samples when the problem involves averages. But machine learning problems can be more complex and sample sizes are not always large enough for normal approximations to apply. Some argue for mathematical convenience. That is no justification especially when computers can easily handle added complexity and computer-intensive resampling approaches. But I think the question should be challenged. Who says the Guassian distribution is "always" used or even just predominantly used in machine learning. Taleb claimed that statistics is dominated by the Gaussian distribution especially when applied to finance. He was very wrong about that! In machine learning aren't kernel density classification approaches, tree classifiers and other nonparametric methods sometimes used? Aren't nearest neighbor methods used for clustering and classification? I think they are and I know statisticians use these methods very frequently.
I had the same question "what the is advantage of doing a Gaussian transformation on predictors or target?" Infact, caret package has a pre-processing step that enables this transformation. I tried reasoning this out and am summarizing my understanding - 1. Usually the data distribution in Nature follows a Normal distribution ( few examples like - age, income, height, weight etc., ) . So its the best approximation when we are not aware of the underlying distribution pattern. 2. Most often the goal in ML/ AI is to strive to make the data linearly separable even if it means projecting the data into higher dimensional space so as to find a fitting "hyperplane" (for example - SVM kernels, Neural net layers, Softmax etc.,). The reason for this being "Linear boundaries always help in reducing variance and is the most simplistic, natural and interpret-able" besides reducing mathematical / computational complexities. And, when we aim for linear separability, its always good to reduce the effect of outliers, influencing points and leverage points. Why? Because the hyperplane is very sensitive to the influencing points and leverage points (aka outliers) - To undertstand this - Lets shift to a 2D space where we have one predictor (X) and one target(y) and assume there exists a good positive correlation between X and y. Given this, if our X is normally distributed and y is also normally distributed, you are most likely to fit a straight line that has many points centered in the middle of the line rather than the end-points (aka outliers, leverage / influencing points). So the predicted regression line will most likely suffer little variance when predicting on unseen data. Extrapolating the above understanding to a n-dimensional space and fitting a hyperplane to make things linearly separable does infact really makes sense because it helps in reducing the variance.
38,237
For example, we always assumed that the data or signal error is a Gaussian distribution? why? I have asked this question on stackoverflow, the link: <https://stackoverflow.com/questions/12616406/anyone-can-tell-me-why-we-always-use-the-gaussian-distribution-in-machine-learni>
2012/09/29
[ "https://stats.stackexchange.com/questions/38237", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/14477/" ]
Machine learning (and statistics as well) treats data as the mix of deterministic (causal) and random parts. The random part of data usually has normal distribution. (Really, the causal relation is reverse: the distribution of random part of variable is called normal). Central limit theorem says that the sum of large number of varibles each having a small influence on the result approximate normal distribution. 1. Why data is treated as normally distributed? In machine learning we want to express dependent variable as some function of a number of independent variables. If this function is sum (or expressed as a sum of some other funstions) and we are suggesting that the number of independent variables is really high, then the dependent variable should have normal distribution (due to central limit theorem). 2. Why errors are looked to be normally distributed? The dependent variable ($Y$) consists of deterministic and random parts. In machine learning we are trying to express deterministic part as a sum of deterministic independent variables: $$deterministic + random = func(deterministic(1))+...+func(deterministic(n))+model\\_error$$ If the whole deterministic part of $Y$ is explained by $X$ then the $model\\_error$ depicts only $random$ part, and thus should have normal distribution. So if error distribution is normal, then we may suggest that the model is successful. Else there are some other features that are absent in model, but have large enough influence on $Y$ (the model is incomplete) or the model is incorrect.
i'm currently studying machine learning and the same question popped to my mind. What I think the reason should be is that in every machine learning problem we assume we have abundant observational data available and whenever data tends to infinity it gets normally distributed around its mean and thats what Normal distribution(Gaussian Distribution) says. Although its not necessary that Gaussian DIstribution will always be a perfect fit to any data that tends to infinity like take a case when your data is always positive then you can easily see if you try to fit gaussian dist to it it will give some weight to negative values of x also(although negligible but still some weight is given) so in such case distribution like Zeta is more suited.
38,237
For example, we always assumed that the data or signal error is a Gaussian distribution? why? I have asked this question on stackoverflow, the link: <https://stackoverflow.com/questions/12616406/anyone-can-tell-me-why-we-always-use-the-gaussian-distribution-in-machine-learni>
2012/09/29
[ "https://stats.stackexchange.com/questions/38237", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/14477/" ]
Machine learning (and statistics as well) treats data as the mix of deterministic (causal) and random parts. The random part of data usually has normal distribution. (Really, the causal relation is reverse: the distribution of random part of variable is called normal). Central limit theorem says that the sum of large number of varibles each having a small influence on the result approximate normal distribution. 1. Why data is treated as normally distributed? In machine learning we want to express dependent variable as some function of a number of independent variables. If this function is sum (or expressed as a sum of some other funstions) and we are suggesting that the number of independent variables is really high, then the dependent variable should have normal distribution (due to central limit theorem). 2. Why errors are looked to be normally distributed? The dependent variable ($Y$) consists of deterministic and random parts. In machine learning we are trying to express deterministic part as a sum of deterministic independent variables: $$deterministic + random = func(deterministic(1))+...+func(deterministic(n))+model\\_error$$ If the whole deterministic part of $Y$ is explained by $X$ then the $model\\_error$ depicts only $random$ part, and thus should have normal distribution. So if error distribution is normal, then we may suggest that the model is successful. Else there are some other features that are absent in model, but have large enough influence on $Y$ (the model is incomplete) or the model is incorrect.
One reason that normal distributions are often (but not always!) assumed: the nature of the distribution often leads to extremely efficient computation. For example, in generalized linear regression, the solution is technically in closed form when your distribution is Gaussian: $\hat \beta = (X^T X)^{-1} X^T Y$ where as for other distributions, iterative algorithms must be used. Technical note: using this direct computation to find $\hat \beta$ is both inefficient and unstable. Quite often, both the theoretical math and numerical methods required are *substaintially* easier if the distribution is a linear transformation of normal variables. Because of this, methods are frequently first developed under the assumption that the data is normal, as the problem is considerably more tractable. Later, the more difficult problem of addressing non-normality is addressed by statistical/machine learning researchers.
38,237
For example, we always assumed that the data or signal error is a Gaussian distribution? why? I have asked this question on stackoverflow, the link: <https://stackoverflow.com/questions/12616406/anyone-can-tell-me-why-we-always-use-the-gaussian-distribution-in-machine-learni>
2012/09/29
[ "https://stats.stackexchange.com/questions/38237", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/14477/" ]
Machine learning (and statistics as well) treats data as the mix of deterministic (causal) and random parts. The random part of data usually has normal distribution. (Really, the causal relation is reverse: the distribution of random part of variable is called normal). Central limit theorem says that the sum of large number of varibles each having a small influence on the result approximate normal distribution. 1. Why data is treated as normally distributed? In machine learning we want to express dependent variable as some function of a number of independent variables. If this function is sum (or expressed as a sum of some other funstions) and we are suggesting that the number of independent variables is really high, then the dependent variable should have normal distribution (due to central limit theorem). 2. Why errors are looked to be normally distributed? The dependent variable ($Y$) consists of deterministic and random parts. In machine learning we are trying to express deterministic part as a sum of deterministic independent variables: $$deterministic + random = func(deterministic(1))+...+func(deterministic(n))+model\\_error$$ If the whole deterministic part of $Y$ is explained by $X$ then the $model\\_error$ depicts only $random$ part, and thus should have normal distribution. So if error distribution is normal, then we may suggest that the model is successful. Else there are some other features that are absent in model, but have large enough influence on $Y$ (the model is incomplete) or the model is incorrect.
I had the same question "what the is advantage of doing a Gaussian transformation on predictors or target?" Infact, caret package has a pre-processing step that enables this transformation. I tried reasoning this out and am summarizing my understanding - 1. Usually the data distribution in Nature follows a Normal distribution ( few examples like - age, income, height, weight etc., ) . So its the best approximation when we are not aware of the underlying distribution pattern. 2. Most often the goal in ML/ AI is to strive to make the data linearly separable even if it means projecting the data into higher dimensional space so as to find a fitting "hyperplane" (for example - SVM kernels, Neural net layers, Softmax etc.,). The reason for this being "Linear boundaries always help in reducing variance and is the most simplistic, natural and interpret-able" besides reducing mathematical / computational complexities. And, when we aim for linear separability, its always good to reduce the effect of outliers, influencing points and leverage points. Why? Because the hyperplane is very sensitive to the influencing points and leverage points (aka outliers) - To undertstand this - Lets shift to a 2D space where we have one predictor (X) and one target(y) and assume there exists a good positive correlation between X and y. Given this, if our X is normally distributed and y is also normally distributed, you are most likely to fit a straight line that has many points centered in the middle of the line rather than the end-points (aka outliers, leverage / influencing points). So the predicted regression line will most likely suffer little variance when predicting on unseen data. Extrapolating the above understanding to a n-dimensional space and fitting a hyperplane to make things linearly separable does infact really makes sense because it helps in reducing the variance.
38,237
For example, we always assumed that the data or signal error is a Gaussian distribution? why? I have asked this question on stackoverflow, the link: <https://stackoverflow.com/questions/12616406/anyone-can-tell-me-why-we-always-use-the-gaussian-distribution-in-machine-learni>
2012/09/29
[ "https://stats.stackexchange.com/questions/38237", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/14477/" ]
One reason that normal distributions are often (but not always!) assumed: the nature of the distribution often leads to extremely efficient computation. For example, in generalized linear regression, the solution is technically in closed form when your distribution is Gaussian: $\hat \beta = (X^T X)^{-1} X^T Y$ where as for other distributions, iterative algorithms must be used. Technical note: using this direct computation to find $\hat \beta$ is both inefficient and unstable. Quite often, both the theoretical math and numerical methods required are *substaintially* easier if the distribution is a linear transformation of normal variables. Because of this, methods are frequently first developed under the assumption that the data is normal, as the problem is considerably more tractable. Later, the more difficult problem of addressing non-normality is addressed by statistical/machine learning researchers.
i'm currently studying machine learning and the same question popped to my mind. What I think the reason should be is that in every machine learning problem we assume we have abundant observational data available and whenever data tends to infinity it gets normally distributed around its mean and thats what Normal distribution(Gaussian Distribution) says. Although its not necessary that Gaussian DIstribution will always be a perfect fit to any data that tends to infinity like take a case when your data is always positive then you can easily see if you try to fit gaussian dist to it it will give some weight to negative values of x also(although negligible but still some weight is given) so in such case distribution like Zeta is more suited.
38,237
For example, we always assumed that the data or signal error is a Gaussian distribution? why? I have asked this question on stackoverflow, the link: <https://stackoverflow.com/questions/12616406/anyone-can-tell-me-why-we-always-use-the-gaussian-distribution-in-machine-learni>
2012/09/29
[ "https://stats.stackexchange.com/questions/38237", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/14477/" ]
I had the same question "what the is advantage of doing a Gaussian transformation on predictors or target?" Infact, caret package has a pre-processing step that enables this transformation. I tried reasoning this out and am summarizing my understanding - 1. Usually the data distribution in Nature follows a Normal distribution ( few examples like - age, income, height, weight etc., ) . So its the best approximation when we are not aware of the underlying distribution pattern. 2. Most often the goal in ML/ AI is to strive to make the data linearly separable even if it means projecting the data into higher dimensional space so as to find a fitting "hyperplane" (for example - SVM kernels, Neural net layers, Softmax etc.,). The reason for this being "Linear boundaries always help in reducing variance and is the most simplistic, natural and interpret-able" besides reducing mathematical / computational complexities. And, when we aim for linear separability, its always good to reduce the effect of outliers, influencing points and leverage points. Why? Because the hyperplane is very sensitive to the influencing points and leverage points (aka outliers) - To undertstand this - Lets shift to a 2D space where we have one predictor (X) and one target(y) and assume there exists a good positive correlation between X and y. Given this, if our X is normally distributed and y is also normally distributed, you are most likely to fit a straight line that has many points centered in the middle of the line rather than the end-points (aka outliers, leverage / influencing points). So the predicted regression line will most likely suffer little variance when predicting on unseen data. Extrapolating the above understanding to a n-dimensional space and fitting a hyperplane to make things linearly separable does infact really makes sense because it helps in reducing the variance.
i'm currently studying machine learning and the same question popped to my mind. What I think the reason should be is that in every machine learning problem we assume we have abundant observational data available and whenever data tends to infinity it gets normally distributed around its mean and thats what Normal distribution(Gaussian Distribution) says. Although its not necessary that Gaussian DIstribution will always be a perfect fit to any data that tends to infinity like take a case when your data is always positive then you can easily see if you try to fit gaussian dist to it it will give some weight to negative values of x also(although negligible but still some weight is given) so in such case distribution like Zeta is more suited.
33,502,647
I have successfully generated EF classes for a remote MySQL database, with a resulting `.edmx`object that contains the `Context` and table-associated C# classes. I built the application and tried to add the EF classes as object data sources, but the wizard only displays the `Properties` namespace and its contents. [![DataSourceWizard](https://i.stack.imgur.com/H5bOj.png)](https://i.stack.imgur.com/H5bOj.png) The same happens when I tried writing a static property that uses the generated classes. The data source wizard doesn't display any other namespace. What am I missing? Thanks.
2015/11/03
[ "https://Stackoverflow.com/questions/33502647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/374253/" ]
Apparently there's a bug in Visual Studio. I reverted to .NET framework 4.5.2 from 4.6 and the data sources reappeared.
I had this problem and it turned out I had written my classes inside my entity framework class. It will let you do it and everything will work as normal, but these classes will not show up in the data source explorer.
33,502,647
I have successfully generated EF classes for a remote MySQL database, with a resulting `.edmx`object that contains the `Context` and table-associated C# classes. I built the application and tried to add the EF classes as object data sources, but the wizard only displays the `Properties` namespace and its contents. [![DataSourceWizard](https://i.stack.imgur.com/H5bOj.png)](https://i.stack.imgur.com/H5bOj.png) The same happens when I tried writing a static property that uses the generated classes. The data source wizard doesn't display any other namespace. What am I missing? Thanks.
2015/11/03
[ "https://Stackoverflow.com/questions/33502647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/374253/" ]
I had same problem. Tried everything, even changed default namespace. On the and it was that, that my project build platform target was x64, after changing that to Any CPU,a after build namespaces and classes reappeared. Regards!
I had this problem and it turned out I had written my classes inside my entity framework class. It will let you do it and everything will work as normal, but these classes will not show up in the data source explorer.
376,572
How electrical energy can be power over time when electrical energy is actually potential energy? from a lot of sources (wiki ,study.com..) comes the information that electric energy is potential or kinetic energy. In other sources is said to be electric power p x t so i am confused by this if anyone could explain to me what was right.
2017/12/27
[ "https://physics.stackexchange.com/questions/376572", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/179787/" ]
> > Would not air pressure keep the paper pressed against the book's cover? > > > To an extent, possibly. This is not the main reason why it is done though; although it does relate to your newspaper-ruler example. The reason would be to minimize the effects of air drag on the piece of paper. Although all objects influenced the same by gravity; they react differently with the air. A piece of paper would fall a lot slower than the book if they were both exposed to air drag. Instead; the piece of paper avoids the drag by travelling in the streamline of the book. Realistically, if the piece of paper were to fall slower than the book under the influence of gravity (due to lower mass) then even with the air pressure, it should still slowly separate from the book. (the reason the ruler breaks in the newspaper experiment is because you are trying to act against the pressure *very quickly*). Either way; this isn't really a great experiment to demonstrate how different masses react the same to gravitational force. Both the book and the paper have very large areas; therefore the drag force is substantial. To eliminate the drag force they set up the experiment in a way that pressure differences could keep the paper and the book falling with similar speeds, even if gravity was acting unevenly. Really, this test should be done in a vacuum to eliminate this source of potential error. It's a good sign that you can *recognize* this error in the experiment. Noticing details like this is important when designing good experiments.
The actual experiment was performed with a stone and a feather in two vacuum tubes of sane length. It was demonstrated that both the stone and the feather fall the same distance in the same time, which shows that the time if fall is independent of the masses of the body. In the experiment you stated, there may be chances of the book and the paper separating due to air interaction and upthrust. It has to be performed in a place where air is absolutely static, otherwise there may be chances of both separating. One may argue that atmospheric pressure keeps the book and the paper together. The argument is completely valid when you look at the experiment solely. But in the light of the actual experiment that I stated above, this argument is ignored, and it is generally taken that air pressure doesn't act on the two bodies.
6,740,655
I'm having a problem doing a request using Typhoeus as my query needs to have quotation marks into it. If the URl is ``` url = "http://app.com/method.json?'my_query'" ``` everything works fine. However, the method I'm trying to run only returns the results I want if the query is the following (i've tested it in browser): ``` url2 = "http://app.com/method.json?"my_query"" ``` When running ``` Typhoeus::Request.get(url2) ``` I get (URI::InvalidURIError) Escaping quotes with "\" does not work. How can I do this? Thanks
2011/07/18
[ "https://Stackoverflow.com/questions/6740655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/558452/" ]
You should be properly encoding your URI with [`URI.encode`](http://ruby-doc.org/stdlib/libdoc/uri/rdoc/classes/URI/Escape.html#M009396) or [`CGI.escape`](http://ruby-doc.org/stdlib/libdoc/cgi/rdoc/classes/CGI.html#M000093), doing so will get you proper URLs like this: ``` http://app.com/method.json?%27my_query%27 # Single quotes http://app.com/method.json?%22my_query%22 # Double quotes ```
Try: ``` require 'uri' URI.encode('"foo"') => "%22foo%22" ```
6,740,655
I'm having a problem doing a request using Typhoeus as my query needs to have quotation marks into it. If the URl is ``` url = "http://app.com/method.json?'my_query'" ``` everything works fine. However, the method I'm trying to run only returns the results I want if the query is the following (i've tested it in browser): ``` url2 = "http://app.com/method.json?"my_query"" ``` When running ``` Typhoeus::Request.get(url2) ``` I get (URI::InvalidURIError) Escaping quotes with "\" does not work. How can I do this? Thanks
2011/07/18
[ "https://Stackoverflow.com/questions/6740655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/558452/" ]
You should be properly encoding your URI with [`URI.encode`](http://ruby-doc.org/stdlib/libdoc/uri/rdoc/classes/URI/Escape.html#M009396) or [`CGI.escape`](http://ruby-doc.org/stdlib/libdoc/cgi/rdoc/classes/CGI.html#M000093), doing so will get you proper URLs like this: ``` http://app.com/method.json?%27my_query%27 # Single quotes http://app.com/method.json?%22my_query%22 # Double quotes ```
Passing json, quotes etc in GET request is tricky. In Ruby 2+ we can use Ruby's URI module's 'escape' method. ``` > URI.escape('http://app.com/method.json?agent={"account": {"homePage":"http://demo.my.com","name":"Senior Leadership"}}') ``` But I suggest use it as POST request and pass it as a message body.
29,952
I've not seen a lot of material on this. I've seen people attempting to bring a C++ program back to C++ code, and claiming how hard it is, but C code from C++ program? I don't know. If it is *possible,* what obstacles would be in the way? If *impossible,* what particular features make it so?
2022/01/29
[ "https://reverseengineering.stackexchange.com/questions/29952", "https://reverseengineering.stackexchange.com", "https://reverseengineering.stackexchange.com/users/40222/" ]
If you're asking whether it's possible for an automated decompiler to produce C code as output for a given C++ input binary (rather than producing C++ code as output), the answer is that most decompilers are going to do this anyway, and are not going to give you a choice as to which language they produce as output. Machine-code decompilers generally produce a C-like pseudocode, which, in general, cannot be immediately recompiled to C code. A better question would be "to what extent can the C-like pseudocode produced by decompilers represent features of C++ that are not in C", to which the answer depends on the specific decompiler in question. If you're asking whether it's possible to manually decompile a C++ program into a C program, the answer is yes. Just as you can take a program written in C++ and manually translate it into C, you can manually decompile a binary into any language you want. There's going to be a lot of manual work regardless of which language you choose to decompile the program into. Although C and C++ are not the same language, the first C++ compilers worked by translating C++ code into C code, and using a regular C compiler on the result (see: CFront <https://en.wikipedia.org/wiki/Cfront>). You can simulate most C++ constructs in C, although it's going to be a lot more work than simply taking advantage of the features introduced by C++.
Of course, yes. Here, the problem is that you need to know well about the difference between c and c++ from the viewpoint of reversing, I suppose. For example, the c++ classes is converted to assem codes like c structure, and the virtual table of a class is converted a first member of a structure and other functions is converted like a regular functions. And the pointer of c++ class is converted a certain register like a "ecx" register in x84 assem code. If you know somethings like this, you can decompile c++ program to c.
4
I am looking for a starting point for my project, preferably using popular systems (ones there is a lot of support for). I have an Arduino Uno, a Raspberry Pi, and a lot of willpower :) Anyone here built a project using the systems above? Observation: I'd like to start with a simple line-following vehicle and build up afterwards.
2012/10/23
[ "https://robotics.stackexchange.com/questions/4", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/32/" ]
The Arduino is really an AVR Atmega328p. The Arduino is a fine off-the-shelf implementation of this microcontroller, but if you make many of them, you can buy the chip for less than $3 each in bulk, and it requires very little circuitry to run on its own -- a crystal and a couple of capacitors to run at 20 Mhz, or not even that if you can run at the built-in 8 MHz resonant oscillator frequency. It's fine for generating control signals: Servo PWM, step/direction, control for H-bridges, etc.) It's also OK for running sensors: Ultrasonic time measurement, IR voltage conversion measurement, on/off contactors, etc -- this includes whatever optical sensor you'd use for "line sensing." There will be a little code space left over after doing these tasks, so the simple control loop of "is the line to the right, left, or center of me -> do the appropriate turn" can be built into that system. However, as soon as you want to do something bigger, like path planning, environmental awareness, memory, SLAM, etc, you will not be able to fit that into the Arduino. Thus, the best system for your requirements probably includes tying all the physical hardware to the Arduino, and then talking to the Arduino from the Raspberry Pi. The RPi has a modicum of CPU power (700 MHz ARM) and RAM (256-512 MB RAM) and thus can run higher-level control algorithms like path planning, localization, SLAM, etc. If you go with a bare AVR controller, there are UART outputs on the Raspberry Pi, but the problem is that the RPi is 3.3V and the Arduino Uno is 5V. Either go with a 3.3V Arduino version, or use a voltage divider to step down 5.0V output from the Arduino to the 3.3V input of the Raspberry Pi. I use a 2.2 kOhm high and 3.3 kOhm low resistor and it works fine. You can feed the 3V output from the Raspberry Pi directly into the RXD of the AVR, because it will treat anything at 1.2V or up as "high."
I built a line following robot with an Arduino before. It was really simple to do and all we used were color sensors on the bottom inputted in the Arduino, and then of course some motors for the wheels. But using an Arduino allowed us to have plenty of room for other components we wanted to add on to make our robot do more things. Also, if you want to see some line following code we used just ask in a comment, but it obviously depends on your setup with the sensors and how you want it to turn at intersections and things like that.
4
I am looking for a starting point for my project, preferably using popular systems (ones there is a lot of support for). I have an Arduino Uno, a Raspberry Pi, and a lot of willpower :) Anyone here built a project using the systems above? Observation: I'd like to start with a simple line-following vehicle and build up afterwards.
2012/10/23
[ "https://robotics.stackexchange.com/questions/4", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/32/" ]
If you want a line-following robot, then something similar to an [m3pi](http://mbed.org/cookbook/m3pi) would be achievable. Photo-transistors seem to be very effective with a black-on-white track. As for a microcontroller, Mario Markarian is probably right, it is down to personal preference and the project you are working on. The m3pi uses an [mbed](http://mbed.org/handbook/mbed-Microcontrollers) and has a lot of IO's to play with. For more advanced robots a raspberry pi or [beagleboard](http://mbed.org/handbook/mbed-Microcontrollers) work, interfaced with slave microcontroller(s) to provide sensor data and offloading any repetitive computations that could otherwise slow down the pi.
If you want to go further than using microcontrollers you could run ROS on you [Raspberry Pi](http://www.ros.org/wiki/ROSberryPi/Setting%20up%20ROS%20on%20RaspberryPi). I have build several robots and a couple of other projects using a [RoboCard](http://robocard.dk/) (site in Danish, but can [be translated](http://translate.google.com/translate?js=y&prev=_t&hl=en&ie=UTF-8&layout=1&eotf=1&u=http://robocard.dk/pages/home.php&sl=da&tl=en)). The RoboCard is build around an ATMega, so that certainly is a viable route.
4
I am looking for a starting point for my project, preferably using popular systems (ones there is a lot of support for). I have an Arduino Uno, a Raspberry Pi, and a lot of willpower :) Anyone here built a project using the systems above? Observation: I'd like to start with a simple line-following vehicle and build up afterwards.
2012/10/23
[ "https://robotics.stackexchange.com/questions/4", "https://robotics.stackexchange.com", "https://robotics.stackexchange.com/users/32/" ]
The Arduino is really an AVR Atmega328p. The Arduino is a fine off-the-shelf implementation of this microcontroller, but if you make many of them, you can buy the chip for less than $3 each in bulk, and it requires very little circuitry to run on its own -- a crystal and a couple of capacitors to run at 20 Mhz, or not even that if you can run at the built-in 8 MHz resonant oscillator frequency. It's fine for generating control signals: Servo PWM, step/direction, control for H-bridges, etc.) It's also OK for running sensors: Ultrasonic time measurement, IR voltage conversion measurement, on/off contactors, etc -- this includes whatever optical sensor you'd use for "line sensing." There will be a little code space left over after doing these tasks, so the simple control loop of "is the line to the right, left, or center of me -> do the appropriate turn" can be built into that system. However, as soon as you want to do something bigger, like path planning, environmental awareness, memory, SLAM, etc, you will not be able to fit that into the Arduino. Thus, the best system for your requirements probably includes tying all the physical hardware to the Arduino, and then talking to the Arduino from the Raspberry Pi. The RPi has a modicum of CPU power (700 MHz ARM) and RAM (256-512 MB RAM) and thus can run higher-level control algorithms like path planning, localization, SLAM, etc. If you go with a bare AVR controller, there are UART outputs on the Raspberry Pi, but the problem is that the RPi is 3.3V and the Arduino Uno is 5V. Either go with a 3.3V Arduino version, or use a voltage divider to step down 5.0V output from the Arduino to the 3.3V input of the Raspberry Pi. I use a 2.2 kOhm high and 3.3 kOhm low resistor and it works fine. You can feed the 3V output from the Raspberry Pi directly into the RXD of the AVR, because it will treat anything at 1.2V or up as "high."
You should use an ARM. Then you can run full linux or android and have access to powerful libraries, high-level functional languages, and a package manager and community. You can use gcc or LLVM, and a modern debugger like gdb. ARMs used to be too expensive and/or too big, but nowadays you can get an ARM for $5 that's only 13x13 mm. You have to use reflow soldering, but you will anyways if you want to make a professional-quality robot. <http://www.eetimes.com/electronics-products/electronic-product-reviews/processors/4230227/TI-debuts--5-Sitara-AM335x-ARM-processors> All other instructions sets have lost the competition. If you pick something like AVR, you will be forever stuck with inferior toolchains, weaker MIPS/dollar, and a much smaller community. If you don't want to engineer the whole motherboard, then Gumstix, BeagleBone, BeagleBoard, and Raspberry Pi are all excellent pre-existing ARM-based devkits, and processor vendors also offer a devkit for every processor they make, bringing out at least a display bus and some serial busses.