qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
114,106
**Context:** I'm currently helping out my friend, who is full on into creating his own cryptocurrencies business, by creating simple landing pages for him, installing WordPress, etc. As we are friends (not that close but still), we do not have any contract or anything written down on paper. **Problem:** Once we decide on the payment for the work I'll be doing for him, I do my part and deliver the code or whatever it is. He often stresses how much time is important to him and asks me to do my work as fast as I can (I'm working a regular job and helping him after hours, which he is aware of). But then, when I deliver, he makes me wait for the payment for weeks. His explanation is usually something along the lines of: > > As you know I keep most of my funds in cryptocurrencies, so often it's not that easy to just get the money out. You wouldn't understand how complex the process is as you do not do that yourself and I'm also very busy with complex market analysis. > > > I already confronted him once and asked him to decide on some fixed date on which I can expect my payment when we discuss any new work, so that I can plan my expenses accordingly - even if that would take a bit of time because of him keeping money in whatever places. He got very agitated and started asking me if I don't trust him and telling me he always keeps his word but I didn't get any unequivocal response. It's hard for me to believe that it always takes him so long to get money. He lives in a nice big house and has a wife and a kid, so I'd imagine he has plenty of expenses during the month - both expected and unexpected. What is more, very recently I started working on a new website and we both agreed on a payment which is considerably higher than the previous ones. A few days into the project, he told me he gave my phone number to his business manager who will contact me from now on as he is very busy an doesn't have much time, implying that from now on we won't be discussing project details directly. I'm slowly losing my trust in him and I'm worried about receiving my payment in any reasonable amount of time, if at all. **Question:** What can I do to make sure I will get paid in a reasonable amount of time? I get the feeling he is very sensitive about this topic. Even though our cooperation isn't going very smoothly, I'd prefer to stay on a good terms with him and possibly work together again in the future, but I'm ready to drop the cooperation if necessary.
2018/06/15
[ "https://workplace.stackexchange.com/questions/114106", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/88149/" ]
Friendship stops when business is involved. His excuses don’t matter even if true. If he can’t find the money to pay you, that’s his problem, not yours. So you should insist on prompt payment, and because of the payment history ask for cash on delivery for your next bit of work. And of course he is sensitive about the topic because it involves giving his money to you. That’s his problem.
Business is business, friendship is friendship. Don't mix them up. You do the work for him. You get paid from him. Simple as that. The things you need to do? Get him sign a contract which states the rate, how much time you work every week, when you get paid after delivery, etc. **Insist on** him signing the contract before continue the work. If you don't get a contract before continuing, I am afraid you'll lose both the pay/time and the friendship. Many small business/startup run by friends failed the way you described in your question.
12,087,152
Trying to get the results of one query into the `WHERE` statement of another: ``` $query1 = "SELECT DISTINCT company_id FROM location WHERE state = 'XX'"; $result1 = mysql_query($query1) or die(mysql_error()); while($row1 = mysql_fetch_array($result1)) { //Collect WHERE STATEMENT HERE } ``` I've tried the following: ``` $q1 = "SELECT company FROM company WHERE id = '16', id = '7' ORDER BY company"; $q1 = "SELECT company FROM company WHERE id = '16' AND id = '7' ORDER BY company"; $q1 = "SELECT company FROM company WHERE id = '16' && id = '7' ORDER BY company"; ``` Along with other variations Googling has only provided multiple `WHERE AND` if using different table names, but not the same. Anyone have any pointers?
2012/08/23
[ "https://Stackoverflow.com/questions/12087152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/987329/" ]
You could also use `IN`: ``` $x = array('16', '7'); $q1 = "SELECT company FROM company WHERE id IN(". implode(',', $x) .") ORDER BY company"; ```
use `OR` ``` $q1 = "SELECT company FROM company WHERE (id = '16' OR id = '7') ORDER BY company"; ```
12,087,152
Trying to get the results of one query into the `WHERE` statement of another: ``` $query1 = "SELECT DISTINCT company_id FROM location WHERE state = 'XX'"; $result1 = mysql_query($query1) or die(mysql_error()); while($row1 = mysql_fetch_array($result1)) { //Collect WHERE STATEMENT HERE } ``` I've tried the following: ``` $q1 = "SELECT company FROM company WHERE id = '16', id = '7' ORDER BY company"; $q1 = "SELECT company FROM company WHERE id = '16' AND id = '7' ORDER BY company"; $q1 = "SELECT company FROM company WHERE id = '16' && id = '7' ORDER BY company"; ``` Along with other variations Googling has only provided multiple `WHERE AND` if using different table names, but not the same. Anyone have any pointers?
2012/08/23
[ "https://Stackoverflow.com/questions/12087152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/987329/" ]
for a generalized code : ``` $ids = array ( [0] => 2 [1] => 4 [2] => 19 [3] => 16 ); $ids = join(',',$ids); $sql = "SELECT * FROM company WHERE id IN ($ids)"; ``` reffer : [same example](https://stackoverflow.com/questions/907806/php-mysql-using-an-array-in-where-clause)
use `OR` ``` $q1 = "SELECT company FROM company WHERE (id = '16' OR id = '7') ORDER BY company"; ```
12,087,152
Trying to get the results of one query into the `WHERE` statement of another: ``` $query1 = "SELECT DISTINCT company_id FROM location WHERE state = 'XX'"; $result1 = mysql_query($query1) or die(mysql_error()); while($row1 = mysql_fetch_array($result1)) { //Collect WHERE STATEMENT HERE } ``` I've tried the following: ``` $q1 = "SELECT company FROM company WHERE id = '16', id = '7' ORDER BY company"; $q1 = "SELECT company FROM company WHERE id = '16' AND id = '7' ORDER BY company"; $q1 = "SELECT company FROM company WHERE id = '16' && id = '7' ORDER BY company"; ``` Along with other variations Googling has only provided multiple `WHERE AND` if using different table names, but not the same. Anyone have any pointers?
2012/08/23
[ "https://Stackoverflow.com/questions/12087152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/987329/" ]
for a generalized code : ``` $ids = array ( [0] => 2 [1] => 4 [2] => 19 [3] => 16 ); $ids = join(',',$ids); $sql = "SELECT * FROM company WHERE id IN ($ids)"; ``` reffer : [same example](https://stackoverflow.com/questions/907806/php-mysql-using-an-array-in-where-clause)
You could also use `IN`: ``` $x = array('16', '7'); $q1 = "SELECT company FROM company WHERE id IN(". implode(',', $x) .") ORDER BY company"; ```
24,936,314
I am trying to import a large database into my WAMP 2.5 server phpmyadmin. After importing some tables an error occurs: > > Fatal error: Maximum execution time of 360 seconds exceeded in C:\wamp\apps\phpmyadmin4.1.14\libraries\dbi\DBIMysqli.class.php on line 285 > > > and the importing process is stopped. I have already increased `max_execution_time` in my php.ini file. Can anyone help me resolve this problem?
2014/07/24
[ "https://Stackoverflow.com/questions/24936314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3336980/" ]
Don't modify the `php.ini` file ! Modify the **alias of the phpMyAdmin** file : `J:\wamp\alias\phpmyadmin.conf` Before the line `</Directory>`, you can describe what you want : ``` php_admin_value upload_max_filesize 128M php_admin_value post_max_size 128M php_admin_value max_execution_time 360 php_admin_value max_input_time 360 </Directory> ``` You can change the **values of time or size as you want**.
Although strongly not recommended, you can remove the maximum script run-time restriction by setting `max_execution_time` to zero: <http://php.net/manual/en/info.configuration.php#ini.max-execution-time> If there's a more reliable way for you to get the file onto the server (SFTP?) I would suggest you try that first.
24,936,314
I am trying to import a large database into my WAMP 2.5 server phpmyadmin. After importing some tables an error occurs: > > Fatal error: Maximum execution time of 360 seconds exceeded in C:\wamp\apps\phpmyadmin4.1.14\libraries\dbi\DBIMysqli.class.php on line 285 > > > and the importing process is stopped. I have already increased `max_execution_time` in my php.ini file. Can anyone help me resolve this problem?
2014/07/24
[ "https://Stackoverflow.com/questions/24936314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3336980/" ]
You can also forget about phpMyAdmin completely and use the `mysql console` Using the wampmanager icon menus do the following :- ``` left click wampmanager -> MySQL -> MySQL Console ``` If you have changed the password for the root userid enter that when challenged or if you have not changed it just hit enter. Make sure there is a `USE databasename` in the backup file, if not enter it manually now and then use the `source` command to run the restore from your backup file. i.e. ``` USE YourDatabase; SOURCE C:/path/to/backup/file.sql; ``` Note the use of UNIX directory seperators even though you are on windows. This tool has no time limitations as its not a PHP script, and will run to the end of your backup with no issues.
Although strongly not recommended, you can remove the maximum script run-time restriction by setting `max_execution_time` to zero: <http://php.net/manual/en/info.configuration.php#ini.max-execution-time> If there's a more reliable way for you to get the file onto the server (SFTP?) I would suggest you try that first.
24,936,314
I am trying to import a large database into my WAMP 2.5 server phpmyadmin. After importing some tables an error occurs: > > Fatal error: Maximum execution time of 360 seconds exceeded in C:\wamp\apps\phpmyadmin4.1.14\libraries\dbi\DBIMysqli.class.php on line 285 > > > and the importing process is stopped. I have already increased `max_execution_time` in my php.ini file. Can anyone help me resolve this problem?
2014/07/24
[ "https://Stackoverflow.com/questions/24936314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3336980/" ]
Don't modify the `php.ini` file ! Modify the **alias of the phpMyAdmin** file : `J:\wamp\alias\phpmyadmin.conf` Before the line `</Directory>`, you can describe what you want : ``` php_admin_value upload_max_filesize 128M php_admin_value post_max_size 128M php_admin_value max_execution_time 360 php_admin_value max_input_time 360 </Directory> ``` You can change the **values of time or size as you want**.
You can also forget about phpMyAdmin completely and use the `mysql console` Using the wampmanager icon menus do the following :- ``` left click wampmanager -> MySQL -> MySQL Console ``` If you have changed the password for the root userid enter that when challenged or if you have not changed it just hit enter. Make sure there is a `USE databasename` in the backup file, if not enter it manually now and then use the `source` command to run the restore from your backup file. i.e. ``` USE YourDatabase; SOURCE C:/path/to/backup/file.sql; ``` Note the use of UNIX directory seperators even though you are on windows. This tool has no time limitations as its not a PHP script, and will run to the end of your backup with no issues.
4,382
The concept of attachment and different attachment styles has a long tradition in developmental psychology. Mary Ainsworth developed a classification for three different attachment styles that she called *secure*, *insecure-resistant* or synonymously *insecure-ambivalent* and finally *insecure-avoidant* (Main, 1996). Assessment of these styles is done with the [Strange-Situation-Test](http://en.wikipedia.org/wiki/Attachment_measures#The_Strange_Situation). Later, a fourth style called *insecure-disorganized-disoriented* was introduced to account for a number of children that would not have been classifiable otherwise (Main & Solomon, 1990). A corresponding classification has also been developed for attachment styles in adults. The four styles here are called *secure-autonomous*, *dismissing*, *preoccupied* and *unresolved-disorganized* (Main, 1996). Assessment is done using the [Adult Attachement Interview](http://en.wikipedia.org/wiki/Attachment_measures#Adult_Attachment_Interview_.28AAI.29). Recently I have read a couple of papers that investigate the association between attachment styles and various forms of stress reactivity, that used the terms *attachment anxiety* and *attachment avoidance* (Selcuk et al., 2012; Ben-Naim et al., 2013; Ein-Dor et al., 2011). The authors explain what is meant by these terms. Those two *attachment orientations* as they are called are asses with the *Experience in Close Relationships Scales* (ECR, Fraley et al., 2000). I am confused as to how these terms fit into the picture of the attachment styles. **Is this another classification of attachement styles?** References: Ben-Naim, S., Hirschberger, G., Ein-Dor, T., & Mikulincer, M. (2013). An experimental study of emotion regulation during relationship conflict interactions: The moderating role of attachment orientations. Emotion, 13(3), 506–519. doi:10.1037/a0031473 Ein-Dor, T., Mikulincer, M., & Shaver, P. R. (2011). Attachment insecurities and the processing of threat-related information: Studying the schemas involved in insecure people’s coping strategies. Journal of Personality and Social Psychology, 101(1), 78–93. doi:10.1037/a0022503 [PDF](http://www.researchgate.net/publication/50224821_Attachment_insecurities_and_the_processing_of_threat-related_information_Studying_the_schemas_involved_in_insecure_people%27s_coping_strategies/file/d922b4f572beebae86.pdf) Fraley, R. C., Waller, N. G., & Brennan, K. A. (2000). An item response theory analysis of self-report measures of adult attachment. Journal of Personality and Social Psychology, 78, 350–365. doi:10.1037/0022- 3514.78.2.350 [PDF](http://www.web-research-design.net/PDF/FW%26B2000.pdf) Main, M. (1996). Introduction to the special section on attachment and psychopathology: 2. Overview of the field of attachment. Journal of consulting and clinical psychology, 64(2), 237. Main, M., & Solomon, J. (1990). Procedures for identifying infants as disorganized/disoriented during the Ainsworth Strange Situation. Attachment in the preschool years: Theory, research, and intervention, 1, 121–160. Selcuk, E., Zayas, V., Günaydin, G., Hazan, C., & Kross, E. (2012). Mental representations of attachment figures facilitate recovery following upsetting autobiographical memory recall. Journal of Personality and Social Psychology, 103(2), 362–378. doi:10.1037/a0028125 [PDF](http://selfcontrol.psych.lsa.umich.edu/papers/SelcukZayasGunaydinHazanKross12.pdf)
2013/08/23
[ "https://cogsci.stackexchange.com/questions/4382", "https://cogsci.stackexchange.com", "https://cogsci.stackexchange.com/users/695/" ]
**Background:** There is abundant research linking childhood attachment styles and adult attachment styles. This doesn't mean that an individual's attachment style is set in stone for life; it is a good indicator of how a child will fare as an adult. **The advent of Attachment theory:** [A Brief Overview of Adult Attachment Theory and Research](http://internal.psychology.illinois.edu/~rcfraley/attachment.htm) R. Chris Fraley | University of Illinois > > ... Bowlby postulated that these attachment behaviors, such as crying and searching, were adaptive responses to separation from with a primary attachment figure--someone who provides support, protection, and care. Because human infants, like other mammalian infants, cannot feed or protect themselves, they are dependent upon the care and protection of "older and wiser" adults. Bowlby argued that, over the course of evolutionary history, infants who were able to maintain proximity to an attachment figure via attachment behaviors would be more likely to survive to a reproductive age. According to Bowlby, a motivational system, what he called the attachment behavioral system, was gradually "designed" by natural selection to regulate proximity to an attachment figure. > > > John Bowlby was the father of Attachment Theory; Mary Ainsworth tested and developed this theory. > > ... John Bowlby formulated the basic tenets of > the theory. ... > > Mary Ainsworth’s innovative > methodology not only made it possible to test some of Bowlby’s ideas empirically hut also > helped expand the theory itself and is responsible for some of the new directions it is now > taking. > > > [THE ORIGINS OF ATTACHMENT THEORY](http://www.psychology.sunysb.edu/attachment/online/inge_origins.pdf): JOHN BOWLBY AND MARY AINSWORTH, INGE BRETHERTON Developmental Psychology (1992), 28, 759-775. John Bowlby - [Attachment Theory](http://psychology.about.com/od/loveandattraction/ss/attachmentstyle.htm) It is difficult to separate more recent attachment theory from its progenitor; as this is the source from which all attachment theory has evolved. --- **Attachment style categorisation:** Any style of attachment, that is not a healthy or **secure attachment style** is classified as an **insecure attachment style** or an **attachment disorder.** This [answer here](https://cogsci.stackexchange.com/a/4492/3267) addresses attachment disorders, in particular, ambivalent attachment disorder in detail. Maryland's Source for [Attachment Disorder Related Information](http://www.attachmentdisordermaryland.com/subtypes.htm) *Note I've added bold for emphasis.* > > **AVOIDANT ATTACHMENT DISORDER** > > > The predominant emotion internally, in Avoidant AD {AvAD} children is sadness. However, the world sees little or none of their sadness. AvAD children believe their sadness is infinite, and should they lapse into it, they see no exit. Hence, they go to extraordinary lengths to avoid any expression of it, and usually effectively shield themselves from even recognizing their sadness. Their internal shields work so well that they often truly do not think they are sad. What AvAD children do feel is an anxious edge in quieter moments. They rarely relax, lest their sadness “creep up” on them. Their hypervigilance is more about deflecting anything that might activate their sadness rather than simply scanning for direct hostile threats. As physical / emotional closeness carries a high potential for triggering their sadness, AvAD children avoid it. Attitudinally, AvAD children are contemptuous of sadness- they define it as the “stuff of sissies”. AvAD children present themselves as omnipotent and without need for others. About half of these children lie somewhere along the spectrum of depressive disorders. > > > **ANXIOUS ATTACHMENT DISORDER** > > > The primary emotion Anxious AD {AxAD} children feel is **anxiety** ... > > > **DISORGANIZED ATTACHMENT DISORDER** > > > The characteristic emotion of children with Disorganized Attachment Disorder {DAD} is overwhelming and unmanageable **anxiety**. > > > **A cross over of avoidance and anxiety attachment disorders:** > > **[AMBIVALENT ATTACHMENT DISORDER](https://cogsci.stackexchange.com/a/4492/3267)** > > > *Note: my answer gives a more comprehensive overview of Ambivalent Attachment Disorder and how it is classified as an Reactive Attachment Disorder.* > > [Reactive attachment disorder](http://rad.disorder-symptoms.com/) > > > **What is reactive attachment disorder?** > > > In reactive attachment disorder, DSM-IV considers two basic types of behavior. Representative of the hindered type of attachment disorder, is a child who “constantly refuses to initiate or respond to social activity, as it is expected of children in his age and level of development. It’s expressed in too depressed, too sensitive or highly controversial reaction, for example, a child may respond differently to the teacher: to avoid and refuse caress or to express increased vigilance (“frozen vigilance”). > > > [Highlights of Changes from DSM-IV-TR to DSM-5](http://www.dsm5.org/Documents/changes%20from%20dsm-iv-tr%20to%20dsm-5.pdf) > > **Reactive Attachment Disorder** > > The DSM-IV childhood diagnosis reactive attachment disorder had two subtypes: emotionally withdrawn/inhibited and indiscriminately social/disinhibited. In DSM-5, these subtypes are defined as > distinct disorders: reactive attachment disorder and disinhibited social engagement disorder. Both of > these disorders are the result of social neglect or other situations that limit a young child’s opportunity > to form selective attachments. Although sharing this etiological pathway, the two disorders differ in > important ways. Because of dampened positive affect, reactive attachment disorder more closely resembles internalizing disorders; it is essentially equivalent to a lack of or incompletely formed preferred > attachments to caregiving adults. In contrast, disinhibited social engagement disorder more closely > resembles ADHD; it may occur in children who do not necessarily lack attachments and may have established or even secure attachments. The two disorders differ in other important ways, including correlates, course, and response to intervention, and for these reasons are considered separate disorders > > > --- [A Brief Overview of Adult Attachment Theory and Research](http://internal.psychology.illinois.edu/~rcfraley/attachment.htm) R. Chris Fraley | University of Illinois > > Recent research on adult attachment has revealed some interesting complexities concerning the relationships between avoidance and defense. Although some avoidant adults, often called fearfully-avoidant adults, are poorly adjusted despite their defensive nature, others, often called dismissing-avoidant adults, are able to use defensive strategies in an adaptive way. For example, in an experimental task in which adults were instructed to discuss losing their partner, Fraley and Shaver (1997) found that dismissing individuals (i.e., individuals who are high on the dimension of attachment-related avoidance but low on the dimension of attachment-related anxiety) were just as physiologically distressed (as assessed by skin conductance measures) as other individuals. When instructed to suppress their thoughts and feelings, however, dismissing individuals were able to do so effectively. That is, they could deactivate their physiological arousal to some degree and minimize the attention they paid to attachment-related thoughts. Fearfully-avoidant individuals were not as successful in suppressing their emotions. > > > This figure from Attachment as an [Organizational Framework for Research on Close Relationships](http://www.psy.miami.edu/faculty/dmessinger/c_c/rsrcs/rdgs/attach/hazanandshaver.pdf) Cindy Hazan Cornell University, Phillip R. Shaver University of California, Davis; shows the basis of cause and effect underlying attachment. ![Attachment model](https://i.stack.imgur.com/SFQWQ.png) **Attachment anxiety and attachment avoidance.** This figure shows how this cause and effect is classified into attachment styles. Defensiveness leading to avoidance, fear leading to anxiety. ![Attachment model2](https://i.stack.imgur.com/FDdDw.png) **Attachment orientations** This figure taken from A Brief Overview of Adult Attachment Theory and Research gives a nice representation of how defensiveness and fear translate into attachment styles or attachment orientations. ![Chart](https://i.stack.imgur.com/0l0QH.jpg) These diagrams also give a good representation of childhood cause and adult attachment style affect. ![secure](https://i.stack.imgur.com/hh7pF.jpg)![ambivalent](https://i.stack.imgur.com/4bYQn.jpg) ![avoidant](https://i.stack.imgur.com/WilGn.jpg)![disorganised](https://i.stack.imgur.com/WfzAz.jpg) images courtesy of [Attachment Styles](http://psychology.about.com/od/loveandattraction/ss/attachmentstyle.htm) By Kendra Cherry, About.com Guide [The Experiences in Close Relationships-Revised](http://internal.psychology.illinois.edu/~rcfraley/measures/ecrritems.htm) (ECR-R) Questionnaire Fraley, Waller, and Brennan (2000) - *Iive added emphasis within this quote.* > > Scoring Information: The first 18 items listed below comprise the **attachment-related anxiety scale**. Items 19 – 36 comprise the **attachment-related avoidance scale**. In real research, the order in which these items are presented should be randomized. Each item is rated on a 7-point scale where 1 = strongly disagree and 7 = strongly agree. **To obtain a score for attachment-related anxiety**, please average a person’s responses to items 1 – 18. However, because items 9 and 11 are “reverse keyed” (i.e., high numbers represent low anxiety rather than high anxiety), you’ll need to reverse the answers to those questions before averaging the responses. (If someone answers with a “6” to item 9, you’ll need to re-key it as a 2 before averaging.) **To obtain a score for attachment-related avoidance**, please average a person’s responses to items 19 – 36. Items 20, 22, 26, 27, 28, 29, 30, 31, 33, 34, 35, and 36 will need to be reverse keyed before you compute this average. > > >
In the [introduction](http://scielo.isciii.es/scielo.php?pid=S0213-61632006000400006&script=sci_arttext) to their study, Conradi et al. (2006) give a brief and very good overview over the different approaches to classify and measure attachment styles. I encourage everyone, who is interested in the subject to read it. However, since it is the answer to my question, I will summarise it here. As I said in [my question](https://cogsci.stackexchange.com/questions/4382/classification-of-attachment-styles), research on attachment styles started with the classification by Ainsworth and Main, who were concerned with the infant-caregiver relationship. Later, an adult attachment focus was established by Hazan and Shaver. The paper then goes on to say that "after that, a bewildering variety of adult attachment typologies, adult attachment-related constructs, and measurement instruments" were developed. Within the adult attachment tradition, Bartholomew then "returned to Bowlby's original conceptualization of two working models", the *model of self* and the *model of other*. From these two bi-polar dimensions, the four attachment styles I mentioned in my question emerge. Brennan and collegues "collected all adult attachment self-report scales known at that time", administered them to a sample of 1086 psychology students and found two underlying factors, which they call *attachment avoidance* and *attachment anxiety*. The 18 items with the highest loadings on each of the two factors were the combined to two subscales which form the *Experiences in Close Relationships Questionaire (ECR)*. So, yes, the distinction between *attachment avoidance* and *attachment anxiety* is a different way of of studying attachment. The ECR (or the revised versions of it) seems to be a promising method for further study, because, as Fraley et al. (2000) mention, research has not supported a categorial model of attachment styles. References: Jan Conradi, H., Gerlsma, C., Duijn, M. V., & Jonge, P. D. (2006). Internal and external validity of the experiences in close relationships questionnaire in an American and two Dutch samples. *The European journal of psychiatry, 20(4)*, 258-269. [HTML](http://scielo.isciii.es/scielo.php?pid=S0213-61632006000400006&script=sci_arttext) Fraley, R. C., Waller, N. G., & Brennan, K. A. (2000). An item response theory analysis of self-report measures of adult attachment. *Journal of Personality and Social Psychology, 78,* 350–365. doi:10.1037/0022- 3514.78.2.350 [PDF](http://www.web-research-design.net/PDF/FW%26B2000.pdf)
4,382
The concept of attachment and different attachment styles has a long tradition in developmental psychology. Mary Ainsworth developed a classification for three different attachment styles that she called *secure*, *insecure-resistant* or synonymously *insecure-ambivalent* and finally *insecure-avoidant* (Main, 1996). Assessment of these styles is done with the [Strange-Situation-Test](http://en.wikipedia.org/wiki/Attachment_measures#The_Strange_Situation). Later, a fourth style called *insecure-disorganized-disoriented* was introduced to account for a number of children that would not have been classifiable otherwise (Main & Solomon, 1990). A corresponding classification has also been developed for attachment styles in adults. The four styles here are called *secure-autonomous*, *dismissing*, *preoccupied* and *unresolved-disorganized* (Main, 1996). Assessment is done using the [Adult Attachement Interview](http://en.wikipedia.org/wiki/Attachment_measures#Adult_Attachment_Interview_.28AAI.29). Recently I have read a couple of papers that investigate the association between attachment styles and various forms of stress reactivity, that used the terms *attachment anxiety* and *attachment avoidance* (Selcuk et al., 2012; Ben-Naim et al., 2013; Ein-Dor et al., 2011). The authors explain what is meant by these terms. Those two *attachment orientations* as they are called are asses with the *Experience in Close Relationships Scales* (ECR, Fraley et al., 2000). I am confused as to how these terms fit into the picture of the attachment styles. **Is this another classification of attachement styles?** References: Ben-Naim, S., Hirschberger, G., Ein-Dor, T., & Mikulincer, M. (2013). An experimental study of emotion regulation during relationship conflict interactions: The moderating role of attachment orientations. Emotion, 13(3), 506–519. doi:10.1037/a0031473 Ein-Dor, T., Mikulincer, M., & Shaver, P. R. (2011). Attachment insecurities and the processing of threat-related information: Studying the schemas involved in insecure people’s coping strategies. Journal of Personality and Social Psychology, 101(1), 78–93. doi:10.1037/a0022503 [PDF](http://www.researchgate.net/publication/50224821_Attachment_insecurities_and_the_processing_of_threat-related_information_Studying_the_schemas_involved_in_insecure_people%27s_coping_strategies/file/d922b4f572beebae86.pdf) Fraley, R. C., Waller, N. G., & Brennan, K. A. (2000). An item response theory analysis of self-report measures of adult attachment. Journal of Personality and Social Psychology, 78, 350–365. doi:10.1037/0022- 3514.78.2.350 [PDF](http://www.web-research-design.net/PDF/FW%26B2000.pdf) Main, M. (1996). Introduction to the special section on attachment and psychopathology: 2. Overview of the field of attachment. Journal of consulting and clinical psychology, 64(2), 237. Main, M., & Solomon, J. (1990). Procedures for identifying infants as disorganized/disoriented during the Ainsworth Strange Situation. Attachment in the preschool years: Theory, research, and intervention, 1, 121–160. Selcuk, E., Zayas, V., Günaydin, G., Hazan, C., & Kross, E. (2012). Mental representations of attachment figures facilitate recovery following upsetting autobiographical memory recall. Journal of Personality and Social Psychology, 103(2), 362–378. doi:10.1037/a0028125 [PDF](http://selfcontrol.psych.lsa.umich.edu/papers/SelcukZayasGunaydinHazanKross12.pdf)
2013/08/23
[ "https://cogsci.stackexchange.com/questions/4382", "https://cogsci.stackexchange.com", "https://cogsci.stackexchange.com/users/695/" ]
**Background:** There is abundant research linking childhood attachment styles and adult attachment styles. This doesn't mean that an individual's attachment style is set in stone for life; it is a good indicator of how a child will fare as an adult. **The advent of Attachment theory:** [A Brief Overview of Adult Attachment Theory and Research](http://internal.psychology.illinois.edu/~rcfraley/attachment.htm) R. Chris Fraley | University of Illinois > > ... Bowlby postulated that these attachment behaviors, such as crying and searching, were adaptive responses to separation from with a primary attachment figure--someone who provides support, protection, and care. Because human infants, like other mammalian infants, cannot feed or protect themselves, they are dependent upon the care and protection of "older and wiser" adults. Bowlby argued that, over the course of evolutionary history, infants who were able to maintain proximity to an attachment figure via attachment behaviors would be more likely to survive to a reproductive age. According to Bowlby, a motivational system, what he called the attachment behavioral system, was gradually "designed" by natural selection to regulate proximity to an attachment figure. > > > John Bowlby was the father of Attachment Theory; Mary Ainsworth tested and developed this theory. > > ... John Bowlby formulated the basic tenets of > the theory. ... > > Mary Ainsworth’s innovative > methodology not only made it possible to test some of Bowlby’s ideas empirically hut also > helped expand the theory itself and is responsible for some of the new directions it is now > taking. > > > [THE ORIGINS OF ATTACHMENT THEORY](http://www.psychology.sunysb.edu/attachment/online/inge_origins.pdf): JOHN BOWLBY AND MARY AINSWORTH, INGE BRETHERTON Developmental Psychology (1992), 28, 759-775. John Bowlby - [Attachment Theory](http://psychology.about.com/od/loveandattraction/ss/attachmentstyle.htm) It is difficult to separate more recent attachment theory from its progenitor; as this is the source from which all attachment theory has evolved. --- **Attachment style categorisation:** Any style of attachment, that is not a healthy or **secure attachment style** is classified as an **insecure attachment style** or an **attachment disorder.** This [answer here](https://cogsci.stackexchange.com/a/4492/3267) addresses attachment disorders, in particular, ambivalent attachment disorder in detail. Maryland's Source for [Attachment Disorder Related Information](http://www.attachmentdisordermaryland.com/subtypes.htm) *Note I've added bold for emphasis.* > > **AVOIDANT ATTACHMENT DISORDER** > > > The predominant emotion internally, in Avoidant AD {AvAD} children is sadness. However, the world sees little or none of their sadness. AvAD children believe their sadness is infinite, and should they lapse into it, they see no exit. Hence, they go to extraordinary lengths to avoid any expression of it, and usually effectively shield themselves from even recognizing their sadness. Their internal shields work so well that they often truly do not think they are sad. What AvAD children do feel is an anxious edge in quieter moments. They rarely relax, lest their sadness “creep up” on them. Their hypervigilance is more about deflecting anything that might activate their sadness rather than simply scanning for direct hostile threats. As physical / emotional closeness carries a high potential for triggering their sadness, AvAD children avoid it. Attitudinally, AvAD children are contemptuous of sadness- they define it as the “stuff of sissies”. AvAD children present themselves as omnipotent and without need for others. About half of these children lie somewhere along the spectrum of depressive disorders. > > > **ANXIOUS ATTACHMENT DISORDER** > > > The primary emotion Anxious AD {AxAD} children feel is **anxiety** ... > > > **DISORGANIZED ATTACHMENT DISORDER** > > > The characteristic emotion of children with Disorganized Attachment Disorder {DAD} is overwhelming and unmanageable **anxiety**. > > > **A cross over of avoidance and anxiety attachment disorders:** > > **[AMBIVALENT ATTACHMENT DISORDER](https://cogsci.stackexchange.com/a/4492/3267)** > > > *Note: my answer gives a more comprehensive overview of Ambivalent Attachment Disorder and how it is classified as an Reactive Attachment Disorder.* > > [Reactive attachment disorder](http://rad.disorder-symptoms.com/) > > > **What is reactive attachment disorder?** > > > In reactive attachment disorder, DSM-IV considers two basic types of behavior. Representative of the hindered type of attachment disorder, is a child who “constantly refuses to initiate or respond to social activity, as it is expected of children in his age and level of development. It’s expressed in too depressed, too sensitive or highly controversial reaction, for example, a child may respond differently to the teacher: to avoid and refuse caress or to express increased vigilance (“frozen vigilance”). > > > [Highlights of Changes from DSM-IV-TR to DSM-5](http://www.dsm5.org/Documents/changes%20from%20dsm-iv-tr%20to%20dsm-5.pdf) > > **Reactive Attachment Disorder** > > The DSM-IV childhood diagnosis reactive attachment disorder had two subtypes: emotionally withdrawn/inhibited and indiscriminately social/disinhibited. In DSM-5, these subtypes are defined as > distinct disorders: reactive attachment disorder and disinhibited social engagement disorder. Both of > these disorders are the result of social neglect or other situations that limit a young child’s opportunity > to form selective attachments. Although sharing this etiological pathway, the two disorders differ in > important ways. Because of dampened positive affect, reactive attachment disorder more closely resembles internalizing disorders; it is essentially equivalent to a lack of or incompletely formed preferred > attachments to caregiving adults. In contrast, disinhibited social engagement disorder more closely > resembles ADHD; it may occur in children who do not necessarily lack attachments and may have established or even secure attachments. The two disorders differ in other important ways, including correlates, course, and response to intervention, and for these reasons are considered separate disorders > > > --- [A Brief Overview of Adult Attachment Theory and Research](http://internal.psychology.illinois.edu/~rcfraley/attachment.htm) R. Chris Fraley | University of Illinois > > Recent research on adult attachment has revealed some interesting complexities concerning the relationships between avoidance and defense. Although some avoidant adults, often called fearfully-avoidant adults, are poorly adjusted despite their defensive nature, others, often called dismissing-avoidant adults, are able to use defensive strategies in an adaptive way. For example, in an experimental task in which adults were instructed to discuss losing their partner, Fraley and Shaver (1997) found that dismissing individuals (i.e., individuals who are high on the dimension of attachment-related avoidance but low on the dimension of attachment-related anxiety) were just as physiologically distressed (as assessed by skin conductance measures) as other individuals. When instructed to suppress their thoughts and feelings, however, dismissing individuals were able to do so effectively. That is, they could deactivate their physiological arousal to some degree and minimize the attention they paid to attachment-related thoughts. Fearfully-avoidant individuals were not as successful in suppressing their emotions. > > > This figure from Attachment as an [Organizational Framework for Research on Close Relationships](http://www.psy.miami.edu/faculty/dmessinger/c_c/rsrcs/rdgs/attach/hazanandshaver.pdf) Cindy Hazan Cornell University, Phillip R. Shaver University of California, Davis; shows the basis of cause and effect underlying attachment. ![Attachment model](https://i.stack.imgur.com/SFQWQ.png) **Attachment anxiety and attachment avoidance.** This figure shows how this cause and effect is classified into attachment styles. Defensiveness leading to avoidance, fear leading to anxiety. ![Attachment model2](https://i.stack.imgur.com/FDdDw.png) **Attachment orientations** This figure taken from A Brief Overview of Adult Attachment Theory and Research gives a nice representation of how defensiveness and fear translate into attachment styles or attachment orientations. ![Chart](https://i.stack.imgur.com/0l0QH.jpg) These diagrams also give a good representation of childhood cause and adult attachment style affect. ![secure](https://i.stack.imgur.com/hh7pF.jpg)![ambivalent](https://i.stack.imgur.com/4bYQn.jpg) ![avoidant](https://i.stack.imgur.com/WilGn.jpg)![disorganised](https://i.stack.imgur.com/WfzAz.jpg) images courtesy of [Attachment Styles](http://psychology.about.com/od/loveandattraction/ss/attachmentstyle.htm) By Kendra Cherry, About.com Guide [The Experiences in Close Relationships-Revised](http://internal.psychology.illinois.edu/~rcfraley/measures/ecrritems.htm) (ECR-R) Questionnaire Fraley, Waller, and Brennan (2000) - *Iive added emphasis within this quote.* > > Scoring Information: The first 18 items listed below comprise the **attachment-related anxiety scale**. Items 19 – 36 comprise the **attachment-related avoidance scale**. In real research, the order in which these items are presented should be randomized. Each item is rated on a 7-point scale where 1 = strongly disagree and 7 = strongly agree. **To obtain a score for attachment-related anxiety**, please average a person’s responses to items 1 – 18. However, because items 9 and 11 are “reverse keyed” (i.e., high numbers represent low anxiety rather than high anxiety), you’ll need to reverse the answers to those questions before averaging the responses. (If someone answers with a “6” to item 9, you’ll need to re-key it as a 2 before averaging.) **To obtain a score for attachment-related avoidance**, please average a person’s responses to items 19 – 36. Items 20, 22, 26, 27, 28, 29, 30, 31, 33, 34, 35, and 36 will need to be reverse keyed before you compute this average. > > >
Please consider the work of Dr. Patricia Crittenden; "Dynamic-Maturational Model (DMM) of Attachment & Adaptation". Based on the theoretical work of Bowlby, as a doctoral student, Dr. Crittenden, in concert with Dr. Ainsworth, began the foundational work of the DMM. The classification system appears to address the problem of "D" (e.g. "cannot classify", disorganized) by building out on the "A" and "C" classifications with an "AC" classification indicative of psychopathology. There are several papers and books which are accessible through the various internet booksellers, her papers are available in scholarly journals but some of her papers can be accessed through the Family Relations Institute website and the International Association for the Study of Attachment. Her work appears to have been neglected in the United States until recently. Consider her text, co-authored with Dr. Landini, "Assessing Adult Attachment" (2011, Norton Press). The DMM builds on the work of Bowlby and Ainsworth by incorporating the scientific developments in the cognitive neurosciences and proposes the "maturation", variation and change, of attachment over the lifespan. Drs. Ainsworth and Crittenden, early on (Crittenden and Ainsworth, 1989) in Crittenden's work stated, the classification of "D" (e.g. disorganized or cannot classify) "...if it occurred, would be transient and replaced by a context-adaptive strategies ..." (Crittenden and Landini, 2011).
4,382
The concept of attachment and different attachment styles has a long tradition in developmental psychology. Mary Ainsworth developed a classification for three different attachment styles that she called *secure*, *insecure-resistant* or synonymously *insecure-ambivalent* and finally *insecure-avoidant* (Main, 1996). Assessment of these styles is done with the [Strange-Situation-Test](http://en.wikipedia.org/wiki/Attachment_measures#The_Strange_Situation). Later, a fourth style called *insecure-disorganized-disoriented* was introduced to account for a number of children that would not have been classifiable otherwise (Main & Solomon, 1990). A corresponding classification has also been developed for attachment styles in adults. The four styles here are called *secure-autonomous*, *dismissing*, *preoccupied* and *unresolved-disorganized* (Main, 1996). Assessment is done using the [Adult Attachement Interview](http://en.wikipedia.org/wiki/Attachment_measures#Adult_Attachment_Interview_.28AAI.29). Recently I have read a couple of papers that investigate the association between attachment styles and various forms of stress reactivity, that used the terms *attachment anxiety* and *attachment avoidance* (Selcuk et al., 2012; Ben-Naim et al., 2013; Ein-Dor et al., 2011). The authors explain what is meant by these terms. Those two *attachment orientations* as they are called are asses with the *Experience in Close Relationships Scales* (ECR, Fraley et al., 2000). I am confused as to how these terms fit into the picture of the attachment styles. **Is this another classification of attachement styles?** References: Ben-Naim, S., Hirschberger, G., Ein-Dor, T., & Mikulincer, M. (2013). An experimental study of emotion regulation during relationship conflict interactions: The moderating role of attachment orientations. Emotion, 13(3), 506–519. doi:10.1037/a0031473 Ein-Dor, T., Mikulincer, M., & Shaver, P. R. (2011). Attachment insecurities and the processing of threat-related information: Studying the schemas involved in insecure people’s coping strategies. Journal of Personality and Social Psychology, 101(1), 78–93. doi:10.1037/a0022503 [PDF](http://www.researchgate.net/publication/50224821_Attachment_insecurities_and_the_processing_of_threat-related_information_Studying_the_schemas_involved_in_insecure_people%27s_coping_strategies/file/d922b4f572beebae86.pdf) Fraley, R. C., Waller, N. G., & Brennan, K. A. (2000). An item response theory analysis of self-report measures of adult attachment. Journal of Personality and Social Psychology, 78, 350–365. doi:10.1037/0022- 3514.78.2.350 [PDF](http://www.web-research-design.net/PDF/FW%26B2000.pdf) Main, M. (1996). Introduction to the special section on attachment and psychopathology: 2. Overview of the field of attachment. Journal of consulting and clinical psychology, 64(2), 237. Main, M., & Solomon, J. (1990). Procedures for identifying infants as disorganized/disoriented during the Ainsworth Strange Situation. Attachment in the preschool years: Theory, research, and intervention, 1, 121–160. Selcuk, E., Zayas, V., Günaydin, G., Hazan, C., & Kross, E. (2012). Mental representations of attachment figures facilitate recovery following upsetting autobiographical memory recall. Journal of Personality and Social Psychology, 103(2), 362–378. doi:10.1037/a0028125 [PDF](http://selfcontrol.psych.lsa.umich.edu/papers/SelcukZayasGunaydinHazanKross12.pdf)
2013/08/23
[ "https://cogsci.stackexchange.com/questions/4382", "https://cogsci.stackexchange.com", "https://cogsci.stackexchange.com/users/695/" ]
In the [introduction](http://scielo.isciii.es/scielo.php?pid=S0213-61632006000400006&script=sci_arttext) to their study, Conradi et al. (2006) give a brief and very good overview over the different approaches to classify and measure attachment styles. I encourage everyone, who is interested in the subject to read it. However, since it is the answer to my question, I will summarise it here. As I said in [my question](https://cogsci.stackexchange.com/questions/4382/classification-of-attachment-styles), research on attachment styles started with the classification by Ainsworth and Main, who were concerned with the infant-caregiver relationship. Later, an adult attachment focus was established by Hazan and Shaver. The paper then goes on to say that "after that, a bewildering variety of adult attachment typologies, adult attachment-related constructs, and measurement instruments" were developed. Within the adult attachment tradition, Bartholomew then "returned to Bowlby's original conceptualization of two working models", the *model of self* and the *model of other*. From these two bi-polar dimensions, the four attachment styles I mentioned in my question emerge. Brennan and collegues "collected all adult attachment self-report scales known at that time", administered them to a sample of 1086 psychology students and found two underlying factors, which they call *attachment avoidance* and *attachment anxiety*. The 18 items with the highest loadings on each of the two factors were the combined to two subscales which form the *Experiences in Close Relationships Questionaire (ECR)*. So, yes, the distinction between *attachment avoidance* and *attachment anxiety* is a different way of of studying attachment. The ECR (or the revised versions of it) seems to be a promising method for further study, because, as Fraley et al. (2000) mention, research has not supported a categorial model of attachment styles. References: Jan Conradi, H., Gerlsma, C., Duijn, M. V., & Jonge, P. D. (2006). Internal and external validity of the experiences in close relationships questionnaire in an American and two Dutch samples. *The European journal of psychiatry, 20(4)*, 258-269. [HTML](http://scielo.isciii.es/scielo.php?pid=S0213-61632006000400006&script=sci_arttext) Fraley, R. C., Waller, N. G., & Brennan, K. A. (2000). An item response theory analysis of self-report measures of adult attachment. *Journal of Personality and Social Psychology, 78,* 350–365. doi:10.1037/0022- 3514.78.2.350 [PDF](http://www.web-research-design.net/PDF/FW%26B2000.pdf)
Please consider the work of Dr. Patricia Crittenden; "Dynamic-Maturational Model (DMM) of Attachment & Adaptation". Based on the theoretical work of Bowlby, as a doctoral student, Dr. Crittenden, in concert with Dr. Ainsworth, began the foundational work of the DMM. The classification system appears to address the problem of "D" (e.g. "cannot classify", disorganized) by building out on the "A" and "C" classifications with an "AC" classification indicative of psychopathology. There are several papers and books which are accessible through the various internet booksellers, her papers are available in scholarly journals but some of her papers can be accessed through the Family Relations Institute website and the International Association for the Study of Attachment. Her work appears to have been neglected in the United States until recently. Consider her text, co-authored with Dr. Landini, "Assessing Adult Attachment" (2011, Norton Press). The DMM builds on the work of Bowlby and Ainsworth by incorporating the scientific developments in the cognitive neurosciences and proposes the "maturation", variation and change, of attachment over the lifespan. Drs. Ainsworth and Crittenden, early on (Crittenden and Ainsworth, 1989) in Crittenden's work stated, the classification of "D" (e.g. disorganized or cannot classify) "...if it occurred, would be transient and replaced by a context-adaptive strategies ..." (Crittenden and Landini, 2011).
57,323,260
Trying to push the Gradle project to Github package registry, but not working as expected. Using `io.freefair.github.package-registry-maven-publish` plugin for Gradle. Configure GitHub in `build.gradle` with data needed to publish - code below. And run the publishing task `publishAllPublicationsToGutHub`. Getting no error but I can't see my package in GitHub package registry. ``` github { slug username = "myGitUserName" token = "myTokenWithRightAccess" tag = "HEAD" travis = true } ``` Expecting some examples of how to publish to Github package registry with Gradle or what I'm doing wrong when publishing
2019/08/02
[ "https://Stackoverflow.com/questions/57323260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9571426/" ]
**New answer**: GitHub has published the official guide: [Configuring Gradle for use with GitHub Packages](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages). --- **Old answer**: It seems like the plugin [is not very stable yet](https://github.com/freefair/gradle-plugins/issues/50). Take a look at [the repository I've created](https://github.com/madhead/so57323260) that has everything set up. I managed to publish a few packages with that plugin [here](https://github.com/madhead/so57323260/packages). Even the packages are published, Gradle shows task as failed, due to some issues with `maven-metadata.xml`: ``` > Task :publishMainPublicationToGitHub madhead Maven PackagesRepository FAILED Could not transfer metadata so57323260:test/maven-metadata.xml from/to remote (https://maven.pkg.github.com/madhead): Could not get resource 'so57323260/test/maven-metadata.xml' FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':publishMainPublicationToGitHub madhead Maven PackagesRepository'. > Failed to publish publication 'main' to repository 'GitHub madhead Maven Packages' > Could not GET 'https://maven.pkg.github.com/madhead/so57323260/test/maven-metadata.xml'. Received status code 422 from server: Unprocessable Entity ``` But that's ok, probably will be fixed one day. I've noticed, that the packages might not be published (see the [linked issue](https://github.com/freefair/gradle-plugins/issues/50)) because of the incorrect `groupId` of a Maven publication. It seems like right now it should be equal to the Github's project name. So, in my case, I had to use `so57323260` as a `groupId` for a `madhead/so57323260` project. That's not how packages work in Maven generally, so that might be your issue.
I was able to publish to the Github Package Registry using the maven-publish plugin. It seems to work just fine now. My build.gradle file looks like this: ``` buildscript { repositories { mavenCentral() } } plugins { id 'java' id 'maven-publish' } group 'com.company.project' archivesBaseName = 'library-name' version '0.1.0' repositories { mavenCentral() } dependencies { // java dependencies } publishing { repositories { maven { name = "Github" url = uri("https://maven.pkg.github.com/<OWNER>/<REPO>") credentials { username = findProperty("github.username") password = findProperty("github.token") } } } publications { register("jar", MavenPublication) { from(components["java"]) pom { url.set("https://github.com/<OWNER>/<REPO>.git") } } } } ``` Put your github username and token into the gradle.properties file.
57,323,260
Trying to push the Gradle project to Github package registry, but not working as expected. Using `io.freefair.github.package-registry-maven-publish` plugin for Gradle. Configure GitHub in `build.gradle` with data needed to publish - code below. And run the publishing task `publishAllPublicationsToGutHub`. Getting no error but I can't see my package in GitHub package registry. ``` github { slug username = "myGitUserName" token = "myTokenWithRightAccess" tag = "HEAD" travis = true } ``` Expecting some examples of how to publish to Github package registry with Gradle or what I'm doing wrong when publishing
2019/08/02
[ "https://Stackoverflow.com/questions/57323260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9571426/" ]
**New answer**: GitHub has published the official guide: [Configuring Gradle for use with GitHub Packages](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages). --- **Old answer**: It seems like the plugin [is not very stable yet](https://github.com/freefair/gradle-plugins/issues/50). Take a look at [the repository I've created](https://github.com/madhead/so57323260) that has everything set up. I managed to publish a few packages with that plugin [here](https://github.com/madhead/so57323260/packages). Even the packages are published, Gradle shows task as failed, due to some issues with `maven-metadata.xml`: ``` > Task :publishMainPublicationToGitHub madhead Maven PackagesRepository FAILED Could not transfer metadata so57323260:test/maven-metadata.xml from/to remote (https://maven.pkg.github.com/madhead): Could not get resource 'so57323260/test/maven-metadata.xml' FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':publishMainPublicationToGitHub madhead Maven PackagesRepository'. > Failed to publish publication 'main' to repository 'GitHub madhead Maven Packages' > Could not GET 'https://maven.pkg.github.com/madhead/so57323260/test/maven-metadata.xml'. Received status code 422 from server: Unprocessable Entity ``` But that's ok, probably will be fixed one day. I've noticed, that the packages might not be published (see the [linked issue](https://github.com/freefair/gradle-plugins/issues/50)) because of the incorrect `groupId` of a Maven publication. It seems like right now it should be equal to the Github's project name. So, in my case, I had to use `so57323260` as a `groupId` for a `madhead/so57323260` project. That's not how packages work in Maven generally, so that might be your issue.
GitHub has published the official document for How to use Gradle with GitHub packager <https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages#authenticating-to-github-packages>
57,323,260
Trying to push the Gradle project to Github package registry, but not working as expected. Using `io.freefair.github.package-registry-maven-publish` plugin for Gradle. Configure GitHub in `build.gradle` with data needed to publish - code below. And run the publishing task `publishAllPublicationsToGutHub`. Getting no error but I can't see my package in GitHub package registry. ``` github { slug username = "myGitUserName" token = "myTokenWithRightAccess" tag = "HEAD" travis = true } ``` Expecting some examples of how to publish to Github package registry with Gradle or what I'm doing wrong when publishing
2019/08/02
[ "https://Stackoverflow.com/questions/57323260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9571426/" ]
**New answer**: GitHub has published the official guide: [Configuring Gradle for use with GitHub Packages](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages). --- **Old answer**: It seems like the plugin [is not very stable yet](https://github.com/freefair/gradle-plugins/issues/50). Take a look at [the repository I've created](https://github.com/madhead/so57323260) that has everything set up. I managed to publish a few packages with that plugin [here](https://github.com/madhead/so57323260/packages). Even the packages are published, Gradle shows task as failed, due to some issues with `maven-metadata.xml`: ``` > Task :publishMainPublicationToGitHub madhead Maven PackagesRepository FAILED Could not transfer metadata so57323260:test/maven-metadata.xml from/to remote (https://maven.pkg.github.com/madhead): Could not get resource 'so57323260/test/maven-metadata.xml' FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':publishMainPublicationToGitHub madhead Maven PackagesRepository'. > Failed to publish publication 'main' to repository 'GitHub madhead Maven Packages' > Could not GET 'https://maven.pkg.github.com/madhead/so57323260/test/maven-metadata.xml'. Received status code 422 from server: Unprocessable Entity ``` But that's ok, probably will be fixed one day. I've noticed, that the packages might not be published (see the [linked issue](https://github.com/freefair/gradle-plugins/issues/50)) because of the incorrect `groupId` of a Maven publication. It seems like right now it should be equal to the Github's project name. So, in my case, I had to use `so57323260` as a `groupId` for a `madhead/so57323260` project. That's not how packages work in Maven generally, so that might be your issue.
Complete those properties correctly 1. OWNER 2. REPOSITORY 3. USERNAME (or gradle property `gpr.user`) 4. PASSWORD (or gradle property `gpr.key`) @See demo 1. <https://github.com/youngerier/packagesdemo> 2. <https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages>
57,323,260
Trying to push the Gradle project to Github package registry, but not working as expected. Using `io.freefair.github.package-registry-maven-publish` plugin for Gradle. Configure GitHub in `build.gradle` with data needed to publish - code below. And run the publishing task `publishAllPublicationsToGutHub`. Getting no error but I can't see my package in GitHub package registry. ``` github { slug username = "myGitUserName" token = "myTokenWithRightAccess" tag = "HEAD" travis = true } ``` Expecting some examples of how to publish to Github package registry with Gradle or what I'm doing wrong when publishing
2019/08/02
[ "https://Stackoverflow.com/questions/57323260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9571426/" ]
**New answer**: GitHub has published the official guide: [Configuring Gradle for use with GitHub Packages](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages). --- **Old answer**: It seems like the plugin [is not very stable yet](https://github.com/freefair/gradle-plugins/issues/50). Take a look at [the repository I've created](https://github.com/madhead/so57323260) that has everything set up. I managed to publish a few packages with that plugin [here](https://github.com/madhead/so57323260/packages). Even the packages are published, Gradle shows task as failed, due to some issues with `maven-metadata.xml`: ``` > Task :publishMainPublicationToGitHub madhead Maven PackagesRepository FAILED Could not transfer metadata so57323260:test/maven-metadata.xml from/to remote (https://maven.pkg.github.com/madhead): Could not get resource 'so57323260/test/maven-metadata.xml' FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':publishMainPublicationToGitHub madhead Maven PackagesRepository'. > Failed to publish publication 'main' to repository 'GitHub madhead Maven Packages' > Could not GET 'https://maven.pkg.github.com/madhead/so57323260/test/maven-metadata.xml'. Received status code 422 from server: Unprocessable Entity ``` But that's ok, probably will be fixed one day. I've noticed, that the packages might not be published (see the [linked issue](https://github.com/freefair/gradle-plugins/issues/50)) because of the incorrect `groupId` of a Maven publication. It seems like right now it should be equal to the Github's project name. So, in my case, I had to use `so57323260` as a `groupId` for a `madhead/so57323260` project. That's not how packages work in Maven generally, so that might be your issue.
Also worth setting up a github action to publish to the github package repo: ``` name: Publish package to GitHub Packages on: release: types: [created] jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-java@v1 with: java-version: 1.8 - name: Publish package run: gradle -Pversion=${{ github.event.release.tag_name }} build publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` This publishes a package every time we create a release tag with that tag as the version.
57,323,260
Trying to push the Gradle project to Github package registry, but not working as expected. Using `io.freefair.github.package-registry-maven-publish` plugin for Gradle. Configure GitHub in `build.gradle` with data needed to publish - code below. And run the publishing task `publishAllPublicationsToGutHub`. Getting no error but I can't see my package in GitHub package registry. ``` github { slug username = "myGitUserName" token = "myTokenWithRightAccess" tag = "HEAD" travis = true } ``` Expecting some examples of how to publish to Github package registry with Gradle or what I'm doing wrong when publishing
2019/08/02
[ "https://Stackoverflow.com/questions/57323260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9571426/" ]
I was able to publish to the Github Package Registry using the maven-publish plugin. It seems to work just fine now. My build.gradle file looks like this: ``` buildscript { repositories { mavenCentral() } } plugins { id 'java' id 'maven-publish' } group 'com.company.project' archivesBaseName = 'library-name' version '0.1.0' repositories { mavenCentral() } dependencies { // java dependencies } publishing { repositories { maven { name = "Github" url = uri("https://maven.pkg.github.com/<OWNER>/<REPO>") credentials { username = findProperty("github.username") password = findProperty("github.token") } } } publications { register("jar", MavenPublication) { from(components["java"]) pom { url.set("https://github.com/<OWNER>/<REPO>.git") } } } } ``` Put your github username and token into the gradle.properties file.
GitHub has published the official document for How to use Gradle with GitHub packager <https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages#authenticating-to-github-packages>
57,323,260
Trying to push the Gradle project to Github package registry, but not working as expected. Using `io.freefair.github.package-registry-maven-publish` plugin for Gradle. Configure GitHub in `build.gradle` with data needed to publish - code below. And run the publishing task `publishAllPublicationsToGutHub`. Getting no error but I can't see my package in GitHub package registry. ``` github { slug username = "myGitUserName" token = "myTokenWithRightAccess" tag = "HEAD" travis = true } ``` Expecting some examples of how to publish to Github package registry with Gradle or what I'm doing wrong when publishing
2019/08/02
[ "https://Stackoverflow.com/questions/57323260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9571426/" ]
I was able to publish to the Github Package Registry using the maven-publish plugin. It seems to work just fine now. My build.gradle file looks like this: ``` buildscript { repositories { mavenCentral() } } plugins { id 'java' id 'maven-publish' } group 'com.company.project' archivesBaseName = 'library-name' version '0.1.0' repositories { mavenCentral() } dependencies { // java dependencies } publishing { repositories { maven { name = "Github" url = uri("https://maven.pkg.github.com/<OWNER>/<REPO>") credentials { username = findProperty("github.username") password = findProperty("github.token") } } } publications { register("jar", MavenPublication) { from(components["java"]) pom { url.set("https://github.com/<OWNER>/<REPO>.git") } } } } ``` Put your github username and token into the gradle.properties file.
Complete those properties correctly 1. OWNER 2. REPOSITORY 3. USERNAME (or gradle property `gpr.user`) 4. PASSWORD (or gradle property `gpr.key`) @See demo 1. <https://github.com/youngerier/packagesdemo> 2. <https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages>
57,323,260
Trying to push the Gradle project to Github package registry, but not working as expected. Using `io.freefair.github.package-registry-maven-publish` plugin for Gradle. Configure GitHub in `build.gradle` with data needed to publish - code below. And run the publishing task `publishAllPublicationsToGutHub`. Getting no error but I can't see my package in GitHub package registry. ``` github { slug username = "myGitUserName" token = "myTokenWithRightAccess" tag = "HEAD" travis = true } ``` Expecting some examples of how to publish to Github package registry with Gradle or what I'm doing wrong when publishing
2019/08/02
[ "https://Stackoverflow.com/questions/57323260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9571426/" ]
Also worth setting up a github action to publish to the github package repo: ``` name: Publish package to GitHub Packages on: release: types: [created] jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-java@v1 with: java-version: 1.8 - name: Publish package run: gradle -Pversion=${{ github.event.release.tag_name }} build publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` This publishes a package every time we create a release tag with that tag as the version.
GitHub has published the official document for How to use Gradle with GitHub packager <https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages#authenticating-to-github-packages>
57,323,260
Trying to push the Gradle project to Github package registry, but not working as expected. Using `io.freefair.github.package-registry-maven-publish` plugin for Gradle. Configure GitHub in `build.gradle` with data needed to publish - code below. And run the publishing task `publishAllPublicationsToGutHub`. Getting no error but I can't see my package in GitHub package registry. ``` github { slug username = "myGitUserName" token = "myTokenWithRightAccess" tag = "HEAD" travis = true } ``` Expecting some examples of how to publish to Github package registry with Gradle or what I'm doing wrong when publishing
2019/08/02
[ "https://Stackoverflow.com/questions/57323260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9571426/" ]
Also worth setting up a github action to publish to the github package repo: ``` name: Publish package to GitHub Packages on: release: types: [created] jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-java@v1 with: java-version: 1.8 - name: Publish package run: gradle -Pversion=${{ github.event.release.tag_name }} build publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` This publishes a package every time we create a release tag with that tag as the version.
Complete those properties correctly 1. OWNER 2. REPOSITORY 3. USERNAME (or gradle property `gpr.user`) 4. PASSWORD (or gradle property `gpr.key`) @See demo 1. <https://github.com/youngerier/packagesdemo> 2. <https://help.github.com/en/github/managing-packages-with-github-packages/configuring-gradle-for-use-with-github-packages>
43,245,115
I have a `RecyclerView` with rows that have views that when clicked will be disabled for that row position. The problem is after I update the adapter like this: ``` adapterData.clear(); adapterData.addAll(refreshedAdapterData); notifyDataSetChanged(); ``` After refreshing the data, the disabled views at the previous recycler position still remain disabled even though the data is refreshed. How can I reset the views to the original state after refreshing adapter data.
2017/04/06
[ "https://Stackoverflow.com/questions/43245115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5326518/" ]
Use below code. ``` adapterData.clear(); adapterData.addAll(refreshedAdapterData); adapter.notifyDataSetChanged(); ``` OR ``` recyclerView.invalidate(); ```
When you call `notifyDataSetChanged()`, the `onBindViewHolder()` method of every view is called. So you could add something like this in the `onBindViewHolder()` of your `Adapter` method: ``` @Override public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int position) { if (refreshedAdapterData.get(position).isInDefaultState()) { //set Default View Values } else { //the code you already have } } ```
43,245,115
I have a `RecyclerView` with rows that have views that when clicked will be disabled for that row position. The problem is after I update the adapter like this: ``` adapterData.clear(); adapterData.addAll(refreshedAdapterData); notifyDataSetChanged(); ``` After refreshing the data, the disabled views at the previous recycler position still remain disabled even though the data is refreshed. How can I reset the views to the original state after refreshing adapter data.
2017/04/06
[ "https://Stackoverflow.com/questions/43245115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5326518/" ]
Use below code. ``` adapterData.clear(); adapterData.addAll(refreshedAdapterData); adapter.notifyDataSetChanged(); ``` OR ``` recyclerView.invalidate(); ```
I have resolved this by putting a conditional statement inside onBindViewHolder method instructing all positions to reset the disabled views if data meets the required conditions for a refreshed data. @Christoph Mayr, thanks for your comments. It helped point me in the right direction.
43,245,115
I have a `RecyclerView` with rows that have views that when clicked will be disabled for that row position. The problem is after I update the adapter like this: ``` adapterData.clear(); adapterData.addAll(refreshedAdapterData); notifyDataSetChanged(); ``` After refreshing the data, the disabled views at the previous recycler position still remain disabled even though the data is refreshed. How can I reset the views to the original state after refreshing adapter data.
2017/04/06
[ "https://Stackoverflow.com/questions/43245115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5326518/" ]
Use below code. ``` adapterData.clear(); adapterData.addAll(refreshedAdapterData); adapter.notifyDataSetChanged(); ``` OR ``` recyclerView.invalidate(); ```
I cleared the data then notify change but the selected checkbox doesn't reset but just moves up one position. Let say I selected item #1 , move out of the RecyclerView, came back and it will auto select item #0. So, I created new adapter again at onResume(), i worked for me but i don't know if it's the right way to handle this situation. ```html @Override public void onResume() { super.onResume(); if(selectedItems != null && selectedItems.size() > 0){ selectedItems.clear(); // if no selected items before then no need to reset anything if(adapter != null && recyclerView != null){ // to remove the checked box adapter = null; adapter = new MyAdapter(items, new MyAdapter.MyAdapterListener() { @Override public void onSelected(int pos) { selectedItems.add(items.get(pos)); } @Override public void onUnSelected(int pos) { selectedItems.remove(items.get(pos)); } }); recyclerView.setAdapter(adapter); } } } ```
43,245,115
I have a `RecyclerView` with rows that have views that when clicked will be disabled for that row position. The problem is after I update the adapter like this: ``` adapterData.clear(); adapterData.addAll(refreshedAdapterData); notifyDataSetChanged(); ``` After refreshing the data, the disabled views at the previous recycler position still remain disabled even though the data is refreshed. How can I reset the views to the original state after refreshing adapter data.
2017/04/06
[ "https://Stackoverflow.com/questions/43245115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5326518/" ]
When you call `notifyDataSetChanged()`, the `onBindViewHolder()` method of every view is called. So you could add something like this in the `onBindViewHolder()` of your `Adapter` method: ``` @Override public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int position) { if (refreshedAdapterData.get(position).isInDefaultState()) { //set Default View Values } else { //the code you already have } } ```
I have resolved this by putting a conditional statement inside onBindViewHolder method instructing all positions to reset the disabled views if data meets the required conditions for a refreshed data. @Christoph Mayr, thanks for your comments. It helped point me in the right direction.
43,245,115
I have a `RecyclerView` with rows that have views that when clicked will be disabled for that row position. The problem is after I update the adapter like this: ``` adapterData.clear(); adapterData.addAll(refreshedAdapterData); notifyDataSetChanged(); ``` After refreshing the data, the disabled views at the previous recycler position still remain disabled even though the data is refreshed. How can I reset the views to the original state after refreshing adapter data.
2017/04/06
[ "https://Stackoverflow.com/questions/43245115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5326518/" ]
When you call `notifyDataSetChanged()`, the `onBindViewHolder()` method of every view is called. So you could add something like this in the `onBindViewHolder()` of your `Adapter` method: ``` @Override public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int position) { if (refreshedAdapterData.get(position).isInDefaultState()) { //set Default View Values } else { //the code you already have } } ```
I cleared the data then notify change but the selected checkbox doesn't reset but just moves up one position. Let say I selected item #1 , move out of the RecyclerView, came back and it will auto select item #0. So, I created new adapter again at onResume(), i worked for me but i don't know if it's the right way to handle this situation. ```html @Override public void onResume() { super.onResume(); if(selectedItems != null && selectedItems.size() > 0){ selectedItems.clear(); // if no selected items before then no need to reset anything if(adapter != null && recyclerView != null){ // to remove the checked box adapter = null; adapter = new MyAdapter(items, new MyAdapter.MyAdapterListener() { @Override public void onSelected(int pos) { selectedItems.add(items.get(pos)); } @Override public void onUnSelected(int pos) { selectedItems.remove(items.get(pos)); } }); recyclerView.setAdapter(adapter); } } } ```
43,245,115
I have a `RecyclerView` with rows that have views that when clicked will be disabled for that row position. The problem is after I update the adapter like this: ``` adapterData.clear(); adapterData.addAll(refreshedAdapterData); notifyDataSetChanged(); ``` After refreshing the data, the disabled views at the previous recycler position still remain disabled even though the data is refreshed. How can I reset the views to the original state after refreshing adapter data.
2017/04/06
[ "https://Stackoverflow.com/questions/43245115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5326518/" ]
I have resolved this by putting a conditional statement inside onBindViewHolder method instructing all positions to reset the disabled views if data meets the required conditions for a refreshed data. @Christoph Mayr, thanks for your comments. It helped point me in the right direction.
I cleared the data then notify change but the selected checkbox doesn't reset but just moves up one position. Let say I selected item #1 , move out of the RecyclerView, came back and it will auto select item #0. So, I created new adapter again at onResume(), i worked for me but i don't know if it's the right way to handle this situation. ```html @Override public void onResume() { super.onResume(); if(selectedItems != null && selectedItems.size() > 0){ selectedItems.clear(); // if no selected items before then no need to reset anything if(adapter != null && recyclerView != null){ // to remove the checked box adapter = null; adapter = new MyAdapter(items, new MyAdapter.MyAdapterListener() { @Override public void onSelected(int pos) { selectedItems.add(items.get(pos)); } @Override public void onUnSelected(int pos) { selectedItems.remove(items.get(pos)); } }); recyclerView.setAdapter(adapter); } } } ```
1,567,731
I am trying to create my first ASP.net server control derived from a Panel. For some reason, I am unable to get the .aspx page to recognize my server tag even though the application recognizes the class and namespace of my control. Here are the steps I've used: 1) I created a class CollapsablePanel that I've placed in my site\_code directory. I am using a Web App not Web Site so App\_Code is not really available to me. ``` Namespace webstation.WebControls Public Class CollapsablePanel Inherits System.Web.UI.WebControls.Panel End Class End Namespace ``` 2) In the .aspx file I've added <%@ Register TagPrefix="webstation" Namespace="MyApplication.webstation.WebControls" %> I've built the project but my custom tag prefix does not appear. If I just go ahead and type the editor does not throw an error, however the page does when I publish it and try to access it. If I try to access the class from the codebehind (Imports MyApplication.webstation.WebControls) the custom control appears in intellisense, so I know that Visual Studio is reading the class information to some extent. What am I doing wrong here? Any thoughts are greatly appreciated. Mike
2009/10/14
[ "https://Stackoverflow.com/questions/1567731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/146452/" ]
seems like you may be missing the TagName attribute as ``` <%@ Register TagPrefix="webstation" TagName="CollapsiblePanel" Namespace="MyApplication.webstation.WebControls" %> ``` once you do this you should be able to access it as ``` <webstations:CollapsiblePanel id='usercontrol1" runat="server" /> ```
Check out Scott Gu's blog post on registering controls, I like registering them in the web.config file myself. <http://weblogs.asp.net/scottgu/archive/2006/11/26/tip-trick-how-to-register-user-controls-and-custom-controls-in-web-config.aspx> You need to make sure you have a fully qualified reference to the control class, meaning the library name and namespace. I place my controls in a class library, but you can include them in your App\_Code folder. You can also register user controls in the web.config, both examples follow:
1,567,731
I am trying to create my first ASP.net server control derived from a Panel. For some reason, I am unable to get the .aspx page to recognize my server tag even though the application recognizes the class and namespace of my control. Here are the steps I've used: 1) I created a class CollapsablePanel that I've placed in my site\_code directory. I am using a Web App not Web Site so App\_Code is not really available to me. ``` Namespace webstation.WebControls Public Class CollapsablePanel Inherits System.Web.UI.WebControls.Panel End Class End Namespace ``` 2) In the .aspx file I've added <%@ Register TagPrefix="webstation" Namespace="MyApplication.webstation.WebControls" %> I've built the project but my custom tag prefix does not appear. If I just go ahead and type the editor does not throw an error, however the page does when I publish it and try to access it. If I try to access the class from the codebehind (Imports MyApplication.webstation.WebControls) the custom control appears in intellisense, so I know that Visual Studio is reading the class information to some extent. What am I doing wrong here? Any thoughts are greatly appreciated. Mike
2009/10/14
[ "https://Stackoverflow.com/questions/1567731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/146452/" ]
seems like you may be missing the TagName attribute as ``` <%@ Register TagPrefix="webstation" TagName="CollapsiblePanel" Namespace="MyApplication.webstation.WebControls" %> ``` once you do this you should be able to access it as ``` <webstations:CollapsiblePanel id='usercontrol1" runat="server" /> ```
I was able to get it work like expected once I went ahead and created a Class Library project in the same solution, built the project, copied the DLL from the bin of the Class Library and placed it in a folder of my Web Project used for holding external binaries. I also added a reference to the .dll in the project. Once I did that, then the syntax: ``` <%@ Register Assembly="webstation.WebControls" Namespace="webstation.WebControls" TagPrefix="webstation" %> ``` began to work. Does anyone know if I am able to somehow automatically update the compiled .DLL in my web project from the class library in the same solution? Or do I just have to go into the bin folder each time and manually copy it into the web project? Thanks, Mike
54,490,627
If β1= β2=0 and β3= 0 is null hypothesis. If β1= β2=0 holds and β3= 0 fails to hold, then what can you conclude? Does it mean there is a strong correlation between x1 and x2? or There is a linear relationship between the outcome variable(Y) and x3?
2019/02/02
[ "https://Stackoverflow.com/questions/54490627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4803521/" ]
There is a linear relationship between the outcome variable(Y) and x3. Since β3=0 fails to hold, it means that x3 is a significant variable in this linear regression model. Thus, we can say that there is a linear relationship between the outcome variable (Y) and x3.
There is a linear relationship between the outcome variable(Y) and x3
54,490,627
If β1= β2=0 and β3= 0 is null hypothesis. If β1= β2=0 holds and β3= 0 fails to hold, then what can you conclude? Does it mean there is a strong correlation between x1 and x2? or There is a linear relationship between the outcome variable(Y) and x3?
2019/02/02
[ "https://Stackoverflow.com/questions/54490627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4803521/" ]
There is a linear relationship between the outcome variable(Y) and x3. Since β3=0 fails to hold, it means that x3 is a significant variable in this linear regression model. Thus, we can say that there is a linear relationship between the outcome variable (Y) and x3.
There is no linear relationship between y and any of the three independent variables.
50,358,310
problem description =================== For a square matrix, one can obtain the SVD ``` X= USV' ``` decomposition, by using simply **numpy.linalg.svd** ``` u,s,vh = numpy.linalg.svd(X) ``` routine or **numpy.linalg.eigh**, to compute the eig decomposition on Hermitian matrix **X'X** and **XX'** Are they using the same algorithm? Calling the same Lapack routine? Is there any difference in terms of speed? and stability?
2018/05/15
[ "https://Stackoverflow.com/questions/50358310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5037235/" ]
Indeed, `numpy.linalg.svd` and `numpy.linalg.eigh` do not call the same routine of Lapack. On the one hand, [`numpy.linalg.eigh`](https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.linalg.eigh.html) refers to LAPACK's `dsyevd()` while `numpy.linalg.svd` makes use LAPACK's `dgesdd()`. The common point between these routines is the use of Cuppen's divide and conquer algorithm, first designed to solve tridiagonal eigenvalue problems. For instance, [`dsyevd()`](http://www.netlib.org/lapack/explore-3.1.1-html/dsyevd.f.html) only handles Hermitian matrix and performs the following steps, only if eigenvectors are required: 1. Reduce matrix to tridiagonal form using DSYTRD() 2. Compute the eigenvectors of the tridiagonal matrix using the divide and conquer algorithm, through DSTEDC() 3. Apply the Householder reflection reported by DSYTRD() using DORMTR(). On the contrary, to compute the SVD, [`dgesdd()`](http://www.netlib.org/lapack/explore-html/db/db4/dgesdd_8f_source.html) performs the following steps, in the case job==A (U and VT required): 1. Bidiagonalize A using `dgebrd()` 2. Compute the SVD of the bidiagonal matrix using divide and conquer algorithm using `DBDSDC()` 3. Revert the bidiagonalization using using the matrices P and Q returned by `dgebrd()` applying `dormbr()` twice, once for U and once for V While the actual operations performed by LAPACK are very different, the strategies are globally similar. It may stem from the fact that computing the SVD of a general matrix A is similar to performing the eigendecomposition of the symmetric matrix A^T.A. Regarding accuracy and performances of lapack divide and conquer SVD, see [This survey of SVD methods](https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20050192421.pdf): * They often achieve the accuracy of QR-based SVD, though it is not proven * The worst case is O(n^3) if no deflation occurs, but often proves better than that * The memory requirement is 8 times the size of the matrix, which can become prohibitive Regarding the symmetric eigenvalue problem, the complexity is 4/3n^3 (but often proves better than that) and the memory footprint is about 2n^2 plus the size of the matrix. Hence, the best choice is likely [`numpy.linalg.eigh`](https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.linalg.eigh.html) if your matrix is symmetric. The actual complexity can be computed for your particular matrices using the following code: ``` import numpy as np from matplotlib import pyplot as plt from scipy.optimize import curve_fit # see https://stackoverflow.com/questions/41109122/fitting-a-curve-to-a-power-law-distribution-with-curve-fit-does-not-work def func_powerlaw(x, m, c): return np.log(np.abs( x**m * c)) import time start = time.time() print("hello") end = time.time() print(end - start) timeev=[] timesvd=[] size=[] for n in range(10,600): print n size.append(n) A=np.zeros((n,n)) #populate A, 1D diffusion. for j in range(n): A[j,j]=2. if j>0: A[j-1,j]=-1. if j<n-1: A[j+1,j]=-1. #EIG Aev=A.copy() start = time.time() w,v=np.linalg.eigh(Aev,'L') end = time.time() timeev.append(end-start) Asvd=A.copy() start = time.time() u,s,vh=np.linalg.svd(Asvd) end = time.time() timesvd.append(end-start) poptev, pcov = curve_fit(func_powerlaw, size[len(size)/2:], np.log(timeev[len(size)/2:]),p0=[2.1,1e-7],maxfev = 8000) print poptev poptsvd, pcov = curve_fit(func_powerlaw, size[len(size)/2:], np.log(timesvd[len(size)/2:]),p0=[2.1,1e-7],maxfev = 8000) print poptsvd plt.figure() fig, ax = plt.subplots() plt.plot(size,timeev,label="eigh") plt.plot(size,[np.exp(func_powerlaw(x, poptev[0], poptev[1])) for x in size],label="eigh-adjusted complexity: "+str(poptev[0])) plt.plot(size,timesvd,label="svd") plt.plot(size,[np.exp(func_powerlaw(x, poptsvd[0], poptsvd[1])) for x in size],label="svd-adjusted complexity: "+str(poptsvd[0])) ax.set_xlabel('n') ax.set_ylabel('time, s') #plt.legend(loc="upper left") ax.legend(loc="lower right") ax.set_yscale("log", nonposy='clip') fig.tight_layout() plt.savefig('eigh.jpg') plt.show() ``` For such 1D diffusion matrices, eigh outperforms svd, but the actual complexity are similar, slightly lower than n^3, something like n^2.5. [![enter image description here](https://i.stack.imgur.com/8AtdM.jpg)](https://i.stack.imgur.com/8AtdM.jpg) Checking of the accuracy could be performed as well.
No they do not use the same algorithm as they do different things. They are somewhat related but also very different. Let's start with the fact that you can do SVD on `m x n` matrices, where `m` and `n` don't need to be the same. Dependent on the version of numpy, you are doing. Here are the eigenvalue routines in lapack for double precision: <http://www.netlib.org/lapack/explore-html/d9/d8e/group__double_g_eeigen.html> And the according SVD routines: <http://www.netlib.org/lapack/explore-html/d1/d7e/group__double_g_esing.html> There are differences in routines. Big differences. If you care for the details, they are specified in the fortran headers very well. In many cases it makes sense to find out, what kind of matrix you have in front of you, to make a good choice of routine. Is the matrix symmetric/hermitian? Is it in upper diagonal form? Is it positive semidefinite? ... There are gynormous differences in runtime. But as rule of thumb EIGs are cheaper than SVDs. But that depends also on convergence speed, which in turn depends a lot on condition number of the matrix, in other words, how ill posed a matrix is, ... SVDs are usually very robust and slow algorithms and oftentimes used for inversion, speed optimisation through truncation, principle component analysis really with the expetation, that the matrix you are dealing with is just a pile of shitty rows ;)
6,059
A friend has asked me to read through a chapter of his story and give my opinion. Lets say he has two main characters **Mr John de Havilland** and **Mrs Sally de Havilland**. I've noticed that the author sometimes uses the full name, **Mr John de Havilland**; Other times he uses the short form, **John** and other times uses a descriptive word instead of the name, i.e **the plumber**. Whilst reading the story, I often found it difficult to work out 'who said what' (especially when I was having to distinguish between Mr de Havilland / Mrs de Havilland). I am going to suggest that he pick one name for each of the characters and stick to it. To keep using various pronouns/roles to refer to the character, but decide on the **one word** to use for their **name**. So, if the name is to be used in the narrative, nearly always to choose "John" instead of varying between "John", "Mr de Havilland" and "Mr John de Havilland". I'm interested to hear if that is a sensible criticism. How much consistency/ variation should there be in specifiying character names? Is it typical to add variation to the words used for a character's name to keep it spicy or is consistency often considered the prioritised goal?
2012/07/11
[ "https://writers.stackexchange.com/questions/6059", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/2754/" ]
Orson Scott Card answers your question precisely and eloquently in his excellent *Character and Viewpoint*, under the heading [One Name Per Character](http://books.google.co.il/books?id=-jehiAI0WJAC&pg=PA56&dq=%22orson+scott+card%22+%22One+Name+Per+Character%22&hl=iw&sa=X&ei=Tor-T-L_Lu-P4gTE4YWBBw&redir_esc=y#v=onepage&q&f=false). Go, read. For posterity, I'll summarize: * Names should be treated as "invisible words" - they're so common, the reader hardly notices them. You can repeat them as often as you like, without worrying about "sounding repetitive". * Alternating between different tags can be confusing and distracting. * Every POV (point of view) should stick to a single tag per character - that's how that person thinks of them. This tag might demonstrate the relationship between the characters - Mr. John de Havilland might be "Johnny" to his wife, "Mr. de Havilland" to his subordinates, "the prig in the yellow shirt" to a street kid, and "Knives" to a newly-released ex-con whose gang he belonged to when he was 11. But the ex-con will never think of him as "Mr. de Havilland," nor as "the plumber." Don't break from the POV's chosen tag unless the story itself calls for it. * Don't use the tags themselves to tell us directly about the character - rotating between "De Havilland," "the plumber," "the 50-year old," "the ugly revolutionary," "the Soviet spy" just to tell us he is all those things. It's clunky, it's confusing, and it's telling us rather than showing us.
It's not about "spicy," it's about not being boring. Using "John" in every single dialogue tag can grate on the inner ear. That said, don't overdo it. I would say you should use character names (or he/she) 90% of the time, and the other 10% can be "the detective," "the doctor," "the captain," "the younger woman," "her older sister," etc. You want to do it just often enough to prevent monotony. If you're having trouble figuring out who "Mrs de Havilland" is in a conversation between a husband and wife, then the writer is doing a poor job of attribution, period. EDIT TO ADD: As JSBangs notes below, using a character's full name and courtesy title (Mr John de Havilland) in a dialog tag sounds very strange to the modern ear. Unless there's some compelling stylistic reason, pick one version of the person's name (Mr de Havilland, Dr. McCoy, John) and stick with that in pretty much all iterations.
6,059
A friend has asked me to read through a chapter of his story and give my opinion. Lets say he has two main characters **Mr John de Havilland** and **Mrs Sally de Havilland**. I've noticed that the author sometimes uses the full name, **Mr John de Havilland**; Other times he uses the short form, **John** and other times uses a descriptive word instead of the name, i.e **the plumber**. Whilst reading the story, I often found it difficult to work out 'who said what' (especially when I was having to distinguish between Mr de Havilland / Mrs de Havilland). I am going to suggest that he pick one name for each of the characters and stick to it. To keep using various pronouns/roles to refer to the character, but decide on the **one word** to use for their **name**. So, if the name is to be used in the narrative, nearly always to choose "John" instead of varying between "John", "Mr de Havilland" and "Mr John de Havilland". I'm interested to hear if that is a sensible criticism. How much consistency/ variation should there be in specifiying character names? Is it typical to add variation to the words used for a character's name to keep it spicy or is consistency often considered the prioritised goal?
2012/07/11
[ "https://writers.stackexchange.com/questions/6059", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/2754/" ]
It's not about "spicy," it's about not being boring. Using "John" in every single dialogue tag can grate on the inner ear. That said, don't overdo it. I would say you should use character names (or he/she) 90% of the time, and the other 10% can be "the detective," "the doctor," "the captain," "the younger woman," "her older sister," etc. You want to do it just often enough to prevent monotony. If you're having trouble figuring out who "Mrs de Havilland" is in a conversation between a husband and wife, then the writer is doing a poor job of attribution, period. EDIT TO ADD: As JSBangs notes below, using a character's full name and courtesy title (Mr John de Havilland) in a dialog tag sounds very strange to the modern ear. Unless there's some compelling stylistic reason, pick one version of the person's name (Mr de Havilland, Dr. McCoy, John) and stick with that in pretty much all iterations.
I also dislike repeating "He" or "John" over and over again. I have a little rule that I use when it gets on my nerves. When I talk about a single character, then I use different variants, eg "the young", "the old man", "fatty", "the scholar" and so on (depending on their defining characteristics). In any other case, I address characters by their short-name or nickname. There are few exceptions to this rule. For example, my Maid character uses "Young master". When I narrate her POV I use "the Young Master". (Sorry for my bad English, not a native).
6,059
A friend has asked me to read through a chapter of his story and give my opinion. Lets say he has two main characters **Mr John de Havilland** and **Mrs Sally de Havilland**. I've noticed that the author sometimes uses the full name, **Mr John de Havilland**; Other times he uses the short form, **John** and other times uses a descriptive word instead of the name, i.e **the plumber**. Whilst reading the story, I often found it difficult to work out 'who said what' (especially when I was having to distinguish between Mr de Havilland / Mrs de Havilland). I am going to suggest that he pick one name for each of the characters and stick to it. To keep using various pronouns/roles to refer to the character, but decide on the **one word** to use for their **name**. So, if the name is to be used in the narrative, nearly always to choose "John" instead of varying between "John", "Mr de Havilland" and "Mr John de Havilland". I'm interested to hear if that is a sensible criticism. How much consistency/ variation should there be in specifiying character names? Is it typical to add variation to the words used for a character's name to keep it spicy or is consistency often considered the prioritised goal?
2012/07/11
[ "https://writers.stackexchange.com/questions/6059", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/2754/" ]
It's not about "spicy," it's about not being boring. Using "John" in every single dialogue tag can grate on the inner ear. That said, don't overdo it. I would say you should use character names (or he/she) 90% of the time, and the other 10% can be "the detective," "the doctor," "the captain," "the younger woman," "her older sister," etc. You want to do it just often enough to prevent monotony. If you're having trouble figuring out who "Mrs de Havilland" is in a conversation between a husband and wife, then the writer is doing a poor job of attribution, period. EDIT TO ADD: As JSBangs notes below, using a character's full name and courtesy title (Mr John de Havilland) in a dialog tag sounds very strange to the modern ear. Unless there's some compelling stylistic reason, pick one version of the person's name (Mr de Havilland, Dr. McCoy, John) and stick with that in pretty much all iterations.
If the two Havillands are in separate scenes and which one has been established, you could use their last names, for example: Havilland threw his hands up in surrender. or: Havilland tapped her foot. I also sometimes use descriptions of appearance or personality which have already been established, for example: The blue-eyed man. or, sometimes: The more arrogant of the two sneered. I hope this was of some help! :)
6,059
A friend has asked me to read through a chapter of his story and give my opinion. Lets say he has two main characters **Mr John de Havilland** and **Mrs Sally de Havilland**. I've noticed that the author sometimes uses the full name, **Mr John de Havilland**; Other times he uses the short form, **John** and other times uses a descriptive word instead of the name, i.e **the plumber**. Whilst reading the story, I often found it difficult to work out 'who said what' (especially when I was having to distinguish between Mr de Havilland / Mrs de Havilland). I am going to suggest that he pick one name for each of the characters and stick to it. To keep using various pronouns/roles to refer to the character, but decide on the **one word** to use for their **name**. So, if the name is to be used in the narrative, nearly always to choose "John" instead of varying between "John", "Mr de Havilland" and "Mr John de Havilland". I'm interested to hear if that is a sensible criticism. How much consistency/ variation should there be in specifiying character names? Is it typical to add variation to the words used for a character's name to keep it spicy or is consistency often considered the prioritised goal?
2012/07/11
[ "https://writers.stackexchange.com/questions/6059", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/2754/" ]
Orson Scott Card answers your question precisely and eloquently in his excellent *Character and Viewpoint*, under the heading [One Name Per Character](http://books.google.co.il/books?id=-jehiAI0WJAC&pg=PA56&dq=%22orson+scott+card%22+%22One+Name+Per+Character%22&hl=iw&sa=X&ei=Tor-T-L_Lu-P4gTE4YWBBw&redir_esc=y#v=onepage&q&f=false). Go, read. For posterity, I'll summarize: * Names should be treated as "invisible words" - they're so common, the reader hardly notices them. You can repeat them as often as you like, without worrying about "sounding repetitive". * Alternating between different tags can be confusing and distracting. * Every POV (point of view) should stick to a single tag per character - that's how that person thinks of them. This tag might demonstrate the relationship between the characters - Mr. John de Havilland might be "Johnny" to his wife, "Mr. de Havilland" to his subordinates, "the prig in the yellow shirt" to a street kid, and "Knives" to a newly-released ex-con whose gang he belonged to when he was 11. But the ex-con will never think of him as "Mr. de Havilland," nor as "the plumber." Don't break from the POV's chosen tag unless the story itself calls for it. * Don't use the tags themselves to tell us directly about the character - rotating between "De Havilland," "the plumber," "the 50-year old," "the ugly revolutionary," "the Soviet spy" just to tell us he is all those things. It's clunky, it's confusing, and it's telling us rather than showing us.
I also dislike repeating "He" or "John" over and over again. I have a little rule that I use when it gets on my nerves. When I talk about a single character, then I use different variants, eg "the young", "the old man", "fatty", "the scholar" and so on (depending on their defining characteristics). In any other case, I address characters by their short-name or nickname. There are few exceptions to this rule. For example, my Maid character uses "Young master". When I narrate her POV I use "the Young Master". (Sorry for my bad English, not a native).
6,059
A friend has asked me to read through a chapter of his story and give my opinion. Lets say he has two main characters **Mr John de Havilland** and **Mrs Sally de Havilland**. I've noticed that the author sometimes uses the full name, **Mr John de Havilland**; Other times he uses the short form, **John** and other times uses a descriptive word instead of the name, i.e **the plumber**. Whilst reading the story, I often found it difficult to work out 'who said what' (especially when I was having to distinguish between Mr de Havilland / Mrs de Havilland). I am going to suggest that he pick one name for each of the characters and stick to it. To keep using various pronouns/roles to refer to the character, but decide on the **one word** to use for their **name**. So, if the name is to be used in the narrative, nearly always to choose "John" instead of varying between "John", "Mr de Havilland" and "Mr John de Havilland". I'm interested to hear if that is a sensible criticism. How much consistency/ variation should there be in specifiying character names? Is it typical to add variation to the words used for a character's name to keep it spicy or is consistency often considered the prioritised goal?
2012/07/11
[ "https://writers.stackexchange.com/questions/6059", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/2754/" ]
Orson Scott Card answers your question precisely and eloquently in his excellent *Character and Viewpoint*, under the heading [One Name Per Character](http://books.google.co.il/books?id=-jehiAI0WJAC&pg=PA56&dq=%22orson+scott+card%22+%22One+Name+Per+Character%22&hl=iw&sa=X&ei=Tor-T-L_Lu-P4gTE4YWBBw&redir_esc=y#v=onepage&q&f=false). Go, read. For posterity, I'll summarize: * Names should be treated as "invisible words" - they're so common, the reader hardly notices them. You can repeat them as often as you like, without worrying about "sounding repetitive". * Alternating between different tags can be confusing and distracting. * Every POV (point of view) should stick to a single tag per character - that's how that person thinks of them. This tag might demonstrate the relationship between the characters - Mr. John de Havilland might be "Johnny" to his wife, "Mr. de Havilland" to his subordinates, "the prig in the yellow shirt" to a street kid, and "Knives" to a newly-released ex-con whose gang he belonged to when he was 11. But the ex-con will never think of him as "Mr. de Havilland," nor as "the plumber." Don't break from the POV's chosen tag unless the story itself calls for it. * Don't use the tags themselves to tell us directly about the character - rotating between "De Havilland," "the plumber," "the 50-year old," "the ugly revolutionary," "the Soviet spy" just to tell us he is all those things. It's clunky, it's confusing, and it's telling us rather than showing us.
If the two Havillands are in separate scenes and which one has been established, you could use their last names, for example: Havilland threw his hands up in surrender. or: Havilland tapped her foot. I also sometimes use descriptions of appearance or personality which have already been established, for example: The blue-eyed man. or, sometimes: The more arrogant of the two sneered. I hope this was of some help! :)
6,059
A friend has asked me to read through a chapter of his story and give my opinion. Lets say he has two main characters **Mr John de Havilland** and **Mrs Sally de Havilland**. I've noticed that the author sometimes uses the full name, **Mr John de Havilland**; Other times he uses the short form, **John** and other times uses a descriptive word instead of the name, i.e **the plumber**. Whilst reading the story, I often found it difficult to work out 'who said what' (especially when I was having to distinguish between Mr de Havilland / Mrs de Havilland). I am going to suggest that he pick one name for each of the characters and stick to it. To keep using various pronouns/roles to refer to the character, but decide on the **one word** to use for their **name**. So, if the name is to be used in the narrative, nearly always to choose "John" instead of varying between "John", "Mr de Havilland" and "Mr John de Havilland". I'm interested to hear if that is a sensible criticism. How much consistency/ variation should there be in specifiying character names? Is it typical to add variation to the words used for a character's name to keep it spicy or is consistency often considered the prioritised goal?
2012/07/11
[ "https://writers.stackexchange.com/questions/6059", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/2754/" ]
If the two Havillands are in separate scenes and which one has been established, you could use their last names, for example: Havilland threw his hands up in surrender. or: Havilland tapped her foot. I also sometimes use descriptions of appearance or personality which have already been established, for example: The blue-eyed man. or, sometimes: The more arrogant of the two sneered. I hope this was of some help! :)
I also dislike repeating "He" or "John" over and over again. I have a little rule that I use when it gets on my nerves. When I talk about a single character, then I use different variants, eg "the young", "the old man", "fatty", "the scholar" and so on (depending on their defining characteristics). In any other case, I address characters by their short-name or nickname. There are few exceptions to this rule. For example, my Maid character uses "Young master". When I narrate her POV I use "the Young Master". (Sorry for my bad English, not a native).
25,286,213
I'm currently developing an Excel Add-In using the Excel-DNA library. Sadly I need to serialize the Add-In somehow into the workbook so if the workbook is opened, the Add-In's code may be executed. Before, I worked with VBA and Excel macros which've been run greatly, I could serialize the macro and upload the workbook. A software put data into it and delivered the edited workbook and I just had to open the workbook for the macro to execute. I tried that with an Add-In (e.g. loading the Add-In and saving the workbook) but that didn't work, the Add-In seems to be not saved at all. Is there any other chance in serializing the Add-In into a workbook so people who just got the workbook can execute the Add-In's code?
2014/08/13
[ "https://Stackoverflow.com/questions/25286213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3436418/" ]
You can include code in the Excel workbook that will install the add-in if it isn't already. You could also have it uninstall the add-in on close if you only want the add-in installed while the workbook is open. Check out JKP's Name Manager, specifically the code in the Setup Name Manager file. <http://www.jkp-ads.com/OfficeMarketPlaceNM-EN.asp> It finds the add-in, which is assumed to be in the same path and as the Setup file, and copies it to the UserLibrary, which is the default path for add-ins. Then it sets the Addin.Installed property to True. JKP's addin is and native Excel add-in, not an Excel DNA one, so there may be some differences (and I don't know what they are). But you may have to deal with Application.COMAddins rather than Application.Addins.
The way I understand Add-Ins, they sit separately in a way they can't be bound together with a workbook. The way I have understood them (and used them up to this point) is, for lack of a better term, a weird 'mini-program' that sits loaded inside Excel itself, not inside your workbook - you install it, it has access to more PC resources, Add-Ins even land in the list of programs for Windows, unlike a VBA macro. Add-Ins solve a lot of problems, but do create a new one in the process. Even if you built a process that reached out on launch for the addin to install, I think it would still require a restart of Excel to be accessible from within the application, which would be frustrating. Add-In deployment is still fairly clunky, in my opinion.
25,286,213
I'm currently developing an Excel Add-In using the Excel-DNA library. Sadly I need to serialize the Add-In somehow into the workbook so if the workbook is opened, the Add-In's code may be executed. Before, I worked with VBA and Excel macros which've been run greatly, I could serialize the macro and upload the workbook. A software put data into it and delivered the edited workbook and I just had to open the workbook for the macro to execute. I tried that with an Add-In (e.g. loading the Add-In and saving the workbook) but that didn't work, the Add-In seems to be not saved at all. Is there any other chance in serializing the Add-In into a workbook so people who just got the workbook can execute the Add-In's code?
2014/08/13
[ "https://Stackoverflow.com/questions/25286213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3436418/" ]
You can include code in the Excel workbook that will install the add-in if it isn't already. You could also have it uninstall the add-in on close if you only want the add-in installed while the workbook is open. Check out JKP's Name Manager, specifically the code in the Setup Name Manager file. <http://www.jkp-ads.com/OfficeMarketPlaceNM-EN.asp> It finds the add-in, which is assumed to be in the same path and as the Setup file, and copies it to the UserLibrary, which is the default path for add-ins. Then it sets the Addin.Installed property to True. JKP's addin is and native Excel add-in, not an Excel DNA one, so there may be some differences (and I don't know what they are). But you may have to deal with Application.COMAddins rather than Application.Addins.
Where I work we have a deployment process to deliver a Start Menu entry that will open excel and the correct version of the xll. I have never heard of people embedding the addin in the workbook. But you can do the opposite, your addin can be coupled with a XLA or you can create an Addin menu with entries for the user to open a specific version of the workbook. This tie the workbook to a specific version of the addin rather than the opposite like you asked but it may be useful for your purposes. Uou could use a network drive for a basic implementation. This would achieve kind of the same result by inverting your logic. However this is a costly solution in terms of manpower to create this infrastructure.
52,001,841
I am building a function that imports excel spreadsheets. I would like the function to include an argument that contains names of variables that the user is interested in seeing. The values from the argument is used in dplyr::filter() inside the function. I would like the default value of the argument to include everything (i.e. not filter anything away). Libraries and Data: ``` library(tidyverse) data("iris") ``` The filter function without any default filter values (this works): ``` FILTER <- function(data = iris, Filter_Values) { data %>% filter(Species %in% Filter_Values) } FILTER(Filter_Values = c("setosa", "virginica")) ``` As written above, I would like the Filter\_Values argument to default into NOT filtering anything. This works, but is of course not general: ``` FILTER <- function(data = iris, Filter_Values = c("setosa", "versicolor", "virginica")) { data %>% filter(Species %in% Filter_Values) } FILTER() ``` Can you help me find a general term that can do the same. I have tried (and failed) with: ``` Filter_Values = TRUE Filter_Values = c(TRUE) Filter_Values = regex(".*") Filter_Values = everything() ``` Any help appreciated, Thanks
2018/08/24
[ "https://Stackoverflow.com/questions/52001841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6412795/" ]
You can create a simple factory for your Continents. ``` public class ContinentFactory { private Set<Continent> continents = new HashSet<>(); public Continent create(String name) { Continent continent = new Continent(name); continents.add(continent); return continent; } public static class Continent { private String continentName; public Continent(String continentName) { this.continentName = continentName; } ... equals and hashcode .... } } ``` You should follow Java naming conventions too: <https://www.oracle.com/technetwork/java/javase/documentation/codeconventions-135099.html>
Mabye is is easier to implement Continent as an inner class: ``` public class Earth { private static HashSet<Continent> globalContinents = new HashSet(); public Earth() { } public void addContinent(String name) { globalContinents.add(new Continent(name)); } private class Continent { private String continent_name; public Continent(String continent_name){ this.continent_name = continent_name; } public String getName() { return this.continent_name; } } } ``` So, all coninents are in a HashSet of Earth, so you need just to create one Object of Earth and then add Coninents with addContinent().
6,471,302
Building up on [Sjoerd solution to add alignment to a manipulate object](https://stackoverflow.com/questions/6469288/adding-alignment-to-a-manipulate-ouput-in-mathematica) : Consider the following : ``` Manipulate[ Panel[Style[Row1, Bold, 20], ImageSize -> 150, Alignment -> Center] Panel[Style[Row2, Bold, 20], ImageSize -> 150, Alignment -> Center], {{Row1, {1}}, {1, 2, 3, 4, 5}, ControlType -> SetterBar,ControlPlacement -> Left}, {{Row2, {2}}, {1, 2, 3, 4, 5}, ControlType -> SetterBar,ControlPlacement -> Left}] ``` ![enter image description here](https://i.stack.imgur.com/K2aYW.png) **Is there a way to have the panel on top of each other aligned with the corresponding SetterBar ?**
2011/06/24
[ "https://Stackoverflow.com/questions/6471302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/769551/" ]
Would something like this work? ``` Manipulate[ Grid[{{SetterBar[Dynamic[Row1], {1, 2, 3, 4, 5}], Panel[Style[Row1, Bold, 20], ImageSize -> 150, Alignment -> Center] }, {SetterBar[ Dynamic[Row2], {1, 2, 3, 4, 5}], Panel[Style[Row2, Bold, 20], ImageSize -> 150, Alignment -> Center]}}], {{Row1, {1}}, ControlType -> None}, {{Row2, {2}}, ControlType -> None}] ``` ![manipulate screenshot](https://i.stack.imgur.com/N7EIW.png) This technically moves the controls into the body of the manipulate, and prevents the actual controls from showing up where they normally would.
You could also do: ``` Manipulate[ Column[ {Panel[Style[Row1, Bold, 20], ImageSize -> {150, 50}, Alignment -> Center] , Panel[Style[Row2, Bold, 20], ImageSize -> {150, 50}, Alignment -> Center]}], Column[ { Control@{{Row1,{},Pane["",ImageSize->{0, 50}]},Range@5,ControlType -> SetterBar}, Control@{{Row2,{},Pane["",ImageSize->{0, 50}]},Range@5,ControlType -> SetterBar} }], ControlPlacement -> Left] ``` ![enter image description here](https://i.stack.imgur.com/gBPjL.png)
6,471,302
Building up on [Sjoerd solution to add alignment to a manipulate object](https://stackoverflow.com/questions/6469288/adding-alignment-to-a-manipulate-ouput-in-mathematica) : Consider the following : ``` Manipulate[ Panel[Style[Row1, Bold, 20], ImageSize -> 150, Alignment -> Center] Panel[Style[Row2, Bold, 20], ImageSize -> 150, Alignment -> Center], {{Row1, {1}}, {1, 2, 3, 4, 5}, ControlType -> SetterBar,ControlPlacement -> Left}, {{Row2, {2}}, {1, 2, 3, 4, 5}, ControlType -> SetterBar,ControlPlacement -> Left}] ``` ![enter image description here](https://i.stack.imgur.com/K2aYW.png) **Is there a way to have the panel on top of each other aligned with the corresponding SetterBar ?**
2011/06/24
[ "https://Stackoverflow.com/questions/6471302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/769551/" ]
Would something like this work? ``` Manipulate[ Grid[{{SetterBar[Dynamic[Row1], {1, 2, 3, 4, 5}], Panel[Style[Row1, Bold, 20], ImageSize -> 150, Alignment -> Center] }, {SetterBar[ Dynamic[Row2], {1, 2, 3, 4, 5}], Panel[Style[Row2, Bold, 20], ImageSize -> 150, Alignment -> Center]}}], {{Row1, {1}}, ControlType -> None}, {{Row2, {2}}, ControlType -> None}] ``` ![manipulate screenshot](https://i.stack.imgur.com/N7EIW.png) This technically moves the controls into the body of the manipulate, and prevents the actual controls from showing up where they normally would.
``` DynamicModule[{Row1 = 1, Row2 = 2}, Manipulate[ Grid[ { { Control[{Row1, {1, 2, 3, 4, 5}}], Panel[Style[Row1, Bold, 20], ImageSize -> 150, Alignment -> Center] }, { Control[{Row2, {1, 2, 3, 4, 5}}], Panel[Style[Row2, Bold, 20], ImageSize -> 150, Alignment -> Center]} } ] ] ] ``` ![enter image description here](https://i.stack.imgur.com/7tY8s.png)
6,471,302
Building up on [Sjoerd solution to add alignment to a manipulate object](https://stackoverflow.com/questions/6469288/adding-alignment-to-a-manipulate-ouput-in-mathematica) : Consider the following : ``` Manipulate[ Panel[Style[Row1, Bold, 20], ImageSize -> 150, Alignment -> Center] Panel[Style[Row2, Bold, 20], ImageSize -> 150, Alignment -> Center], {{Row1, {1}}, {1, 2, 3, 4, 5}, ControlType -> SetterBar,ControlPlacement -> Left}, {{Row2, {2}}, {1, 2, 3, 4, 5}, ControlType -> SetterBar,ControlPlacement -> Left}] ``` ![enter image description here](https://i.stack.imgur.com/K2aYW.png) **Is there a way to have the panel on top of each other aligned with the corresponding SetterBar ?**
2011/06/24
[ "https://Stackoverflow.com/questions/6471302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/769551/" ]
``` DynamicModule[{Row1 = 1, Row2 = 2}, Manipulate[ Grid[ { { Control[{Row1, {1, 2, 3, 4, 5}}], Panel[Style[Row1, Bold, 20], ImageSize -> 150, Alignment -> Center] }, { Control[{Row2, {1, 2, 3, 4, 5}}], Panel[Style[Row2, Bold, 20], ImageSize -> 150, Alignment -> Center]} } ] ] ] ``` ![enter image description here](https://i.stack.imgur.com/7tY8s.png)
You could also do: ``` Manipulate[ Column[ {Panel[Style[Row1, Bold, 20], ImageSize -> {150, 50}, Alignment -> Center] , Panel[Style[Row2, Bold, 20], ImageSize -> {150, 50}, Alignment -> Center]}], Column[ { Control@{{Row1,{},Pane["",ImageSize->{0, 50}]},Range@5,ControlType -> SetterBar}, Control@{{Row2,{},Pane["",ImageSize->{0, 50}]},Range@5,ControlType -> SetterBar} }], ControlPlacement -> Left] ``` ![enter image description here](https://i.stack.imgur.com/gBPjL.png)
12,868,546
I'm new to visual basic and have been using vb.net to create a console/text based game. I want to make my game a little bit more "smart". The idea I've had to do this is to create an array of synonyms for yes and an array of synonyms for no, and similar arrays for over words. I intended on using a case statement with the array to decide weather the users input was a synonym for yes or for no. I have had no luck so far, and I was wondering if anybody here knew how it can be done or if I'm barking up the wrong tree. Maybe there is a different way for me to approach this? My Select attempt: ``` Select Case userInput Case yes(0) To yes(34) Console.WriteLine("you said something like yes, you said {0}", userInput) End Select ``` The start of my array: (there are 34 synonyms so far) ``` Dim yes(0 To 34) As String yes(0) = "yes" yes(1) = "ok" yes(2) = "yep" yes(3) = "yeah" ``` If anybody can help me it would be very much appreciated :) Thank you very much!
2012/10/12
[ "https://Stackoverflow.com/questions/12868546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1742565/" ]
Adding a pom dependency only pulls down transitive dependencies, that is jar dependencies defined as dependencies in the pom. The pom does not get added on the classpath for obvious reasons, but the transitive dependencies reachable from pom will be added to classpath. What you ideally need to do is have dependencies of type `jar` Default dependency type is `jar` and you can simply define dependencies without any `type` element in the dependency section. If you have located the jar files you need in Maven Cental, then you simply need to provide groupId artifactId and version for each one of those in dependencies section.
Personally I cannot think of any case when one would need to add `pom` type dependency. I usually use `pom` packaging for parent module in a project (specify common project configuration like plugin versions, common dependencies, like `log4j` for example, repositories, properties etc.) and for utility package module (the one that assembles the project and does some other necessary things). Judging from my experience (I did it several times), when migrating project from ant to maven you should take all the jar files that your project used to depend on and convert them into maven dependencies (`groupId:artifactId:version`). Most probably all of these dependencies will not have any `<type>` (e.g. be jars).
1,170
In movie *[The Reader](http://www.imdb.com/title/tt0976051/)*, **Hanna Schmitz** was sentenced to life imprisonment because of her role in the death of 300 victims. But I could not understand whether she was really responsible for that *or* whether she was **framed by her colleague** because of her illiteracy? Did she **really do that**? Why didn't they show this part in the movie? ![enter image description here](https://i.stack.imgur.com/nJHgv.jpg)
2012/02/03
[ "https://movies.stackexchange.com/questions/1170", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/556/" ]
Hanna Smitchz was, in a way, responsible for the the death of the 300 people. Her illiteracy does not omit her from the wrongs she had committed when she sent several people to die. Illiteracy is simply an academic disadvantage that may result to social difficulties, but would not necessarily blind her moral capabilities. She was, unfortunately, framed by her colleagues as the master mind behind the deed. Being the 'master mind' behind the crime would ultimately lead to more years in jail, and indeed she did- she received a life sentence in jail (she got out at 18 years) whereas her colleagues received far less. The important part is, however, in legal scholarship you can be held responsible for a crime if you were simply a part of the scheme. Your role in the crime will be a factor when the judge issues a sentence, but she is not entirely innocent. Even if Michael Berg did disclose the details on her illiteracy to the judge, she would not be without a life sentence.
Hanna was probably guilty but you would have to question her overall intelligence. In the film she had no understanding of right or wrong. First of all having an affair with a kid.she saw nothing wrong with this and also in court she saw nothing wrong with condemning 300 people to death. I think she was a pawn and was took advantage of due to her lack of intelligence or understanding of situations so ultimately I could not find her guilty.a misfortune misled woman.
1,170
In movie *[The Reader](http://www.imdb.com/title/tt0976051/)*, **Hanna Schmitz** was sentenced to life imprisonment because of her role in the death of 300 victims. But I could not understand whether she was really responsible for that *or* whether she was **framed by her colleague** because of her illiteracy? Did she **really do that**? Why didn't they show this part in the movie? ![enter image description here](https://i.stack.imgur.com/nJHgv.jpg)
2012/02/03
[ "https://movies.stackexchange.com/questions/1170", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/556/" ]
> > She denies authorship of a report on the church fire, despite pressure from the other defendants, but then admits it rather than complying with a demand to provide a handwriting sample.... she is illiterate and has concealed it her whole life. The other female guards who claim she wrote the report are lying to place responsibility on Hanna. [wikipedia](http://en.wikipedia.org/wiki/The_Reader_%282008_film%29) > > > So, she said she was guilty (even though she wasn't) only not to write down something, because she wasn't able. The whole life she's too ashamed of this thing so she never admitted, even if admitting it would have reduced her sentence in prison. I don't think the other female guards knew about her illiteracy or at list it's not shown in the movie (you could read the book -- [The reader](http://en.wikipedia.org/wiki/The_Reader) if you want to have more details), but I think that's the point: she can easily admit she can't read or write to defend herself. I also think she was not guilty (because the movie led me that way) even if I found several sources stating that the movie contained a cutback scene to her standing refusing to open the doors and allowing the 300 to burn.
Hanna is a morally ambiguous character. I have read that some believe she was based on Ilsa Koch, but the crimes and cruelty that Hanna was accused of pale in comparison to the cruelty that Ilsa exhibited. Certainly Hanna was guilty of the crime at the church, but no more than the other defendants and due to her illiteracy, maybe, just maybe, a little less. Still, she had more than enough guilt on her conscience and when, she was finally able to read about what the consequences were for those people, her guilt became overwhelming. So yeah.. she was guilty, but in more than just the legal sense. After all, the story is about the German people dealing with the guilt of the Holocaust.
1,170
In movie *[The Reader](http://www.imdb.com/title/tt0976051/)*, **Hanna Schmitz** was sentenced to life imprisonment because of her role in the death of 300 victims. But I could not understand whether she was really responsible for that *or* whether she was **framed by her colleague** because of her illiteracy? Did she **really do that**? Why didn't they show this part in the movie? ![enter image description here](https://i.stack.imgur.com/nJHgv.jpg)
2012/02/03
[ "https://movies.stackexchange.com/questions/1170", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/556/" ]
> > She denies authorship of a report on the church fire, despite pressure from the other defendants, but then admits it rather than complying with a demand to provide a handwriting sample.... she is illiterate and has concealed it her whole life. The other female guards who claim she wrote the report are lying to place responsibility on Hanna. [wikipedia](http://en.wikipedia.org/wiki/The_Reader_%282008_film%29) > > > So, she said she was guilty (even though she wasn't) only not to write down something, because she wasn't able. The whole life she's too ashamed of this thing so she never admitted, even if admitting it would have reduced her sentence in prison. I don't think the other female guards knew about her illiteracy or at list it's not shown in the movie (you could read the book -- [The reader](http://en.wikipedia.org/wiki/The_Reader) if you want to have more details), but I think that's the point: she can easily admit she can't read or write to defend herself. I also think she was not guilty (because the movie led me that way) even if I found several sources stating that the movie contained a cutback scene to her standing refusing to open the doors and allowing the 300 to burn.
In response to the poster above who remarks that Hanna was not intelligent and could thus not distinguish right from wrong, I would like to make a comment.Hanna was not unintelligent. Her actions had nothing to do with intelligence. Hanna's illiteracy resulted in the facts that she could not appreciate or recognize ambiguity or recognize that she--not others--had the power to make choices for herself. Being a prisoner of her illiteracy, she did not recognize that she had the power to choose to open the door. She could not understand subtlety or irony or paradox or "breaking the rules" because she was a "black or white" or either/or thinker. Hanna was both guilty because she sent women to their deaths and did not open the doors, but not guilty because she did not understand that she had the power to make choices that were not the rules imposed on her by her authorities. Tragically, the greatest victim in "The Reader" is Hanna.
1,170
In movie *[The Reader](http://www.imdb.com/title/tt0976051/)*, **Hanna Schmitz** was sentenced to life imprisonment because of her role in the death of 300 victims. But I could not understand whether she was really responsible for that *or* whether she was **framed by her colleague** because of her illiteracy? Did she **really do that**? Why didn't they show this part in the movie? ![enter image description here](https://i.stack.imgur.com/nJHgv.jpg)
2012/02/03
[ "https://movies.stackexchange.com/questions/1170", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/556/" ]
> > She denies authorship of a report on the church fire, despite pressure from the other defendants, but then admits it rather than complying with a demand to provide a handwriting sample.... she is illiterate and has concealed it her whole life. The other female guards who claim she wrote the report are lying to place responsibility on Hanna. [wikipedia](http://en.wikipedia.org/wiki/The_Reader_%282008_film%29) > > > So, she said she was guilty (even though she wasn't) only not to write down something, because she wasn't able. The whole life she's too ashamed of this thing so she never admitted, even if admitting it would have reduced her sentence in prison. I don't think the other female guards knew about her illiteracy or at list it's not shown in the movie (you could read the book -- [The reader](http://en.wikipedia.org/wiki/The_Reader) if you want to have more details), but I think that's the point: she can easily admit she can't read or write to defend herself. I also think she was not guilty (because the movie led me that way) even if I found several sources stating that the movie contained a cutback scene to her standing refusing to open the doors and allowing the 300 to burn.
Hanna was probably guilty but you would have to question her overall intelligence. In the film she had no understanding of right or wrong. First of all having an affair with a kid.she saw nothing wrong with this and also in court she saw nothing wrong with condemning 300 people to death. I think she was a pawn and was took advantage of due to her lack of intelligence or understanding of situations so ultimately I could not find her guilty.a misfortune misled woman.
1,170
In movie *[The Reader](http://www.imdb.com/title/tt0976051/)*, **Hanna Schmitz** was sentenced to life imprisonment because of her role in the death of 300 victims. But I could not understand whether she was really responsible for that *or* whether she was **framed by her colleague** because of her illiteracy? Did she **really do that**? Why didn't they show this part in the movie? ![enter image description here](https://i.stack.imgur.com/nJHgv.jpg)
2012/02/03
[ "https://movies.stackexchange.com/questions/1170", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/556/" ]
According to director [Stephen Daldry](http://www.cinemablend.com/new/Interview-The-Reader-Director-Stephen-Daldry-11178.html), the ambiguity is intentional: > > I think it's a complex story, and there is a great ambiguity. And one > of the things we work very hard to do is to maintain that ambiguity, > so people can have different responses to it. Mr. Schlink wrote the > book about a generational issue, about how to love. I think he wanted > to talk about, for his generation, the difficulties of loving your > parents or your teachers or your pastors, and to heighten that issue, > put the generational issue into a love affair. How is it possible to > love in the context of a generation that's been through [genocide]? Is > it possible to love? Is that love valid or invalid? When you find out > the truth about the person you love, does that mean that everything > you had together is a lie? > > > One of the stories that Michael reads to her, Checkhov's *The Lady with the Dog*, was chosen particularly because it is known for its lack of resolution. The story is a parable which was written to help the generation that came after deal with what came before. The question facing the court is not whether she is guilty or not, but her level of responsibility for this particular event. She admits her guilt with regard to the women whom she sent to be gassed. She demonstrates brutality in her dominant relationship with Michael. Whether or not she ordered the burning, she did not stop it, so she is guilty. That she would accept full responsibility for the burning over the others because she was embarrassed to admit illiteracy is telling - her illiteracy is a metaphor for whatever blindness allowed Germans to allow these atrocities to happen, and no matter what the level of actual involvement, many Germans of that generation carry the guilt as if they had ordered the atrocities themselves. Whatever excuse they have for the decisions they made seem trivial in light of the atrocities, and we see that juxtaposition in Hanna's case before the court. The challenge for Michael is what to do with the love he felt for her, just as the next generation of Germans had to deal with their love for their parents.
Hanna was probably guilty but you would have to question her overall intelligence. In the film she had no understanding of right or wrong. First of all having an affair with a kid.she saw nothing wrong with this and also in court she saw nothing wrong with condemning 300 people to death. I think she was a pawn and was took advantage of due to her lack of intelligence or understanding of situations so ultimately I could not find her guilty.a misfortune misled woman.
1,170
In movie *[The Reader](http://www.imdb.com/title/tt0976051/)*, **Hanna Schmitz** was sentenced to life imprisonment because of her role in the death of 300 victims. But I could not understand whether she was really responsible for that *or* whether she was **framed by her colleague** because of her illiteracy? Did she **really do that**? Why didn't they show this part in the movie? ![enter image description here](https://i.stack.imgur.com/nJHgv.jpg)
2012/02/03
[ "https://movies.stackexchange.com/questions/1170", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/556/" ]
Hanna Smitchz was, in a way, responsible for the the death of the 300 people. Her illiteracy does not omit her from the wrongs she had committed when she sent several people to die. Illiteracy is simply an academic disadvantage that may result to social difficulties, but would not necessarily blind her moral capabilities. She was, unfortunately, framed by her colleagues as the master mind behind the deed. Being the 'master mind' behind the crime would ultimately lead to more years in jail, and indeed she did- she received a life sentence in jail (she got out at 18 years) whereas her colleagues received far less. The important part is, however, in legal scholarship you can be held responsible for a crime if you were simply a part of the scheme. Your role in the crime will be a factor when the judge issues a sentence, but she is not entirely innocent. Even if Michael Berg did disclose the details on her illiteracy to the judge, she would not be without a life sentence.
Hanna is a morally ambiguous character. I have read that some believe she was based on Ilsa Koch, but the crimes and cruelty that Hanna was accused of pale in comparison to the cruelty that Ilsa exhibited. Certainly Hanna was guilty of the crime at the church, but no more than the other defendants and due to her illiteracy, maybe, just maybe, a little less. Still, she had more than enough guilt on her conscience and when, she was finally able to read about what the consequences were for those people, her guilt became overwhelming. So yeah.. she was guilty, but in more than just the legal sense. After all, the story is about the German people dealing with the guilt of the Holocaust.
1,170
In movie *[The Reader](http://www.imdb.com/title/tt0976051/)*, **Hanna Schmitz** was sentenced to life imprisonment because of her role in the death of 300 victims. But I could not understand whether she was really responsible for that *or* whether she was **framed by her colleague** because of her illiteracy? Did she **really do that**? Why didn't they show this part in the movie? ![enter image description here](https://i.stack.imgur.com/nJHgv.jpg)
2012/02/03
[ "https://movies.stackexchange.com/questions/1170", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/556/" ]
According to director [Stephen Daldry](http://www.cinemablend.com/new/Interview-The-Reader-Director-Stephen-Daldry-11178.html), the ambiguity is intentional: > > I think it's a complex story, and there is a great ambiguity. And one > of the things we work very hard to do is to maintain that ambiguity, > so people can have different responses to it. Mr. Schlink wrote the > book about a generational issue, about how to love. I think he wanted > to talk about, for his generation, the difficulties of loving your > parents or your teachers or your pastors, and to heighten that issue, > put the generational issue into a love affair. How is it possible to > love in the context of a generation that's been through [genocide]? Is > it possible to love? Is that love valid or invalid? When you find out > the truth about the person you love, does that mean that everything > you had together is a lie? > > > One of the stories that Michael reads to her, Checkhov's *The Lady with the Dog*, was chosen particularly because it is known for its lack of resolution. The story is a parable which was written to help the generation that came after deal with what came before. The question facing the court is not whether she is guilty or not, but her level of responsibility for this particular event. She admits her guilt with regard to the women whom she sent to be gassed. She demonstrates brutality in her dominant relationship with Michael. Whether or not she ordered the burning, she did not stop it, so she is guilty. That she would accept full responsibility for the burning over the others because she was embarrassed to admit illiteracy is telling - her illiteracy is a metaphor for whatever blindness allowed Germans to allow these atrocities to happen, and no matter what the level of actual involvement, many Germans of that generation carry the guilt as if they had ordered the atrocities themselves. Whatever excuse they have for the decisions they made seem trivial in light of the atrocities, and we see that juxtaposition in Hanna's case before the court. The challenge for Michael is what to do with the love he felt for her, just as the next generation of Germans had to deal with their love for their parents.
it seems to me that the whole theme of the movie was that she had decided to cover up being illiterate at all costs ------- and she proved it by agreeing to be the fall guy for all six guards
1,170
In movie *[The Reader](http://www.imdb.com/title/tt0976051/)*, **Hanna Schmitz** was sentenced to life imprisonment because of her role in the death of 300 victims. But I could not understand whether she was really responsible for that *or* whether she was **framed by her colleague** because of her illiteracy? Did she **really do that**? Why didn't they show this part in the movie? ![enter image description here](https://i.stack.imgur.com/nJHgv.jpg)
2012/02/03
[ "https://movies.stackexchange.com/questions/1170", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/556/" ]
Hanna Smitchz was, in a way, responsible for the the death of the 300 people. Her illiteracy does not omit her from the wrongs she had committed when she sent several people to die. Illiteracy is simply an academic disadvantage that may result to social difficulties, but would not necessarily blind her moral capabilities. She was, unfortunately, framed by her colleagues as the master mind behind the deed. Being the 'master mind' behind the crime would ultimately lead to more years in jail, and indeed she did- she received a life sentence in jail (she got out at 18 years) whereas her colleagues received far less. The important part is, however, in legal scholarship you can be held responsible for a crime if you were simply a part of the scheme. Your role in the crime will be a factor when the judge issues a sentence, but she is not entirely innocent. Even if Michael Berg did disclose the details on her illiteracy to the judge, she would not be without a life sentence.
In response to the poster above who remarks that Hanna was not intelligent and could thus not distinguish right from wrong, I would like to make a comment.Hanna was not unintelligent. Her actions had nothing to do with intelligence. Hanna's illiteracy resulted in the facts that she could not appreciate or recognize ambiguity or recognize that she--not others--had the power to make choices for herself. Being a prisoner of her illiteracy, she did not recognize that she had the power to choose to open the door. She could not understand subtlety or irony or paradox or "breaking the rules" because she was a "black or white" or either/or thinker. Hanna was both guilty because she sent women to their deaths and did not open the doors, but not guilty because she did not understand that she had the power to make choices that were not the rules imposed on her by her authorities. Tragically, the greatest victim in "The Reader" is Hanna.
1,170
In movie *[The Reader](http://www.imdb.com/title/tt0976051/)*, **Hanna Schmitz** was sentenced to life imprisonment because of her role in the death of 300 victims. But I could not understand whether she was really responsible for that *or* whether she was **framed by her colleague** because of her illiteracy? Did she **really do that**? Why didn't they show this part in the movie? ![enter image description here](https://i.stack.imgur.com/nJHgv.jpg)
2012/02/03
[ "https://movies.stackexchange.com/questions/1170", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/556/" ]
According to director [Stephen Daldry](http://www.cinemablend.com/new/Interview-The-Reader-Director-Stephen-Daldry-11178.html), the ambiguity is intentional: > > I think it's a complex story, and there is a great ambiguity. And one > of the things we work very hard to do is to maintain that ambiguity, > so people can have different responses to it. Mr. Schlink wrote the > book about a generational issue, about how to love. I think he wanted > to talk about, for his generation, the difficulties of loving your > parents or your teachers or your pastors, and to heighten that issue, > put the generational issue into a love affair. How is it possible to > love in the context of a generation that's been through [genocide]? Is > it possible to love? Is that love valid or invalid? When you find out > the truth about the person you love, does that mean that everything > you had together is a lie? > > > One of the stories that Michael reads to her, Checkhov's *The Lady with the Dog*, was chosen particularly because it is known for its lack of resolution. The story is a parable which was written to help the generation that came after deal with what came before. The question facing the court is not whether she is guilty or not, but her level of responsibility for this particular event. She admits her guilt with regard to the women whom she sent to be gassed. She demonstrates brutality in her dominant relationship with Michael. Whether or not she ordered the burning, she did not stop it, so she is guilty. That she would accept full responsibility for the burning over the others because she was embarrassed to admit illiteracy is telling - her illiteracy is a metaphor for whatever blindness allowed Germans to allow these atrocities to happen, and no matter what the level of actual involvement, many Germans of that generation carry the guilt as if they had ordered the atrocities themselves. Whatever excuse they have for the decisions they made seem trivial in light of the atrocities, and we see that juxtaposition in Hanna's case before the court. The challenge for Michael is what to do with the love he felt for her, just as the next generation of Germans had to deal with their love for their parents.
In response to the poster above who remarks that Hanna was not intelligent and could thus not distinguish right from wrong, I would like to make a comment.Hanna was not unintelligent. Her actions had nothing to do with intelligence. Hanna's illiteracy resulted in the facts that she could not appreciate or recognize ambiguity or recognize that she--not others--had the power to make choices for herself. Being a prisoner of her illiteracy, she did not recognize that she had the power to choose to open the door. She could not understand subtlety or irony or paradox or "breaking the rules" because she was a "black or white" or either/or thinker. Hanna was both guilty because she sent women to their deaths and did not open the doors, but not guilty because she did not understand that she had the power to make choices that were not the rules imposed on her by her authorities. Tragically, the greatest victim in "The Reader" is Hanna.
1,170
In movie *[The Reader](http://www.imdb.com/title/tt0976051/)*, **Hanna Schmitz** was sentenced to life imprisonment because of her role in the death of 300 victims. But I could not understand whether she was really responsible for that *or* whether she was **framed by her colleague** because of her illiteracy? Did she **really do that**? Why didn't they show this part in the movie? ![enter image description here](https://i.stack.imgur.com/nJHgv.jpg)
2012/02/03
[ "https://movies.stackexchange.com/questions/1170", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/556/" ]
Hanna Smitchz was, in a way, responsible for the the death of the 300 people. Her illiteracy does not omit her from the wrongs she had committed when she sent several people to die. Illiteracy is simply an academic disadvantage that may result to social difficulties, but would not necessarily blind her moral capabilities. She was, unfortunately, framed by her colleagues as the master mind behind the deed. Being the 'master mind' behind the crime would ultimately lead to more years in jail, and indeed she did- she received a life sentence in jail (she got out at 18 years) whereas her colleagues received far less. The important part is, however, in legal scholarship you can be held responsible for a crime if you were simply a part of the scheme. Your role in the crime will be a factor when the judge issues a sentence, but she is not entirely innocent. Even if Michael Berg did disclose the details on her illiteracy to the judge, she would not be without a life sentence.
it seems to me that the whole theme of the movie was that she had decided to cover up being illiterate at all costs ------- and she proved it by agreeing to be the fall guy for all six guards
720,900
We wish to classify the factor group $(\mathbb{Z} \times \mathbb{Z})/\langle (2, 2) \rangle$, that is, find a group to which it is isomorphic. (According to the fundamental theorem of finitely generated abelian groups. Initially, I thought the group had but two cosets, forcing an isomorphism to $\mathbb{Z}\_2$. Obviously, this is wrong, due to the existence of cosets such as $(1, 0) + \langle (2, 2) \rangle$ However, I am unable to see how I am to find an isomorphism here.
2014/03/21
[ "https://math.stackexchange.com/questions/720900", "https://math.stackexchange.com", "https://math.stackexchange.com/users/92231/" ]
Hints: * Show that $\Bbb{Z}\times\Bbb{Z}$ is generated (freely) by the elements $u=(1,0)$ and $v=(1,1)$. IOW every element $(a,b)\in\Bbb{Z}\times\Bbb{Z}$ can be written as a linear combination of $u$ and $v$ with integer coefficients in a unique way. * Show that $mu+nv$ is in the subgroup generated by $(2,2)$ if and only if $m=0$ and $n$ is even. * Show that the mapping $mu+nv+\langle(2,2)\rangle \mapsto (m,\overline{n})$ is an isomorphism from $(\Bbb{Z}\times\Bbb{Z})/\langle(2,2)\rangle$ to $\Bbb{Z}\times(\Bbb{Z}/2\Bbb{Z})$.
The kernel of the surjective map $\mathbb Z\times\mathbb Z\to \mathbb Z\times\mathbb Z/2\mathbb Z$ given by $(m,n)\mapsto (m-n,n)$ is $\langle(2,2)\rangle$.
26,892,023
First off im a newbie to android dev so im not 100% sure what im doing. I've a log-out button which works but the other button i have coded (the scan button) is no longer working, i did have it working before i put in the code for the log out button. In log cat when i press the scan button no errors at all come up which obviously suggests its not being called at all and im not sure were ive gone wrong. ``` import library.UserFunctions; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.google.zxing.integration.android.IntentIntegrator; import com.google.zxing.integration.android.IntentResult; public class menuActivity extends Activity implements OnClickListener { private Button scan; private TextView contentTxt; UserFunctions userFunctions; Button btnLogout; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.menu); scan = (Button)findViewById(R.id.btnbarcode); contentTxt = (TextView)findViewById(R.id.manText); scan.setOnClickListener(this); // Check login status in database userFunctions = new UserFunctions(); if(userFunctions.isUserLoggedIn(getApplicationContext())) { // user already logged in show menu setContentView(R.layout.menu); btnLogout = (Button)findViewById(R.id.btnLogout); btnLogout.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { // TODO Auto-generated method stub userFunctions.logoutUser(getApplicationContext()); Intent login = new Intent(getApplicationContext(), LoginActivity.class); login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(login); // Closing menu screen finish(); } }); }else{ // user is not logged in show login screen Intent login = new Intent(getApplicationContext(), LoginActivity.class); login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(login); // Closing the menu screen finish(); } } @Override public void onClick(View v) { if(v.getId()==R.id.btnbarcode) { IntentIntegrator scanIntegrator = new IntentIntegrator(this); scanIntegrator.initiateScan(); } } public void onActivityResult(int requestCode, int resultCode, Intent intent) { //retrieve scan result IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanningResult != null) { //we have a result String scanContent = scanningResult.getContents(); contentTxt.setText(scanContent); } else { Toast toast = Toast.makeText(getApplicationContext(), "No scan data received!", Toast.LENGTH_SHORT); toast.show(); } } } ``` Thanks Folks
2014/11/12
[ "https://Stackoverflow.com/questions/26892023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4244746/" ]
Yes, it runs twice if not redirected... Do this ``` $data['review'] = $this->review_model->GetReview($data['review_type'], $data['review_id']); if (!$data['review']) { redirect(); } ```
For your question, No, once `redirect()` method called, further line not executed. But your checking is not good. you can change it is as following ``` $data['review'] = $this->review_model->GetReview($data['review_type'], $data['review_id']); if(!$data['review']){ redirect(); } ```
14,251,711
I have two apps, A and B. I want to call B by A. My code in A is as below: ``` Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(new ComponentName("com.example.bapp","com.example.bapp.BActivity")); intent.putExtra ("test2abc", "abctest2"); startActivity(intent); ``` And B's intent filter in manifest as below: ``` <intent-filter> <action android:name="ACTION_BACKCALL" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> ``` But it will close B before launch B while B had opened. I find below code to open \*.txt file. This will open two txt reader app at the same time. ``` Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), mimetype); startActivity(inte ``` nt); How can I arrive that?
2013/01/10
[ "https://Stackoverflow.com/questions/14251711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1070896/" ]
you might want to try **android:launchMode="singleInstance"** and **android:finishOnTaskLaunch="true"** while defining launcher activity. ``` <activity android:name="com.example.test.sampleMediaPlayer" android:label="@string/app_name" android:launchMode="singleInstance" android:finishOnTaskLaunch="true" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> ``` For Activity A.
hey i found this code snippet [Launch an application from another application on Android](https://stackoverflow.com/questions/3872063/android-launch-an-application-from-another-application) which will work for you set the address of the application which you want to launch ``` Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address"); startActivity(LaunchIntent); ```
16,130
I have this sentence in my JLPT exercise book: > > 彼{かれ}は有名人{ゆうめいじん}ゆえの不自由{ふじゆう}さから逃{に}げたくなった。 > > > The translation offered is: > > He wanted to get away from the difficulties of being a celebrity. > > > What is throwing me is the `逃{に}げたくなった` part. It seems to me that the past tense form of "wanted to get away" should be `逃{に}げたかった`, and the past tense form of "did not want to get away" should be `逃{に}げたくなかった`. I feel the English translation probably represents the intended meaning, because it would be weird to not want to get away from difficulties, but on the other hand my own translation of the original Japanese is something along the lines that he did not want to escape. So what is `逃{に}げたくなった`? Am I wrong about the verb forms I think it should be, or is something else going on here?
2014/05/27
[ "https://japanese.stackexchange.com/questions/16130", "https://japanese.stackexchange.com", "https://japanese.stackexchange.com/users/119/" ]
逃げたくなった is: * 逃げる = "to flee", in its stem form (連用形) → 逃げ * ~たい = the suffix that expresses wanting to do, conjugated to ~たく (again, the 連用形) * なる = "to become", in past tense → なった So this means something to the effect of "it became the case that he wanted to get away". For the sentence as a whole, I would offer a translation like "he began to want to get away from the difficulties of being a celebrity". For "he did not want to get away", you would indeed use 逃げたくな**か**った.
逃げたくなった is the past tense form of 逃げ+たく+なる which consists of 動詞「逃げる」 + 助動詞「たい」 + 動詞「なる」. 逃げ >> 連用形(continuative form) of 逃げる >> run away たく >> 連用形(continuative form) of the volitional たい >> want to なった >> the past tense form of なる(成る) >> become So it's like "became to want to run away", i.e. "started to feel like running away".
64,487,754
In the R session below, `summary(model)` shows the formula as `model_str`. How do I get it to show as `mpg ~ cyl + hp` while still being able to set the model formula via a string? ``` > data(mtcars) > names(mtcars) [1] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear" "carb" > model_str <- 'mpg ~ cyl + hp' > model <- lm(model_str, data=mtcars) > summary(model) Call: lm(formula = model_str, data = mtcars) Residuals: Min 1Q Median 3Q Max -4.4948 -2.4901 -0.1828 1.9777 7.2934 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 36.90833 2.19080 16.847 < 2e-16 *** cyl -2.26469 0.57589 -3.933 0.00048 *** hp -0.01912 0.01500 -1.275 0.21253 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 3.173 on 29 degrees of freedom Multiple R-squared: 0.7407, Adjusted R-squared: 0.7228 F-statistic: 41.42 on 2 and 29 DF, p-value: 3.162e-09 ```
2020/10/22
[ "https://Stackoverflow.com/questions/64487754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34935/" ]
It's a bit of a hack and so probably fragile, but modifying the `formula` element of the `call` element of the model works: ``` model$call$formula <- formula(model_str) summary(model) ## Call: ## lm(formula = mpg ~ cyl + hp, data = mtcars) ```
Use `str2lang`, then `do.call`. ``` fo <- str2lang("mpg ~ hp + am") do.call("lm", list(fo, quote(mtcars))) # # Call: # lm(formula = mpg ~ hp + am, data = mtcars) # # Coefficients: # (Intercept) hp am # 26.58491 -0.05889 5.27709 ```
64,487,754
In the R session below, `summary(model)` shows the formula as `model_str`. How do I get it to show as `mpg ~ cyl + hp` while still being able to set the model formula via a string? ``` > data(mtcars) > names(mtcars) [1] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear" "carb" > model_str <- 'mpg ~ cyl + hp' > model <- lm(model_str, data=mtcars) > summary(model) Call: lm(formula = model_str, data = mtcars) Residuals: Min 1Q Median 3Q Max -4.4948 -2.4901 -0.1828 1.9777 7.2934 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 36.90833 2.19080 16.847 < 2e-16 *** cyl -2.26469 0.57589 -3.933 0.00048 *** hp -0.01912 0.01500 -1.275 0.21253 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 3.173 on 29 degrees of freedom Multiple R-squared: 0.7407, Adjusted R-squared: 0.7228 F-statistic: 41.42 on 2 and 29 DF, p-value: 3.162e-09 ```
2020/10/22
[ "https://Stackoverflow.com/questions/64487754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34935/" ]
Use `do.call` so that `model_str` gets evaluated before being sent to `lm` but quote `mtcars` so that it is not (otherwise there would be a huge output showing the actual values in `mtcars`). ``` do.call("lm", list(as.formula(model_str), data = quote(mtcars))) ``` giving: ``` Call: lm(formula = mpg ~ cyl + hp, data = mtcars) Coefficients: (Intercept) cyl hp 36.90833 -2.26469 -0.01912 ```
It's a bit of a hack and so probably fragile, but modifying the `formula` element of the `call` element of the model works: ``` model$call$formula <- formula(model_str) summary(model) ## Call: ## lm(formula = mpg ~ cyl + hp, data = mtcars) ```
64,487,754
In the R session below, `summary(model)` shows the formula as `model_str`. How do I get it to show as `mpg ~ cyl + hp` while still being able to set the model formula via a string? ``` > data(mtcars) > names(mtcars) [1] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear" "carb" > model_str <- 'mpg ~ cyl + hp' > model <- lm(model_str, data=mtcars) > summary(model) Call: lm(formula = model_str, data = mtcars) Residuals: Min 1Q Median 3Q Max -4.4948 -2.4901 -0.1828 1.9777 7.2934 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 36.90833 2.19080 16.847 < 2e-16 *** cyl -2.26469 0.57589 -3.933 0.00048 *** hp -0.01912 0.01500 -1.275 0.21253 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 3.173 on 29 degrees of freedom Multiple R-squared: 0.7407, Adjusted R-squared: 0.7228 F-statistic: 41.42 on 2 and 29 DF, p-value: 3.162e-09 ```
2020/10/22
[ "https://Stackoverflow.com/questions/64487754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34935/" ]
You can build and evaluate the call directly in a single line: ```r eval(as.call(list(quote(lm), formula = model_str, data = quote(mtcars)))) #> #> Call: #> lm(formula = "mpg ~ cyl + hp", data = mtcars) #> #> Coefficients: #> (Intercept) cyl hp #> 36.90833 -2.26469 -0.01912 ```
Use `str2lang`, then `do.call`. ``` fo <- str2lang("mpg ~ hp + am") do.call("lm", list(fo, quote(mtcars))) # # Call: # lm(formula = mpg ~ hp + am, data = mtcars) # # Coefficients: # (Intercept) hp am # 26.58491 -0.05889 5.27709 ```
64,487,754
In the R session below, `summary(model)` shows the formula as `model_str`. How do I get it to show as `mpg ~ cyl + hp` while still being able to set the model formula via a string? ``` > data(mtcars) > names(mtcars) [1] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear" "carb" > model_str <- 'mpg ~ cyl + hp' > model <- lm(model_str, data=mtcars) > summary(model) Call: lm(formula = model_str, data = mtcars) Residuals: Min 1Q Median 3Q Max -4.4948 -2.4901 -0.1828 1.9777 7.2934 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 36.90833 2.19080 16.847 < 2e-16 *** cyl -2.26469 0.57589 -3.933 0.00048 *** hp -0.01912 0.01500 -1.275 0.21253 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 3.173 on 29 degrees of freedom Multiple R-squared: 0.7407, Adjusted R-squared: 0.7228 F-statistic: 41.42 on 2 and 29 DF, p-value: 3.162e-09 ```
2020/10/22
[ "https://Stackoverflow.com/questions/64487754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34935/" ]
Use `do.call` so that `model_str` gets evaluated before being sent to `lm` but quote `mtcars` so that it is not (otherwise there would be a huge output showing the actual values in `mtcars`). ``` do.call("lm", list(as.formula(model_str), data = quote(mtcars))) ``` giving: ``` Call: lm(formula = mpg ~ cyl + hp, data = mtcars) Coefficients: (Intercept) cyl hp 36.90833 -2.26469 -0.01912 ```
You can build and evaluate the call directly in a single line: ```r eval(as.call(list(quote(lm), formula = model_str, data = quote(mtcars)))) #> #> Call: #> lm(formula = "mpg ~ cyl + hp", data = mtcars) #> #> Coefficients: #> (Intercept) cyl hp #> 36.90833 -2.26469 -0.01912 ```
64,487,754
In the R session below, `summary(model)` shows the formula as `model_str`. How do I get it to show as `mpg ~ cyl + hp` while still being able to set the model formula via a string? ``` > data(mtcars) > names(mtcars) [1] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear" "carb" > model_str <- 'mpg ~ cyl + hp' > model <- lm(model_str, data=mtcars) > summary(model) Call: lm(formula = model_str, data = mtcars) Residuals: Min 1Q Median 3Q Max -4.4948 -2.4901 -0.1828 1.9777 7.2934 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 36.90833 2.19080 16.847 < 2e-16 *** cyl -2.26469 0.57589 -3.933 0.00048 *** hp -0.01912 0.01500 -1.275 0.21253 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 3.173 on 29 degrees of freedom Multiple R-squared: 0.7407, Adjusted R-squared: 0.7228 F-statistic: 41.42 on 2 and 29 DF, p-value: 3.162e-09 ```
2020/10/22
[ "https://Stackoverflow.com/questions/64487754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34935/" ]
Use `do.call` so that `model_str` gets evaluated before being sent to `lm` but quote `mtcars` so that it is not (otherwise there would be a huge output showing the actual values in `mtcars`). ``` do.call("lm", list(as.formula(model_str), data = quote(mtcars))) ``` giving: ``` Call: lm(formula = mpg ~ cyl + hp, data = mtcars) Coefficients: (Intercept) cyl hp 36.90833 -2.26469 -0.01912 ```
Use `str2lang`, then `do.call`. ``` fo <- str2lang("mpg ~ hp + am") do.call("lm", list(fo, quote(mtcars))) # # Call: # lm(formula = mpg ~ hp + am, data = mtcars) # # Coefficients: # (Intercept) hp am # 26.58491 -0.05889 5.27709 ```
593,928
I work a lot in two folders: ``` /home/valter/Dropbox/Development/git/valter /home/valter/Dropbox/Development/git/company ``` I would like to create command like: ``` $valter ``` and enter in `/home/valter/Dropbox/Development/git/valter` and ``` $company ``` and enter in `/home/valter/Dropbox/Development/git/company` ``` /home/valter/Dropbox/Development/git/company ``` I tried create some alias in `~/.bashrc` but nothing works so far. ``` alias valter="cd /home/valter/Dropbox/Development/git/valter/" ``` **update** @mpy: ``` meniac chef: valter No command 'valter' found, did you mean: Command 'qalter' from package 'torque-client' (universe) Command 'qalter' from package 'gridengine-client' (universe) Command 'qalter' from package 'torque-client-x11' (universe) valter: command not found ```
2013/05/10
[ "https://superuser.com/questions/593928", "https://superuser.com", "https://superuser.com/users/101020/" ]
As requested, I'll post an answer, but `@mpy`'s suggestion would've also done the job. You'll have to re-source your ~/.bashrc using `source ~/.bashrc` **or** establish a new session (which would source that for you).
Try replacing `"`'s (quote) with `'`'s (single-quote) instead. Also, make sure you reload your `.bashrc` either by starting a new terminal emulator window, or by doing `. .bashrc` in your home folder.
31,351,533
I'm new to JavaScript and am trying to create a recursive function that checks if two DOM nodes are equivalent. This function seems to be returning true for everything and isn't checking the DOM the way I want it to for some reason. Only nodes 1 & 4 are equivalent. ``` var htmlStrings = ['<div id="one">Some<span>node <em>contents</em> for</span>comparison</div>', '<div id="two">Some<span>node contents for</span>comparison</div>', '<div id="one">Some<span>node <strong>contents</strong> for</span>comparison</div>', '<div id="four">Some<span>node <em>contents</em> for</span>comparison</div>']; var div1 = document.createElement('div'); div1.innerHTML = htmlStrings[0]; document.body.appendChild(div1); var div2 = document.createElement('div'); div2.innerHTML = htmlStrings[1]; document.body.appendChild(div2); var div3 = document.createElement('div'); div3.innerHTML = htmlStrings[2]; document.body.appendChild(div3); var div4 = document.createElement('div'); div4.innerHTML = htmlStrings[3]; document.body.appendChild(div4); function nodeEquivalence(node1, node2) { var passed = false; if (node1.nodeType === node2.nodeType) { if ((node1.tagName === node2.tagName && node1.nodeValue === node2.nodeValue)) { passed = true; } } node1 = node1.firstChild; node2 = node2.firstChild; while (node1 && node2) { nodeEquivalence(node1, node2); node1 = node1.nextSibling; node2 = node2.nextSibling; } return passed; } console.log(nodeEquivalence(div1, div2)); console.log(nodeEquivalence(div1, div4)); ```
2015/07/10
[ "https://Stackoverflow.com/questions/31351533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4178793/" ]
You're passing strings, not DOM elements. You need to convert the HTML to DOM elements. There are many solutions described at [Creating a new DOM element from an HTML string using built-in DOM methods or prototype](https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro) So you can do: ```js var html1 = '<div id="one">Some<span>node <em>contents</em> for</span>comparison</div>'; var html2 = '<div id="four">Some<span>node <em>contents</em> for</span>comparison</div>'; var html3 = '<div id="one">Some<span>node <b>contents</b> for</span>comparison</div>'; var div1 = document.createElement('div'); div1.innerHTML = html1; var div2 = document.createElement('div'); div2.innerHTML = html2; var div3 = document.createElement('div'); div3.innerHTML = html3; alert(nodeEquivalence(div1.firstChild, div2.firstChild)); alert(nodeEquivalence(div1.firstChild, div3.firstChild)); function nodeEquivalence (node1, node2) { var passed = true; function test(node1, node2) { if ((node1.nodeType === node2.nodeType) && (node1.tagName === node2.tagName || node1.nodeValue === node2.nodeValue) && (node1.childNodes.length === node2.childNodes.length)) { passed = true; } else { passed = false; } } node1 = node1.firstChild; node2 = node2.firstChild; while (passed && node1 && node2) { test(node1, node2); node1 = node1.nextSibling; node2 = node2.nextSibling; } //test(document.body); return passed; }; ```
Use `document.createElement(*tagName*)` [Here](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement) is some documentation. For example, you'll want to create two elements, pass them both in and see if they're equivalent. And then you can base the same one in twice. ``` var newDiv = document.createElement("div"); var newSpan = document.createElement("span"); ```
31,351,533
I'm new to JavaScript and am trying to create a recursive function that checks if two DOM nodes are equivalent. This function seems to be returning true for everything and isn't checking the DOM the way I want it to for some reason. Only nodes 1 & 4 are equivalent. ``` var htmlStrings = ['<div id="one">Some<span>node <em>contents</em> for</span>comparison</div>', '<div id="two">Some<span>node contents for</span>comparison</div>', '<div id="one">Some<span>node <strong>contents</strong> for</span>comparison</div>', '<div id="four">Some<span>node <em>contents</em> for</span>comparison</div>']; var div1 = document.createElement('div'); div1.innerHTML = htmlStrings[0]; document.body.appendChild(div1); var div2 = document.createElement('div'); div2.innerHTML = htmlStrings[1]; document.body.appendChild(div2); var div3 = document.createElement('div'); div3.innerHTML = htmlStrings[2]; document.body.appendChild(div3); var div4 = document.createElement('div'); div4.innerHTML = htmlStrings[3]; document.body.appendChild(div4); function nodeEquivalence(node1, node2) { var passed = false; if (node1.nodeType === node2.nodeType) { if ((node1.tagName === node2.tagName && node1.nodeValue === node2.nodeValue)) { passed = true; } } node1 = node1.firstChild; node2 = node2.firstChild; while (node1 && node2) { nodeEquivalence(node1, node2); node1 = node1.nextSibling; node2 = node2.nextSibling; } return passed; } console.log(nodeEquivalence(div1, div2)); console.log(nodeEquivalence(div1, div4)); ```
2015/07/10
[ "https://Stackoverflow.com/questions/31351533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4178793/" ]
You're passing strings, not DOM elements. You need to convert the HTML to DOM elements. There are many solutions described at [Creating a new DOM element from an HTML string using built-in DOM methods or prototype](https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro) So you can do: ```js var html1 = '<div id="one">Some<span>node <em>contents</em> for</span>comparison</div>'; var html2 = '<div id="four">Some<span>node <em>contents</em> for</span>comparison</div>'; var html3 = '<div id="one">Some<span>node <b>contents</b> for</span>comparison</div>'; var div1 = document.createElement('div'); div1.innerHTML = html1; var div2 = document.createElement('div'); div2.innerHTML = html2; var div3 = document.createElement('div'); div3.innerHTML = html3; alert(nodeEquivalence(div1.firstChild, div2.firstChild)); alert(nodeEquivalence(div1.firstChild, div3.firstChild)); function nodeEquivalence (node1, node2) { var passed = true; function test(node1, node2) { if ((node1.nodeType === node2.nodeType) && (node1.tagName === node2.tagName || node1.nodeValue === node2.nodeValue) && (node1.childNodes.length === node2.childNodes.length)) { passed = true; } else { passed = false; } } node1 = node1.firstChild; node2 = node2.firstChild; while (passed && node1 && node2) { test(node1, node2); node1 = node1.nextSibling; node2 = node2.nextSibling; } //test(document.body); return passed; }; ```
yes, instead of comparing 2 html elements, you are simply comparing 2 strings. And your node1, node2 will always be undefined. by the way, this following has some nice examples as to how to compare 2 html elements. [How to compare two HTML elements](https://stackoverflow.com/questions/10679762/how-to-compare-two-html-elements)
31,351,533
I'm new to JavaScript and am trying to create a recursive function that checks if two DOM nodes are equivalent. This function seems to be returning true for everything and isn't checking the DOM the way I want it to for some reason. Only nodes 1 & 4 are equivalent. ``` var htmlStrings = ['<div id="one">Some<span>node <em>contents</em> for</span>comparison</div>', '<div id="two">Some<span>node contents for</span>comparison</div>', '<div id="one">Some<span>node <strong>contents</strong> for</span>comparison</div>', '<div id="four">Some<span>node <em>contents</em> for</span>comparison</div>']; var div1 = document.createElement('div'); div1.innerHTML = htmlStrings[0]; document.body.appendChild(div1); var div2 = document.createElement('div'); div2.innerHTML = htmlStrings[1]; document.body.appendChild(div2); var div3 = document.createElement('div'); div3.innerHTML = htmlStrings[2]; document.body.appendChild(div3); var div4 = document.createElement('div'); div4.innerHTML = htmlStrings[3]; document.body.appendChild(div4); function nodeEquivalence(node1, node2) { var passed = false; if (node1.nodeType === node2.nodeType) { if ((node1.tagName === node2.tagName && node1.nodeValue === node2.nodeValue)) { passed = true; } } node1 = node1.firstChild; node2 = node2.firstChild; while (node1 && node2) { nodeEquivalence(node1, node2); node1 = node1.nextSibling; node2 = node2.nextSibling; } return passed; } console.log(nodeEquivalence(div1, div2)); console.log(nodeEquivalence(div1, div4)); ```
2015/07/10
[ "https://Stackoverflow.com/questions/31351533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4178793/" ]
You're passing strings, not DOM elements. You need to convert the HTML to DOM elements. There are many solutions described at [Creating a new DOM element from an HTML string using built-in DOM methods or prototype](https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro) So you can do: ```js var html1 = '<div id="one">Some<span>node <em>contents</em> for</span>comparison</div>'; var html2 = '<div id="four">Some<span>node <em>contents</em> for</span>comparison</div>'; var html3 = '<div id="one">Some<span>node <b>contents</b> for</span>comparison</div>'; var div1 = document.createElement('div'); div1.innerHTML = html1; var div2 = document.createElement('div'); div2.innerHTML = html2; var div3 = document.createElement('div'); div3.innerHTML = html3; alert(nodeEquivalence(div1.firstChild, div2.firstChild)); alert(nodeEquivalence(div1.firstChild, div3.firstChild)); function nodeEquivalence (node1, node2) { var passed = true; function test(node1, node2) { if ((node1.nodeType === node2.nodeType) && (node1.tagName === node2.tagName || node1.nodeValue === node2.nodeValue) && (node1.childNodes.length === node2.childNodes.length)) { passed = true; } else { passed = false; } } node1 = node1.firstChild; node2 = node2.firstChild; while (passed && node1 && node2) { test(node1, node2); node1 = node1.nextSibling; node2 = node2.nextSibling; } //test(document.body); return passed; }; ```
Most of the relevant part is **innerHTML**. Most of the information is in there. If the innerHTML of the two HTML nodes are the same, than nearly everything is the same. Than the **tagName** and for `<input>` tags the **type** attribute: ``` function nodeEquivalence(node1, node2) { var equal = false; if (node1.innerHTML === node2.innerHTML) { if (node1.tagName === node2.tagName) { if (node1.type === node2.type) { equal = true; } } } return equal; } ``` I think, this function will catch nearly all cases. Note that there is a little difference, if you access the node via **id** or **class name**: ``` var el = document.getElementById(id); el.innerHTML var el2 = document.getElementsByClassName(className); el[0].innerHTML; ``` Also, you can compare by **outerHTML**. When you give each HTML node the same class name, you will have the exact same thing. [Example](http://jsfiddle.net/zh61e9qb/3/) Create a HTML element: ``` var div = document.createElement("div"); var text = document.createTextNode("some text"); div.appendChild(text); document.body.appendChild(div); ```
38,024,631
How can I get a list of all class names used inside an HTML Snippet? For example, the HTML Snippet below, ``` <div class="name"> <div class="first"></div> <div class="last"></div> </div> ``` would have output `name`, `first`, `last` or `name`, `name > first`, `name > last`. Here, I am concerned about finding all class selectors first. Nesting could be optional. I expect to use Javascript or Regular Expressions.
2016/06/25
[ "https://Stackoverflow.com/questions/38024631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2156512/" ]
Piggybacking off of the one-liner from @user1679669 and @Nermin's answer using [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set), you can get a list of all the classes on a page with this one-liner: ```js const allClasses = [...new Set([].concat(...[...document.querySelectorAll('*')].map(elt => [...elt.classList])))]; ```
**This is HTML:** ``` <div id="oye"> <div class="pop"></div> <div class="hop"></div> <div class="bob"></div> </div> <p id="my"></p> ``` In Jquery, You will get array of all class name, Check below code ``` $(document).ready(function(){ var myclass = []; var parent = $("#oye"); var divs = parent.children(); for(var i = 0; i < divs.length; i++){ myclass.push(divs[i].className) } //console.log(myclass); var myclasses = myclass.join(', '); $("#my").html(myclasses); }); ``` See Demo Here: <https://codepen.io/ihemant360/pen/PzWJZP>
38,024,631
How can I get a list of all class names used inside an HTML Snippet? For example, the HTML Snippet below, ``` <div class="name"> <div class="first"></div> <div class="last"></div> </div> ``` would have output `name`, `first`, `last` or `name`, `name > first`, `name > last`. Here, I am concerned about finding all class selectors first. Nesting could be optional. I expect to use Javascript or Regular Expressions.
2016/06/25
[ "https://Stackoverflow.com/questions/38024631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2156512/" ]
A one-liner that returns unique class names in alphabetical order, the query part based on @torazaburo's answer: ``` [].concat(...[...document.querySelectorAll('*')].map(e=>[...e.classList])).filter((d,i,a)=>a.indexOf(d)==i).sort() ```
Get all the classes & the unique ones in one dimension. ```js const allClasses = Array.from(new Set(document.querySelectorAll("*").map(el => el.classNames))); const flatClasses = Array.from(new Set(allClasses.flat(1))) ```
38,024,631
How can I get a list of all class names used inside an HTML Snippet? For example, the HTML Snippet below, ``` <div class="name"> <div class="first"></div> <div class="last"></div> </div> ``` would have output `name`, `first`, `last` or `name`, `name > first`, `name > last`. Here, I am concerned about finding all class selectors first. Nesting could be optional. I expect to use Javascript or Regular Expressions.
2016/06/25
[ "https://Stackoverflow.com/questions/38024631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2156512/" ]
Get all the elements in the document using `querySelectorAll`, then loop through them, getting each one's class, breaking it apart on spaces, and adding new ones to an `allClasses` array: ```js var allClasses = []; var allElements = document.querySelectorAll('*'); for (var i = 0; i < allElements.length; i++) { var classes = allElements[i].className.toString().split(/\s+/); for (var j = 0; j < classes.length; j++) { var cls = classes[j]; if (cls && allClasses.indexOf(cls) === -1) allClasses.push(cls); } } console.log(allClasses); ``` ```html <div class="foo"> <div class="bar baz"></div> </div> ``` To get the classnames in only one part of the document, specify that in the `querySelectorAll` call: ``` var allElements = document.getElementById('my-elt').querySelectorAll('*'); ``` ### Modern approach Using ES6, we can write this more functionally as: ``` [].concat( // concatenate ...[... // an array of document.querySelectorAll('*') // all elements ] . map( // mapping each elt => // element [... // to the array of elt.classList // its classes ] ) ); ``` Or, as a one liner: ``` [].concat(...[...document.querySelectorAll('*')].map(elt => [...elt.classList])); ``` Then you will want to apply `uniq` to the result. You can write that yourself, or use Underscore's `_.uniq` etc. Here's a simple one for use here: ``` function unique(array) { var prev; return array.sort().filter(e => e !== prev && (prev = e)); } ```
Get all the classes & the unique ones in one dimension. ```js const allClasses = Array.from(new Set(document.querySelectorAll("*").map(el => el.classNames))); const flatClasses = Array.from(new Set(allClasses.flat(1))) ```
38,024,631
How can I get a list of all class names used inside an HTML Snippet? For example, the HTML Snippet below, ``` <div class="name"> <div class="first"></div> <div class="last"></div> </div> ``` would have output `name`, `first`, `last` or `name`, `name > first`, `name > last`. Here, I am concerned about finding all class selectors first. Nesting could be optional. I expect to use Javascript or Regular Expressions.
2016/06/25
[ "https://Stackoverflow.com/questions/38024631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2156512/" ]
Simple ES10 new Set() approach ============================== ``` const allClasses = Array.from(document.querySelectorAll('[class]')).flatMap(e => e.className.toString().split(/\s+/)) const classes = new Set() allClasses.forEach(c => classes.add(c)) console.log(classes) ``` Get all the class names and split on space so for example, "child first" would become 'child' and 'first'. If you don't like this behaviour you can remove the toString and split functions. Then add every class name to the set. There is no need to check for duplicates since the set does that for us. If you do want to store duplicates you can use a Map instead.
**This is HTML:** ``` <div id="oye"> <div class="pop"></div> <div class="hop"></div> <div class="bob"></div> </div> <p id="my"></p> ``` In Jquery, You will get array of all class name, Check below code ``` $(document).ready(function(){ var myclass = []; var parent = $("#oye"); var divs = parent.children(); for(var i = 0; i < divs.length; i++){ myclass.push(divs[i].className) } //console.log(myclass); var myclasses = myclass.join(', '); $("#my").html(myclasses); }); ``` See Demo Here: <https://codepen.io/ihemant360/pen/PzWJZP>
38,024,631
How can I get a list of all class names used inside an HTML Snippet? For example, the HTML Snippet below, ``` <div class="name"> <div class="first"></div> <div class="last"></div> </div> ``` would have output `name`, `first`, `last` or `name`, `name > first`, `name > last`. Here, I am concerned about finding all class selectors first. Nesting could be optional. I expect to use Javascript or Regular Expressions.
2016/06/25
[ "https://Stackoverflow.com/questions/38024631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2156512/" ]
Get all the elements in the document using `querySelectorAll`, then loop through them, getting each one's class, breaking it apart on spaces, and adding new ones to an `allClasses` array: ```js var allClasses = []; var allElements = document.querySelectorAll('*'); for (var i = 0; i < allElements.length; i++) { var classes = allElements[i].className.toString().split(/\s+/); for (var j = 0; j < classes.length; j++) { var cls = classes[j]; if (cls && allClasses.indexOf(cls) === -1) allClasses.push(cls); } } console.log(allClasses); ``` ```html <div class="foo"> <div class="bar baz"></div> </div> ``` To get the classnames in only one part of the document, specify that in the `querySelectorAll` call: ``` var allElements = document.getElementById('my-elt').querySelectorAll('*'); ``` ### Modern approach Using ES6, we can write this more functionally as: ``` [].concat( // concatenate ...[... // an array of document.querySelectorAll('*') // all elements ] . map( // mapping each elt => // element [... // to the array of elt.classList // its classes ] ) ); ``` Or, as a one liner: ``` [].concat(...[...document.querySelectorAll('*')].map(elt => [...elt.classList])); ``` Then you will want to apply `uniq` to the result. You can write that yourself, or use Underscore's `_.uniq` etc. Here's a simple one for use here: ``` function unique(array) { var prev; return array.sort().filter(e => e !== prev && (prev = e)); } ```
Simple ES10 new Set() approach ============================== ``` const allClasses = Array.from(document.querySelectorAll('[class]')).flatMap(e => e.className.toString().split(/\s+/)) const classes = new Set() allClasses.forEach(c => classes.add(c)) console.log(classes) ``` Get all the class names and split on space so for example, "child first" would become 'child' and 'first'. If you don't like this behaviour you can remove the toString and split functions. Then add every class name to the set. There is no need to check for duplicates since the set does that for us. If you do want to store duplicates you can use a Map instead.
38,024,631
How can I get a list of all class names used inside an HTML Snippet? For example, the HTML Snippet below, ``` <div class="name"> <div class="first"></div> <div class="last"></div> </div> ``` would have output `name`, `first`, `last` or `name`, `name > first`, `name > last`. Here, I am concerned about finding all class selectors first. Nesting could be optional. I expect to use Javascript or Regular Expressions.
2016/06/25
[ "https://Stackoverflow.com/questions/38024631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2156512/" ]
Simple ES10 new Set() approach ============================== ``` const allClasses = Array.from(document.querySelectorAll('[class]')).flatMap(e => e.className.toString().split(/\s+/)) const classes = new Set() allClasses.forEach(c => classes.add(c)) console.log(classes) ``` Get all the class names and split on space so for example, "child first" would become 'child' and 'first'. If you don't like this behaviour you can remove the toString and split functions. Then add every class name to the set. There is no need to check for duplicates since the set does that for us. If you do want to store duplicates you can use a Map instead.
Get all the classes & the unique ones in one dimension. ```js const allClasses = Array.from(new Set(document.querySelectorAll("*").map(el => el.classNames))); const flatClasses = Array.from(new Set(allClasses.flat(1))) ```
38,024,631
How can I get a list of all class names used inside an HTML Snippet? For example, the HTML Snippet below, ``` <div class="name"> <div class="first"></div> <div class="last"></div> </div> ``` would have output `name`, `first`, `last` or `name`, `name > first`, `name > last`. Here, I am concerned about finding all class selectors first. Nesting could be optional. I expect to use Javascript or Regular Expressions.
2016/06/25
[ "https://Stackoverflow.com/questions/38024631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2156512/" ]
A one-liner that returns unique class names in alphabetical order, the query part based on @torazaburo's answer: ``` [].concat(...[...document.querySelectorAll('*')].map(e=>[...e.classList])).filter((d,i,a)=>a.indexOf(d)==i).sort() ```
**This is HTML:** ``` <div id="oye"> <div class="pop"></div> <div class="hop"></div> <div class="bob"></div> </div> <p id="my"></p> ``` In Jquery, You will get array of all class name, Check below code ``` $(document).ready(function(){ var myclass = []; var parent = $("#oye"); var divs = parent.children(); for(var i = 0; i < divs.length; i++){ myclass.push(divs[i].className) } //console.log(myclass); var myclasses = myclass.join(', '); $("#my").html(myclasses); }); ``` See Demo Here: <https://codepen.io/ihemant360/pen/PzWJZP>
38,024,631
How can I get a list of all class names used inside an HTML Snippet? For example, the HTML Snippet below, ``` <div class="name"> <div class="first"></div> <div class="last"></div> </div> ``` would have output `name`, `first`, `last` or `name`, `name > first`, `name > last`. Here, I am concerned about finding all class selectors first. Nesting could be optional. I expect to use Javascript or Regular Expressions.
2016/06/25
[ "https://Stackoverflow.com/questions/38024631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2156512/" ]
**This is HTML:** ``` <div id="oye"> <div class="pop"></div> <div class="hop"></div> <div class="bob"></div> </div> <p id="my"></p> ``` In Jquery, You will get array of all class name, Check below code ``` $(document).ready(function(){ var myclass = []; var parent = $("#oye"); var divs = parent.children(); for(var i = 0; i < divs.length; i++){ myclass.push(divs[i].className) } //console.log(myclass); var myclasses = myclass.join(', '); $("#my").html(myclasses); }); ``` See Demo Here: <https://codepen.io/ihemant360/pen/PzWJZP>
Get all the classes & the unique ones in one dimension. ```js const allClasses = Array.from(new Set(document.querySelectorAll("*").map(el => el.classNames))); const flatClasses = Array.from(new Set(allClasses.flat(1))) ```
38,024,631
How can I get a list of all class names used inside an HTML Snippet? For example, the HTML Snippet below, ``` <div class="name"> <div class="first"></div> <div class="last"></div> </div> ``` would have output `name`, `first`, `last` or `name`, `name > first`, `name > last`. Here, I am concerned about finding all class selectors first. Nesting could be optional. I expect to use Javascript or Regular Expressions.
2016/06/25
[ "https://Stackoverflow.com/questions/38024631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2156512/" ]
A one-liner that returns unique class names in alphabetical order, the query part based on @torazaburo's answer: ``` [].concat(...[...document.querySelectorAll('*')].map(e=>[...e.classList])).filter((d,i,a)=>a.indexOf(d)==i).sort() ```
I'd do something like the snippet below, it uses jQuery but that's just easier to read imo, a Javascript version wouldn't be much harder I'd assume. Basically you want to get all of the `nodes`, then add all of the unique classes to a list.. This is **much** harder to implement if you're looking for dynamic classes which may be applied with Javascript. Nesting would require more insight as to how it should be performed, how to handle dupe classes but not dupe class arrays and similar.. *If this get's downvoted because of the jQuery I'll be upset.* ```js var classes = []; $('body *:not(script)').each(function(){ _classes = $(this).attr('class') ? $(this).attr('class').split(' ') : [] _classes.forEach(function(entry){ if(classes.indexOf(entry) < 0){ classes.push(entry) } }) }) console.log(classes) ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="dog"></div> <span class="dog cat"></span> <div></div> <blockquote class="bird"></blockquote> ```
38,024,631
How can I get a list of all class names used inside an HTML Snippet? For example, the HTML Snippet below, ``` <div class="name"> <div class="first"></div> <div class="last"></div> </div> ``` would have output `name`, `first`, `last` or `name`, `name > first`, `name > last`. Here, I am concerned about finding all class selectors first. Nesting could be optional. I expect to use Javascript or Regular Expressions.
2016/06/25
[ "https://Stackoverflow.com/questions/38024631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2156512/" ]
Simple ES10 new Set() approach ============================== ``` const allClasses = Array.from(document.querySelectorAll('[class]')).flatMap(e => e.className.toString().split(/\s+/)) const classes = new Set() allClasses.forEach(c => classes.add(c)) console.log(classes) ``` Get all the class names and split on space so for example, "child first" would become 'child' and 'first'. If you don't like this behaviour you can remove the toString and split functions. Then add every class name to the set. There is no need to check for duplicates since the set does that for us. If you do want to store duplicates you can use a Map instead.
I'd do something like the snippet below, it uses jQuery but that's just easier to read imo, a Javascript version wouldn't be much harder I'd assume. Basically you want to get all of the `nodes`, then add all of the unique classes to a list.. This is **much** harder to implement if you're looking for dynamic classes which may be applied with Javascript. Nesting would require more insight as to how it should be performed, how to handle dupe classes but not dupe class arrays and similar.. *If this get's downvoted because of the jQuery I'll be upset.* ```js var classes = []; $('body *:not(script)').each(function(){ _classes = $(this).attr('class') ? $(this).attr('class').split(' ') : [] _classes.forEach(function(entry){ if(classes.indexOf(entry) < 0){ classes.push(entry) } }) }) console.log(classes) ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="dog"></div> <span class="dog cat"></span> <div></div> <blockquote class="bird"></blockquote> ```
60,074,345
I wrote the put request which works perfectly, I want to connect it with axios to make it work on frontend with `onClick` method. ``` router.put("/:name", (req, res, next) => { Papp.findOneAndUpdate({ _pappName: req.params.pappName }, req.body, { new: true }).then(function(state) { res.send(state); }); }); ``` [![enter image description here](https://i.stack.imgur.com/c17Le.png)](https://i.stack.imgur.com/c17Le.png) To make it more clear: Buttons get their state from database via the props. User can click button and change its state but only on frontend now, I want to change it so user will be able to change record in database because of the request.
2020/02/05
[ "https://Stackoverflow.com/questions/60074345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11907983/" ]
You can decode / encode using a different name with the `dataclasses_json` lib, from their [docs](https://lidatong.github.io/dataclasses-json/): ``` from dataclasses import dataclass, field from dataclasses_json import config, dataclass_json @dataclass_json @dataclass class Person: given_name: str = field(metadata=config(field_name="overriddenGivenName")) Person(given_name="Alice") # Person('Alice') Person.from_json('{"overriddenGivenName": "Alice"}') # Person('Alice') Person('Alice').to_json() # {"overriddenGivenName": "Alice"} ```
I found next solution for my purposes. ``` @dataclass class ExampleClass: def __post_init__(self): self.__setattr__("class", self.class_) self.__delattr__("class_") class_: str ``` It requires to set init value in `class_` attribute. Also you can't directly use this attribute like `example_class_instance.class`, workaround is `example_class_instance.__getattribute__("class")`. And the dataclass has broken repr, can be avoided by changing decorator to `dataclass(repr=False)`
63,196,058
How can I get values in a particular row by using Rowid in sqlite3. In my have written the python code: ``` conn = sqlite3.connect('database.db') c = conn.cursor() c.execute("SELECT rowid, * FROM aqn_data WHERE rowid = 25") ``` *This prints* [] where I want to print the values from row 25.
2020/07/31
[ "https://Stackoverflow.com/questions/63196058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12738283/" ]
The problem on my end was arising because I was using NVM yet I had already previously installed NPM independently. All I did to solve the issue was delete the npm and npm-cache folder located here: C:\Users\your-username\AppData\Roaming. No need of doing a fresh npm install (just leave that to NVM)
Just install what is required from the official site of Node.js <https://nodejs.org/en/> No SO version or command lines required
63,196,058
How can I get values in a particular row by using Rowid in sqlite3. In my have written the python code: ``` conn = sqlite3.connect('database.db') c = conn.cursor() c.execute("SELECT rowid, * FROM aqn_data WHERE rowid = 25") ``` *This prints* [] where I want to print the values from row 25.
2020/07/31
[ "https://Stackoverflow.com/questions/63196058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12738283/" ]
I found the work-around ! First you need to open your cmd line, and use " **npm install -g npm@latest** " you'll get the error like this ``` C:\Users\KimeruLenovo>npm install -g npm@latest npm WARN npm npm does not support Node.js v14.7.0 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9. npm WARN npm You can find the latest version at https://nodejs.org/ npm ERR! cb.apply is not a function npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\KimeruLenovo\AppData\Roaming\npm-cache\_logs\2020-08 10T09_36_56_388Z-debug.log ``` Go to the path where you can find the debug log( this file is found in your npm-cache folder) C:\Users\KimeruLenovo\AppData\Roaming Delete the NPM and NPM-Cache folder, but **DO NOT** reinstall node . once deleted go back to your comand line and re-use the command " **npm install -g npm@latest** " This should do the trick :)
I also had the same issue, Windows 10 with npm v6.4.1 and trying to upgrade node from v9 to v12.18.3. The problem seemed to be that whenever I tried to install the latest version of node, npm wasn't upgraded and npm v6.4.1 only supported node up until v11 (even though the download page says "Latest LTS Version: 12.18.3 (includes npm 6.14.6)": <https://nodejs.org/en/download/>). [This Github issue](https://github.com/nodejs/help/issues/1713) led me to the solution, which was to uninstall node (Settings -> Add or remove programs), then navigate to `C:\Users\{User}\AppData\Roaming` and delete the `npm` and `npm-chache` folder and finally install node again (using the installer).
63,196,058
How can I get values in a particular row by using Rowid in sqlite3. In my have written the python code: ``` conn = sqlite3.connect('database.db') c = conn.cursor() c.execute("SELECT rowid, * FROM aqn_data WHERE rowid = 25") ``` *This prints* [] where I want to print the values from row 25.
2020/07/31
[ "https://Stackoverflow.com/questions/63196058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12738283/" ]
I found the work-around ! First you need to open your cmd line, and use " **npm install -g npm@latest** " you'll get the error like this ``` C:\Users\KimeruLenovo>npm install -g npm@latest npm WARN npm npm does not support Node.js v14.7.0 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9. npm WARN npm You can find the latest version at https://nodejs.org/ npm ERR! cb.apply is not a function npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\KimeruLenovo\AppData\Roaming\npm-cache\_logs\2020-08 10T09_36_56_388Z-debug.log ``` Go to the path where you can find the debug log( this file is found in your npm-cache folder) C:\Users\KimeruLenovo\AppData\Roaming Delete the NPM and NPM-Cache folder, but **DO NOT** reinstall node . once deleted go back to your comand line and re-use the command " **npm install -g npm@latest** " This should do the trick :)
I had same issue. I tried to install node with `choco install -y nodejs.install`. then, `npm i` works fine. (before that, nodist was uninstalled) I used `nodist` to install node. it may be the cause I think.
63,196,058
How can I get values in a particular row by using Rowid in sqlite3. In my have written the python code: ``` conn = sqlite3.connect('database.db') c = conn.cursor() c.execute("SELECT rowid, * FROM aqn_data WHERE rowid = 25") ``` *This prints* [] where I want to print the values from row 25.
2020/07/31
[ "https://Stackoverflow.com/questions/63196058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12738283/" ]
I found the work-around ! First you need to open your cmd line, and use " **npm install -g npm@latest** " you'll get the error like this ``` C:\Users\KimeruLenovo>npm install -g npm@latest npm WARN npm npm does not support Node.js v14.7.0 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9. npm WARN npm You can find the latest version at https://nodejs.org/ npm ERR! cb.apply is not a function npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\KimeruLenovo\AppData\Roaming\npm-cache\_logs\2020-08 10T09_36_56_388Z-debug.log ``` Go to the path where you can find the debug log( this file is found in your npm-cache folder) C:\Users\KimeruLenovo\AppData\Roaming Delete the NPM and NPM-Cache folder, but **DO NOT** reinstall node . once deleted go back to your comand line and re-use the command " **npm install -g npm@latest** " This should do the trick :)
> > Go to the path where you can find the debug log( this file is found in your npm-cache folder) C:\Users\KimeruLenovo\AppData\Roaming > > > > > Delete the NPM and NPM-Cache folder, but DO NOT reinstall node . once deleted go back to your comand line and re-use the command " npm install -g npm@latest " > > > > > This should do the trick :) > > > As mentioned earlier, is that I deleted these folders before installing the new version and also worked.
63,196,058
How can I get values in a particular row by using Rowid in sqlite3. In my have written the python code: ``` conn = sqlite3.connect('database.db') c = conn.cursor() c.execute("SELECT rowid, * FROM aqn_data WHERE rowid = 25") ``` *This prints* [] where I want to print the values from row 25.
2020/07/31
[ "https://Stackoverflow.com/questions/63196058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12738283/" ]
I also had the same issue, Windows 10 with npm v6.4.1 and trying to upgrade node from v9 to v12.18.3. The problem seemed to be that whenever I tried to install the latest version of node, npm wasn't upgraded and npm v6.4.1 only supported node up until v11 (even though the download page says "Latest LTS Version: 12.18.3 (includes npm 6.14.6)": <https://nodejs.org/en/download/>). [This Github issue](https://github.com/nodejs/help/issues/1713) led me to the solution, which was to uninstall node (Settings -> Add or remove programs), then navigate to `C:\Users\{User}\AppData\Roaming` and delete the `npm` and `npm-chache` folder and finally install node again (using the installer).
I had the same problem. Delete `node` and `npm` cache in AppData folder inside `C:` drive and install recommended version on another drive.
63,196,058
How can I get values in a particular row by using Rowid in sqlite3. In my have written the python code: ``` conn = sqlite3.connect('database.db') c = conn.cursor() c.execute("SELECT rowid, * FROM aqn_data WHERE rowid = 25") ``` *This prints* [] where I want to print the values from row 25.
2020/07/31
[ "https://Stackoverflow.com/questions/63196058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12738283/" ]
I also had the same issue, Windows 10 with npm v6.4.1 and trying to upgrade node from v9 to v12.18.3. The problem seemed to be that whenever I tried to install the latest version of node, npm wasn't upgraded and npm v6.4.1 only supported node up until v11 (even though the download page says "Latest LTS Version: 12.18.3 (includes npm 6.14.6)": <https://nodejs.org/en/download/>). [This Github issue](https://github.com/nodejs/help/issues/1713) led me to the solution, which was to uninstall node (Settings -> Add or remove programs), then navigate to `C:\Users\{User}\AppData\Roaming` and delete the `npm` and `npm-chache` folder and finally install node again (using the installer).
If none of these solutions work which happened to me just go to <https://nodejs.org/en/> and download the recommended version manually super fast!
63,196,058
How can I get values in a particular row by using Rowid in sqlite3. In my have written the python code: ``` conn = sqlite3.connect('database.db') c = conn.cursor() c.execute("SELECT rowid, * FROM aqn_data WHERE rowid = 25") ``` *This prints* [] where I want to print the values from row 25.
2020/07/31
[ "https://Stackoverflow.com/questions/63196058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12738283/" ]
I had the same problem. Delete `node` and `npm` cache in AppData folder inside `C:` drive and install recommended version on another drive.
Use `n`. I am so glad discovered this package. if `npm` installed; ``` npm install -g n n lts ``` for other ways or more details; <https://www.npmjs.com/package/n>
63,196,058
How can I get values in a particular row by using Rowid in sqlite3. In my have written the python code: ``` conn = sqlite3.connect('database.db') c = conn.cursor() c.execute("SELECT rowid, * FROM aqn_data WHERE rowid = 25") ``` *This prints* [] where I want to print the values from row 25.
2020/07/31
[ "https://Stackoverflow.com/questions/63196058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12738283/" ]
I found the work-around ! First you need to open your cmd line, and use " **npm install -g npm@latest** " you'll get the error like this ``` C:\Users\KimeruLenovo>npm install -g npm@latest npm WARN npm npm does not support Node.js v14.7.0 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9. npm WARN npm You can find the latest version at https://nodejs.org/ npm ERR! cb.apply is not a function npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\KimeruLenovo\AppData\Roaming\npm-cache\_logs\2020-08 10T09_36_56_388Z-debug.log ``` Go to the path where you can find the debug log( this file is found in your npm-cache folder) C:\Users\KimeruLenovo\AppData\Roaming Delete the NPM and NPM-Cache folder, but **DO NOT** reinstall node . once deleted go back to your comand line and re-use the command " **npm install -g npm@latest** " This should do the trick :)
If none of these solutions work which happened to me just go to <https://nodejs.org/en/> and download the recommended version manually super fast!
63,196,058
How can I get values in a particular row by using Rowid in sqlite3. In my have written the python code: ``` conn = sqlite3.connect('database.db') c = conn.cursor() c.execute("SELECT rowid, * FROM aqn_data WHERE rowid = 25") ``` *This prints* [] where I want to print the values from row 25.
2020/07/31
[ "https://Stackoverflow.com/questions/63196058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12738283/" ]
Go to the path where you can find the debug log (this file is found in your npm-cache folder) C:\Users\yourname\AppData\Roaming Delete the NPM and NPM-Cache folder, but DO NOT reinstall node. Once deleted go back to your command line and re-use the command " npm install -g npm@latest "
> > Go to the path where you can find the debug log( this file is found in your npm-cache folder) C:\Users\KimeruLenovo\AppData\Roaming > > > > > Delete the NPM and NPM-Cache folder, but DO NOT reinstall node . once deleted go back to your comand line and re-use the command " npm install -g npm@latest " > > > > > This should do the trick :) > > > As mentioned earlier, is that I deleted these folders before installing the new version and also worked.
63,196,058
How can I get values in a particular row by using Rowid in sqlite3. In my have written the python code: ``` conn = sqlite3.connect('database.db') c = conn.cursor() c.execute("SELECT rowid, * FROM aqn_data WHERE rowid = 25") ``` *This prints* [] where I want to print the values from row 25.
2020/07/31
[ "https://Stackoverflow.com/questions/63196058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12738283/" ]
I found the work-around ! First you need to open your cmd line, and use " **npm install -g npm@latest** " you'll get the error like this ``` C:\Users\KimeruLenovo>npm install -g npm@latest npm WARN npm npm does not support Node.js v14.7.0 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9. npm WARN npm You can find the latest version at https://nodejs.org/ npm ERR! cb.apply is not a function npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\KimeruLenovo\AppData\Roaming\npm-cache\_logs\2020-08 10T09_36_56_388Z-debug.log ``` Go to the path where you can find the debug log( this file is found in your npm-cache folder) C:\Users\KimeruLenovo\AppData\Roaming Delete the NPM and NPM-Cache folder, but **DO NOT** reinstall node . once deleted go back to your comand line and re-use the command " **npm install -g npm@latest** " This should do the trick :)
Use `n`. I am so glad discovered this package. if `npm` installed; ``` npm install -g n n lts ``` for other ways or more details; <https://www.npmjs.com/package/n>
1,379,507
The number of customers arriving at a bank counter is in accordance with a Poisson distribution with mean rate of 5 customers in 3 minutes. Service time at the counter follows exponential distribution with mean service rate of 6 customers in 2 minutes. If there were 20 customers waiting in the line just before opening the counter, what is the probability that more than 20 customers will be waiting in the line, 2 hours after opening the counter? Assume that no customers leave the line without service. Here arrival rate is $\lambda=5/3$ and service rate is $\mu=3$. If $W$ is the average number of people waiting in the line then $W= \lambda/(\mu - \lambda)$ . But I don't know how to calculate number of waiting customer using a given time span. I didn't find any formula to do it in the book. Please help.
2015/07/30
[ "https://math.stackexchange.com/questions/1379507", "https://math.stackexchange.com", "https://math.stackexchange.com/users/257958/" ]
Extended Comment, not Answer. I do not believe all of the speculations in the Question and Comments are exactly correct and relevant. Here are some things I believe are correct, assuming you are dealing with an M/M/1 queue. The formula $W = \lambda/(\mu - \lambda) = \rho/(1 - \rho),$ where $\rho = \lambda/\mu$ is for the average number of customers in an M/M/1 queueing system *at equilibrium,* including anyone being served. The formula $W\_Q = \rho^2/(1-\rho)$ is for the average number waiting to be served (again when the system is at equilibrium). Such systems reach equilibrium quickly for values of $\lambda$ and $\mu$ such as yours. Agreeing with @Michael, I think the 2 hours is supposed to indicate enough time to reach equilibrium. (Markov processes have some memory, but after 'time to equilibrium' memory of the starting state is assumed irrelevant.) The distribution at equilibrium of an M/M/1 queue is well known, and should be in your text or notes--along with much of what I have said earlier on.
The 15 minutes mentioned by BrianTung is indeed the exact average time to empty, starting in an initial state of 20 jobs. Here is the explanation: The average duration of a busy period in an $M/M/1$ queue is $\overline{B} = \frac{1}{\mu-\lambda}$. This can be proven using the renewal theory identity: $$ \rho = \frac{\overline{B}}{\overline{B} + \overline{I}} $$ where $\rho=\lambda/\mu$ is the fraction of time busy (with $\rho<1$), and $\overline{I} = 1/\lambda$ is the average idle time in between busy periods. The fact that the average time to empty, given an initial state of 20, is just $20\overline{B}$, follows from the very clever (and standard) argument that this time is the same regardless of whether the service is LIFO or FIFO. With a LIFO (Last-in-First-out) thought experiment, we can imagine each of the 20 initial jobs as generating their own busy periods, each distributed the same as a usual busy period, and these are carried out successively. Notice that the average time to empty, starting in an initial state of 1 job, is $\overline{B}$. So the total average time to empty is $\overline{B} + \overline{B} + \cdots + \overline{B} = 20\overline{B}$.
1,200,208
I need to compute the -5th term to the 5th term of the Laurent expansion of $(\cos(z))^2/\sin(z)$. I know that I can make this into $\csc(z)-\sin(z)$ but I wouldn't know what to do with the $\csc(z)$ in terms of a series. Also, I feel like several of these Laurent expansion coefficients would be zero. Could someone give me some help with this one I am struggling a little bit with Laurent series in general. I also need to find the domain of convergence.
2015/03/21
[ "https://math.stackexchange.com/questions/1200208", "https://math.stackexchange.com", "https://math.stackexchange.com/users/153009/" ]
$$ \cos^2z = 1-z^2+\frac{z^4}{3}-\frac{2z^6}{45}+\cdots $$ The function $\frac{1}{\sin z}$ has a simple pole at $z=0$ and it is analytic in a punctured disc around $z=0$, so it's Laurent series is $\frac{a\_{-1}}{z}+a\_0+a\_1z + \cdots$ and it converges to $\frac{1}{\sin z}$ in a punctured disc around $z=0$. Since $\sin z = z-\frac{z^3}{6}+\frac{z^5}{120} + \cdots$ we have have for $z\ne0$: $$ 1=\Big( \frac{a\_{-1}}{z}+a\_0+a\_1z + \cdots \Big)\Big( z-\frac{z^3}{6}+\frac{z^5}{120} -\frac{z^7}{5040}+ \cdots \Big) $$ or: $$ 1=\Big( a\_{-1}+a\_0z+a\_1z^2 + \cdots \Big)\Big( 1-\frac{z^2}{6}+\frac{z^4}{120} -\frac{z^6}{5040}+ \cdots \Big) $$ By comparing the coefficients of the powers of $z$ in both sides you get: $$ a\_{-1}=1,\space a\_0=0, \space a\_1=\frac{1}{6}, \space a\_2=0, \space a\_3=\frac{7}{360}, \space a\_4=0, \space a\_5=\frac{31}{15120} $$ And so we have: $$ \frac{1}{\sin z} = \frac{1}{z} + \frac{z}{6} + \frac{7z^3}{360} + \frac{31z^5}{15120} + \cdots $$ And therefore: $$ \frac{\cos^2z}{\sin z} = \Big( \frac{1}{z} + \frac{z}{6} + \frac{7z^3}{360} + \frac{31z^5}{15120} + \cdots \Big) \Big( 1-z^2+\frac{z^4}{3}-\frac{2z^6}{45}+\cdots \Big) $$ $$ = \frac{1}{z}-\frac{5z}{6} + \frac{67z^3}{360}-\frac{19z^5}{3024} + \cdots $$
An idea: $$\frac{\cos^2x}{\sin x}=\frac{\left(1-\frac{x^2}2+\frac{x^4}{24}-\ldots\right)^2}{x-\frac{x^3}6+\frac{x^5}{120}-\ldots}=\frac{1-x^2+\frac{x^4}3+\mathcal (x^6)}{x\left(1-\frac{x^2}6+\mathcal O(x^4)\right)}=$$ $$=\frac1x\left(1-x^2+\frac{x^4}3+\mathcal O (x^6)\right)\left(1+\frac{x^2}6+\frac{x^4}{36}+\mathcal O(x^6)\right)$$
52,071,277
My file "index.php" has the script below: ``` <?php $pagina = empty($_GET['p']) ? 'home' : $_GET['p']; switch ($pagina): case 'contato': $titulo = 'Contato '; $keywords = ''; $descricao = ''; break; case 'privacidade': $titulo = 'Privacidade '; $keywords = ''; $descricao = ''; break; case 'ultimasnoticias': $titulo = 'Ultimas Noticias'; $keywords = ''; $descricao = ''; break; default: $titulo = 'Home'; $keywords = ''; $descricao = ''; $pagina = 'home'; endswitch; ?> <html> <head> <title><?php echo $titulo; ?></title> <meta name="keywords" content="<?php echo $keywords; ?>"> <meta name="description" content="<?php echo $descricao; ?>"> </head> <body> <?php require_once 'page_' . $pagina . '.php'; ?> <footer>Rodapé</footer> </body> </header> ``` I had some problems trying to explain my problem, my English is really bad, so I will try to explain what I need with the image below. [![my image](https://i.stack.imgur.com/eebB5.jpg)](https://i.stack.imgur.com/eebB5.jpg)
2018/08/29
[ "https://Stackoverflow.com/questions/52071277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282450/" ]
The error your getting is because you're mixing the firebase native api & angularfire. ``` selectedUser$: AngularFirestoreDocument<any>; ``` Calling `.ref` on your `AngularFirestoreCollection` converts it to type `firebase.firestore.CollectionReference` That being said, there are 2 possibilities to solve your issue: Using `angularfire`: I'm assuming your userCollection looks something like this: `this.afs.collection<User>`. Since you're querying a collection, there is no way to ensure your query predicate `uid == key` is unique in firebase. So you query the collection and `limit()` the result. This will return you an array with one document. `flatMap()`will return you a single user. ``` this.afs.collection<User>('users', ref => ref.where('uid', '==', key).limit(1)) .valueChanges() .pipe( flatMap(users=> users) ); ``` Using the `firebase` native api: ``` const query = this.usersCollection.ref.where('uid', '==', key); query.get().then(querySnapshot => { if (querySnapshot.empty) { console.log('no data found'); } else if (querySnapshot.size > 1) { console.log('no unique data'); } else { querySnapshot.forEach(documentSnapshot => { this.selectedUser$ = this.afs.doc(documentSnapshot.ref); // this.afs.doc(documentSnapshot.ref).valueChanges().subscribe(console.log); }); } }); ``` This way it's a bit easier to chain multiple `.where` clauses if it's needed
It will be easier to help you if you add more details about the structure of your Firestore collection and your typescript file. However, to query the collection I do the following: 1. Define a private AngularFirestore in the constructor. ``` constructor( private afStore: AngularFirestore, ) { } ``` 2. Define the query and pass the result to the AngularFirestoreDocument. ``` this.selectedUser$ = this.afStore .collection('TheNameOfYourCollection').doc<any>(key); ```
52,071,277
My file "index.php" has the script below: ``` <?php $pagina = empty($_GET['p']) ? 'home' : $_GET['p']; switch ($pagina): case 'contato': $titulo = 'Contato '; $keywords = ''; $descricao = ''; break; case 'privacidade': $titulo = 'Privacidade '; $keywords = ''; $descricao = ''; break; case 'ultimasnoticias': $titulo = 'Ultimas Noticias'; $keywords = ''; $descricao = ''; break; default: $titulo = 'Home'; $keywords = ''; $descricao = ''; $pagina = 'home'; endswitch; ?> <html> <head> <title><?php echo $titulo; ?></title> <meta name="keywords" content="<?php echo $keywords; ?>"> <meta name="description" content="<?php echo $descricao; ?>"> </head> <body> <?php require_once 'page_' . $pagina . '.php'; ?> <footer>Rodapé</footer> </body> </header> ``` I had some problems trying to explain my problem, my English is really bad, so I will try to explain what I need with the image below. [![my image](https://i.stack.imgur.com/eebB5.jpg)](https://i.stack.imgur.com/eebB5.jpg)
2018/08/29
[ "https://Stackoverflow.com/questions/52071277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282450/" ]
This worked for me with the latest versions: 2021-July ``` this.store .collection("Products",ref=>ref.where("stock","==",10)) .get() .subscribe(data=>data.forEach(el=>console.log(el.data()))); ``` PS: I'm using get() and no event listener.
It will be easier to help you if you add more details about the structure of your Firestore collection and your typescript file. However, to query the collection I do the following: 1. Define a private AngularFirestore in the constructor. ``` constructor( private afStore: AngularFirestore, ) { } ``` 2. Define the query and pass the result to the AngularFirestoreDocument. ``` this.selectedUser$ = this.afStore .collection('TheNameOfYourCollection').doc<any>(key); ```
52,071,277
My file "index.php" has the script below: ``` <?php $pagina = empty($_GET['p']) ? 'home' : $_GET['p']; switch ($pagina): case 'contato': $titulo = 'Contato '; $keywords = ''; $descricao = ''; break; case 'privacidade': $titulo = 'Privacidade '; $keywords = ''; $descricao = ''; break; case 'ultimasnoticias': $titulo = 'Ultimas Noticias'; $keywords = ''; $descricao = ''; break; default: $titulo = 'Home'; $keywords = ''; $descricao = ''; $pagina = 'home'; endswitch; ?> <html> <head> <title><?php echo $titulo; ?></title> <meta name="keywords" content="<?php echo $keywords; ?>"> <meta name="description" content="<?php echo $descricao; ?>"> </head> <body> <?php require_once 'page_' . $pagina . '.php'; ?> <footer>Rodapé</footer> </body> </header> ``` I had some problems trying to explain my problem, my English is really bad, so I will try to explain what I need with the image below. [![my image](https://i.stack.imgur.com/eebB5.jpg)](https://i.stack.imgur.com/eebB5.jpg)
2018/08/29
[ "https://Stackoverflow.com/questions/52071277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282450/" ]
``` this.afs.collection<User>('users', ref => ref.where('uid', '==', key).limit(1)) ); ```
It will be easier to help you if you add more details about the structure of your Firestore collection and your typescript file. However, to query the collection I do the following: 1. Define a private AngularFirestore in the constructor. ``` constructor( private afStore: AngularFirestore, ) { } ``` 2. Define the query and pass the result to the AngularFirestoreDocument. ``` this.selectedUser$ = this.afStore .collection('TheNameOfYourCollection').doc<any>(key); ```
52,071,277
My file "index.php" has the script below: ``` <?php $pagina = empty($_GET['p']) ? 'home' : $_GET['p']; switch ($pagina): case 'contato': $titulo = 'Contato '; $keywords = ''; $descricao = ''; break; case 'privacidade': $titulo = 'Privacidade '; $keywords = ''; $descricao = ''; break; case 'ultimasnoticias': $titulo = 'Ultimas Noticias'; $keywords = ''; $descricao = ''; break; default: $titulo = 'Home'; $keywords = ''; $descricao = ''; $pagina = 'home'; endswitch; ?> <html> <head> <title><?php echo $titulo; ?></title> <meta name="keywords" content="<?php echo $keywords; ?>"> <meta name="description" content="<?php echo $descricao; ?>"> </head> <body> <?php require_once 'page_' . $pagina . '.php'; ?> <footer>Rodapé</footer> </body> </header> ``` I had some problems trying to explain my problem, my English is really bad, so I will try to explain what I need with the image below. [![my image](https://i.stack.imgur.com/eebB5.jpg)](https://i.stack.imgur.com/eebB5.jpg)
2018/08/29
[ "https://Stackoverflow.com/questions/52071277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282450/" ]
The error your getting is because you're mixing the firebase native api & angularfire. ``` selectedUser$: AngularFirestoreDocument<any>; ``` Calling `.ref` on your `AngularFirestoreCollection` converts it to type `firebase.firestore.CollectionReference` That being said, there are 2 possibilities to solve your issue: Using `angularfire`: I'm assuming your userCollection looks something like this: `this.afs.collection<User>`. Since you're querying a collection, there is no way to ensure your query predicate `uid == key` is unique in firebase. So you query the collection and `limit()` the result. This will return you an array with one document. `flatMap()`will return you a single user. ``` this.afs.collection<User>('users', ref => ref.where('uid', '==', key).limit(1)) .valueChanges() .pipe( flatMap(users=> users) ); ``` Using the `firebase` native api: ``` const query = this.usersCollection.ref.where('uid', '==', key); query.get().then(querySnapshot => { if (querySnapshot.empty) { console.log('no data found'); } else if (querySnapshot.size > 1) { console.log('no unique data'); } else { querySnapshot.forEach(documentSnapshot => { this.selectedUser$ = this.afs.doc(documentSnapshot.ref); // this.afs.doc(documentSnapshot.ref).valueChanges().subscribe(console.log); }); } }); ``` This way it's a bit easier to chain multiple `.where` clauses if it's needed
This worked for me with the latest versions: 2021-July ``` this.store .collection("Products",ref=>ref.where("stock","==",10)) .get() .subscribe(data=>data.forEach(el=>console.log(el.data()))); ``` PS: I'm using get() and no event listener.
52,071,277
My file "index.php" has the script below: ``` <?php $pagina = empty($_GET['p']) ? 'home' : $_GET['p']; switch ($pagina): case 'contato': $titulo = 'Contato '; $keywords = ''; $descricao = ''; break; case 'privacidade': $titulo = 'Privacidade '; $keywords = ''; $descricao = ''; break; case 'ultimasnoticias': $titulo = 'Ultimas Noticias'; $keywords = ''; $descricao = ''; break; default: $titulo = 'Home'; $keywords = ''; $descricao = ''; $pagina = 'home'; endswitch; ?> <html> <head> <title><?php echo $titulo; ?></title> <meta name="keywords" content="<?php echo $keywords; ?>"> <meta name="description" content="<?php echo $descricao; ?>"> </head> <body> <?php require_once 'page_' . $pagina . '.php'; ?> <footer>Rodapé</footer> </body> </header> ``` I had some problems trying to explain my problem, my English is really bad, so I will try to explain what I need with the image below. [![my image](https://i.stack.imgur.com/eebB5.jpg)](https://i.stack.imgur.com/eebB5.jpg)
2018/08/29
[ "https://Stackoverflow.com/questions/52071277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282450/" ]
The error your getting is because you're mixing the firebase native api & angularfire. ``` selectedUser$: AngularFirestoreDocument<any>; ``` Calling `.ref` on your `AngularFirestoreCollection` converts it to type `firebase.firestore.CollectionReference` That being said, there are 2 possibilities to solve your issue: Using `angularfire`: I'm assuming your userCollection looks something like this: `this.afs.collection<User>`. Since you're querying a collection, there is no way to ensure your query predicate `uid == key` is unique in firebase. So you query the collection and `limit()` the result. This will return you an array with one document. `flatMap()`will return you a single user. ``` this.afs.collection<User>('users', ref => ref.where('uid', '==', key).limit(1)) .valueChanges() .pipe( flatMap(users=> users) ); ``` Using the `firebase` native api: ``` const query = this.usersCollection.ref.where('uid', '==', key); query.get().then(querySnapshot => { if (querySnapshot.empty) { console.log('no data found'); } else if (querySnapshot.size > 1) { console.log('no unique data'); } else { querySnapshot.forEach(documentSnapshot => { this.selectedUser$ = this.afs.doc(documentSnapshot.ref); // this.afs.doc(documentSnapshot.ref).valueChanges().subscribe(console.log); }); } }); ``` This way it's a bit easier to chain multiple `.where` clauses if it's needed
``` this.afs.collection<User>('users', ref => ref.where('uid', '==', key).limit(1)) ); ```
52,071,277
My file "index.php" has the script below: ``` <?php $pagina = empty($_GET['p']) ? 'home' : $_GET['p']; switch ($pagina): case 'contato': $titulo = 'Contato '; $keywords = ''; $descricao = ''; break; case 'privacidade': $titulo = 'Privacidade '; $keywords = ''; $descricao = ''; break; case 'ultimasnoticias': $titulo = 'Ultimas Noticias'; $keywords = ''; $descricao = ''; break; default: $titulo = 'Home'; $keywords = ''; $descricao = ''; $pagina = 'home'; endswitch; ?> <html> <head> <title><?php echo $titulo; ?></title> <meta name="keywords" content="<?php echo $keywords; ?>"> <meta name="description" content="<?php echo $descricao; ?>"> </head> <body> <?php require_once 'page_' . $pagina . '.php'; ?> <footer>Rodapé</footer> </body> </header> ``` I had some problems trying to explain my problem, my English is really bad, so I will try to explain what I need with the image below. [![my image](https://i.stack.imgur.com/eebB5.jpg)](https://i.stack.imgur.com/eebB5.jpg)
2018/08/29
[ "https://Stackoverflow.com/questions/52071277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10282450/" ]
This worked for me with the latest versions: 2021-July ``` this.store .collection("Products",ref=>ref.where("stock","==",10)) .get() .subscribe(data=>data.forEach(el=>console.log(el.data()))); ``` PS: I'm using get() and no event listener.
``` this.afs.collection<User>('users', ref => ref.where('uid', '==', key).limit(1)) ); ```
256,964
Inspired by a challenge from the [OUCC 2022 Seniors competition](https://challenge.bebras.uk/index.php?action=anon_join&grp_id=12427). ### Background Two teams are playing "capture the flag". They take turns invading each other's base and capturing their opposing team's flag in the shortest amount of time. The attacking players each have one soft ball they can throw at the defenders. Teams get to reduce the time they took to capture the flag by 3 seconds for each of the defenders team that gets hit with a ball. ### Your Task Write a program that calculates which team won based on who had the smallest accumulated time. ### Clarifications * There are two teams. * There will be an even number of rounds played. * Both teams will attack an equal number of times but it could be in any order. ### Example Let's say we have the input `[['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]]`. We go through each inner list: * `['A', 20, 0]`: The `A` tells us we need to add to team A. To get the number we need to add, we use `time - 3*hits`. In this case, it is `20-3*0` = 20. * `['A', 30, 1]`: We again need to add to team A. This time it's `30-3*1` = 27. Team A is now on 47. * `['B', 40, 6]`: This time it's 22 * `['B', 20, 2]`: 14. B is now at 36. Now we get the team with the lower score, in this case B, and output. ### Test cases ``` Input -> Output [['A', 100, 5], ['B', 95, 2]] -> A [['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]] -> B ['A', 50, 3], ['A', 70, 5], ['B', 35, 0], ['A', 25, 1], ['B', 60, 2], ['B', 40, 4] -> B [] -> Draw ``` ### Input / Output formats * You must take an arbitrary even number of inputs (these can all be in a list, or taken separately). * Each input must be a list of three items (in whatever order you prefer): + The team. You must choose two distinct values for this, e.g. `0` and `1`, `'A'` and `'B'`, etc. + The time taken for the team to get the flag (a positive integer of seconds) + The number of hits they got (a positive integer)Note: The number of hits will never exceed the time taken / 5, so the score will never be negative. * You must have three distinct output possibilities: + One for the first team winning + One for the second team winning + One for a draw * **This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins!**
2023/01/21
[ "https://codegolf.stackexchange.com/questions/256964", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/114446/" ]
[Jelly](https://github.com/DennisMitchell/jelly), 8 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) =================================================================================================================== Employs the team identification trick from [Arnauld's JavaScript ES6 answer](https://codegolf.stackexchange.com/a/256965/53748). ``` Ḣ×)ḅ-3SṠ ``` A monadic Link that accepts a list of triples, `[team, hits, time]` with teams represented as `-1` and `1`, and yields the losing team or `0` for a draw (i.e. `-1` if `1` won and vice versa). **[Try it online!](https://tio.run/##y0rNyan8///hjkWHp2s@3NGqaxz8cOeC////R0cb6igY6yiYGcTqKETrAjmWOgoWcI6pjoIJmANkgxQaxMYCAA "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##y0rNyan8///hjkWHp2s@3NGqaxz8cOeC/4fbHzWt@f8/Ojpa11BHwVRHwdDAIFZHIRrIMdJRsDSNjdXhUoBIGgCFwHIgDhAZwxSa6SiYIGkCKkJoMgYaCtcENN4cphBomrEpkmlGpggTzGCKTMAmg00DErEA "Jelly – Try It Online"). ### How? ``` Ḣ×)ḅ-3SṠ - Link: list of [team, hits, time] triples ) - for each triple: Ḣ - head -> removes team and yields it × - multiply by ([hits, time]) -> [team * hits, team * time] ḅ-3 - convert (each) from base -3 -> -3 ** 1 * team * hits + -3 ** 0 * team * time = team * (time - 3 * hits) S - sum Ṡ - sign ``` --- Equivalently, `Ḣ×ḅ-3)SṠ`. Similarly, `Ḣ)ḋḅ-3$Ṡ` (using a dot-product).
[Nim](https://nim-lang.org/), 77 bytes ====================================== ``` import math,sequtils proc c[S](s:S):int=sgn sum s.mapIt it[0]*(it[1]-3*it[2]) ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m704LzN3wYKlpSVpuhY3fTNzC_KLShRyE0sydIpTC0tLMnOKuQqK8pMVkqODYzWKrYI1rTLzSmyL0_MUiktzFYr1chMLPEsUMkuiDWK1NICUYayusRaQNorVhBpqkJqcka-QrOEQrWGoY2SgY6CpA2QYG-gYAhm6hjomBjpmEBZQ0kgTpg_mKAA) Takes `1` and `-1` as the team names. Outputs the team with a bigger score, or `0` for a draw.
256,964
Inspired by a challenge from the [OUCC 2022 Seniors competition](https://challenge.bebras.uk/index.php?action=anon_join&grp_id=12427). ### Background Two teams are playing "capture the flag". They take turns invading each other's base and capturing their opposing team's flag in the shortest amount of time. The attacking players each have one soft ball they can throw at the defenders. Teams get to reduce the time they took to capture the flag by 3 seconds for each of the defenders team that gets hit with a ball. ### Your Task Write a program that calculates which team won based on who had the smallest accumulated time. ### Clarifications * There are two teams. * There will be an even number of rounds played. * Both teams will attack an equal number of times but it could be in any order. ### Example Let's say we have the input `[['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]]`. We go through each inner list: * `['A', 20, 0]`: The `A` tells us we need to add to team A. To get the number we need to add, we use `time - 3*hits`. In this case, it is `20-3*0` = 20. * `['A', 30, 1]`: We again need to add to team A. This time it's `30-3*1` = 27. Team A is now on 47. * `['B', 40, 6]`: This time it's 22 * `['B', 20, 2]`: 14. B is now at 36. Now we get the team with the lower score, in this case B, and output. ### Test cases ``` Input -> Output [['A', 100, 5], ['B', 95, 2]] -> A [['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]] -> B ['A', 50, 3], ['A', 70, 5], ['B', 35, 0], ['A', 25, 1], ['B', 60, 2], ['B', 40, 4] -> B [] -> Draw ``` ### Input / Output formats * You must take an arbitrary even number of inputs (these can all be in a list, or taken separately). * Each input must be a list of three items (in whatever order you prefer): + The team. You must choose two distinct values for this, e.g. `0` and `1`, `'A'` and `'B'`, etc. + The time taken for the team to get the flag (a positive integer of seconds) + The number of hits they got (a positive integer)Note: The number of hits will never exceed the time taken / 5, so the score will never be negative. * You must have three distinct output possibilities: + One for the first team winning + One for the second team winning + One for a draw * **This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins!**
2023/01/21
[ "https://codegolf.stackexchange.com/questions/256964", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/114446/" ]
[Japt](https://github.com/ETHproductions/japt) [`-g`](https://codegolf.meta.stackexchange.com/a/14339/), ~~16~~ 14 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) ======================================================================================================================================================================== ``` x_o *3)nZo)*Zo ``` [Try it online](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWc&code=eF9vICozKW5abykqWm8&input=W1stMSwgMjAsIDBdLCBbLTEsIDMwLCAxXSwgWzEsIDQwLCA2XSwgWzEsIDIwLCAyXV0) or [verify all test cases](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=eF9vICozKW5abykqWm8&footer=Zw&input=WwpbWy0xLCAxMDAsIDVdLCBbMSwgOTUsIDJdXQpbWy0xLCAyMCwgMF0sIFstMSwgMzAsIDFdLCBbMSwgNDAsIDZdLCBbMSwgMjAsIDJdXQpbWy0xLCA1MCwgM10sIFstMSwgNzAsIDVdLCBbMSwgMzUsIDBdLCBbLTEsIDI1LCAxXSwgWzEsIDYwLCAyXSwgWzEsIDQwLCA0XV0KW10KXS1tUg). Port of @AndrovT's Vyxal answer. Takes -1 for A and 1 for B. Outputs 1 for A, -1 for B, and 0 for draw. ``` x_o *3)nZo)*Zo : implicit input array x_ : map each element to ... and sum o *3) : pop hits and multiply by three nZo) : subtract from {pop time} *Zo : multiply by {pop A or B, -1 for A and 1 for B} : end sum. -g: output sign of the number ```
[Arturo](https://arturo-lang.io), 52 bytes ========================================== ```arturo $[a][n:sum map a't->t\0*t\1-t\2*3(0=n)?->0->n/abs n] ``` [Try it](http://arturo-lang.io/playground?WaFmuA) A port of my [Factor answer](https://codegolf.stackexchange.com/a/256975/97916), though it suffers from a lack of sign function. ``` $[a][ ; a function taking an argument a n: ; assign n to sum ; sum map a 't -> ; map over a and assign current element to t t\2 * 3 ; last number in triplet times three t\1 - ; subtracted from second number in triplet t\0 * ; times first number in triplet (0=n)? ; is n zero? -> 0 ; zero if so -> n / abs n ; n divided by the absolute value of n if not ] ; end function ```
256,964
Inspired by a challenge from the [OUCC 2022 Seniors competition](https://challenge.bebras.uk/index.php?action=anon_join&grp_id=12427). ### Background Two teams are playing "capture the flag". They take turns invading each other's base and capturing their opposing team's flag in the shortest amount of time. The attacking players each have one soft ball they can throw at the defenders. Teams get to reduce the time they took to capture the flag by 3 seconds for each of the defenders team that gets hit with a ball. ### Your Task Write a program that calculates which team won based on who had the smallest accumulated time. ### Clarifications * There are two teams. * There will be an even number of rounds played. * Both teams will attack an equal number of times but it could be in any order. ### Example Let's say we have the input `[['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]]`. We go through each inner list: * `['A', 20, 0]`: The `A` tells us we need to add to team A. To get the number we need to add, we use `time - 3*hits`. In this case, it is `20-3*0` = 20. * `['A', 30, 1]`: We again need to add to team A. This time it's `30-3*1` = 27. Team A is now on 47. * `['B', 40, 6]`: This time it's 22 * `['B', 20, 2]`: 14. B is now at 36. Now we get the team with the lower score, in this case B, and output. ### Test cases ``` Input -> Output [['A', 100, 5], ['B', 95, 2]] -> A [['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]] -> B ['A', 50, 3], ['A', 70, 5], ['B', 35, 0], ['A', 25, 1], ['B', 60, 2], ['B', 40, 4] -> B [] -> Draw ``` ### Input / Output formats * You must take an arbitrary even number of inputs (these can all be in a list, or taken separately). * Each input must be a list of three items (in whatever order you prefer): + The team. You must choose two distinct values for this, e.g. `0` and `1`, `'A'` and `'B'`, etc. + The time taken for the team to get the flag (a positive integer of seconds) + The number of hits they got (a positive integer)Note: The number of hits will never exceed the time taken / 5, so the score will never be negative. * You must have three distinct output possibilities: + One for the first team winning + One for the second team winning + One for a draw * **This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins!**
2023/01/21
[ "https://codegolf.stackexchange.com/questions/256964", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/114446/" ]
[Japt](https://github.com/ETHproductions/japt) [`-g`](https://codegolf.meta.stackexchange.com/a/14339/), 10 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) ================================================================================================================================================================= Port of [Jonathan's Jelly solution](https://codegolf.stackexchange.com/a/256988/58974). ``` xÈm*Xv)ì3n ``` [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWc&code=eMhtKlh2Kewzbg&input=W1sxLCAzLCA2MF0sIFstMSwgOSwgODBdLCBbLTEsIDUsIDQwXSwgWzEsIDEsIDMwXV0) ``` xÈm*Xv)ì3n :Implicit input of 2D array x :Reduce by addition after È :Passing each X through the following function m* : Map & multiply by Xv : Remove & return the first element, mutating the original array ) : End map ì : Convert from base 3n : -3 :Implicit output of sign of result ```
[Nim](https://nim-lang.org/), 77 bytes ====================================== ``` import math,sequtils proc c[S](s:S):int=sgn sum s.mapIt it[0]*(it[1]-3*it[2]) ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m704LzN3wYKlpSVpuhY3fTNzC_KLShRyE0sydIpTC0tLMnOKuQqK8pMVkqODYzWKrYI1rTLzSmyL0_MUiktzFYr1chMLPEsUMkuiDWK1NICUYayusRaQNorVhBpqkJqcka-QrOEQrWGoY2SgY6CpA2QYG-gYAhm6hjomBjpmEBZQ0kgTpg_mKAA) Takes `1` and `-1` as the team names. Outputs the team with a bigger score, or `0` for a draw.
256,964
Inspired by a challenge from the [OUCC 2022 Seniors competition](https://challenge.bebras.uk/index.php?action=anon_join&grp_id=12427). ### Background Two teams are playing "capture the flag". They take turns invading each other's base and capturing their opposing team's flag in the shortest amount of time. The attacking players each have one soft ball they can throw at the defenders. Teams get to reduce the time they took to capture the flag by 3 seconds for each of the defenders team that gets hit with a ball. ### Your Task Write a program that calculates which team won based on who had the smallest accumulated time. ### Clarifications * There are two teams. * There will be an even number of rounds played. * Both teams will attack an equal number of times but it could be in any order. ### Example Let's say we have the input `[['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]]`. We go through each inner list: * `['A', 20, 0]`: The `A` tells us we need to add to team A. To get the number we need to add, we use `time - 3*hits`. In this case, it is `20-3*0` = 20. * `['A', 30, 1]`: We again need to add to team A. This time it's `30-3*1` = 27. Team A is now on 47. * `['B', 40, 6]`: This time it's 22 * `['B', 20, 2]`: 14. B is now at 36. Now we get the team with the lower score, in this case B, and output. ### Test cases ``` Input -> Output [['A', 100, 5], ['B', 95, 2]] -> A [['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]] -> B ['A', 50, 3], ['A', 70, 5], ['B', 35, 0], ['A', 25, 1], ['B', 60, 2], ['B', 40, 4] -> B [] -> Draw ``` ### Input / Output formats * You must take an arbitrary even number of inputs (these can all be in a list, or taken separately). * Each input must be a list of three items (in whatever order you prefer): + The team. You must choose two distinct values for this, e.g. `0` and `1`, `'A'` and `'B'`, etc. + The time taken for the team to get the flag (a positive integer of seconds) + The number of hits they got (a positive integer)Note: The number of hits will never exceed the time taken / 5, so the score will never be negative. * You must have three distinct output possibilities: + One for the first team winning + One for the second team winning + One for a draw * **This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins!**
2023/01/21
[ "https://codegolf.stackexchange.com/questions/256964", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/114446/" ]
[Vyxal](https://github.com/Vyxal/Vyxal), ~~12~~ ~~10~~ 8 bytes ============================================================== ``` ƛ÷T-*;∑± ``` [Try it Online!](https://vyxal.pythonanywhere.com/#WyJBIiwiIiwixpvDt1QtKjviiJHCsSIsIiIsIltbLTEsIDEwMCwgNV0sIFsxLCA5NSwgMl1dXG5bWy0xLCAyMCwgMF0sIFstMSwgMzAsIDFdLCBbMSwgNDAsIDZdLCBbMSwgMjAsIDJdXVxuW1stMSwgNTAsIDNdLCBbLTEsIDcwLCA1XSwgWzEsIDM1LCAwXSwgWy0xLCAyNSwgMV0sIFsxLCA2MCwgMl0sIFsxLCA0MCwgNF1dXG5bXSJd) Inspired by [Arnaulds answer](https://codegolf.stackexchange.com/a/256965/116074). Expects `-1` for 'A' and `1` for 'B'. Returns `1`, `-1` or `0` for A wins, B wins and draw respectively. ``` ƛ ; # map: ÷ # push each on stack T # triple - # subtract * # multiply ∑ # sum ± # sign ```
[Factor](https://factorcode.org/) + `math.unicode`, 33 bytes ============================================================ ```factor [ [ first3 3 * - * ] map Σ sgn ] ``` [Try it online!](https://tio.run/##ZU/LCoJAFN37FadtoYyPMSoIiiDatIlW4kJsLBepjSMR4tf0P/2S3SxxoLkMnHM5D24SxSqX7fGw22/nuEbqYlVZGucngVLcKpHFouzWKKRQ6lHINFNYGEZtgF5NY9qwGQNHQ2RiY8bhEG4wgrnEStc5DKyTEXYZ7N7iMfg9Jo1mX@t2zuD29qnW6PIh1uFDrP@N6iu8/9gf3cjobjRtgABJKkvlUs8YJv2Qji/weqI8ZwjbD7HaNw "Factor – Try It Online") This answer uses the following values: * `-1` for Team A * `1` for Team B * `1` for Team A victory * `-1` for Team B victory * `0` for draw ### How? For each triplet, * Multiply the last number by three * Subtract this value from the second number * Multiply this by the first number (the team value [-1 or 1]) Then, * Sum the results * Get the sign (returning -1, 0 or 1 for negative, zero, and positive)
256,964
Inspired by a challenge from the [OUCC 2022 Seniors competition](https://challenge.bebras.uk/index.php?action=anon_join&grp_id=12427). ### Background Two teams are playing "capture the flag". They take turns invading each other's base and capturing their opposing team's flag in the shortest amount of time. The attacking players each have one soft ball they can throw at the defenders. Teams get to reduce the time they took to capture the flag by 3 seconds for each of the defenders team that gets hit with a ball. ### Your Task Write a program that calculates which team won based on who had the smallest accumulated time. ### Clarifications * There are two teams. * There will be an even number of rounds played. * Both teams will attack an equal number of times but it could be in any order. ### Example Let's say we have the input `[['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]]`. We go through each inner list: * `['A', 20, 0]`: The `A` tells us we need to add to team A. To get the number we need to add, we use `time - 3*hits`. In this case, it is `20-3*0` = 20. * `['A', 30, 1]`: We again need to add to team A. This time it's `30-3*1` = 27. Team A is now on 47. * `['B', 40, 6]`: This time it's 22 * `['B', 20, 2]`: 14. B is now at 36. Now we get the team with the lower score, in this case B, and output. ### Test cases ``` Input -> Output [['A', 100, 5], ['B', 95, 2]] -> A [['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]] -> B ['A', 50, 3], ['A', 70, 5], ['B', 35, 0], ['A', 25, 1], ['B', 60, 2], ['B', 40, 4] -> B [] -> Draw ``` ### Input / Output formats * You must take an arbitrary even number of inputs (these can all be in a list, or taken separately). * Each input must be a list of three items (in whatever order you prefer): + The team. You must choose two distinct values for this, e.g. `0` and `1`, `'A'` and `'B'`, etc. + The time taken for the team to get the flag (a positive integer of seconds) + The number of hits they got (a positive integer)Note: The number of hits will never exceed the time taken / 5, so the score will never be negative. * You must have three distinct output possibilities: + One for the first team winning + One for the second team winning + One for a draw * **This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins!**
2023/01/21
[ "https://codegolf.stackexchange.com/questions/256964", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/114446/" ]
JavaScript (ES6), 43 bytes ========================== *-2 thanks to [@l4m2](https://codegolf.stackexchange.com/users/76323/l4m2)* Expects `1` for `'A'` and `-1` for `'B'`. Returns `false`, `true` or `0` for *A wins*, *B wins* and *draw* respectively. ```javascript a=>a.map(([i,t,n])=>s+=i*=t-n*3,s=0)|s&&s>0 ``` [Try it online!](https://tio.run/##ndCxDoIwEAbg3afoRFosUCjFOJRE41s0HRoUg0FKKNHFd69FJTIQjd50f3LNd9eTuihTdFXbB43eH2zJreK5Cs@qhVBUuMeNRDw3S1753M34FBtO0M14nsmJLXRjdH0Ia32EJRQixiAmBAMmMRCBS2uGQSIlQuD3iiKwWcwIiQPIALieuj4esdSFbAzD1DfZCds5gbm39CWspudQ9qYTNqGzhzbZI33Sc8J/v/Hhhl2nrvYO "JavaScript (Node.js) – Try It Online") ### Commented ```javascript a => // a[] = input array a.map(([i, t, n]) => // for each entry (i = team, t = time, n = hits): s += // update the sum s: i *= // either add or subtract: t - n * 3, // t - 3n s = 0 // start with s = 0 ) // end of map() | s // return 0 if s = 0 && s > 0 // return true if s is positive, false otherwise ```
[Nim](https://nim-lang.org/), 77 bytes ====================================== ``` import math,sequtils proc c[S](s:S):int=sgn sum s.mapIt it[0]*(it[1]-3*it[2]) ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m704LzN3wYKlpSVpuhY3fTNzC_KLShRyE0sydIpTC0tLMnOKuQqK8pMVkqODYzWKrYI1rTLzSmyL0_MUiktzFYr1chMLPEsUMkuiDWK1NICUYayusRaQNorVhBpqkJqcka-QrOEQrWGoY2SgY6CpA2QYG-gYAhm6hjomBjpmEBZQ0kgTpg_mKAA) Takes `1` and `-1` as the team names. Outputs the team with a bigger score, or `0` for a draw.
256,964
Inspired by a challenge from the [OUCC 2022 Seniors competition](https://challenge.bebras.uk/index.php?action=anon_join&grp_id=12427). ### Background Two teams are playing "capture the flag". They take turns invading each other's base and capturing their opposing team's flag in the shortest amount of time. The attacking players each have one soft ball they can throw at the defenders. Teams get to reduce the time they took to capture the flag by 3 seconds for each of the defenders team that gets hit with a ball. ### Your Task Write a program that calculates which team won based on who had the smallest accumulated time. ### Clarifications * There are two teams. * There will be an even number of rounds played. * Both teams will attack an equal number of times but it could be in any order. ### Example Let's say we have the input `[['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]]`. We go through each inner list: * `['A', 20, 0]`: The `A` tells us we need to add to team A. To get the number we need to add, we use `time - 3*hits`. In this case, it is `20-3*0` = 20. * `['A', 30, 1]`: We again need to add to team A. This time it's `30-3*1` = 27. Team A is now on 47. * `['B', 40, 6]`: This time it's 22 * `['B', 20, 2]`: 14. B is now at 36. Now we get the team with the lower score, in this case B, and output. ### Test cases ``` Input -> Output [['A', 100, 5], ['B', 95, 2]] -> A [['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]] -> B ['A', 50, 3], ['A', 70, 5], ['B', 35, 0], ['A', 25, 1], ['B', 60, 2], ['B', 40, 4] -> B [] -> Draw ``` ### Input / Output formats * You must take an arbitrary even number of inputs (these can all be in a list, or taken separately). * Each input must be a list of three items (in whatever order you prefer): + The team. You must choose two distinct values for this, e.g. `0` and `1`, `'A'` and `'B'`, etc. + The time taken for the team to get the flag (a positive integer of seconds) + The number of hits they got (a positive integer)Note: The number of hits will never exceed the time taken / 5, so the score will never be negative. * You must have three distinct output possibilities: + One for the first team winning + One for the second team winning + One for a draw * **This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins!**
2023/01/21
[ "https://codegolf.stackexchange.com/questions/256964", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/114446/" ]
[Factor](https://factorcode.org/) + `math.unicode`, 33 bytes ============================================================ ```factor [ [ first3 3 * - * ] map Σ sgn ] ``` [Try it online!](https://tio.run/##ZU/LCoJAFN37FadtoYyPMSoIiiDatIlW4kJsLBepjSMR4tf0P/2S3SxxoLkMnHM5D24SxSqX7fGw22/nuEbqYlVZGucngVLcKpHFouzWKKRQ6lHINFNYGEZtgF5NY9qwGQNHQ2RiY8bhEG4wgrnEStc5DKyTEXYZ7N7iMfg9Jo1mX@t2zuD29qnW6PIh1uFDrP@N6iu8/9gf3cjobjRtgABJKkvlUs8YJv2Qji/weqI8ZwjbD7HaNw "Factor – Try It Online") This answer uses the following values: * `-1` for Team A * `1` for Team B * `1` for Team A victory * `-1` for Team B victory * `0` for draw ### How? For each triplet, * Multiply the last number by three * Subtract this value from the second number * Multiply this by the first number (the team value [-1 or 1]) Then, * Sum the results * Get the sign (returning -1, 0 or 1 for negative, zero, and positive)
awk, ~~78~~ ~~76~~ ~~71~~ 69 bytes ================================== In the following, remove newline (that's only for readability) and save one byte. 1. 79 bytes ``` {s[$1]=s[$1]+$2-(3*$3)} END{print (s["A"]>s["B"])?"A":(s["A"]<s["B"])?"B":"="} ``` 2. 77 bytes ``` {s[$1]=s[$1]+$2-(3*$3)} END{a=s["A"];b=s["B"];print (a>b)?"A":(a<b)?"B":"="} ``` 3. 72 bytes ``` {s[$1]+=$2-(3*$3)} END{a=s["A"];b=s["B"];print (a>b)?"A":(a<b)?"B":"="} ``` 4. 70 bytes ``` {s[$1]+=$2-3*$3} END{a=s["A"];b=s["B"];print (a>b)?"A":(a<b)?"B":"="} ``` There must be some tricks, I dunno, to make it shorter. Usage and notes --------------- Use of AWK require some adaptation of the input. * The outer list is a file to pass to the script. * The inner lists are lines of the input file. * Items in sub lists are separated by blanks only. The example given (1 line for 57 bytes) ``` [['A', 20, 0], ['A', 30, 1], ['B', 40, 6], ['B', 20, 2]] ``` becomes then (4 lines for 28 bytes) ``` A 20 0 A 30 1 B 40 6 B 20 2 ``` Once the data file created, let's say `match.list`, call the script, let's say `twist.awk`, by issuing the command line ```sh awk -f twist.awk match.list ``` You can also replace `-f twist.awk` with the script directly. Ungolfed/explanation -------------------- For golfing purposes I've used `s` instead of a more useful variable name. ``` { # This is the main block, executed for each line s[$1]=s[$1]+$2-(3*$3) # Update Score table indexed by first field (team) # precisely, creation then update next iterations } END{ # This block is executed once after main processing print "A=" s["A"], # add this for debug purpose "B=" s["B"], "" ; (s["A"]>s["B"]) # if team A scores more than team B ? # then print "A" # says that A wins : # else (s["A"]<s["B"]) # if team A scores less than team B ? # then print "B" # says that B wins : # else print "=" # says it's a drawn } ``` For golfing purpose, we use [ternary operator](https://www.tutorialspoint.com/awk/awk_ternary_operators.htm) in place of the [if-then statement](https://linuxhandbook.com/awk-if-else/), and replace the `if (cond) {foo} else {bar}` becomes `(cond)?{foo}:{bar}` By the same way, `if (cond) {foo} else if (alt) {baz} else {bar}` becomes `(cond)?{foo}:(alt)?{baz}:{bar}` and here we can factorise `print`.