contain

Read line containing String (Bash)

房东的猫 提交于 2019-12-04 11:08:38
I have a file, and its something like this: Device: name1 random text Device: name2 random text Device: name3 random text I have a variable: MainComputer What I want to get (for each name, i have like 40 names): MainComputer -> name1 MainComputer -> name2 MainComputer -> name3 What I have: var="MainComputer" var1=$(awk '/Device/ {print $3}' file) echo "$var -> $var1" This only gives the arrow "->" and the link for the first variable, I want them for the other 40 variables... Thanks anyway! fedorqui Let me present you awk : $ awk '/Device/ {print $2}' file name1 name2 name3 This prints the

Make a .div act like an image

谁说胖子不能爱 提交于 2019-12-02 12:19:38
问题 I have a question about the display of a container. First, I managed to simulate the attribute "object-fit: contain;" for an image by using a verticaly alligned strut and the attribute "text-align: center" (thank you IE). See it there: http://codepen.io/babybackart/pen/vGQeoK html: <body> <div class="plancheBox"> <div class="strut"></div><!-- --><img src="http://images.forwallpaper.com/files/thumbs/preview/23/236747__kitten-soft-fluffy-tender_p.jpg"> </div> </body> css: body{ height: 100%;

Search strings in list containing specific letters in random order

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 09:32:57
I am writing a code in Python 2.7 in which I have defined a list of strings. I then want to search this list's elements for a set of letters. These letters must be in random order. i.e. search the list for every single letter from input. I have been google'ing around but i haven't found a solution. Here's what i got: wordlist = ['mississippi','miss','lake','que'] letters = str(aqk) for item in wordlist: if item.find(letters) != -1: print item This is an example. Here the only output should be 'lake' and 'que' since these words contain 'a','q' and 'k'. How can I rewrite my code so that this

Search strings in list containing specific letters in random order

元气小坏坏 提交于 2019-11-27 02:58:58
问题 I am writing a code in Python 2.7 in which I have defined a list of strings. I then want to search this list's elements for a set of letters. These letters must be in random order. i.e. search the list for every single letter from input. I have been google'ing around but i haven't found a solution. Here's what i got: wordlist = ['mississippi','miss','lake','que'] letters = str(aqk) for item in wordlist: if item.find(letters) != -1: print item This is an example. Here the only output should be

Java check if two rectangles overlap at any point

不羁的心 提交于 2019-11-27 01:08:20
I have multiple rectangles and one special rectangle: the selection rect. I want to check for each rectangle if the rectangle contains at least one point which is inside the selection rectangle. Here is an image for clarity: CodeCamper This will find if the rectangle is overlapping another rectangle: public boolean overlaps (Rectangle r) { return x < r.x + r.width && x + width > r.x && y < r.y + r.height && y + height > r.y; } We can determine a rectangle with only one of its diagonal. Let's say left rectangle's diagonal is (x1, y1) to (x2, y2) And right rectangle's diagonal is (x3, y3) to (x4

Java check if two rectangles overlap at any point

感情迁移 提交于 2019-11-26 09:37:31
问题 I have multiple rectangles and one special rectangle: the selection rect. I want to check for each rectangle if the rectangle contains at least one point which is inside the selection rectangle. Here is an image for clarity: 回答1: This will find if the rectangle is overlapping another rectangle: public boolean overlaps (Rectangle r) { return x < r.x + r.width && x + width > r.x && y < r.y + r.height && y + height > r.y; } 回答2: We can determine a rectangle with only one of its diagonal. Let's