Search Results

Search found 1132 results on 46 pages for 'teh noob'.

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

  • Noob - Cycle through stored names and skip blanks

    - by ActiveJimBob
    NOOB trying to make my code more efficient. On scroll button push, the function 'SetName' stores a number to integer 'iName' which is index against 5 names stored in memory. If a name is not set in memeory, it skips to the next. The code works, but takes up a lot of room. Any advice appreciated. Code: #include <string.h> int iName = 0; int iNewName = 0; BYTE GetName () { return iName; } void SetName (int iNewName) { while (iName != iNewName) { switch (byNewName) { case 1: if (strlen (memory.m_nameA) == 0) new_name++; else iName = iNewName; break; case 2: if (strlen (memory.m_nameB) == 0) new_name++; else iName = iNewName; break; case 3: if (strlen (memory.m_nameC) == 0) new_name++; else iName = iNewName; break; case 4: if (strlen (memory.m_nameD) == 0) new_name++; else iName = iNewName; break; case 5: if (strlen (memory.m_nameE) == 0) new_name++; else iName = iNewName; break; default: iNewName = 1; break; } // end of case } // end of loop } // end of SetName function void main () { while(1) { if (Button_pushed) SetName(GetName+1); } // end of infinite loop } // end of main

    Read the article

  • iPhone noob - setting NSMutableDictionary entry inside Singleton?

    - by codemonkey
    Yet another iPhone/Objective-C noob question. I'm using a singleton to store app state information. I'm including the singleton in a Utilities class that holds it (and eventually other stuff). This utilities class is in turn included and used from various view controllers, etc. The utilities class is set up like this: // Utilities.h #import <Foundation/Foundation.h> @interface Utilities : NSObject { } + (id)GetAppState; - (id)GetAppDelegate; @end // Utilities.m #import "Utilities.h" #import "CHAPPAppDelegate.h" #import "AppState.h" @implementation Utilities CHAPPAppDelegate* GetAppDelegate() { return (CHAPPAppDelegate *)[UIApplication sharedApplication].delegate; } AppState* GetAppState() { return [GetAppDelegate() appState]; } @end ... and the AppState singleton looks like this: // AppState.h #import <Foundation/Foundation.h> @interface AppState : NSObject { NSMutableDictionary *challenge; NSString *challengeID; } @property (nonatomic, retain) NSMutableDictionary *challenge; @property (nonatomic, retain) NSString *challengeID; + (id)appState; @end // AppState.m #import "AppState.h" static AppState *neoAppState = nil; @implementation AppState @synthesize challengeID; @synthesize challenge; # pragma mark Singleton methods + (id)appState { @synchronized(self) { if (neoAppState == nil) [[self alloc] init]; } return neoAppState; } + (id)allocWithZone:(NSZone *)zone { @synchronized(self) { if (neoAppState == nil) { neoAppState = [super allocWithZone:zone]; return neoAppState; } } return nil; } - (id)copyWithZone:(NSZone *)zone { return self; } - (id)retain { return self; } - (unsigned)retainCount { return UINT_MAX; //denotes an object that cannot be released } - (void)release { // never release } - (id)init { if (self = [super init]) { challengeID = [[NSString alloc] initWithString:@"0"]; challenge = [NSMutableDictionary dictionary]; } return self; } - (void)dealloc { // should never be called, but just here for clarity [super dealloc]; } @end ... then, from a view controller I'm able to set the singleton's "challengeID" property like this: [GetAppState() setValue:@"wassup" forKey:@"challengeID"]; ... but when I try to set one of the "challenge" dictionary entry values like this: [[GetAppState() challenge] setObject:@"wassup" forKey:@"wassup"]; ... it fails giving me an "unrecognized selector sent..." error. I'm probably doing something really obviously dumb? Any insights/suggestions will be appreciated.

    Read the article

  • Noob Objective-C/C++ - Linker Problem/Method Signature Problem

    - by Josh
    There is a static class Pipe, defined in C++ header that I'm including. The static method I'm interested in calling (from Objetive-c) is here: static ERC SendUserGet(const UserId &_idUser,const GUID &_idStyle,const ZoneId &_idZone,const char *_pszMsg); I have access to an objetive-c data structure that appears to store a copy of userID, and zoneID -- it looks like: @interface DataBlock : NSObject { GUID userID; GUID zoneID; } Looked up the GUID def, and its a struct with a bunch of overloaded operators for equality. UserId and ZoneId from the first function signature are #typedef GUID Now when I try to call the method, no matter how I cast it (const UserId), (UserId), etc, I get the following linker error: Ld build/Debug/Seeker.app/Contents/MacOS/Seeker normal i386 cd /Users/josh/Development/project/Mac/Seeker setenv MACOSX_DEPLOYMENT_TARGET 10.5 /Developer/usr/bin/g++-4.2 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -L/Users/josh/Development/TS/Mac/Seeker/build/Debug -L/Users/josh/Development/TS/Mac/Seeker/../../../debug -L/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1 -F/Users/josh/Development/TS/Mac/Seeker/build/Debug -filelist /Users/josh/Development/TS/Mac/Seeker/build/Seeker.build/Debug/Seeker.build/Objects-normal/i386/Seeker.LinkFileList -mmacosx-version-min=10.5 -framework Cocoa -framework WebKit -lSAPI -lSPL -o /Users/josh/Development/TS/Mac/Seeker/build/Debug/Seeker.app/Contents/MacOS/Seeker Undefined symbols: "SocPipe::SendUserGet(_GUID const&, _GUID const&, _GUID const&, char const*)", referenced from: -[PeoplePaneController clickGet:] in PeoplePaneController.o ld: symbol(s) not found collect2: ld returned 1 exit status Is this a type/function signature error, or truly some sort of linker error? I have the headers where all these types and static classes are defined #imported -- I tried #include too, just in case, since I'm already stumbling :P Forgive me, I come from a web tech background, so this c-style memory management and immutability stuff is super hazy. Edit: Added full linker error text. Changed "function" to "method" Thanks, Josh

    Read the article

  • Noob Objective-C/C++ - Linker Problem/Function Def Problem

    - by Josh
    There is a static class Pipe, defined in C++ header that I'm including. The function I'm interested in calling (from Objetive-c) is here: static ERC SendUserGet(const UserId &_idUser,const GUID &_idStyle,const ZoneId &_idZone,const char *_pszMsg); I have access to an objetive-c data structure that appears to store a copy of userID, and zoneID -- it looks like: @interface DataBlock : NSObject { GUID userID; GUID zoneID; } Looked up the GUID def, and its a struct with a bunch of overloaded operators for equality. UserId and ZoneId from the first function signature are #typedef GUID Now when I try to call the function, no matter how I cast it (const UserId), (UserId), etc, I get the following linker error: "Pipe::SendUserGet(_GUID const&, _GUID const&, _GUID const&, char const*)", referenced from: -[PeoplePaneController clickGet:] in PeoplePaneController.o Is this a type/function signature error, or truly some sort of linker error? I have the headers where all these types and static classes are defined #imported -- I tried #include too, just in case, since I'm already stumbling :P Forgive me, I come from a web tech background, so this c-style memory management and immutability stuff is super hazy. Thanks, Josh

    Read the article

  • Javascript Noob Question. Need Help With Simple Script

    - by three3
    Hi everyone, I am new to JavaScript (only a couple of days of reading a book) and I am stuck on this code snippet. I have looked at it over and over again but cannot seem to figure out why it is not working. I am sure it is something really simple that I have just looked over but I really just need a fresh pair of eyes to look at this. The code is supposed to update a placeholder image on a page without the page having to reload. But when I am clicking on the link of an image, it is taking me to the link where the image is located instead of replacing the placeholder image. Here is my HTML code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Image Gallery</title> <script type="text/javascript" src="scripts/showPic.js"></script> </head> <body> <h1>Snapshots</h1> <ul> <li> <a href="images/cat.jpg" onclick="showPic(this); return false;" title="A Cat">Cat</a> </li> <li> <a href="images/night.jpg" onclick="showPic(this); return false;" title="Night">Night</a> </li> <li> <a href="images/coke.jpg" onclick="showPic(this); return false;" title="Coke">Coke</a> </li> <li> <a href="images/sport.jpg" onclick="showPic(this); return false;" title="Sports">Sport</a> </li> <li> <a href="images/mnms.png" onclick="showPic(this); return false;" title="MnM's">MnM's</a> </li> <li> <a href="images/kid.jpg" onclick="showPic(this); return false;" title="A Kid">Kid</a> </li> </ul> <br /> <img id="placeholder" src="images/placeholder.jpg" alt="Place Holder Image" /> </body> </html> And here is the JavaScript function I am using to get this done: <script type="text/javascript"> function showPic(whichpic) { var source = whichpic.getAttribute("href"); var placeholder = document.getElementById("placeholder"); placeholder.setAttribute("src",source); } </script> Any help is greatly appreciated and thanks in advance for the help.

    Read the article

  • Javascript Noob: How to emulate slideshow on front page by automatically cycling through existing ho

    - by Zildjoms
    hey everyone. hope you could help me out am working on this website and i've finished all the hover effects i like - they're exactly how i want them to be: http://s5ent.brinkster.net/beta3.asp - try hovering over the four links and you'll see a very simple fade effect at work, which degrades into a regular css hover without javascript. what i plan to do is to make the page look like it had a fancy slideshow going on upon loading and while idle, and i wanted to achieve that by capitalizing on the existing hover styling/behavior of the main page links instead of using another script to create the effect from scratch. to do this i imagined i'll need a script that emulates a hover action on each link at regular time intervals once the page has loaded, starting from left to right (footcare, lawn & equipment, about us, contact us), looping through all 4 links indefinitely (footcare, lawn & equipment, about us, contact us, footcare, lawn& equipment, etc.) but pauses when any of them have been actually hovered over by a viewer and resumes from wherever the user left off upon mouseout. hope you get my drift... i also want to achieve this without unnecessarily disrupting the current html. so i guess everything will have to be done by scripting as much as possible.. i'm very new to javascript and jquery. as you can see at s5ent.brinkster.net/beta3.1-autohover.asp, the following script i made works wrong: it hovers-on all of them at the same time and doesn't hover-out anymore. when you try to actually hover into and out of each link the link just comes back on: <script type="text/javascript"> $(document).ready(function () { var speed = 5000; var run = setInterval('rotate()', speed); }); function rotate() { $('.lilevel1 a').each(function(i) { $(this).mouseover(); }); } </script> it's just gross. aside from the fact that this last bit of script isn't even working in ie. could you please help me make this thing happen? that'd be really sweet, guys. i know there are tonsa geniuses out there who could whip this up in no time. or if you have a better way to go about it by all means kindly lemme know. thanks guys, hope you're all havin a blast.

    Read the article

  • Noob-Ready Cython Tutorials

    - by spearfire
    I know a bunch of scripting languages, (python, ruby, lua, php) but I don't know any compiled languages like C/C++ , I wanted to try and speed up some python code using cython, which is essentially a python - C compiler, aimed at creating C extensions for python. Basically you code in a stricter version of python which compiles into C - native code. here's the problem, I don't know C, yet the cython documentation is aimed at people who obviously already know C (nothing is explained, only presented), and is of no help to me, I need to know if there are any good cython tutorials aimed at python programmers, or if I'm gonna have to learn C before I learn Cython. bear in mind I'm a competent python programmer, i would much rather learn cython from the perspective of the language I'm already good at, rather than learn a whole new language in order to learn cython. 1) PLEASE don't recommend psyco edit: ANY information that will help understand the oficial cython docs is useful information

    Read the article

  • Need Help With This Simple Script (JavaScript Noob Question)

    - by three3
    Hi everyone, I am new to JavaScript (only a couple of days of reading a book) and I am stuck on this code snippet. I have looked at it over and over again but cannot seem to figure out why it is not working. I am sure it is something really simple that I have just looked over but I really just need a fresh pair of eyes to look at this. The code is supposed to update a placeholder image on a page without the page having to reload. But when I am clicking on the link of an image, it is taking me to the link where the image is located instead of replacing the placeholder image. Here is my HTML code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Image Gallery</title> <script type="text/javascript" src="scripts/showPic.js"></script> </head> <body> <h1>Snapshots</h1> <ul> <li> <a href="images/cat.jpg" onclick="showPic(this); return false;" title="A Cat">Cat</a> </li> <li> <a href="images/night.jpg" onclick="showPic(this); return false;" title="Night">Night</a> </li> <li> <a href="images/coke.jpg" onclick="showPic(this); return false;" title="Coke">Coke</a> </li> <li> <a href="images/sport.jpg" onclick="showPic(this); return false;" title="Sports">Sport</a> </li> <li> <a href="images/mnms.png" onclick="showPic(this); return false;" title="MnM's">MnM's</a> </li> <li> <a href="images/kid.jpg" onclick="showPic(this); return false;" title="A Kid">Kid</a> </li> </ul> <br /> <img src="images/placeholder.jpg" title="Place Holder Image"> </body> </html> And here is the JavaScript function I am using to get this done: <script type="text/javascript"> function showPic(whichpic) { var source = whichpic.getAttribute("href"); var placeholder = document.getElementById("placeholder"); placeholder.setAttribute("src",source); } </script> Any help is greatly appreciated and thanks in advance for the help.

    Read the article

  • Html / Email / Distribution list problem from a noob

    - by Hezeus
    I need to create a feature for a website that will allow a user to enter their email in order to receive a free promotion (which will be emailed immediately) and be added to an announcement list. I haven't done any web programming and am wondering where I should start? Should I just create a database and everytime an email is entered, add the email to the database, then when I want to send out an announcement just write a script that will send an email to every address? Thanks!

    Read the article

  • NOOB Memory Problem - EXC_BAD_ACCESS (OBJ-C/iPhone)

    - by Michael Bordelon
    I have been banging my head against the wall for a couple days and need some help. I have a feeling that I am doing something really silly here, but I cannot find the issue. This is the controller for a table view. I put the SQL in line to simplify it as part of the troubleshooting of this error. Normally, it would be in an accessor method in a model class. It gets through the SQL read just fine. Finds the two objects, loads them into the todaysWorkout array and then builds the cells for the table view. The table view actually comes up on the scree and then it throws the EXC_BAD_ACCESS. I ran instruments and it shows the following: 0 CFString Malloc 1 00:03.765 0x3946470 176 Foundation -[NSPlaceholderString initWithFormat:locale:arguments:] 1 CFString Autorelease 00:03.765 0x3946470 0 Foundation NSRecordAllocationEvent 2 CFString CFRelease 0 00:03.767 0x3946470 0 Bring It -[WorkoutViewController viewDidLoad] 3 CFString Zombie -1 00:03.917 0x3946470 0 Foundation NSPopAutoreleasePool Here is the source code for the controller. I left it all in there just in case there is something extraneous causing the problem. I sincerely appreciate any help I can get: HEADER: #import <UIKit/UIKit.h> #import <sqlite3.h> #import "NoteCell.h" #import "BIUtility.h" #import "Bring_ItAppDelegate.h" #import "MoveListViewController.h" @class MoveListViewController; @class BIUtility; @interface WorkoutViewController : UITableViewController { NSMutableArray *todaysWorkouts; IBOutlet NoteCell *woNoteCell; MoveListViewController *childController; NSInteger scheduleDay; BIUtility *bi; } @property (nonatomic, retain) NSMutableArray *todaysWorkouts; @property (nonatomic, retain) NoteCell *woNoteCell; @property (nonatomic,retain) BIUtility *bi; //@property (nonatomic, retain) SwitchCell *woSwitchCell; @end CLASS: #import "WorkoutViewController.h" #import "MoveListViewController.h" #import "Profile.h" static sqlite3 *database = nil; @implementation WorkoutViewController @synthesize todaysWorkouts; @synthesize woNoteCell; @synthesize bi; //@synthesize woSwitchCell; - (void)viewDidLoad { [super viewDidLoad]; bi = [[BIUtility alloc] init]; todaysWorkouts = [[NSMutableArray alloc] init]; NSString *query; sqlite3_stmt *statement; //open the database if (sqlite3_open([[BIUtility getDBPath] UTF8String], &database) != SQLITE_OK) { sqlite3_close(database); NSAssert(0, @"Failed to opendatabase"); } query = [NSString stringWithFormat:@"SELECT IWORKOUT.WOINSTANCEID, IWORKOUT.WORKOUTID, CWORKOUTS.WORKOUTNAME FROM CWORKOUTS JOIN IWORKOUT ON IWORKOUT.WORKOUTID = CWORKOUTS.WORKOUTID AND DATE = '%@'", [BIUtility todayDateString]]; if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { Workout *wo = [[Workout alloc] init]; wo.woInstanceID = sqlite3_column_int(statement, 0); wo.workoutID = sqlite3_column_int(statement, 1); wo.workoutName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 2)]; [todaysWorkouts addObject:wo]; [wo release]; } sqlite3_finalize(statement); } if(database) sqlite3_close(database); [query release]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //todaysWorkouts = [BIUtility todaysScheduledWorkouts]; static NSString *noteCellIdentifier = @"NoteCellIdentifier"; UITableViewCell *cell; if (indexPath.section < ([todaysWorkouts count])) { cell = [tableView dequeueReusableCellWithIdentifier:@"OtherCell"]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier: @"OtherCell"] autorelease]; cell.accessoryType = UITableViewCellAccessoryNone; } if (indexPath.row == 0) { Workout *wo = [todaysWorkouts objectAtIndex:indexPath.section]; [cell.textLabel setText:wo.workoutName]; } else { [cell.textLabel setText:@"Completed?"]; [cell.textLabel setFont:[UIFont fontWithName:@"Arial" size:15]]; [cell.textLabel setTextColor:[UIColor blueColor]]; } } else { cell = (NoteCell *)[tableView dequeueReusableCellWithIdentifier:noteCellIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"NoteCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } } return cell; //[cell release]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; if (indexPath.section < ([todaysWorkouts count]) && (row == 0)) { MoveListViewController *moveListController = [[MoveListViewController alloc] initWithStyle:UITableViewStylePlain]; moveListController.workoutID = [[todaysWorkouts objectAtIndex:indexPath.section] workoutID]; moveListController.workoutName = [[todaysWorkouts objectAtIndex:indexPath.section] workoutName]; moveListController.woInstanceID = [[todaysWorkouts objectAtIndex:indexPath.section] woInstanceID]; NSLog(@"Workout Selected: %@", [[todaysWorkouts objectAtIndex:indexPath.section] workoutName]); Bring_ItAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.workoutNavController pushViewController:moveListController animated:YES]; } else { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if (indexPath.section < ([todaysWorkouts count]) && (row == 1)) { if (cell.accessoryType == UITableViewCellAccessoryNone) { cell.accessoryType = UITableViewCellAccessoryCheckmark; } else { cell.accessoryType = UITableViewCellAccessoryNone; } } } [tableView deselectRowAtIndexPath:indexPath animated:YES]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger h = 35; return h; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return ([todaysWorkouts count] + 1); //return ([todaysWorkouts count]); } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section < ([todaysWorkouts count])) { return 2; } else { return 1; } } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if (section < ([todaysWorkouts count])) { return @"Workout"; } else { return @"How Was Your Workout?"; } } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [todaysWorkouts release]; [bi release]; [super dealloc]; } @end

    Read the article

  • MVC noob - changing part of URL in a link

    - by vidalsasoon
    Hi, I have a site that supports localization. I would like to be able to switch between english and french. Let say the user is currently at URL: http://www.mysite.com/en/Home I would like to redirect to: http://www.mysite.com/fr/Home If the user click on a "French" link how to change the URL part to "fr" yet not change the "Home" part of the URL (basically I want preserve the current location of the user) Hope my question makes sense! I'm probably missing something very basic?

    Read the article

  • noob question : reading xml from url link by using php

    - by mireille raad
    Hello, I am trying to build an authentication plugin that uses php/xml. My application can communicate to another application by sending this : http://tst.example.net/remote/validate_user.jhtml?ticket=$ticket_value in return i get a formatted xml document. i want to be able to parse that document. I googled and read a bit around here , but what i could find is that using php_simplexml i can do the following $xml = simplexml_load_file("test.xml"); echo $xml-getName() . ""; foreach($xml-children() as $child) { echo $child-getName() . ": " . $child . ""; } my question is : i don't have a test.xml file, it is a url that i am reading/parsing, any way how to get the info from the url, not a file. I know this is a very noobish question, i would appreciate the help

    Read the article

  • Clojure Box: Problem with classpath (noob question)

    - by Rainer
    Hello, I'm stuck with "Programming Clojure" on page 37 on a Windows 7 machine. After downloading the "examples" dir into "C:/clojure", I typed: user (require 'examples.introduction) and I got ; Evaluation aborted. java.io.FileNotFoundException: Could not locate examples/ introduction__init.class or examples/introduction.clj on classpath: (NO_SOURCE_FILE:0) My .emacs file looks like this: (setq swank-clojure-extra-classpaths (list "C:/Clojure")) The files in C:/Clojure are there (I triplechecked) Any help will be appreciated.

    Read the article

  • cannot output a json encoded dict containing accents (noob inside)

    - by user296546
    Hi all, here is a fairly simple example wich is driving me nuts since a couple of days. Considering the following script: # -*- coding: utf-8 -* from json import dumps as json_dumps machaine = u"une personne émérite" print(machaine) output = {} output[1] = machaine jsonoutput = json_dumps(output) print(jsonoutput) The result of this from cli: une personne émérite {"1": "une personne \u00e9m\u00e9rite"} I don't understand why their such a difference between the two strings. i have been trying all sorts of encode, decode etc but i can't seem to be able to find the right way to do it. Does anybody has an idea ? Thanks in advance. Matthieu

    Read the article

  • Noob question about a statement in a Java program

    - by happysoul
    I am beginner to java and was trying out this code puzzle from the book head first java which I solved as follows and got the output correct :D class DrumKit { boolean topHat=true; boolean snare=true; void playSnare() { System.out.println("bang bang ba-bang"); } void playTopHat() { System.out.println("ding ding da-ding"); } } public class DrumKitTestDriver { public static void main(String[] args) { DrumKit d =new DrumKit(); if(d.snare==true) { d.playSnare(); } d.playTopHat(); } } Output is :: bang bang ba-bang ding ding da-ding Now the problem is that in that code puzzle one code snippet is left that I did not include..it's as follows d.snare=false; Even though I did not write it , I got the output like the book. I am wondering why is there need for us to set it's value as false even when we know the code is gonna run without it too !?? I am wondering what the coder had in mind ..I mean what could be the possible future use and motive behind doing this ? I am sorry if it's a dumb question. I just wanna know why or why not to include that particular statement ? It's not like there's a loop or something that we need to come out of. Why is that statement there ?

    Read the article

  • Noob Rails ? about learning Rails

    - by user271916
    Hi All I have been programming for a while and for the past 3 or 4 months have been learning ruby. I am not an expert by any means but I believe I have the basics down. I decided to start learning RoR and bought the "Agile Web Development with Rails 3rd Edition" and have been dutifully going through the chapters one by one. Currently I am in chapter 8 and have had no problems so far. My question is I know I have learned several things so far and I know that I am starting to get a sense of the Rails framework I have this fear that I am just not learning as much as I should. Some things I get and understand the interconnections while I feel on other things I am just going through the motions and don't fully comprehend the total interconnectivity. Now, there is still a large amount of the book for me to complete. I guess I am just wondering if I complete this book what should I expect to be able to accomplish on my own and what should be my next steps. Thanks

    Read the article

  • NOOB Memory Problem - EXC_BAD_ACCESS

    - by Michael Bordelon
    I have been banging my head against the wall for a couple days and need some help. I have a feeling that I am doing something really silly here, but I cannot find the issue. This is the controller for a table view. I put the SQL in line to simplify it as part of the troubleshooting of this error. Normally, it would be in an accessor method in a model class. It gets through the SQL read just fine. Finds the two objects, loads them into the todaysWorkout array and then builds the cells for the table view. The table view actually comes up on the scree and then it throws the EXC_BAD_ACCESS. I ran instruments and it shows the following: 0 CFString Malloc 1 00:03.765 0x3946470 176 Foundation -[NSPlaceholderString initWithFormat:locale:arguments:] 1 CFString Autorelease 00:03.765 0x3946470 0 Foundation NSRecordAllocationEvent 2 CFString CFRelease 0 00:03.767 0x3946470 0 Bring It -[WorkoutViewController viewDidLoad] 3 CFString Zombie -1 00:03.917 0x3946470 0 Foundation NSPopAutoreleasePool Here is the source code for the controller. I left it all in there just in case there is something extraneous causing the problem. I sincerely appreciate any help I can get: #import "WorkoutViewController.h" #import "MoveListViewController.h" #import "Profile.h" static sqlite3 *database = nil; @implementation WorkoutViewController @synthesize todaysWorkouts; @synthesize woNoteCell; @synthesize bi; //@synthesize woSwitchCell; - (void)viewDidLoad { [super viewDidLoad]; bi = [[BIUtility alloc] init]; todaysWorkouts = [[NSMutableArray alloc] init]; NSString *query; sqlite3_stmt *statement; //open the database if (sqlite3_open([[BIUtility getDBPath] UTF8String], &database) != SQLITE_OK) { sqlite3_close(database); NSAssert(0, @"Failed to opendatabase"); } query = [NSString stringWithFormat:@"SELECT IWORKOUT.WOINSTANCEID, IWORKOUT.WORKOUTID, CWORKOUTS.WORKOUTNAME FROM CWORKOUTS JOIN IWORKOUT ON IWORKOUT.WORKOUTID = CWORKOUTS.WORKOUTID AND DATE = '%@'", [BIUtility todayDateString]]; if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { Workout *wo = [[Workout alloc] init]; wo.woInstanceID = sqlite3_column_int(statement, 0); wo.workoutID = sqlite3_column_int(statement, 1); wo.workoutName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 2)]; [todaysWorkouts addObject:wo]; [wo release]; } sqlite3_finalize(statement); } if(database) sqlite3_close(database); [query release]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //todaysWorkouts = [BIUtility todaysScheduledWorkouts]; static NSString *noteCellIdentifier = @"NoteCellIdentifier"; UITableViewCell *cell; if (indexPath.section < ([todaysWorkouts count])) { cell = [tableView dequeueReusableCellWithIdentifier:@"OtherCell"]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier: @"OtherCell"] autorelease]; cell.accessoryType = UITableViewCellAccessoryNone; } if (indexPath.row == 0) { Workout *wo = [todaysWorkouts objectAtIndex:indexPath.section]; [cell.textLabel setText:wo.workoutName]; } else { [cell.textLabel setText:@"Completed?"]; [cell.textLabel setFont:[UIFont fontWithName:@"Arial" size:15]]; [cell.textLabel setTextColor:[UIColor blueColor]]; } } else { cell = (NoteCell *)[tableView dequeueReusableCellWithIdentifier:noteCellIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"NoteCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } } return cell; //[cell release]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; if (indexPath.section < ([todaysWorkouts count]) && (row == 0)) { MoveListViewController *moveListController = [[MoveListViewController alloc] initWithStyle:UITableViewStylePlain]; moveListController.workoutID = [[todaysWorkouts objectAtIndex:indexPath.section] workoutID]; moveListController.workoutName = [[todaysWorkouts objectAtIndex:indexPath.section] workoutName]; moveListController.woInstanceID = [[todaysWorkouts objectAtIndex:indexPath.section] woInstanceID]; NSLog(@"Workout Selected: %@", [[todaysWorkouts objectAtIndex:indexPath.section] workoutName]); Bring_ItAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.workoutNavController pushViewController:moveListController animated:YES]; } else { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if (indexPath.section < ([todaysWorkouts count]) && (row == 1)) { if (cell.accessoryType == UITableViewCellAccessoryNone) { cell.accessoryType = UITableViewCellAccessoryCheckmark; } else { cell.accessoryType = UITableViewCellAccessoryNone; } } } [tableView deselectRowAtIndexPath:indexPath animated:YES]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger h = 35; return h; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return ([todaysWorkouts count] + 1); //return ([todaysWorkouts count]); } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section < ([todaysWorkouts count])) { return 2; } else { return 1; } } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if (section < ([todaysWorkouts count])) { return @"Workout"; } else { return @"How Was Your Workout?"; } } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [todaysWorkouts release]; [bi release]; [super dealloc]; } @end

    Read the article

  • php run function on all images from one dir in recursive mode (noob)

    - by Steve
    hey guyz i have a function $result = create_watermark( 'input_file_name' ,'output_file_name'); i have dir called /images n have 500 images in it and all images are link images_(some_unknown_numbers).png (all png) now i want run them thru function in loop and want out put like /markedimage/images_1.png images_2.png images_3.png i need help how can i run them in loop and how out put name can change want run script on Ubuntu so we can use shell too if any body want check function it is here http://paste2.org/p/789149 plz provide me code because i m newbie thanks in advance

    Read the article

  • Noob LINQ - reading, filtering XML with XDocument

    - by user316117
    I'm just learning XDocument and LINQ queries. Here's some simple XML (which doesn't look formatted exactly right in this forum in my browser, but you get the idea . . .) <?xml version="1.0" encoding="utf-8"?> <quiz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.com/name XMLFile2.xsd" title="MyQuiz1"> <q_a> <q_a_num>1</q_a_num> <q_>Here is question 1</q_> <_a>Here is the answer to 1</_a> </q_a> <q_a> <q_a_num>2</q_a_num> <q_>Here is question 2</q_> <_a>Here is the answer to 2</_a> </q_a> </quiz> I can iterate across all elements in my XML file and display their Name, Value, and NodeType in a ListBox like this, no problem: XDocument doc = XDocument.Load(sPath); IEnumerable<XElement> elems = doc.Descendants(); IEnumerable<XElement> elem_list = from elem in elems select elem; foreach (XElement element in elem_list) { String str0 = "Name = " + element.Name.ToString() + ", Value = " + element.Value.ToString() + ", Nodetype = " + element.NodeType.ToString(); System.Windows.Controls.Label strLabel = new System.Windows.Controls.Label(); strLabel.Content = str0; listBox1.Items.Add(strLabel); } ...but now I want to add a "where" clause to my query so that I only select elements with a certain name (e.g., "qa") but my element list comes up empty. I tried . . . IEnumerable<XElement> elem_list = from elem in elems where elem.Name.ToString() == "qa" select elem; Could someone please explain what I'm doing wrong? (and in general are there some good tips for debugging Queries?) Thanks in advance!

    Read the article

  • Noob Question: Wordpress Looping

    - by dclowd9901
    Can someone give me an essential Wordpress Loop and explain to me what's happening with it? I'd like to put together some templates, but I don't do well with blackboxing. In other words, I'm fully capable of writing my own CMS, but when it comes to using someone else's and its arbitrary rules, I'm completely at a loss, and I just can't get my head around the standard loop Wordpress uses. Thanks for your patient guidance.

    Read the article

  • jquery noob problem with variables (scope?)

    - by aharon
    I'm trying to retrieve data from a php file named return that just contains <?php echo 'here is a string'; ?> I'm doing this through an html file containing <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script> var x; $.get("return.php", function(data){ x = data; }) function showAlert() {alert(x);} $(document).ready(function(){ alert(x); }); </script> </head> <body> <input type = "button" value = "Click here" onClick="showAlert();"> </body> </html> When the button is clicked it retrieves and displays the code fine, but on the $(document).ready thing, it displays "undefined" instead of the data in return.php. Any solutions? Thanks.

    Read the article

  • Building Paypal based membership website - total noob - would appreciate help

    - by Ali
    this is a follow up on my question on paypal integration. I'm working ona membership site for racing fans. My membership site has 3 membership levels - free, gold and premium. When a user signs up he/she can gets a free membership on the spot but has the option to upgrade to a gold membership for 4 Dollars a month or a premium membership for 10 Dollars a month. I've gone through the paypal integration guide a few times though and have a vague understanding of how to get this to work. I think the recurring payments option would be fine enough - however I don't know how do I implement this in my system. Like when a user decides to go for a paid account i.e. Gold or premium from basic - what should I do on both my code side and on the paypal account side - I'd really appreciate if anyone would outline what I'd have to do here. Plus when a user decides to upgrade from lets say a Gold to a premium account - there is the issue of computing how much should be charged to upgrade his/her account eg: a user has been billed for 4 dollars and the next day opts to go for a premium account so assuming that the surplus for the rest of the month is 5 dollars and further from that all payments would be recurring 10 dollars monthly - how do I implement this? And in case a user decides to downgrade from a premium account of 10 dollars a month to a gold account of 4 dollars a month - how do I handle the surplus which would have to be refunded for that month alone and changing the membership? And like wise if someone wishes to cancel membership and go to having a free account - how do I refund whatever is owed and cancel the subscription. I'm sorry if it sounds like I'm asking to be spoon fed :( I'm quite new to this and this is for a client and I would really appreciate all the help here and really have to get this working right. Thanks again everyone - waiting for all your replies.

    Read the article

  • Hibernate noob fetch join problem

    - by Bruce
    Hi all I have two classes, Test2 and Test3. Test2 has an attribute test3 that is an instance of Test3. In other words, I have a unidirectional OneToOne association, with test2 having a reference to test3. When I select Test2 from the db, I can see that a separate select is being made to get the details of the associated test3 class. This is the famous 1+N selects problem. To fix this to use a single select, I am trying to use the fetch=join annotation, which I understand to be @Fetch(FetchMode.JOIN) However, with fetch set to join, I still see separate selects. Here are the relevant portions of my setup.. hibernate.cfg.xml: <property name="max_fetch_depth">2</property> Test2: public class Test2 { @OneToOne (cascade=CascadeType.ALL , fetch=FetchType.EAGER) @JoinColumn (name="test3_id") @Fetch(FetchMode.JOIN) public Test3 getTest3() { return test3; } NB I set the FetchType to EAGER out of desperation, even though it defaults to EAGER anyway for OneToOne mappings, but it made no difference. Thanks for any help! Edit: I've pretty much given up on trying to use FetchMode.JOIN - can anyone confirm that they have got it to work ie produce a left outer join? In the docs I see that "Usually, the mapping document is not used to customize fetching. Instead, we keep the default behavior, and override it for a particular transaction, using left join fetch in HQL" If I do a left join fetch instead: query = session.createQuery("from Test2 t2 left join fetch t2.test3"); then I do indeed get the results I want - ie a left outer join in the query.

    Read the article

  • Super Noob C++ variable help

    - by julian
    Ok, I must preface this by stating that I know so so little about c++ and am hoping someone can just help me out... I have the below code: string GoogleMapControl::CreatePolyLine(RideItem *ride) { std::vector<RideFilePoint> intervalPoints; ostringstream oss; int cp; int intervalTime = 30; // 30 seconds int zone =ride->zoneRange(); if(zone >= 0) { cp = 300; // default cp to 300 watts } else { cp = ride->zones->getCP(zone); } foreach(RideFilePoint* rfp, ride->ride()->dataPoints()) { intervalPoints.push_back(*rfp); if((intervalPoints.back().secs - intervalPoints.front().secs) > intervalTime) { // find the avg power and color code it and create a polyline... AvgPower avgPower = for_each(intervalPoints.begin(), intervalPoints.end(), AvgPower()); // find the color QColor color = GetColor(cp,avgPower); // create the polyline CreateSubPolyLine(intervalPoints,oss,color); intervalPoints.clear(); intervalPoints.push_back(*rfp); } } return oss.str(); } void GoogleMapControl::CreateSubPolyLine(const std::vector<RideFilePoint> &points, std::ostringstream &oss, QColor color) { oss.precision(6); QString colorstr = color.name(); oss.setf(ios::fixed,ios::floatfield); oss << "var polyline = new GPolyline(["; BOOST_FOREACH(RideFilePoint rfp, points) { if (ceil(rfp.lat) != 180 && ceil(rfp.lon) != 180) { oss << "new GLatLng(" << rfp.lat << "," << rfp.lon << ")," << endl; } } oss << "],\"" << colorstr.toStdString() << "\",4);"; oss << "GEvent.addListener(polyline, 'mouseover', function() {" << endl << "var tooltip_text = 'Avg watts:" << avgPower <<" <br> Avg Speed: <br> Color: "<< colorstr.toStdString() <<"';" << endl << "var ss={'weight':8};" << endl << "this.setStrokeStyle(ss);" << endl << "this.overlay = new MapTooltip(this,tooltip_text);" << endl << "map.addOverlay(this.overlay);" << endl << "});" << endl << "GEvent.addListener(polyline, 'mouseout', function() {" << endl << "map.removeOverlay(this.overlay);" << endl << "var ss={'weight':5};" << endl << "this.setStrokeStyle(ss);" << endl << "});" << endl; oss << "map.addOverlay (polyline);" << endl; } And I'm trying to get the avgPower from this part: AvgPower avgPower = for_each(intervalPoints.begin(), intervalPoints.end(), AvgPower()); the first part to cary over to the second part: << "var tooltip_text = 'Avg watts:" << avgPower <<" <br> Avg Speed: <br> Color: "<< colorstr.toStdString() <<"';" << endl But of course I haven't the slightest clue how to do it... anyone feeling generous today? Thanks in advance

    Read the article

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