Wednesday, December 25, 2019

How to Split Strings in Ruby

Unless user input is a single word or number, that input will need to be split  or turned into a list of strings or numbers. For instance, if a program asks for your full name, including middle initial, it will first need to split that input into three separate strings before it can work with your individual first, middle and last name. This is achieved using the String#split method. How String#split Works In its most basic form, String#split takes a single argument: the field delimiter as a string. This delimiter will be removed from the output and an array of strings split on the delimiter will be returned. So, in the following example, assuming the user input their name correctly, you should receive a three-element Array from the split. #!/usr/bin/env rubyprint What is your full name? full_name gets.chompname full_name.split( )puts Your first name is #{name.first}puts Your last name is #{name.last} If we run this program and enter a name, well get some expected results. Also, note that name.first and name.last are coincidences. The name variable will be an Array, and those two method calls will be equivalent to name[0] and name[-1] respectively. $ ruby split.rbWhat is your full name? Michael C. MorinYour first name is MichaelYour last name is Morin However,  String#split is a bit smarter than youd think. If the argument to String#split is a string, it does indeed use that as the delimiter, but if the argument is a string with a single space (as we used), then it infers that you want to split on any amount of whitespace  and that you also want to remove any leading whitespace. So, if we were to give it some slightly malformed input such as Michael C. Morin (with extra spaces), then String#split would still do what is expected. However, thats the only special case when you pass a String as the first argument. Regular Expression Delimiters You can also pass a regular expression as the first argument. Here, String#split becomes a bit more flexible. We can also make our little name splitting code a bit smarter. We dont want the period at the end of the middle initial. We know its a middle initial, and the database wont want a period there, so we can remove it while we split. When String#split matches a regular expression, it does the same exact thing as if it had just matched a string delimiter: it takes it out of the output and splits it at that point. So, we can evolve our example a little bit: $ cat split.rb#!/usr/bin/env rubyprint What is your full name? full_name gets.chompname full_name.split(/\.?\s/)puts Your first name is #{name.first}puts Your middle initial is #{name[1]}puts Your last name is #{name.last} Default Record Separator Ruby is not really big on special variables that you might find in languages like Perl, but String#split does use one you need to be aware of. This is the default record separator variable, also known as $;. Its a global, something you dont often see in Ruby, so if you change it, it might affect other parts of the code—just be sure to change it back when finished. However, all this variable does is act as the default value for the first argument to String#split. By default, this variable seems to be set to nil. However, if String#splits first argument is nil, it will replace it with a single space string. Zero-Length Delimiters If the delimiter passed to String#split is a zero-length string or regular expression, then String#split will act a bit differently. It will remove nothing at all from the original string and split on every character. This essentially turns the string into an array of equal length containing only one-character strings, one for each character in the string. This can be useful for iterating over the string and was used in pre-1.9.x and pre-1.8.7 (which backported a number of features from 1.9.x) to iterate over characters in a string without worrying about breaking up multi-byte Unicode characters. However, if what you really want to do is iterate over a string, and youre using 1.8.7 or 1.9.x, you should probably use String#each_char instead. #!/usr/bin/env rubystr She turned me into a newt!str.split().each do|c| puts cend Limiting The Length of the Returned Array So back to our name parsing example, what if someone has a space in their last name? For instance, Dutch surnames can often begin with van (meaning of or from). We only really want a 3-element array, so we can use the second argument to String#split that we have so far ignored. The second argument is expected to be a Fixnum. If this argument is positive, at most, that many elements will be filled in the array. So in our case, we would want to pass 3 for this argument. #!/usr/bin/env rubyprint What is your full name? full_name gets.chompname full_name.split(/\.?\s/, 3)puts Your first name is #{name.first}puts Your middle initial is #{name[1]}puts Your last name is #{name.last} If we run this again and give it a Dutch name, it will act as expected. $ ruby split.rbWhat is your full name? Vincent Willem van GoghYour first name is VincentYour middle initial is WillemYour last name is van Gogh However, if this argument is negative (any negative number), then there will be no limit on the number of elements in the output array and any trailing delimiters will appear as zero-length strings at the end of the array. This is demonstrated in this IRB snippet: :001 this,is,a,test,,,,.split(,, -1) [this, is, a, test, , , , ]

Tuesday, December 17, 2019

Therapeutic Benefits of Stem Cells Essay - 1193 Words

Therapeutic Benefits of Stem Cells A stem cell is a cell which can differentiate into any other type of cell in the body. It can become a blood cell, a liver cell, or even a nerve cell. The only problem with stem cells is that they can only be found in the bone marrow of living humans or the gonadal tissue of developing fetuses. There are many people who believe that stem cells are the miracle cure for cancer, Parkinson’s, and many other terminal diseases, but there are large groups of people opposed to the use of stem cells because of the means by which they are attained. This debate will go on indefinitely, because there are prodigious amounts of support for both sides of the issue. The many benefits of stem cells out weigh the†¦show more content†¦Scientists have used gene therapy ( Inserting a strand of RNA into a virus which will then cause the cell to create new proteins) to insert a normal gene into the stem cells of the children’s bone marrow (FDA, 2003). By doing this the scientists hav e been able to successfully treat nine out of the eleven of the children who were afflicted with the disease. The scientists say that â€Å"The children went on to live relatively normal lives† (FDA, 2003). If the stem cells were not used, the children would have certainly died before they even had a chance to live. These are just a few examples of the many benefits of stem cells. People in the religious community as well as the human rights community do not like stem cells because they either come from a living patient’s bone marrow or the developing tissues of fetuses. They believe that the unborn child is â€Å"alive†, and so they think that using stem cells is murder. The fact is that scientists use primarily aborted fetuses, which would only be incinerated instead. These people are not focused on the ethical issues of stem cells, rather they are trying to combat abortion, a problem which has persisted through history. The most promising use of stem cells is in the field of nerve damage. Your body stops creating nerve cells right when you are born, so if your nerves get damaged, you cannot create any new cells. People who are paralyzed inShow MoreRelatedReport on Therapeutic Cloning1109 Words   |  4 PagesArgumentative Paper - Therapeutic Cloning A sheep named Dolly is the first thing to come to mind when the term cloning arises. Everyone remembers the hoopla or has read of the hoopla that surrounded the birth and survival of the first successfully cloned animal. This is because cloning, to some, is a questionable practice at best. In general terms, cloning is the replication of another animal. It is a process whereby an identical twin is created in a lab. However, cloning is not limited toRead MoreModern Medicine And Biotechnology Have Increased The Lifespan Of Humans Across The World1282 Words   |  6 Pagesworld. One example of a form of biotechnology are muscle stimulators, which help keep muscles strong while broken bones heal, because a human can’t really use a muscle with a broken bone. Another example is a nerve regenerator, which help produce cells that encourages nerve development. Cloning is a form of biotechnology. The process of producing an organism that is genetically identical is called cloning. Cloning is an asexual reproduction process. Cloning in biotechnology is manually cloning anRead MoreTwo of Us: Cloning Essay1477 Words   |  6 Pageslike if you did not? Cloning is the creation of an organism that is an exact genetic copy of another. The first successful clone was in 1997 when scientist Edinburgh cloned Dolly the sheep. She was the first animal to be cloned with an adult somatic cell by using the process of nuclear transfer. She was born on July 5 1996, lived to the age of six and died after being diagnosed with lung disease called Jaagsiekte. (First Cloned Sheep Dolly Dies at 6 page 1). This is a common disease in sheep causedRead MoreTherapeutic Cloning And Its Controversy1313 Words   |  6 PagesTherapeutic Cloning and its Controversy The idea of finding a way to cure people of diseases with their own cells is one that scientists, physicians, and those who are afflicted by such diseases find very enticing. Therapeutic cloning is a process that scientists believe has the potential to achieve such goals in the future. While therapeutic cloning brings with it a variety of potential benefits and innovations, it also carries with it a polarizing ethical conflict that poses a strong impedimentRead MoreTherapeutic Cloning Essay1412 Words   |  6 Pageswrong, the process of therapeutic cloning, the completely different procedure of therapeutic cloning is completely moral and could save millions of people. Therapeutic cloning is a credible scientific procedure with many benefits, and uses that could greatly benefit humanity. However, to its dismay, it has been unfittingly coined with the unethical human replication, commonly known as cloning, and has been unfortunately been categorized along with this other procedure. Therapeutic cloning, however, isRead MoreThe Controversial Topic Of Stem Cell Research Essay1414 Words   |  6 PagesStem Cell Research is still the most controversial topic in science today. The idea behind the experiment involves the development, use, and destruction of human embryos. The research method mainly focuses on embryonic stem cells, which involves taking tissue from an aborted embryo to get a better look at the cell and obtain information for the fundamental properties of the cells. Embryonic stem cells play a major role in the research because the cell provides information for cell development toRead MoreEssay Problems with Embryonic Stem-Cell Research1416 Words   |  6 PagesRecently in the scientific world, the field of embryonic stem cell research has become a popular topic and has been the subject for many heated debates. Experts in the field of stem cell research promise that this will be the future of medicine; that stem cells will be the cure to all the debi litating diseases and afflictions of today, such as Alzheimer’s disease, heart disease, cancer and nerve damage. The truth about embryonic stem cell research is that it is not as hopeful and as revolutionaryRead MoreCloning for the Greater Good Essay1270 Words   |  6 PagesThe possibility of therapeutic cloning and embryonic stem cell research not only brings hope to people with diseases but also brings fear to many when the thought of clones walking the earth comes to mind. Therapeutic cloning is an advanced procedure also known as somatic cell nuclear transfer (SCNT) where DNA is removed from an egg and replaced with DNA from a somatic cell. After the DNA is transferred into the egg, the egg is shocked into thinking it was fertilized and cells start to divide. TheRead MoreHuman Embryonic Stem Cell Research1313 Words   |  6 PagesJessica Rogers Kendra Gallos English III Honors 18 April 2016 Human Embryonic Stem Cell Research Human Embryonic Stem Cell Research, or HES cell research, is a very controversial ethical debate. This issues is a dilemma for scientist, religious activist, and many more. HES cell research is being disputed because the practice is morally wrong. The other side of the issue stands with many scientist, being that they see the potential lives it could save in the long run. Religious activist, andRead MoreEthical Justification Of Moderate Hesc Policy1601 Words   |  7 PagesEthical Justification of Moderate hESC Policy By definition, discovery implies uncertainty, but progress cannot exist without either. They are codependent upon each other. Whether the use of embryonic stem cells is truly the destruction of human life and whether the potential of human life is equal to the possible realization of that potential is also codependent. Neither of these questions can be answered without simultaneously answering the other. Arguments from both sides of this issue are extremely

Monday, December 9, 2019

Roundtable on Land and Water Management - MyAssignmenthelp.com

Question: Discuss about theRoundtable on Land and Water Management. Answer: Egypt is one of the most populated Middle Eastern countries in northern Africa. Its economy is one of the best in the northern African region. Egypt has the most developed economy. Egypt's economy is driven by the service sector which dominates at 47%, the agricultural sector is second at 29% and the industrial sector at 24%. Investing in real estates is one of the most promising business that international investors ought to invest in, in Egypt. Since the prices of real estate keep on rising every year, this is the best area to invest in. Political Factors Egyptian politics has been dominated by the military for many years until the 2011 uprising. This politics has always had a lot of animosity. There is animosity toward the Muslim Brotherhood. The Muslim brotherhood is so far the most organized political party in Egypt. Military influence has been very paramount in Egyptian politics given that a majority of the people see the military as a sign of stability. Mayfield (2014), observes that a Zogby poll which was published in the year 2013 revealed that nearly 94% confidence level. A majority of non-Islamists tend to favor a return to military rule while Islamists (nearly all of them) opposes this idea and this has brought a deep divide politically and religiously. This is what makes Egypt's political environment is hostile and risky for investment given the political turmoil that has been experienced in Egypt during the Arab spring beginning with the overthrow of Hosni Mubarak in 2011. Egypts politics has seriously affected the Egyptia n market. The Egyptian market is currently grossed with serious serious political risks for foreign investors. While these risks can be successfully diversified, especially by integrating available stock into an investment portfolio, it is still important to give political risk serious attention. Inflation rate have soured high, unemployment rate is also high and businesses are also seriously affected. According to Mayfield (2014), the political risk associated with Egypts politics especially the transition brought about a negatively affected the country and brought about disinvestment. Legal Factors The official language in Egypt is Arabic. All documents especially business documents are written in Arabic if they are to have the necessary value expected of them. Expatriates who are not well conversant with the Arabic language can find it difficult to operate in Egypt. It is possible that an agreement can be drafted in another language, however, such an agreement or proposal must be accompanied by an approved official translation in Arabic. Arabic is Egypt's official language and all documents have to be written in this language if they are to have legal value (Shalaby and Dardik 2017) A contract can be written in another language, however it has to be accompanied by an official translation in approved Arabic. This can pose a serious challenge to foreign nationals who would like to operate in Egypt. While making drafts and agreements, the point of references is the 1971 constitution. The prevailing legal system in Egypt is highly influenced by the French law from which it borrows a lot. Sharia laws can also apply in some circumstances to question civil positions. Egypt encourages foreign investors to invest in Egypt. This can be seen from the fact that Egypts Incentive Law clearly recognizes investors. The rights of investors in accommodated by Egyptian policies and law. Investors can solve disputes more amicably through bilateral arrangements. The Egyptian law also allows for the application of UN Commission of Trade Law according to Kleinman and Lin (2017) What Egypt is Doing to Improve Foreign Investment? New Egyptian legislation encourages foreign investments. These new laws have put in place incentives to help attract more foreign investment. (Kleinman and Lin 2017) With these new laws Egypt hopes to come up with an attractive business environment. By this legislation Egypt has set up a conducive business environment to ensure that foreign investors get fair treatment when signing business contracts just as the locals. Foreigners also have equal opportunities just as local investors. According to Kleinman and Lin (2017), provisions in articles 30 of the Egyptian constitution states that foreign investor are exempted from paying fees for documenting the companies as well as stamp taxes. Conclusion Egypt is a booming market for foreign investment following its approximately 4 years of economic stagnation. Culture wise and economically, Egypt stand out as the country that encourages huge foreign investment. This is because it has a bigger population and a stronger economy. Despite the political upheavals, Egypt is secure compared to other nations in the middles east. The only factors that may affect the successful set up of operations may result from language barrier from expatriates not familiar with Arabic and a few cultural influences given that Egypt is an Islam state. Works Cited Gomaa, S.S., 20015. Environmental policy making in Egypt. In Roundtable on Land and Water Management: proceedings, Cairo, 13-15 Dec. 1993. IDRC, Regional Office for North Africa and the Middle East, Cairo, EG. Caiazza, R., 2014. Identifying international market opportunities: the case of Italian companies in Egypt. Benchmarking: An International Journal, 21(4), pp.665-674. Kleinman, G. and Lin, B.B., 2017. Audit regulation in an international setting: Testing the impact of religion, culture, market factors, and legal code on national regulatory efforts. International Journal of Disclosure and Governance, 14(1), pp.62-94. Shalaby, S.Y. and Dardik, A., 2017. Comparison of Investment opportunities in Egypt with the United States. In Economic Survey (pp. 127-129). Springer International Publishing. Kleinman, G. and Lin, B.B., 2017. Audit regulation in an international setting: Testing the impact of religion, culture, market factors, and legal code on national regulatory efforts. International Journal of Disclosure and Governance, 14(1), pp.62-94. Mayfield, J.B., 2014. Rural politics in Nasser's Egypt: a quest for legitimacy. University of Texas Press.

Monday, December 2, 2019

Modern Manifestation of Buddhism free essay sample

Buddhist practices have flourished throughout Asia for thousands of years. These practices didnt reach the Western culture until the late 19th century. However, over the past decade Buddhist teachings seemed to have an attraction within our rapidly changing culture. Unlike many religions, which focus only within their institutions, the Buddhist focus point is to achieve inner peace within ones self, in which can have a profound rippling effect. The manifestation of Buddhism throughout the western culture has slowly been increasing and has become more accepted within ur political society. In order to fully understand this manifestation, one must first understand Buddhism and where it came from. Buddhism began about 2,500 years ago in India when Siddhartha Gautama, a wealthy prince, became dissatisfied with his lavish lifestyle ( in class). Siddhartha left behind his wife and children to set out on a path to find the true virtues of life. In leaving his kingdom he cut off his hair and renounced the selfish lifestyle that he once led. We will write a custom essay sample on Modern Manifestation of Buddhism or any similar topic specifically for you Do Not WasteYour Time HIRE WRITER Only 13.90 / page Upon his Journey, Gautama saw sickness, old age, and death. He couldnt understand how there could be happiness in world that was filled with suffering. Within his search, he survived off a very limited diet, only eating roots and berries (in class). He grew even more dissatisfied when he realized that, Neither my life of luxury in the palace nor my life as an ascetic in the forest is the way to freedom. As his impatience started to grow, he told himself that he would sit under a tree and would not walk away until he was free from suffering. Siddhartha fell into a deep meditation, in which he met copious amounts of evil that tried to lure him away from reaching his goal. As the struggle subsided, he was free from suffering and gained supreme wisdom. It was this moment that he was known as Buddha. Upon his enlightenment, the Buddha and his followers spent the next forty-five years spreading Dharma, his teachings. Social class played no role in the path that the Buddha sought out to pave. His acceptance among all economic classes represents the amount of compassion that he had for every sentient being. He understood all of the hardships that everyone faced because he dealt with their true emotions. The Buddha stressed to not believe in his teachings Just on blind faith. He encouraged his followers to meditate as well, for that is the only way for one to evelop their true virtue. Buddhism has been labeled as a religion, which is quite untrue. To an outsider it may seem that the Buddha is seen as a religious icon. However, for those who partake in meditative practices, the Buddha is viewed as a mental reinforcement and support. Buddhists dont believe in supernatural spirits unlike every other religion etc. (Christianity, Judaism, and Islam). The Buddha stressed that everyone needs support to make sure that they stay on the right path. Before the Buddha died, he encouraged his followers to continue to support the novice beginners, because life is ull of illusions; if not guided in the right direction they could lose the wisdom that any teacher, parent, or coach. Within the basic teachings of Buddhism, it is understood that the universe is consistently changing, which history proves to be true. New ideas are born, and then eventually die off. For example, fashion, because its constantly changing. Karma is one of the universal truths that explains life as a result of cause and effect. Basically, if you do good things, then good things will happen to you. If you do evil things then bad things will happen. Ones thoughts and actions will determine how the future plays out. Within Buddhism it is explained that ignorance, attachment, and aversion are the reasons for suffering (Rinpoche P. 1 17). Ignorance is the inability to see things for how they truly are. When perceptions are distorted, it causes disillusionment and makes one unable to recognize the infinite potential within the human mind. Attachment is described as the perception of self and other. Attachment is an addictive trait that causes a compulsive dependency on external objects or experiences to generate an illusion of wholeness (Rinpoche P. 18). Aversion is the strong attachment one generates towards someone or something. To many this causes a sense of satisfaction and happiness once one has achieved their goal. Unfortunately, this attachment will cause an equally powerful fear if one fails get what they want or lose what they have gained. Changes are inevitable, by trying to go against change will not only cause one to suffer but, it will hinder the infinite potential of happiness. Naturally, it is genetically within humans to differentiate self and other. This genetic is very similar to the reptilian gene, which is living Just to survive. When surviving is the only thing that matters, others are viewed as enemies, or as obstacles that may refrain one from achieving happiness (Rinpoche P. 105). Unfortunately, by feeding the ego, it causes a conflict of interest because we live in a world that depends on others. For example, food, gas, clothes, or any kind of provided service. This often complicates the relationship with others and ones self. In Buddhism it is understood that happiness is best when shared. One way to override the ego is developing a sense of compassion for ones self and for others. Compassion is much ifferent from the ordinary sense, which means feeling sorry for others. But in Tibetan terms, compassion represents the spontaneous feeling of a connection with all sentient things. Once one has realized, that Just like them, everyone wants to achieve peace and avoid suffering. Instead of seeing a particular individual as an enemy, one can see them in a different light, simply by realizing that he/she is Just trying to free themselves from suffering. Compassion is the recognition that everyone and everything is simply a reflection of everyone and everything (Rinpoche p. 174). Over the past few decades, anxiety has been a main health issue for Americans. Many have disputed on the causes of this mental affliction, whether its the economy, poor health, pressure at Jobs, or even stress within the household. More than 18 percent of American adults are suffering from an anxiety disorder, which makes the United States the most anxious country in the world (Clark). Robert Leahy, a psychologist, said that the average high school kid today has the same level of anxiety as the average psychiatric patient in the early 1950s. Many ask well why is this? America, to many outsiders, is viewed as a land of opportunity and yet countries, such as Nigeria, that they are up to 5 times less likely to show significant signs of anxiety than Americans (Clark). It seems as though Americans are being forced to become more independent. This goes back to the ego state of mind, separating self and other. When one alienates ones self to protect their own interests, they miss the element of in-person connection (Clark). From the day a child is born, the child needs to receive affection. It has been shown in the past that if a new born was Just given food and shelter, he/she simply wouldnt survive or they ould have serious social problems as that child reached adulthood. As time progresses, new technology will arise and material objects will continue to play a huge role for many Americans. It is important to understand that one wants to free oneself from the sufferings from stress and anxiety, one needs to create some sort of a balance. Some may argue the fact that medication can help treat these sufferings but, in fact they do quite the opposite. Yes, it provides immediate results, but as time progresses, that particular person will build up a tolerance to the drug. Once this happens, many choose to increase the amount of dosage. This was cause many health risks physically and mentally. Physically, these drugs will wear down the stomach lining, which can cause ulcers and the breakdown of ones liver. Mentally, one will become extremely dependent on this drug, causing the anxiety/stress levels to increase even higher than before ever taking the medication. Though medications may help some, it makes many extremely dependent on a drug, which causes a fear that if he/she is not on the medication then they cant cope or deal with everyday situations. The point that is being made here, is that by dealing with ones stress in a ognitive and logical way, it enables one to cope with their problems rather than running away from them. Facing fear is the only way to relieve it. Mediation is great way to become in touch with themselves and reality. Much of the western culture is a melting pot, a mixture of many ethnicities and religions. Due to the increase in technology, it has made it easier for most of the population to develop a well-educated opinion on religion, politics, and health. Many of the Buddhists meditative practices have eased their way into the western culture because it doesnt matter whether one is religious or not. Many psychologists have adopted mediation as a practice that they use on their patients. Meditation has immense side effects Just on a physiological level. The Transcendental meditation is a technique used to reduce stress and strengthen the communication between the prefrontal cortex and other areas in the brain (tm. org). When one becomes at ease within the natural state of their mind a sense of openness is brought about. For many, compassion for one another grows tremendously which can enable a very stable life and work environment. Meditation is a way to self-regulate ones self and iscover the inner workings within the mind. There are many different methods in meditating but, the main ones are Right Mindfulness, Right Concentration, and Right View. Each of these types helps generate new neurological activity within the brain, which can cause tremendous health benefits. Sara Lazar, a psychologist at Harvard University conducted a study that compared the brain activity between those who meditate and those who dont (YudhiJit). Within her study she used magnetic resonance imaging scans to monitor the brain activity between both groups. Her senses, were thicker in the subjects who practiced meditation. Lazar said, The differences in the thickness were pronounced in older subjects, suggesting that regular practice of meditation might reduce normal age-related thinning of the brain (YudhiJit). Stress and anxiety have become the nations modern epidemic. The United States spends more than $300 billion per year on trying to fix the anxiety and stress levels that are amongst many Americans (Clark). Mediation seems to be the perfect solution. The results are realistically astonishing. Why realistic? Because when meditating your not chasing a particular feeling, unlike many medications. When one is able understand how the mind works and how it reacts in certain situations, it makes it much easier to cope with everyday problems. The reliance on materialistic objects never seems to satisfy the sense of wholeness that everyone is longing for. The best part about meditation, if practiced regularly, many seem to find that the sense of wholeness that he/she has been longing for has been their the whole time. Instead of complaining about the things he/she doesnt have, one is able to see all of the wonderful aspects that they do have. The sense of clarity is a more riceless asset than any iPod, computer, or television. Being able to expect the good and the bad is part of accepting ones fears, anxiety, or stress. Stress and anxiety is only the bodies reaction to how the mind perceives a situation. For example, lets say two people get into an altercation and started a argument. The only reason that they are fghting is because the other individual poses as a threat, maybe due to his actions or something that he/she had said. Now what if they both spoke two completely different languages, would they still have gotten into a fght?