Search Results

Search found 556 results on 23 pages for 'newton falls'.

Page 5/23 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How do I get 3 lines of text from a paragraph

    - by Keltex
    I'm trying to create an "snippet" from a paragraph. I have a long paragraph of text with a word hilighted in the middle. I want to get the line containing the word before that line and the line after that line. I have the following piece of information: The text (in a string) The lines are deliminated by a NEWLINE character \n I have the index into the string of the text I want to hilight A couple other criteria: If my word falls on first line of the paragraph, it should show the 1st 3 lines If my word falls on the last line of the paragraph, it should show the last 3 lines Should show the entire paragraph in the degenative cases (the paragraph only has 1 or 2 lines) Here's an example: This is the 1st line of CAT text in the paragraph This is the 2nd line of BIRD text in the paragraph This is the 3rd line of MOUSE text in the paragraph This is the 4th line of DOG text in the paragraph This is the 5th line of RABBIT text in the paragraph Example, if my index points to BIRD, it should show lines 1, 2, & 3 as one complete string like this: This is the 1st line of CAT text in the paragraph This is the 2nd line of BIRD text in the paragraph This is the 3rd line of MOUSE text in the paragraph If my index points to DOG, it should show lines 3, 4, & 5 as one complete string like this: This is the 3rd line of MOUSE text in the paragraph This is the 4th line of DOG text in the paragraph This is the 5th line of RABBIT text in the paragraph etc. Anybody want to help tackle this?

    Read the article

  • Can I trigger PHP garbage collection to happen automatically if I have circular references?

    - by Beau Simensen
    I seem to recall a way to setup the __destruct for a class in such a way that it would ensure that circular references would be cleaned up as soon as the outside object falls out of scope. However, the simple test I built seems to indicate that this is not behaving as I had expected/hoped. Is there a way to setup my classes in such a way that PHP would clean them up correctly when the outermost object falls out of scope? I am not looking for alternate ways to write this code, I am looking for whether or not this can be done, and if so, how? I generally try to avoid these types of circular references where possible. class Bar { private $foo; public function __construct($foo) { $this->foo = $foo; } public function __destruct() { print "[destroying bar]\n"; unset($this->foo); } } class Foo { private $bar; public function __construct() { $this->bar = new Bar($this); } public function __destruct() { print "[destroying foo]\n"; unset($this->bar); } } function testGarbageCollection() { $foo = new Foo(); } for ( $i = 0; $i < 25; $i++ ) { echo memory_get_usage() . "\n"; testGarbageCollection(); } The output looks like this: 60440 61504 62036 62564 63092 63620 [ destroying foo ] [ destroying bar ] [ destroying foo ] [ destroying bar ] [ destroying foo ] [ destroying bar ] [ destroying foo ] [ destroying bar ] [ destroying foo ] [ destroying bar ] What I had hoped for: 60440 [ destorying foo ] [ destorying bar ] 60440 [ destorying foo ] [ destorying bar ] 60440 [ destorying foo ] [ destorying bar ] 60440 [ destorying foo ] [ destorying bar ] 60440 [ destorying foo ] [ destorying bar ] 60440 [ destorying foo ] [ destorying bar ]

    Read the article

  • Dragging an UIView inside UIScrollView

    - by Sergey Mikhanov
    Hello community! I am trying to solve a basic problem with drag and drop on iPhone. Here's my setup: I have a UIScrollView which has one large content subview (I'm able to scroll and zoom it) Content subview has several small tiles as subviews that should be dragged around inside it. My UIScrollView subclass has this method: - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView *tile = [contentView pointInsideTiles:[self convertPoint:point toView:contentView] withEvent:event]; if (tile) { return tile; } else { return [super hitTest:point withEvent:event]; } } Content subview has this method: - (UIView *)pointInsideTiles:(CGPoint)point withEvent:(UIEvent *)event { for (TileView *tile in tiles) { if ([tile pointInside:[self convertPoint:point toView:tile] withEvent:event]) return tile; } return nil; } And tile view has this method: - (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:self.superview]; self.center = location; } This works, but not fully correct: the tile sometimes "falls down" during the drag process. More precisely, it stops receiving touchesMoved: invocations, and scroll view starts scrolling instead. I noticed that this depends on the drag speed: the faster I drag, the quicker the tile "falls". Any ideas on how to keep the tile glued to the dragging finger? Thanks in advance!

    Read the article

  • How do I get 3 lines of text from a paragraph in C#

    - by Keltex
    I'm trying to create an "snippet" from a paragraph. I have a long paragraph of text with a word hilighted in the middle. I want to get the line containing the word before that line and the line after that line. I have the following piece of information: The text (in a string) The lines are deliminated by a NEWLINE character \n I have the index into the string of the text I want to hilight A couple other criteria: If my word falls on first line of the paragraph, it should show the 1st 3 lines If my word falls on the last line of the paragraph, it should show the last 3 lines Should show the entire paragraph in the degenative cases (the paragraph only has 1 or 2 lines) Here's an example: This is the 1st line of CAT text in the paragraph This is the 2nd line of BIRD text in the paragraph This is the 3rd line of MOUSE text in the paragraph This is the 4th line of DOG text in the paragraph This is the 5th line of RABBIT text in the paragraph Example, if my index points to BIRD, it should show lines 1, 2, & 3 as one complete string like this: This is the 1st line of CAT text in the paragraph This is the 2nd line of BIRD text in the paragraph This is the 3rd line of MOUSE text in the paragraph If my index points to DOG, it should show lines 3, 4, & 5 as one complete string like this: This is the 3rd line of MOUSE text in the paragraph This is the 4th line of DOG text in the paragraph This is the 5th line of RABBIT text in the paragraph etc. Anybody want to help tackle this?

    Read the article

  • Optimizing a bin-placement algorithm

    - by user258651
    Alright, I've got two collections, and I need to place elements from collection1 into the bins (elements) of collection2, based on whether their value falls within a given bin's range. For a concrete example, assume I have a sorted collection objects (bins) which have an int range ([1...4], [5..10], etc). I need to determine the range an int falls in, and place it in the appropriate bin. foreach(element n in collection1) { foreach(bin m in collection2) { if (m.inRange(n)) { m.add(n); break; } } } So the obvious NxM complexity algorithm is there, but I really would like to see Nxlog(M). To do this I'd like to use BinarySearch in place of the inner foreach loop. To use BinarySearch, I need to implement an IComparer class to do the searching for me. The problem I'm running into is this approach would require me to make an IComparer.Compare function that compares two different types of objects (an element to its bin), and that doesn't seem possible or correct. So I'm asking, how should I write this algorithm?

    Read the article

  • Is this feasbile with GIS?

    - by Gnu Engineer
    I'm just getting myself to familiarize with GIS but i like to know before hand if the following is feasible with current GIS apps/tools... I get the point for an address by geocoding. Easy part. Now if the point falls within a boundary (may be a city/county/state) then i need to get the data (any id/flag) associated with the boundary. Based on the id/flag i then apply some business logic. My question is... How do i define the boundary? What tools should i use for it? How can i store the boundary definition in database in order to check if the point falls within it? This has to be done in the back end and not in visual maps as we don't intend to show/use maps. How do i associate my custom data (id/flag) with the above boundary definition? Hope i'm having right assumption on capabilities of GIS. Most of examples what i see is around people trying to show maps with data which is exactly not what i'm looking for. Also please suggest me some tools/books on this.

    Read the article

  • Determine if a Range contains a value

    - by Brad Dwyer
    I'm trying to figure out a way to determine if a value falls within a Range in Swift. Basically what I'm trying to do is adapt one of the examples switch statement examples to do something like this: let point = (1, -1) switch point { case let (x, y) where (0..5).contains(x): println("(\(x), \(y)) has an x val between 0 and 5.") default: println("This point has an x val outside 0 and 5.") } As far as I can tell, there isn't any built in way to do what my imaginary .contains method above does. So I tried to extend the Range class. I ended up running into issues with generics though. I can't extend Range<Int> so I had to try to extend Range itself. The closest I got was this but it doesn't work since >= and <= aren't defined for ForwardIndex extension Range { func contains(val:ForwardIndex) -> Bool { return val >= self.startIndex && val <= self.endIndex } } How would I go about adding a .contains method to Range? Or is there a better way to determine whether a value falls within a range? Edit2: This seems to work to extend Range extension Range { func contains(val:T) -> Bool { for x in self { if(x == val) { return true } } return false } } var a = 0..5 a.contains(3) // true a.contains(6) // false a.contains(-5) // false I am very interested in the ~= operator mentioned below though; looking into that now.

    Read the article

  • c# Find value in a range using lambda

    - by n4rzul
    I'm trying to find an item in a list of values based on another value using a lambda expression using the Find method. In this example I'm expecting to get back -1000, but for the life of me, I just can't come up with the proper lamda expression. If that sounds confusing I hope the code and comments below explain it better. TIA. using System; using System.Collections.Generic; namespace TestingStuff { class Program { static void Main(string[] args) { double amount = -200; //The Range of values List<MyValue> values = new List<MyValue>(); values.Add(new MyValue(-1000)); values.Add(new MyValue(-100)); values.Add(new MyValue(-10)); values.Add(new MyValue(0)); values.Add(new MyValue(100)); values.Add(new MyValue(1000)); //Find it!!! MyValue fVal = values.Find(x => (x.Value > amount) && (x.Value < amount)); //Expecting -1000 as a result here since -200 falls between -1000 and -100 //if it were -90 I'd expect -100 since it falls between -100 and 0 if (fVal != null) Console.WriteLine(fVal.Value); Console.ReadKey(); } } public class MyValue { public double Value { get; set; } public MyValue(double value) { Value = value; } } }

    Read the article

  • Elliptical orbit modeling

    - by Nathon
    I'm playing with orbits in a simple 2-d game where a ship flies around in space and is attracted to massive things. The ship's velocity is stored in a vector and acceleration is applied to it every frame as appropriate given Newton's law of universal gravitation. The point masses don't move (there's only 1 right now) so I would expect an elliptical orbit. Instead, I see this: I've tried with nearly circular orbits, and I've tried making the masses vastly different (a factor of a million) but I always get this rotated orbit. Here's some (D) code, for context: void accelerate(Vector delta) { velocity = velocity + delta; // Velocity is a member of the ship class. } // This function is called every frame with the fixed mass. It's a // method of the ship's. void fall(Well well) { // f=(m1 * m2)/(r**2) // a=f/m // Ship mass is 1, so a = f. float mass = 1; Vector delta = well.position - loc; float rSquared = delta.magSquared; float force = well.mass/rSquared; accelerate(delta * force * mass); }

    Read the article

  • Explaining odd sound effects during BSOD

    - by bizzz
    Hello, over the years of using Microsoft operating systems, I many times encountered the situation that I only now want to understand. When you get BSOD while listening to music, there is a short period of time (1-2 sec), when screen freezes and the last part of music is repeated several times, before everything falls into blue abyss. Today I became very curious about mechanics behind this situation - what makes that certain part of audio to loop? I beg you, kind sirs, to satisfy my curiosity.

    Read the article

  • Setting a non-standard proxy

    - by Julio Guerra
    I am behind a proxy which requires users to login during the first connection with a username and password with a HTML form. Thus, it is not handled with usual http://username:[email protected] and any attempt to access the internet from this setting falls into the login form. How could I automatically login to the proxy? In linux, what manages proxy stuffs when a command tries to access the internet? Thank you.

    Read the article

  • USING a Windows 7 Restore Point

    - by Guy Thomas
    What I seek is advice, or experience of, actually USING a Windows 7 Restore Point in ANGER. I have created the restore points, can see them, and read the instructions. I also realize it won't harm my documents, but are there any pit-falls? Actually the machine is a quiet, under-used with no recent program additions, so I don't anticipate any complications, nevertheless gotchas and tips are appreciated.

    Read the article

  • MS Excel - splitting a formula into individual cells?

    - by Nick
    I'm not sure if this is possible, or if I'll have to do it manually, but I have lots of cells in the following format: =87.12+56.52-16.50+98.21-9.51 If possible, I'd like to break it up into columns, like so: I have a data in excel in the format: 87.12 | 56.52 | -16.50 | 98.21 | -9.51 I've tried text to columns based on the '+' symbol, but it falls short when I then try to break it down by the '-' symbol, it moves into columns as appropriate, it removes the minus from the start of the figure Any suggestions would be very welcome! Thank you

    Read the article

  • IF function that refers to another cell if true

    - by geoconfusion
    Can someone please help? I am using the IF function to find cells within certain ranges, but want the cell to contain the value if it falls within that specific range. for example: =IF (AA3 is between 150 and 400 then AD3 is equal to AA3 and if not leave blank) my current formula below does not work: =IF(AND(AA3150, AA3<400), AD3=AA3, "" ) where AD3 is the cell I am working in... any suggestions?

    Read the article

  • Project Dashboards

    - by EightyEight
    I'm attempting to create a dashboard so that people not intimately involved with the project can get an indication of project's health. I'm struggling with determining what to put on said dashboard. I think it needs to be brief to be useful, yet complete. The project I'm working on depends on both 3rd party contractors, external hardware and of course my team's effort. Are there any suggestions or guidelines on how to encapsulate it all in a relatively easy manner? Mods, I believe this question falls squarely between development methodologies and business concerns as outlined in the faq. Thank you!

    Read the article

  • Exadata Storage Server software upgrade is a new era in Patching

    - by Luis Moreno Campos
    Since it was first released, Exadata Storage Server software has been releasing patch releases like every software on the planet. Storage administrators would have to do this, but by some weird tradition, no matter what level of technology, if it says "Oracle" in it, IT Managers will immediately associate this with a task for the DBA. Not the case, but if it falls onto a DBA lap, fear no evil.The last patch released for Exadata Cells, is a true master piece in patching technology. This sentence is not mine, it's from both the customer and the partner that witnessed how 3 Exadata Cells where patch in less than 4 hours, after 12 months of without a single upgrade.The patch manager that takes care of everything will patch not only the software but also the firmware and the operating system. And you know it will all work out because back in the lab everything was already tested.All you have to do is stare at the 3 Sun ILOM Windows from the 3 cells and watch as they boot and reboot, patch and fix to the latest versions all layers of the storage machines. It's a new era in Patching technology!LMC

    Read the article

  • 3D Ray Casting / Picking

    - by Chris
    Hi, I am not sure if I should post this link, but I feel this falls into game development just as much as it does math. I have a ray cast's far and near values and I am trying to calculate the end point of the ray so that I can either draw a line to show the ray, or render an object at the end of 3d mouse position. Here is my post on the stack overflow math site, if there is a problem with me doing this just close the thread. Thank you. http://math.stackexchange.com/questions/15918/help-with-matrix-mathematica

    Read the article

  • How to move a sprite on a slope in chipmunk Spacemanager

    - by Anil gupta
    I have used one polygon shape image (terrain) in my game. It's just like a mountain, and now I want to move the tanker on a mountain path from one side to the other and then turn around at the edge of the screen and go back. I don't understand the method to move the tanker on the slope (image) path in chipmunk spacemanager. When collision detection happens like that, if any bomb falls on the slope (image of mountain) then I want to do a little damage to the slope (image of mountain) like this video.

    Read the article

  • SSD temperature sensor readout with hddtemp

    - by Dande Un
    It seems hddtemp cannot detect the temperature sensor of my SSD (Samsung EVO 840) properly.This is the bash output when running hddtemp: WARNUNG: Laufwerk /dev/sda scheint keinen Temperatur-Sensor zu haben. WARNUNG: Das bedeutet nicht, dass es keinen besitzt. WARNUNG: Falls Sie sicher sind, dass es einen besitzt, kontaktieren Sie mich bitte ([email protected]). WARNUNG: Siehe Optionen --help, --debug und --drivebase. /dev/sda: Samsung SSD 840 EVO 120G B ?@: kein Sensor I looked in the most recent .db file posted on http://nongnu.mirrors.hostinginnederland.nl//hddtemp/hddtemp.db, but it doesn't seem to list any SSD drives at all. Was anyone able to readout the temp-sensor of a SSD with hddtemp?

    Read the article

  • Tesla Coil Fights Combines Electricity and Choreography [Video]

    - by Jason Fitzpatrick
    We’ve seen quite a few Tesla-coil tricks over the years but never choreographed fighting between two guys balanced on Tesla coils. This definitely falls deeply into the don’t try this at home category–two guys in special suits are standing atop Tesla coils and directing the blasts of electricity at each other in a type of stylized combat. While their suits are clearly acting as Faraday cages to protect them from the electricity, we prefer our Faraday cages to be beefier and not attached directly to our skin. [via Obvious Winner] HTG Explains: Why It’s Good That Your Computer’s RAM Is Full 10 Awesome Improvements For Desktop Users in Windows 8 How To Play DVDs on Windows 8

    Read the article

  • Computer-controlled Lights and Music Synced into Christmas Rock Spectacular

    - by Jason Fitzpatrick
    This spectacular computer controlled and synchronized lighting display combines thousands of feet of LED lighting, multiple controllers, and a rock medley to great effect. The above display started life as the personal Christmas light display of Sioux Falls, ND resident Joe Noe. When Noe moved, he donated his display to a local mall in order to preserve the tradition of people stopping by to see it and making donations to the Make-A-Wish foundation. The local mall, Western Mall, expanded the display and added in even more LEDs and controllers. The end result is an impressive display synced to a Christmas rock medley by UK musician Richard Campbell. [via Mashable] Secure Yourself by Using Two-Step Verification on These 16 Web Services How to Fix a Stuck Pixel on an LCD Monitor How to Factory Reset Your Android Phone or Tablet When It Won’t Boot

    Read the article

  • Getting a sphere to roll down a .FBX object Unity3D/C#

    - by Timothy Williams
    I'm working on a little ramp and ball game in Unity, I modeled the ramp outside Unity and exported it to a .FBX file, then I imported the ramp in to Unity. I set up the ball and ramp, both have Rigidbodies, Ramp is set to isKinematic = true, yet when I play the game the ball just falls right through the ramp and hits the floor below it fine. So it's something wrong with the ramp. Am I doing something wrong? Are .FBX files unable to apply physics? Thanks, Tim.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >