Search Results

Search found 163 results on 7 pages for 'banana'.

Page 5/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • Insert text at cursor in a content editable div

    - by nijikunai
    I have a contenteditable div where I need to insert text at the caret position, This can be done in IE by document.selection.createRange().text = "banana" Is there a similar way of implementing this in Firefox/Chrome? (I know a solution exists here , but it looks sorta clumsy) Thank you!

    Read the article

  • Best way to check for string in comma-delimited list with .NET?

    - by Jeremy Stein
    I'm reading a comma-delimited list of strings from a config file. I need to check whether another string is in that list. For example: "apple,banana,cheese" If I check for "apple" I should find it, but if I check for "app" I should not. What's the most straight-forward and concise way to do this? It doesn't have to be fast. (I'll add my solution as an answer, but I'm hoping someone has something better.)

    Read the article

  • Javascript "inlet" or "offset" function for drop-list options

    - by Camran
    I have seen on several sites that drop list values can have offsets... For example this drop-list: Fruits Apple Banana Orange Colors Red White Black The above are all options, but some have "inlets" or "offsets" or whatever you want to call it. How is this done with js? (regular js, not jquery at the moment) Thanks If you need more input let me know.

    Read the article

  • Foreign keys and NULL in mySQL

    - by Industrial
    Hi everyone, Can I have a column in my values table (value) referenced as a foreign key to knownValues table, and let it be NULL whenever needed, like in the example: Table: values product type value freevalue 0 1 NULL 100 1 2 NULL 25 3 3 1 NULL Table: types id name prefix 0 length cm 1 weight kg 2 fruit NULL Table: knownValues id Type name 0 2 banana Note: The types in the table values & knownValues are of course referenced into the types table. Thanks!

    Read the article

  • Game doesn't Quit properly

    - by W.K.S
    I have an app that so far consists of two Activities: The Main Menu Activity. The Game Activity The Main Menu Activity contains a button that starts the Game Activity with the following code: public void onClick(View clickedButton) { switch(clickedButton.getId()) { case R.id.buttonPlay: Intent i = new Intent("apple.banana.BouncingBallActivity"); startActivity(i); break; } When the user is done with the Game Activity, he presses the back button. This calls the onPause() method first, which pauses the animation thread of the game. It then calls the onStop() which calls finish() on the activity altogether. The user is returned to the Main Menu activity. The code is outlined below: public class BouncingBallActivity extends Activity{ private BouncingBallView bouncingBallView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); bouncingBallView = new BouncingBallView(this); bouncingBallView.resume(); setContentView(bouncingBallView); } @Override protected void onPause() { super.onPause(); bouncingBallView.pause(); } @Override protected void onResume() { super.onResume(); bouncingBallView.resume(); } @Override protected void onStop() { super.onStop(); this.finish(); } } The problem is that this only works if I launch the application from Eclipse. When I click on the app icon, the game starts from the Game Activity. The main menu activity does not appear. I am not clear about why this happens. It could be something to do with the manifest. I've pasted the relevant portions below: <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".BouncingBallActivity" android:label="@string/app_name" android:screenOrientation="landscape" > <intent-filter> <action android:name="apple.banana.BouncingBallActivity" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".MainMenu" android:label="@string/app_name" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> I'd really appreciate any help with this. Thanks.

    Read the article

  • Can I do a "one-time" file content search in Windows Server 2008 without adding the folder to the index?

    - by G-.
    Can I search for files which contain a specific string in a folder if that folder is not in the search index? So, lets say folder 'textFiles' is not in the index. I navigate to this folder in windows explorer. I type '.ini' in the search box I want to see a result list containing only 'b.txt' FOLDER C:\textFiles\ FILE a.php CONTENT once twice thrice mice moose monkey FILE b.txt CONTENT mingle muddle middle.ini banana beer FILE c.spo CONTENT sellotape stapler phone book I do not have permission to add folders to the windows index and I do not have permission to install or run any executables that did not ship with the server or approved applications. I'd be happy with a windows native command line solution if necessary? Thanks G

    Read the article

  • Advanced (?) Excel sorting

    - by Preston Grayskull
    First of all, I'd like to admit that I don't really know anything about Excel, but I have tried to look up a solution to this in Excel books and Googling. Here's what I'm trying to do: I have a really long spreadsheet There are 7 columns total, but only two columns that I'm most interested in. Here's an example CSV that is much more simple than my actual dataset, but the search/sort is analogous: John, Apple Dave, Apple Dave, Orange Steve, Apple Steve, Orange Steve, Kiwi Bob, Apple Bob, Banana I'm interested in extracting the entire rows (all of the columns) that meet the following criteria: ["Apple"] OR ["Apple" and "Orange"] NOT ["Apple" and "Orange" and Anything Else] NOT ["Apple" and Anything that isn't Orange] So with the above CSV, I would get the entire rows for John and Dave, but not Steve and not Bob. I started doing this manually, and will likely finish by the time this question has an answer, but I would like to know this for future reference. Thanks!

    Read the article

  • replace set of integers with respective string values

    - by Tripz
    I have a query which return the output like -- 5,4,6 Where 1 = apple, 2 = mango, 3 = banana, 4 = plum, 5 = cherry, 6 = kiwi etc. I would like to update my output as cherry,plum,kiwi instead of 5,4,6 How can I achieve that in the same select statment. I am okay to hard code the values. Please confirm May be I did explain clearly Here is the sample SELECT fruits FROM t_fruitid where id = 7 is returning me '5,6,4' as a single row Now I want to update this single row output as 'cherry,plum,kiwi' How do I do this Thanku

    Read the article

  • Vim - select text highlighted by search?

    - by GorillaSandwich
    In vim, I often perform searches to hop to a word or phrase instead of navigating there with h/j/k/l. Then I hit n to hop between occurrences. Say I've got this text: Time flies like an arrow; fruit flies like a banana. - Groucho Marx I type /an arrow and hit enter. That phrase is highlighted, and I jump to it. Now I want to visually select that text, maybe to change it or delete it. (Yes, I'm aware of the :s substitution command.) Since my cursor is at the letter "a" at the beginning of "an arrow," I can hit v, then press e a couple of times to highlight the entire phrase. But I have a feeling there's a shorter and more semantic way. After all, I've already specified the text I'm interested in. How might I compose a command to say "visually select the current search selection?"

    Read the article

  • Create a term-document matrix from files

    - by Joe
    I have a set of files from example001.txt to example100.txt. Each file contains a list of keywords from a superset (the superset is available if we want it). So example001.txt might contain apple banana ... otherfruit I'd like to be able to process these files and produce something akin to a matrix so there is the list of examples* on the top row, the fruit down the side, and a '1' in a column if the fruit is in the file. An example might be... x example1 example2 example3 Apple 1 1 0 Babana 0 1 0 Coconut 0 1 1 Any idea how I might build some sort of command-line magic to put this together? I'm on OSX and happy with perl or python...

    Read the article

  • Jquery change function don’t work properly

    - by user1493448
    I have same id, name two html select. If I change first html select then it’s work properly but If I change second html select then it’s not work. Please can someone point out what I may be doing wrong here? Many thanks. Here is my code: <html> <head> <title>the title</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript" language="javascript"> $(document).ready(function() { $("#name").change(function(){ $.post( "data.php", $("#testform").serialize(), function(data) { $('#stage1').html(data); } ); var str = $("#testform").serialize(); $("#stage2").text(str); }); }); </script> </head> <body> <div id="stage1" style="background-color:blue; color: white"> STAGE - 1 </div> <form id="testform"> <table> <tr> <td><p>Fruit:</p></td> <td> <select id="name" name="name[]"> <option>Apple</option> <option>Mango</option> <option>Orange</option> <option>Banana</option> </select> </td> </tr> <tr> <td><p>Fruit:</p></td> <td> <select id="name" name="name[]"> <option>Apple</option> <option>Mango</option> <option>Orange</option> <option>Banana</option> </select> </td> </tr> </table> </form> </body> </html> Php code: <?php $fruit=$_REQUEST["name"]; $n = count($fruit); for($i=0;$i<$n; $i++) { echo $fruit[$i]."<br/>"; } ?>

    Read the article

  • Remove box2d bodies after collision deduction android?

    - by jubin
    Can any one explain me how to destroy box2d body when collide i have tried but my application crashed.First i have checked al collisions then add all the bodies in array who i want to destroy.I am trying to learning this tutorial My all the bodies are falling i want these bodies should destroy when these bodies will collide my actor monkey but when it collide it destroy but my aplication crashed.I have googled and from google i got the application crash reasons we should not destroy body in step funtion but i am removing body in the last of tick method. could any one help me or provide me code aur check my code why i am getting this prblem or how can i destroy box2d bodies. This is my code what i am doing. Please could any one check my code and tell me what is i am doing wrong for removing bodies. The code is for multiple box2d objects falling on my actor monkey it should be destroy when it will fall on the monkey.It is destroing but my application crahes. static class Box2DLayer extends CCLayer { protected static final float PTM_RATIO = 32.0f; protected static final float WALK_FACTOR = 3.0f; protected static final float MAX_WALK_IMPULSE = 0.2f; protected static final float ANIM_SPEED = 0.3f; int isLeft=0; String dir=""; int x =0; float direction; CCColorLayer objectHint; // protected static final float PTM_RATIO = 32.0f; protected World _world; protected static Body spriteBody; CGSize winSize = CCDirector.sharedDirector().winSize(); private static int count = 200; protected static Body monkey_body; private static Body bodies; CCSprite monkey; float animDelay; int animPhase; CCSpriteSheet danceSheet = CCSpriteSheet.spriteSheet("phases.png"); CCSprite _block; List<Body> toDestroy = new ArrayList<Body>(); //CCSpriteSheet _spriteSheet; private static MyContactListener _contactListener = new MyContactListener(); public Box2DLayer() { this.setIsAccelerometerEnabled(true); CCSprite bg = CCSprite.sprite("jungle.png"); addChild(bg,0); bg.setAnchorPoint(0,0); bg.setPosition(0,0); CGSize s = CCDirector.sharedDirector().winSize(); // Use scaled width and height so that our boundaries always match the current screen float scaledWidth = s.width/PTM_RATIO; float scaledHeight = s.height/PTM_RATIO; Vector2 gravity = new Vector2(0.0f, -30.0f); boolean doSleep = false; _world = new World(gravity, doSleep); // Create edges around the entire screen // Define the ground body. BodyDef bxGroundBodyDef = new BodyDef(); bxGroundBodyDef.position.set(0.0f, 0.0f); // The body is also added to the world. Body groundBody = _world.createBody(bxGroundBodyDef); // Register our contact listener // Define the ground box shape. PolygonShape groundBox = new PolygonShape(); Vector2 bottomLeft = new Vector2(0f,0f); Vector2 topLeft = new Vector2(0f,scaledHeight); Vector2 topRight = new Vector2(scaledWidth,scaledHeight); Vector2 bottomRight = new Vector2(scaledWidth,0f); // bottom groundBox.setAsEdge(bottomLeft, bottomRight); groundBody.createFixture(groundBox,0); // top groundBox.setAsEdge(topLeft, topRight); groundBody.createFixture(groundBox,0); // left groundBox.setAsEdge(topLeft, bottomLeft); groundBody.createFixture(groundBox,0); // right groundBox.setAsEdge(topRight, bottomRight); groundBody.createFixture(groundBox,0); CCSprite floorbg = CCSprite.sprite("grassbehind.png"); addChild(floorbg,1); floorbg.setAnchorPoint(0,0); floorbg.setPosition(0,0); CCSprite floorfront = CCSprite.sprite("grassfront.png"); floorfront.setTag(2); this.addBoxBodyForSprite(floorfront); addChild(floorfront,3); floorfront.setAnchorPoint(0,0); floorfront.setPosition(0,0); addChild(danceSheet); //CCSprite monkey = CCSprite.sprite(danceSheet, CGRect.make(0, 0, 48, 73)); //addChild(danceSprite); monkey = CCSprite.sprite("arms_up.png"); monkey.setTag(2); monkey.setPosition(200,100); BodyDef spriteBodyDef = new BodyDef(); spriteBodyDef.type = BodyType.DynamicBody; spriteBodyDef.bullet=true; spriteBodyDef.position.set(200 / PTM_RATIO, 300 / PTM_RATIO); monkey_body = _world.createBody(spriteBodyDef); monkey_body.setUserData(monkey); PolygonShape spriteShape = new PolygonShape(); spriteShape.setAsBox(monkey.getContentSize().width/PTM_RATIO/2, monkey.getContentSize().height/PTM_RATIO/2); FixtureDef spriteShapeDef = new FixtureDef(); spriteShapeDef.shape = spriteShape; spriteShapeDef.density = 2.0f; spriteShapeDef.friction = 0.70f; spriteShapeDef.restitution = 0.0f; monkey_body.createFixture(spriteShapeDef); //Vector2 force = new Vector2(10, 10); //monkey_body.applyLinearImpulse(force, spriteBodyDef.position); addChild(monkey,10000); this.schedule(tickCallback); this.schedule(createobjects, 2.0f); objectHint = CCColorLayer.node(ccColor4B.ccc4(255,0,0,128), 200f, 100f); addChild(objectHint, 15000); objectHint.setVisible(false); _world.setContactListener(_contactListener); } private UpdateCallback tickCallback = new UpdateCallback() { public void update(float d) { tick(d); } }; private UpdateCallback createobjects = new UpdateCallback() { public void update(float d) { secondUpdate(d); } }; private void secondUpdate(float dt) { this.addNewSprite(); } public void addBoxBodyForSprite(CCSprite sprite) { BodyDef spriteBodyDef = new BodyDef(); spriteBodyDef.type = BodyType.StaticBody; //spriteBodyDef.bullet=true; spriteBodyDef.position.set(sprite.getPosition().x / PTM_RATIO, sprite.getPosition().y / PTM_RATIO); spriteBody = _world.createBody(spriteBodyDef); spriteBody.setUserData(sprite); Vector2 verts[] = { new Vector2(-11.8f / PTM_RATIO, -24.5f / PTM_RATIO), new Vector2(11.7f / PTM_RATIO, -24.0f / PTM_RATIO), new Vector2(29.2f / PTM_RATIO, -14.0f / PTM_RATIO), new Vector2(28.7f / PTM_RATIO, -0.7f / PTM_RATIO), new Vector2(8.0f / PTM_RATIO, 18.2f / PTM_RATIO), new Vector2(-29.0f / PTM_RATIO, 18.7f / PTM_RATIO), new Vector2(-26.3f / PTM_RATIO, -12.2f / PTM_RATIO) }; PolygonShape spriteShape = new PolygonShape(); spriteShape.set(verts); //spriteShape.setAsBox(sprite.getContentSize().width/PTM_RATIO/2, //sprite.getContentSize().height/PTM_RATIO/2); FixtureDef spriteShapeDef = new FixtureDef(); spriteShapeDef.shape = spriteShape; spriteShapeDef.density = 2.0f; spriteShapeDef.friction = 0.70f; spriteShapeDef.restitution = 0.0f; spriteShapeDef.isSensor=true; spriteBody.createFixture(spriteShapeDef); } public void addNewSprite() { count=0; Random rand = new Random(); int Number = rand.nextInt(10); switch(Number) { case 0: _block = CCSprite.sprite("banana.png"); break; case 1: _block = CCSprite.sprite("backpack.png");break; case 2: _block = CCSprite.sprite("statue.png");break; case 3: _block = CCSprite.sprite("pineapple.png");break; case 4: _block = CCSprite.sprite("bananabunch.png");break; case 5: _block = CCSprite.sprite("hat.png");break; case 6: _block = CCSprite.sprite("canteen.png");break; case 7: _block = CCSprite.sprite("banana.png");break; case 8: _block = CCSprite.sprite("statue.png");break; case 9: _block = CCSprite.sprite("hat.png");break; } int padding=20; //_block.setPosition(CGPoint.make(100, 100)); // Determine where to spawn the target along the Y axis CGSize winSize = CCDirector.sharedDirector().displaySize(); int minY = (int)(_block.getContentSize().width / 2.0f); int maxY = (int)(winSize.width - _block.getContentSize().width / 2.0f); int rangeY = maxY - minY; int actualY = rand.nextInt(rangeY) + minY; // Create block and add it to the layer float xOffset = padding+_block.getContentSize().width/2+((_block.getContentSize().width+padding)*count); _block.setPosition(CGPoint.make(actualY, 750)); _block.setTag(1); float w = _block.getContentSize().width; objectHint.setVisible(true); objectHint.changeWidth(w); objectHint.setPosition(actualY-w/2, 460); this.addChild(_block,10000); // Create ball body and shape BodyDef ballBodyDef1 = new BodyDef(); ballBodyDef1.type = BodyType.DynamicBody; ballBodyDef1.position.set(actualY/PTM_RATIO, 480/PTM_RATIO); bodies = _world.createBody(ballBodyDef1); bodies.setUserData(_block); PolygonShape circle1 = new PolygonShape(); Vector2 verts[] = { new Vector2(-11.8f / PTM_RATIO, -24.5f / PTM_RATIO), new Vector2(11.7f / PTM_RATIO, -24.0f / PTM_RATIO), new Vector2(29.2f / PTM_RATIO, -14.0f / PTM_RATIO), new Vector2(28.7f / PTM_RATIO, -0.7f / PTM_RATIO), new Vector2(8.0f / PTM_RATIO, 18.2f / PTM_RATIO), new Vector2(-29.0f / PTM_RATIO, 18.7f / PTM_RATIO), new Vector2(-26.3f / PTM_RATIO, -12.2f / PTM_RATIO) }; circle1.set(verts); FixtureDef ballShapeDef1 = new FixtureDef(); ballShapeDef1.shape = circle1; ballShapeDef1.density = 10.0f; ballShapeDef1.friction = 0.0f; ballShapeDef1.restitution = 0.1f; bodies.createFixture(ballShapeDef1); count++; //Remove(); } @Override public void ccAccelerometerChanged(float accelX, float accelY, float accelZ) { //Apply the directional impulse /*float impulse = monkey_body.getMass()*accelY*WALK_FACTOR; Vector2 force = new Vector2(impulse, 0); monkey_body.applyLinearImpulse(force, monkey_body.getWorldCenter());*/ walk(accelY); //Remove(); } private void walk(float accelY) { // TODO Auto-generated method stub direction = accelY; } private void Remove() { for (Iterator<MyContact> it1 = _contactListener.mContacts.iterator(); it1.hasNext();) { MyContact contact = it1.next(); Body bodyA = contact.fixtureA.getBody(); Body bodyB = contact.fixtureB.getBody(); // See if there's any user data attached to the Box2D body // There should be, since we set it in addBoxBodyForSprite if (bodyA.getUserData() != null && bodyB.getUserData() != null) { CCSprite spriteA = (CCSprite) bodyA.getUserData(); CCSprite spriteB = (CCSprite) bodyB.getUserData(); // Is sprite A a cat and sprite B a car? If so, push the cat // on a list to be destroyed... if (spriteA.getTag() == 1 && spriteB.getTag() == 2) { //Log.v("dsfds", "dsfsd"+bodyA); //_world.destroyBody(bodyA); // removeChild(spriteA, true); toDestroy.add(bodyA); } // Is sprite A a car and sprite B a cat? If so, push the cat // on a list to be destroyed... else if (spriteA.getTag() == 2 && spriteB.getTag() == 1) { //Log.v("dsfds", "dsfsd"+bodyB); toDestroy.add(bodyB); } } } // Loop through all of the box2d bodies we want to destroy... for (Iterator<Body> it1 = toDestroy.iterator(); it1.hasNext();) { Body body = it1.next(); // See if there's any user data attached to the Box2D body // There should be, since we set it in addBoxBodyForSprite if (body.getUserData() != null) { // We know that the user data is a sprite since we set // it that way, so cast it... CCSprite sprite = (CCSprite) body.getUserData(); // Remove the sprite from the scene _world.destroyBody(body); removeChild(sprite, true); } // Destroy the Box2D body as well // _contactListener.mContacts.remove(0); } } public synchronized void tick(float delta) { synchronized (_world) { _world.step(delta, 8, 3); //_world.clearForces(); //addNewSprite(); } CCAnimation danceAnimation = CCAnimation.animation("dance", 1.0f); // Iterate over the bodies in the physics world Iterator<Body> it = _world.getBodies(); while(it.hasNext()) { Body b = it.next(); Object userData = b.getUserData(); if (userData != null && userData instanceof CCSprite) { //Synchronize the Sprites position and rotation with the corresponding body CCSprite sprite = (CCSprite)userData; if(sprite.getTag()==1) { //b.applyLinearImpulse(force, pos); sprite.setPosition(b.getPosition().x * PTM_RATIO, b.getPosition().y * PTM_RATIO); sprite.setRotation(-1.0f * ccMacros.CC_RADIANS_TO_DEGREES(b.getAngle())); } else { //Apply the directional impulse float impulse = monkey_body.getMass()*direction*WALK_FACTOR; Vector2 force = new Vector2(impulse, 0); b.applyLinearImpulse(force, b.getWorldCenter()); sprite.setPosition(b.getPosition().x * PTM_RATIO, b.getPosition().y * PTM_RATIO); animDelay -= 1.0f/60.0f; if(animDelay <= 0) { animDelay = ANIM_SPEED; animPhase++; if(animPhase > 2) { animPhase = 1; } } if(direction < 0 ) { isLeft=1; } else { isLeft=0; } if(isLeft==1) { dir = "left"; } else { dir = "right"; } float standingLimit = (float) 0.1f; float vX = monkey_body.getLinearVelocity().x; if((vX > -standingLimit)&& (vX < standingLimit)) { // Log.v("sasd", "standing"); } else { } } } } Remove(); } } Sorry for my english. Thanks in advance.

    Read the article

  • List<> capacity has more items than added.

    - by Pete
    List <string> ali = new List<string>(); ali.Clear(); ali.Add("apple"); ali.Add("orange"); ali.Add("banana"); ali.Add("cherry"); ali.Add("mango"); ali.Add("plum"); ali.Add("jackfruit"); Console.WriteLine("the List has {0} items in it.",ali.Capacity.ToString()); when I run this the Console displays: the List has 8 items in it. I don't understand why its showing a capacity of 8, when I only added 7 items.

    Read the article

  • Fetched Property in XCode Data Model Editor for minimum value

    - by wal
    How do I add a Fetched Property in XCode's Data Model Editor for minimum value of one attribute?? My model: Item (name, note, storedItem) StoredItem (price, item) Item 1 ---> N StoredITem (1->N Relationship) I want that Item has a fetched property named minPrice and its value is the minimum value setted for price in the storedItems. Example: Item1 (banana, storedItem1 ... storedItem4, 10) StoredItem1 (10,item1) StoredItem2 (15,item1) StoredItem3 (30,item1) StoredItem4 (54,item1) What do I put in Destination?? StoredItem? And what do I put in Expression??

    Read the article

  • Can nusoap returns arrray of string ?

    - by Tim
    Hi all, I would like to return an array of string in my web services I've tryed : <?php require_once('nusoap/nusoap.php'); $server = new soap_server(); $server->configureWSDL('NewsService', 'urn:NewsService'); $server->register('GetAllNews', array(), array('return' => 'xsd:string[]'), 'urn:NewsService', 'urn:NewsService#GetAllNews', 'rpc', 'literal', '' ); // Define the method as a PHP function function GetAllNews() { $stack = array("orange", "banana"); array_push($stack, "apple", "raspberry"); return $stack; } but it doesn't work. What is the correct syntax for that ? Thanks in advance for any help

    Read the article

  • Can nusoap return array of string ?

    - by Tim
    Hi all, I would like to return an array of string in my web services I've tryed : <?php require_once('nusoap/nusoap.php'); $server = new soap_server(); $server->configureWSDL('NewsService', 'urn:NewsService'); $server->register('GetAllNews', array(), array('return' => 'xsd:string[]'), 'urn:NewsService', 'urn:NewsService#GetAllNews', 'rpc', 'literal', '' ); // Define the method as a PHP function function GetAllNews() { $stack = array("orange", "banana"); array_push($stack, "apple", "raspberry"); return $stack; } but it doesn't work. What is the correct syntax for that ? Thanks in advance for any help

    Read the article

  • Using a dynamic number of checkboxes in a rails form

    - by TenJack
    I am trying to create a form with a dynamic number of checkboxes that each link to a string that is not a model number but is instead just a word. For examples: <% form_for(@words) do |f| %> <% ["apple","banana","orange"].each do |word| %> <%= f.check_box :word %> <%= f.submit %> <% end %> <% end %> So, if "apple" was checked, it would just send the string "apple" in the params. Anyone know how to do this?

    Read the article

  • filtering for multiple values on one column. All values must exist, else - return zero

    - by Andrew
    Hello All, I would like to filter one column in a table for couple values and show results only if all those values are there. If one or more is missing, then return zero results. example table +----+--------+----------+ | id | Fruit | Color | +----+--------+----------+ | 1 | apple | red | | 2 | mango | yellow | | 3 | banana | yellow | +----+--------+----------+ example "wrong" code: (this must return 3 rows) select Fruit FROM table WHERE Color = red AND Color = yellow but select Fruit FROM table WHERE Color = red AND Color = green must return 0 rows. (If i use select Fruit FROM table WHERE Color = red OR Color = green i get 1 row which is not what i need) I am using PHP with form where user checks different checkboxes that represent different values of the same column. So when he selects multiple checkboxes, all those values should be in the result set, otherwise no result should be given. Thank you, Andrew

    Read the article

  • A simple explanation of Naive Bayes Classification

    - by Jaggerjack
    I am finding it hard to understand the process of Naive Bayes, and I was wondering if someone could explained it with a simple step by step process in English. I understand it takes comparisons by times occurred as a probability, but I have no idea how the training data is related to the actual dataset. Please give me an explanation of what role the training set plays. I am giving a very simple example for fruits here, like banana for example training set--- round-red round-orange oblong-yellow round-red dataset---- round-red round-orange round-red round-orange oblong-yellow round-red round-orange oblong-yellow oblong-yellow round-red

    Read the article

  • How to implement filter system in SQL?

    - by sadvaw
    Right now I am planning to add a filter system to my site. Examples: (ID=apple, COLOR=red, TASTE=sweet, ORIGIN=US) (ID=mango, COLOR=yellow, TASTE=sweet, ORIGIN=MEXICO) (ID=banana, COLOR=yellow, TASTE=bitter-sweet, ORIGIN=US) so now I am interested in doing the following: SELECT ID FROM thisTable WHERE COLOR='yellow' AND TASTE='SWEET' But my problem is I am doing this for multiple categories in my site, and the columns are NOT consistent. (like if the table is for handphones, then it will be BRAND, 3G-ENABLED, PRICE, COLOR, WAVELENGTH, etc) how could I design a general schema that allows this? Right now I am planning on doing: table(ID, KEY, VALUE) This allows arbitary number of columns, but for the query, I am using SELECT ID FROM table WHERE (KEY=X1 AND VALUE=V1) AND (KEY=X2 AND VALUE=V2), .. which returns an empty set. Can someone recommend a good solution to this? Note that the number of columns WILL change regularly

    Read the article

  • Own data format for the iPhone

    - by Stefan
    Hi, I would like to create my own data format for an iPhone app. The files should be similar structured as e.g. Apple's iWork files (.pages). That means, I have a folder with some files in it: The file 'Juicy.fruit' contains: Fruits ---> Apple.xml ---> Banana.xml ---> Pear.xml ---> PreviewPicture.png This folder "Fruits" should be packed in a handy file 'Juicy.fruit'. Compression isn't necessary. How could I achieve this? I've discovered some open source ZIP-libraries. However, I would like to to build my own data format with the iPhones built-in libs (if possible). Best regards, Stefan

    Read the article

  • Can I suppress newlines with Django's template engine?

    - by ento
    In Rails ERB, you can suppress newlines by adding a trailing hyphen to tags: <ul> <% for @item in @items -%> <li><%= @item %></li> <% end -%> </ul> becomes: <ul> <li>apple</li> <li>banana</li> <li>cacao</li> </ul> Is there a way to do this in Django? (Disclosure: I'm generating a csv file with Django)

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >