Tuesday, May 19, 2020

Using Glob with Directories in Ruby

Globbing files (with Dir.glob) in Ruby allows you to select just the files you want, such as all the XML files, in a given directory. Even though Dir.blog  is like  regular  expressions, it is not. Its very limited compared to Rubys regular expressions and is more closely related to shell expansion wildcards. The opposite of globbing, iterating over all the files in a directory, can be done with the Dir.foreach  method. Example The following glob will match all files ending in .rb in the current directory. It uses a single wildcard, the asterisk. The asterisk will match zero or more characters, so any file ending in .rb will match this glob, including a file called simply .rb, with nothing before the file extension and its preceding period. The glob method will return all files that match the globbing rules as an array, which can be saved for later use or iterated over. #!/usr/bin/env ruby Dir.glob(*.rb).each do|f| puts f end Wildcards and More There are only a few wildcards to learn: * – Match zero or more characters. A glob consisting of only the asterisk and no other characters or wildcards will match all files in the current directory. The asterisk is usually combined with a file extension if not more characters to narrow down the search.** – Match all directories recursively. This is used to descend into the directory tree and find all files in sub-directories of the current directory, rather than just files in the current directory. This wildcard is explored in the example code below.? – Match any one character. This is useful for finding files whose name are in a particular format. For example, 5 characters and a .xml extension could be expressed as .xml.[a-z] – Match any character in the character set. The set can be either a list of characters or a range separated with the hyphen character. Character sets follow the same syntax as and behave in the same manner as character sets in regular expressions.{a,b} – Match patter n a or b. Though this looks like a regular expression quantifier, it isnt. For example, in regular expression, the pattern a{1,2} will match 1 or 2 a characters. In globbing, it will match the string a1 or a2. Other patterns can be nested inside of this construct. One thing to consider is case sensitivity. Its up to the operating system to determine whether TEST.txt and TeSt.TxT refer to the same file. On Linux and other systems, these are different files. On Windows, these will refer to the same file. The operating system is also responsible for the order in which the results are displayed. It may differ if youre on Windows versus Linux, for example. One final thing to note is the Dir[globstring] convenience method. This is functionally the same as Dir.glob(globstring) and is also semantically correct (you are indexing a directory, much like an array). For this reason, you may see Dir[] more often than Dir.glob, but they are the same thing. Examples Using Wildcards The following example program will demonstrate as many patterns as it can in many different combinations. #!/usr/bin/env ruby # Get all .xml files Dir[*.xml] # Get all files with 5 characters and a .jpg extension Dir[.jpg] # Get all jpg, png and gif images Dir[*.{jpg,png,gif}] # Descend into the directory tree and get all jpg images # Note: this will also file jpg images in the current directory Dir[**/*.jpg] # Descend into all directories starting with Uni and find all # jpg images. # Note: this only descends down one directory Dir[Uni**/*.jpg] # Descend into all directories starting with Uni and all # subdirectories of directories starting with Uni and find # all .jpg images Dir[Uni**/**/*.jpg]

Wednesday, May 6, 2020

We See and Understand Things Not as They Are but as We Are

Theory of Knowledge â€Å"We see and understand things not as they are but as we are† Discuss this claim in relation to at least two ways of knowing. Name: Carlos Hill Quinta Candidate Number: 0650 035 Word count: 1,495 People are aware of reality just how they see it and how they live it. People perceive things how they understand it which sometimes can lead to conflicts and discussions on the fact that each person can perceive things differently. One way speaking people perceive and understand things by using their five senses: seeing; hearing; smelling; feeling and tasting. People can have different perceptions of reality by means of drugs, diseases or some kind of sense deficient, such as blindness, deafness or muteness.†¦show more content†¦For instance: Art people in general would not be able to see and understand the work as it is but how they perceive it as they think it is and as they want to. Different people will have different opinions from others which will in fact identify the claim where People see and understand things not as things are but as they are, because each person has a different way of thinking and of interpreting things which leads to a different understanding of the matter. That’s why Art is so subjective towards reality and self-understanding. And this is why the so called ‘Emotional ones’ interpret reality depending on culture and education which rely on ethics and on their self-actualisation of global perspectives. On the other hand ‘reasonable ones’ are objective on what they want and on what they believe. They see things just as they are with no second thoughts and no discussions on other ways of perceiving things. They have explicit points of view where all they perceive is rational and exponential, for it relies on morals and on efficient and productive perceptions on how things are. These people are considered in society today as the smart ones; they are always right on their decisions and on what they believe. But in the end everyone enjoys Arts in all forms: musicals, productions, or even exhibitions because artists see reality as they are and not as people would reason it. An exampleShow MoreRelatedWe See and Understand Things Not as They Are but as We Are.†1030 Words   |  5 Pagesâ€Å"We see and understand things not as they are but as we are.† Discuss the claim in relation to at least two ways of knowing. We all have our different views and opinions on things in life, as each and every person is unique and therefore we understand things differently. However, many questions come up when wondering if what we understand is not what everyone else understands and is clearly based on who we are as a person and what influences our lives. Also, there are many limitations to this statementRead More‘We See and Understand Things Not as They Are but as We Are’ Discuss This Claim in Relation to at Least Two Ways of Knowing1596 Words   |  7 Pages‘We see and understand things not as they are but as we are’ Discuss this claim in relation to at least two ways of knowing The typical description of a nice day outside includes lush green grass and clear blue sky. Everyone can relate to it, we see the colour, we can smell the scents and we can feel the texture. Yet do we see colour and smell the scents? Or does colour and scent exist in the world and all we as humans do is simply comprehend them? Is the day really a nice day? Or are we just inRead MoreWe See and Understand Things Not as They Are but as We Are. Discuss This Claim in Relation to at Least Two Ways of Knowing.1666 Words   |  7 PagesWhen we are trying to understand something, we sometimes rely on our senses and use reason to seek for the truth. We also use intuition to discover unknown things. As environment and culture may affect people’s way of thinking, people from different backgrounds may interpret things differently. People from the same background can even have different personal experiences, which also affect people’s understanding of the surroundings. No two people have exactly the same idea and we try to understandRead MoreSense Perception Essay1160 Words   |  5 PagesWe see and understand things not as they are but as we are Christopher Columbus, in the 1440’s on his voyage to America, saw three mermaids and described them as insight of females who rose from the sea. Did Christopher Columbus Imagine the mermaids because he was interested in fantasies or did he actual see it? On one hand I do believe that we understand and see things not as they are but as we are, on the other hand disagree with this statement. The way we view things reflects on our personalityRead MoreReflection Of Epictetus743 Words   |  3 PagesWhen Epictetus says that we should get angry if there is someone splashing in the bathhouse, he means that we should get up set at the way things are going. He would say that getting splashed at the bathhouse was out of your control. That no matter what the splashing would have happened, because it was already set up to happen that way, and there is no other way that it could have happened. The point that he is trying to make is that things in life are out of our control. They happen b ecause thereRead MoreArt 100 Paper1017 Words   |  5 Pagesmight be taken as things that are different from what we are used to be taken as threat. American people in general have a closed minded way of looking at things. The other aesthetic perspective for this art piece that are noted is linguistic. Linguistic are has symbols as well and the gun could also be seen as a symbol. It has words written in it too specifically on the feet. This artistic piece is powerful because it can have so many meanings to it and can mean many things to many differentRead MoreReflection Of Epictetus750 Words   |  3 Pages. When Epictetus says that we should get angry if there is someone splashing in the bathhouse, he means that we should get upset at the way things are going. He would say that getting splashed at the bathhouse was out of your control. That no matter what the splashing would have happened, because it was already set up to happen that way, and there is no other way that it coul d have happened. The point that he is trying to make is that things in life are out of our control. They happen because thereRead MoreThe Tragedy Of The 9 / 11 Attack On Our Nation1246 Words   |  5 PagesBeing a Christian we fail to understand sometimes why God allows bad things to happen to good people or bad things to happen in our life when all we are trying to do is live it the best we can. Or like that old saying goes â€Å"when it rains, it pours†. Why does evil exist in the first place if God created the world to be holy and sacred? Honestly we have all asked ourselves this question at least one in our life if not multiple times a week! This is considered a theodicy problem, and thereRead MoreThe Importance Of Happiness In Literature767 Words   |  4 Pagesto down to one thing within everyone, which is happiness. Through literature that authors provide insight, comfort, and oftentimes advice to help us cope with our humanity. In literature, it illustrates all the human conditions that we humans face. We are so fond of some literature because we can relate to the human condition even though we may not know it sometimes. Through a few literatures I am going to link the human condition, â€Å"Happiness†, and connect it to our society to see where that relativenessRead MoreFarnehiet 451 by Ray Bradbury727 Words   |  3 Pagesnew silence for thinking. You have a different perspective on the things around you. We are living in a real world where real things happen. We need to know our surroundings and know how to act according to them. The book Fahrenheit 451 happens in the future when books are aga inst the law. A fireman named Montag just so happens to undergo this situation of â€Å"waking up†. This essay will tell how he started to â€Å"wake up†, what things he needs learn, contrasts in cultures, and reflections on these contrasts

Space Exploration Essay Sample free essay sample

Space – a new frontier for the enlargement of human mind. To research the existence and convey back to earth its many admirations is an thought that has been engrained into the very nature of humanity itself. Although it seems a simple thought. to go into infinite is an tremendous enterprise. It requires a virtually illimitable budget and an ethical position that deems infinite geographic expedition admissible. To many. the geographic expedition of the last frontier would be an priceless human achievement. To many others. nevertheless. to fiddle with the landscape of the contents of the existence would be to destruct the enigma and singularity of said admirations. The subject of infinite geographic expedition is heatedly debated. The most of import things to see when developing a point of view or sentiment on the affair should include the moralss of fiddling with nature. the amount of money spent on the necessary equipment. and the overall addition for humanity – Is it truly worth it? Exploration of infinite would necessitate people to fiddle with the environment of their location. Is this ethical? One could reason that people tamper with environments on Earth to make full their desire for cognition. Why would making this in infinite be any different? One could besides reason. nevertheless. that fiddling with things is infinite is extremely unethical. These people would reason that the cliche . â€Å"Leave it better than how you found it. † should use. Space itself is infinite. but its resources are non. They are non expendable. Margaret R. McLean. writer of â€Å"To Boldly Go: Ethical Considerations for Space Exploration† . provinces that worlds are â€Å"Not†¦ proprietors of the solar system. but†¦ responsible directors of its admiration and beauty† ( Source E ) . McLean has three rules for infinite geographic expedition that trade with saving. preservation. and holding an ethical mentality ( Source E ) . These are. so. good things to see when covering with this really volatile subject. but there is another side to the argument. Some would reason that the benefits of infinite geographic expedition could immensely spread out the potency of the human race. One could safely assume that really few. if any. of these people are expecting destructing the universe’s environment. They are likely concerned with the issue of preservation. but see the happy medium between the two thoughts. There is the possible for a complete displacement in the manner humans view the universe that could be gained from encompassing what infinite has to offer. The lone manner to see those new thoughts become world is to continue infinite and encompass the admirations it has to offer – herein lies the happy medium. Space geographic expedition is expensive. In 2008. 17 billion dollars was budgeted for NASA. $ 5. 3 billion was specifically dedicated to infinite geographic expedition. This disbursal accounts for less than 2 cents out of every federal dollar spent ( Source C ) . Although this seems a reasonably ample sum. one should halt to see where it goes. This money pays for fabrication. wages. insurance companies. research. development. and many other topographic points. It flows through the American economic system merely like money spent on other authorities affiliated enterprises ( Source A ) . Space geographic expedition has benefits that extend beyond what one can larn from sing another planet. The dream of being an spaceman. a physicist. an applied scientist. a scientist. or any other dream for that affair. can be inspired by infinite geographic expedition. These dreams inspire the immature people of today to work difficult and do positive picks ( Source A ) . The idea of understanding t he existence can drive one to desire cognition more than about anything else. When cognition is sought after. it is attained. Knowledge can be put to utilize in many Fieldss and can assist many people. Puting the money into infinite geographic expedition can take to inspiration. Inspiration leads to discovery. Why non put in find. cognition. and the wellbeing of humanity as a whole? Space geographic expedition can profit humanity in many different ways and is really good deserving seting attempt into. As stated antecedently. it can animate the young person of today to work hard and woolgather large. It can besides supply new and unheard of substances. Some of the substances could perchance bring around malignant neoplastic disease or do other effectual medical specialties that society demands. New stuffs for building could be discovered doing things more efficient and lasting. One could even venture to state that our thoughts on the formation and workings of the existence. and by extension ourselves. could be drastically altered or wholly overhauled! Michael Collins in his book. â€Å"Carrying the Fire: An Astronaut’s Journeys† . he states that the political leaders of today could larn a thing or two from looking at Earth from a distance. â€Å"The bantam Earth would go on to turn. serenely disregarding its subdivisions†¦Ã¢â‚¬  ( Source G ) . Collins makes the point that boundaries would go all but meaningless and that worlds are truly non every bit important as they think that they are ( Source G ) . â€Å"I think that the position from 100. 000 stat mis could be priceless in acquiring people together to work out joint solutions. by doing them to recognize that the planet we portion unites us in a manner far more basic and far more of import than differences in skin colour or faith or economic system. † ~Michael Collins ( Source G ) Space geographic expedition requires many factors to be taken into history. One must see the moralss. cost. and overall addition of said enterprise. Space geographic expedition is an intelligibly hard subject to delegate value to sing the unattainability of immediate benefits. But. when seting the facts about infinite geographic expedition together. one cryptic truth remains – the cost is minimum. the moralss are agreeable. and the benefits are perfectly priceless.