Thursday, March 5, 2020

How to Split Strings in Ruby

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, , , , ]

Wednesday, February 19, 2020

Human Resource Management Essay Example | Topics and Well Written Essays - 1750 words - 7

Human Resource Management - Essay Example Human resource intranets are one of the fastest growing technologies in the market place. This offers a compatible and user friendly solutions which can be customized and offered according to the organizational needs. This helps in connecting various departments and branches of any organization to share information and communicate effectively. The first part of the paper deals with the human resource management. It describes various human resource management functions that are required for any organization. The second part deals with the intranet and its benefits and drawbacks. The last section of the paper describes the HR intranets and the activities it can handle. Challenges faced by the organizations in the research and the various factors of the environment influence development of their operations. The heterogeneity is present in the culture, political legal set up, social set up, availability of investors and funding parties for that particular area, work force, management att itude and perception about the host country. These all factors influence most of the industries and organizations in the strategic decision making process. There are number of activities within any organization that are very important like marketing and sales, human resource management, production and manufacturing, operations, information technologies which functions together for the organizational goal and profitability.

Tuesday, February 18, 2020

The Cold War in Berlin Research Paper Example | Topics and Well Written Essays - 1750 words

The Cold War in Berlin - Research Paper Example He stated that if one was claiming that communism was good, he should come to West Berlin and see the capitalism taste. This was meant to demonstrate how well the capitalism ideology had spurred significant economic growth and political freedom in West Berlin. He also asserted that dividing people and putting them under oppression was not only contravention of individual human rights but a recipe to economic backwardness. He reiterated the need for a united people and pursuit of capitalism which was characterized by democracy â€Å"Freedom has many difficulties, and democracy is not perfect But we have never had to put a wall up to keep our people in, to prevent them from leaving us!† He demonstrated how West Berlin had prospered despite being physically separated from the rest of the world and directly championed for adoption of democracy as a tool towards capitalism before he gave a closing remark amidst a cheering crowd of how proud he was to be a West Berliner (Smyser, 200 9).It is worth to note that John. Kennedy’s visit was also meant for a meeting with the Soviet Union Leader Nikita Khrushchev in Vienna Austria for a retreat in terms of the oppressive rule over the East Berlin people. The meeting ended in a stalemate and increased tension between US and Soviet Union. At some point, the US threatened to react with military force if their rights in West Berlin were interfered with in any way by the communist Soviet Union. To achieve this, the second wall which was known as border wall 75 was created in 1975.

Tuesday, February 4, 2020

Commuincation in Business Culture Term Paper Example | Topics and Well Written Essays - 1000 words

Commuincation in Business Culture - Term Paper Example This essay explains the rules in communicating in a business culture and explains situations when a rule may be violated. When considering communication in business culture it’s clear there are a number of overarching rules one must consider. When considering communication in the business context, it’s first necessary to examine the nature of forms of communication. In these regards, there is the obvious form of face-to-face communication in the specific business environment. Still, there are numerous other forms of communication that do not involve such interaction. For instance, business communication increasingly involves technological mediation, with employees remaining in context with each other through email, telephone, or forms of social media. One of the notable features of these elements of communication is the understanding that in large-part the medium of communication influences the rules for successful communication. In further examining the rules of commun ication within business culture it’s clear there are a number of rules that emerge. One of the primary rules of business communication is avoiding barriers to direct and efficient communication practices. One of the primary barriers to communication is complex-messages. ... Not following this rule can result in decreased efficiency levels, as employees need to work to ensure that they gained the correct meaning of the message. In more serious business contexts, it is even possible for such forms of communication to have disastrous consequences. Still, it’s recognized that there are instances when individuals need to use complex messages in business communication. For instance, in financial climates or areas of high-density business, it’s clear that in properly articulating messages it’s necessary to implement complex linguistic forms of expression. Another major rule of communication in the business culture concerns the importance of not withholding information. While withholding information is slightly more complex a formulation than the rule of not delivering complex messages, it’s equally important. The nature of a functional business environment relies on open and clear communication practices. Indeed, it’s been ar gued that, â€Å"if employees consistently withhold information the issue can become a pervasive one affecting all levels of organizational structure† (Dianne 2010, pg. 111). When employees withhold information this results in decreased efficiency levels and affects the company’s ultimate profitability. Withholding information occurs for a variety of reasons. For instance employees may withhold information as a means of maintaining power through knowledge disparity. In this context of understanding, one considers the notion of ‘knowledge is power’ as a central consideration. Other employees may withhold information from each other simply out of a general dislike or avoidance. In these regards, it’s necessary for

Monday, February 3, 2020

Analyze the def-14a by JPMorgan of advanced corporate finance Term Paper

Analyze the def-14a by JPMorgan of advanced corporate finance - Term Paper Example Michael A Neal has had quite an experience too (JPMorgan Chase & Co.). He has had quite an extensive experience in management of large complex businesses within regulated industries around the world. As a vice chair person of the general electric company, he oversaw financial services as well as products provision to customers and organizations of different sizes in south America, north America, Australia, Asia and Europe. He has experience strategic planning, risk management as well as operations (JPMorgan Chase & Co.). The basic responsibility of aiding the board in overseeing in respect to legal risks, operating risks, as well as compliance tests does rest with the company’s audit committee. Every board committee does oversee issues of reputation risk within its responsibility scope. The way guidelines on membership in the director’s risk policy committee show that the committee is very independent and members are well vetted before they are given their posts. The firm has a chief risk management officer who does report to the company’s CEO and is accountable to the company’s board. The chief risk officer is well vetted before appointment and the proposed priorities, staffing plans as well as budget are reviewed annually. The firm’s fiduciary risks are the responsibility of director’s risk policy committee (JPMorgan Chase & Co.). Risk management in the financial services business, involves assessment as well as quantification of business risks and then putting in place measures to control them. Risk management also happens to be part of compliance function and part of precise business units (Kolakowski). JPMorgan has done the best to put in place different units that are independent in risk decision making to ensure risks are anticipated, minimized hence well managed. A bachelor’s degree is the minimum education

Monday, January 27, 2020

A Problem Question on Contract Law

A Problem Question on Contract Law Introduction A contract refers to an agreement between two or more parties which is legally binding in the eyes of the law. Based on Contract Act 1950, section 2 (h), an agreement that is enforceable by law is a contract. Any other agreements that is not enforceable by law is said to be void, section 2 (g). Therefore, section 2 (j) a contract which is ceases to be enforceable by the law becomes void when it ceases to be enforceable. A contract consists of 6 elements which is proposal (section 2) and acceptance (section 7). The agreement made must be certain and lawful to fulfill the requirement of entering a contract. The consideration (section 26) of a contract have to be in price theory or the benefit and detriment theory. Next, certainty (section 30) said that the terms and agreements of a contract need to be certain and clear. Besides that, all party in the contract have to be free consent, section 10. Lastly, section 11 capacity said that minors, person that disqualified from contracting by any law and unsound mind are not competent to enter a contract. Ah Beng Ah Beng wished to sell his 3-year old motorcycle. He have the intention to create legal relations, commercial contract. In a business contract the presumption is that there is an intention to create legal relations. Unlike domestic contract where agreement made between parties are stated as no intention to create such a legal relations. For example, agreement between spouses, between parent and child and agreements between friends. Case law Balfour v. Balfour. The husband promised to pay a monthly allowance as maintenance to his wife. The court held that it was not a legally enforceable agreement, the parties should be attended by legal consequences. According to section 2 (a), when one signifies to another his willingness to do said to make a proposal, Ah Beng is the offeror before he advertised the sale in a local newspaper. After the advertisement,he becomes an acceptor. Advertisement consist of two types of offer, Bilateral and Unilateral offer. Unilateral offer is a party (X) undertakes to do something is another party (Y) decides to accept by performing some lawful act specified by X. For instance, Carlill v. Carbolic Smoke Ball Co. Carbolic Smoke Ball company made an offer to the pubic by issuing an advertisement saying that whoever still suffered from influenza after taking their product (a drug) will get  £ 100 in a specified manner and for a specified period of time. Mrs Carlill sued the company for the promise reward. The court held that the advertisement is an offer to the world. Referring to the Bilateral case law Majumder v. Attorney General of Sarawak 1967, a newspaper advertisement stated a medical officer war required and set out the salary scale. The Federal Court held that the advertisement in the newspaper for the post of a medical officer was an invitation to treat. Therefore the advertisement by Ah Beng is a Bilateral Contracts, where both parties make promises to one another, a mutual exchange of promise and this leads to invitation to treat. For example, a job advertisement is not an offer but an Invitation to Treat. The applicant is the offeror for the job and if it is accepted, the promisor is obligated to perform by giving the applicant a position and remuneration in accordance with the advertisement, a promise for a promise. Ah Beng and Ahmad Ah Beng called his colleague Ahmad who had previously told him that he is looking for a used motorcycle for his son for RM 2,500.00 in cash. As they discussed, Ahmad asked Ah Beng to hold the offer till end of the month and Ah Beng did not give an affirmative answer. Based on section 2 (a) , when one signifies to another his willingness to do said to make a proposal. Therefore Ah Beng is the offeror and Ahmad is the acceptor. However, the contract is not valid. There are components under Contracts Act 1950 to determine whether a contract is valid or invalid. When Ah Beng offered Ahmad at the first place, Ahmad request for extension, â€Å"until the end of the month†, setting a new request to Ah Beng. According to section 7 (a), conditional acceptance is no acceptance. Case law Branca v. Cobarro. Ahmad’s act has caused the contract to be invalid. Moreover, at the end of the conversation Ah Beng did not give an affirmative answer to Ahmad , section 7 (a) Acceptance must be absolute as referring to case law of Kam Mah Theatre Sdn. Bhd. v. Tan Lay Soon 1994. The acceptance given by Ahmad must be absolute and unqualified in order to make the contract between him and Ah Beng valid. After two days, Ahmad rang up Ah Beng’s house to inform that he is interested to buy the motorcycle and will go over the next day to make the payment of RM 2,500.00 after seeing Ah Beng has advertised to sell the motorcycle for RM 2,800.00 on the local newspaper. Unfortunately Ah Beng was not in and Ah Beng’s wife is the person who was answering the call. Based on section 4 (1) , a communication is complete when it comes to the knowledge of the person to whom it is made. Refers to case law, R v. Clarke. Clarke was an accomplice to the murder of two policeman, the Australian published a notice granting pardon and a reward of A$ 1,000. Clark supplied the information but he admitted that at the time he gave the information he had forgotten about the reward money. The court held that he was not entitled to the reward as he was not aware of the reward at all. The contract is therefore invalid as Ahmad did not deliver his messages and offers to Ah Beng’s knowledge and not conforming to Section 4(2)(b). However, the contract can still be valid if Ah Beng give authorization to his wife to accept the offer on behalf of Ah Beng. This is illustrated in the case law Powell n Lee, the court held that there was no authorized communication made by the acceptor. Ah Beng and Maniam Maniam read the advertisement and went over Ah Beng’s house to look for the motorcycle. Maniam’s act is to inquire more information about the motorcycle. The conversation between Maniam and Ah Beng signifies that the advertisement made by Ah Beng regarding the motorcycle is uncertain as there are informations about the motorcycle that Ah Beng did not mention clearly in the advertisement such as the model of the motorcycle, colour of the motorcycle, accident free and current condition of the motorcycle have not been told from the advertisement. This have caused uncertainty for the consideration of an agreement, therefore invalid contract based on section 30. This scenario can be referred to the case law, Karuppan Chetty v. Suah Thian 1916, â€Å"lease at $35.00 per month as long as he like† is unacceptable by the court therefore declared void for uncertainty. Maniam noticed that the battery was weak and both of the tyres were worn off during the inspection of the motorcycle. Ah Beng immediately offered the price to RM 2,700.00 and has become the new offeror, on the other hand Maniam become the new acceptor. As the negotiation going on, case law Lau Brothers Co v. China Pacific Navigation Co. Ltd 1965, no agreement will be formed under negotiation. However Maniam agreed to bring the cash on the next day expecting Ah Beng to replace the two tyres with the new ones. It is a new condition set by Maniam, leading to a counter offer. Based on section 7 (a), the acceptance made must be absolute and unqualified. Therefore the contract is not valid as Maniam’s counter offer is a rejection of the initial contract, contracts subject to contract. The contract would only be valid if it is free consent from both parties. Refers to case law Hyde v. Wrench 1840, the defendant offered to sell his estate to the plaintiff on 6th of Jun for  £1,000. On 8th of June the plaintiff made a counter proposal, 27th of June the defendant refused to accept his offer. Two days later the plaintiff wrote to the defendant that he was prepare to pay  £1,000, the defendant refused. The court held that there was no acceptance as by rejecting the original offer the plaintiff had destroyed the offer. In effect the plaintiff is now making a new offer. By asking Ah Beng to replace the worn off tyres with new ones, Maniam has become the offeror again whereas Ah Beng as the acceptor of this new agreement. At the end of the day, Ah Beng did not give response to Maniam’s further request. Based on section 7 (b), Mental acceptance is no acceptance, silence will not amount to acceptance. Refers to case law Felthouse v. Bindley, plaintif’s uncle offered to buy a horse from plaintiff for  £30 adding â€Å"If i hear no more about him, i consider the horse mine at the price†. The court held that the plaintiff’s silence did not amount to acceptance of the offer. In this case, Ah Beng’s reaction towards Maniam is not an acceptance to the contract, therefore the agreements between Ah Beng and Maniam is invalid. Ah Beng and Jack A classmate of Ah Beng’s 16 year old son, also came to know about the advertisement. Jack immediately went over to Ah Beng’s house and gave five hundred ringgit in cash to Ah Beng’s son with a promise that he will pay the balance the next day after he gets it from his parents. Section 10 (1) states that if the agreements are made by free consent of parties for a lawful consideration are not hereby expressly declared to be void. Jack is willing to enter the contract by offering his money Ah Beng without being forced. Based on section 11 Capacity as per Age of Majority Act 1971, said that the age of majority to enter a contract is at the age of 18 and above. Case law Tan Hee Juan v. Teh Boon Keat, a minor entered into a contract of transferring land. The court held that the contract was void. Jack is a minor, 16 years old and incapable of entering a contract. Moreover, section 69 said that the necessaries suited to his condition in life is not valid. Case law Nash Vs. Inman (1908) a minor, who was already having sufficient supply of clothing suitable to his position, was supplied further clothing by a tailor. Unlike case law Scarborough v. Sturzaker 1905 where the minor needs a motorcycle to travel to work for 12 miles (19 km ) distance everyday. In this case, a motorcycle is necessaries suited to the condition in life. However, there are few exception for necessity which is valid contract. Such as marriage contract, case law Rajeswary v. Balakrishnan 1958. Case law Government of Malaysia v. Gurcharan Singh 1971 stated that scholarship contract is valid for a minor as education is a necessity nowadays. Insurance is also a valid contract for a minor. Based on Insurance Act 1963, a minor can enter an insurance contract if he is above ten years old. According to section 66, obligation of person who has received advantage under void agreement or contract that becomes void. When a contract becomes void, any person who has received any advantage under the agreement is bound to restore it, or make compensation for it to the person from whom he received it. Therefore, Ah Beng is obligated to restore balance, return the five hundred ringgit to Jack. Referring to case law, Thong Foo Ching Ors v. Shigenori Ono 1998. Conclusion In conclusion, non of the person above have a valid contract with Ah Beng. First, the communication is yet to be complete between Ah Beng and Ahmad as Ahmad called and Ah Beng’s wife is the person who answered the call (section 4 (1) Communication). Next, being silence did not amount to acceptance of the offer (section 7 (a). Therefore invalid contract with Maniam as Ah Beng remain silence. Next, the capacity of both parties must be competent to enter a contract in order to make it legal, section 11 Competent to contract. In this case the contract between Ah Beng and Jack is invalid due to the age of Jack, minor (16 years old) .

Sunday, January 26, 2020

Extracorporeal Membrane Oxygenation (ECMO)

Extracorporeal Membrane Oxygenation (ECMO) Cardiovascular Devices Chiara Tarenghi When a patient suffers from critical conditions which prevent to lungs or heart to work properly and to grant adequate blood flow and oxygen supply, either because of congenital disease, surgery or other reasons (severe pneumonia, sepsis, heart malformations, congenital diaphragmatic hernia, Respiratory Distress Syndrome ), a mechanical circulatory support is needed to take over temporarily the cardiopulmonary functions. These devices are known as extracorporeal life support (ECLS). ECMO is an invasive, non-therapeutic technique, consists essentially of an artificial external lung, a membrane oxygenator, which reproduces the physiological function of the gas exchange in the lungs (the blood releases CO2 and gains O2 according to the partial pressure gradient). It has successfully been employed as a bridge to recovery, cardiac transplantation, or implantation of a ventricular assist device, and it has met great application in paediatric surgery field (i.e. premature infants). It grants a steady amount of oxygen to the body while resting   and recover the lungs and heart. The device pumps blood from the body through the oxygenator with a roller pump (or a centrifugal pump, which causes major haemolysis though). There are three types of oxygenator commercially available: bubble oxygenator ( the gas is bubbled into blood), membrane oxygenator (allows exchanges of diffusion through a semipermeable membrane of silicon rubber that completely separates gas and blood), and hollow fibres oxygenator (fibres of PVC or PTFE hollow inside and semipermeable to gases). The blood is then warmed up through a heat exchanger (a coiled tubing containing warm water flowing counter current) and is injected back into the body. Each section of the machine is connected through cannulae. The blood flow is monitored continuamente to avoid the presence of microscopic air bubbles, thrombi and other emboli. Hazardous occlusions of tubing or thrombosis are detected by pressure monitors. Before letting blood flow through the tubes, the latter are primed by flushing with CO2 and then with crystalloid prime, albumin (to limit platelets adherence) and finally blood. The flow and amount of oxygenation is adjusted according to the needs of the patient. As the heart function improves, the flow is lowered. Blood volume can be assessed by urine output and central venous and mean arterial pressure. After a few days of mechanical assistance, the device is usually removed. ECMO is a valid alternative to pulmonary ventilation, since the latter pushes oxygen into patients lungs, regulating its amount and pressure, but high gas pressure could further damage lungs. Risks associated to ECMO include blood clot formation (which is prevented through anticoagulant like heparin) and, related to this, haemorrhage, infection, transfusions problems (thromboembolism and related stroke or ischaemia), mechanical failures. There are different ways of perfusion : ECMO VENO ARTERIAL (VA) : It requires three tubes to be inserted, venous blood is removed from the right atrium or vena cava, passing through the   jugular or femoral vein, and returned to ascending aorta (central ECMO) or femoral artery (peripheral artery). It is a hemodynamic and respiratory support for patients suffering from cardiogenic shock, sepsis, severe pneumonia, persistent pulmonary hypertension. Advantages: Low cost, can be applied to children and adults, support double heart and lungs. Disadvantages: It is more invasive than VV ECMO is a complex circuit, can cause embolism, neurological complications and require a sternotomy. ECMO VENO VENOUS   (VV):   In this case two tubes are inserted into the largest veins as jugular or femoral, but most often a single Y shaped cannula is inserted in the both veins. Blood is drained from the vena cava , blood is returned through the right atrium into the tricuspid valve. It is only a respiratory support for patients suffering from severe respiratory failure, asthmas, persistent pulmonary hypertension. Disadvantages: No cardiac support. ARTERIO VENUS   (AV):uses patients arterial pressure to pump the blood from artery to vein, it can be used only as a short-term support.

The May Fourth Movement Essays - Republic Of China, Chiang Kai-shek

The May Fourth Movement After World War I The Chinese felt deceived. Outrage and dissatisfaction emitted in exhibitions on May 4, 1919, i...