Search Results

Search found 2455 results on 99 pages for 'blueraja the green unicorn'.

Page 18/99 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Do I need to use decimal places when using floats? Is the "f" suffix necessary?

    - by Paulo Fierro
    I've seen several examples in books and around the web where they sometimes use decimal places when declaring float values even if they are whole numbers, and sometimes using an "f" suffix. Is this necessary? For example: [UIColor colorWithRed:0.8 green:0.914 blue:0.9 alpha:1.00]; How is this different from: [UIColor colorWithRed:0.8f green:0.914f blue:0.9f alpha:1.00f]; Does the trailing "f" mean anything special? Getting rid of the trailing zeros for the alpha value works too, so it becomes: [UIColor colorWithRed:0.8 green:0.914 blue:0.9 alpha:1]; So are the decimal zeros just there to remind myself and others that the value is a float? Just one of those things that has puzzled me so any clarification is welcome :)

    Read the article

  • PHP Encrypt/Decrypt with TripleDes, PKCS7, and ECB

    - by Brandon Green
    I've got my encryption function working properly however I cannot figure out how to get the decrypt function to give proper output. Here is my encrypt function: function Encrypt($data, $secret) { //Generate a key from a hash $key = md5(utf8_encode($secret), true); //Take first 8 bytes of $key and append them to the end of $key. $key .= substr($key, 0, 8); //Pad for PKCS7 $blockSize = mcrypt_get_block_size('tripledes', 'ecb'); $len = strlen($data); $pad = $blockSize - ($len % $blockSize); $data .= str_repeat(chr($pad), $pad); //Encrypt data $encData = mcrypt_encrypt('tripledes', $key, $data, 'ecb'); return base64_encode($encData); } Here is my decrypt function: function Decrypt($data, $secret) { $text = base64_decode($data); $data = mcrypt_decrypt('tripledes', $secret, $text, 'ecb'); $block = mcrypt_get_block_size('tripledes', 'ecb'); $pad = ord($data[($len = strlen($data)) - 1]); return substr($data, 0, strlen($data) - $pad); } Right now I am using a key of test and I'm trying to encrypt 1234567. I get the base64 output from encryption I'm looking for, but when I go to decrypt I get a blank response. I'm not very well versed in encryption/decryption so any help is much appreciated!!

    Read the article

  • How can I use images provided by the iPhone OS?

    - by Topher Fangio
    Hello all, First, let me state what brought this question about: I saw the green checkmark icon in this post and I would like to use it in my own application. However, since it looks so much like the UITableViewCellAccessoryDetailDisclosureButton my assumption is that this green checkmark icon is provided by the iPhone OS in some form or fashion. So, my question is: how can I use the green checkmark icon and/or other OS-provided images in my own applications? As a side question: where can I find a list of the OS-provided images (if they even exist)? Thanks very much for any input :-)

    Read the article

  • Visual Studio 2008 - formatting/control characters/marks

    - by AL
    Hi, I don't know what I did but somehow the IDE has started displaying a green dot whenever I press spacebar and a green arrowhead whenever I press TAB. The source has become littered with these characters all over and I am finding it very difficult to code in the presence of so many formatting marks. I have tried to search a solution on Google but couldn't perhaps enter the right keywords so haven't been able to fix the behavior. Is there any way I can stop VS2008 IDE from littering my source code with these green dots and arrowheads whenever I press spacebar/tab? I would be really thankful for this help. Thanks, -AL PS: Re-posting the question as I am new to this forum and probably couldn't see the email notification option earlier. My apologies for this inconvenience.

    Read the article

  • refactoring in iSeries (RPG), is it realistic

    - by albert green
    Implementing agile in projects requires the ability to do refactoring. It is not really a must, but code refactoring has proven to be a good engineering practice. In an agile (Scrum) project on the iSeries platform, which requires development (new code and modifications to legacy code) in RPG, RPG LE, is it possible to implement refactoring? If so what are the techniques to do it? If someone who has tried it could share their experience or just point to references, I would greatly appreciate it.

    Read the article

  • page transitions using javascript

    - by hasan
    hey, i saw this on a site a couple of days ago and i cant seem to find it again. in any case, this is what was on the site: the page opened regularly when you entered the url. upon clicking one of the links on the page, it "transitioned" to the next page (there was a color change). and the url in the address bar was changed to reflect that. eg: if the background was blue on site.com, when clicking on the about link, the background would change to green and the browser would show site.com/about. and so on. also, if the url entered was site.com/about, the bg would be green and on cliking the home page, the site would transition from green to blue and browser would show site.com im interested in finding out how this was done. searching on google got me the meta-refresh tag, but the ffect was much more complex and worked on all browsers. is there any other method out there?

    Read the article

  • c++ - strange problem with polymorphism - cellular automaton

    - by Green
    Hello, I am making "game of life" implementation that, when cell has: two live neighbours I make object of class CCellB two live neighbours I make object of class CCellA when has 3 or <2 I make object of class CCellX (dead) Class CCell is base of CCellA, CCellB, CCellX My problem is: That works fine, until I change new CCell(); to new CCellB();: CCell ***temp = allocateArray(); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { c = arr[i][j]->countAliveNeighbor(); if(c == 3) { temp[i][j] = new CCellA(); temp[i][j]->alive = 1; }else if(c == 2) { temp[i][j] = new CCell(); // HERE, WHEN I CHANGE IT TO CCELLB IT DON'T WORKS temp[i][j]->alive = tab[i][j]->alive; }else if((c >= 4)||(c < 2)) { temp[i][j] = new CCellX(); } } } Then it seems don't work properly... Seems like neighbours are not count properly, Cell with 4,5 neighbours still alive alive var is member of base class - CCell, all is public, please help!

    Read the article

  • How can I stop and start individual websites in IIS using PowerShell?

    - by Joey Green
    I have multiple sites configured in IIS7 on my Windows7 development machine to run on the same port and usually only run one at a time depending on what I'm working on. I would like to be able to start and stop my development sites from PowerShell instead of having the IIS manager opened. Does anyone have a good resource to point me in the right direction or a script that already accomplishes this? Thanks

    Read the article

  • Consulting a Prolog Source Code from within a VS2008 Solution File

    - by Joshua Green
    I have a Prolog file (Hanoi.pl) containing the code for solving the Hanoi Towers puzzle: hanoi( N ):- move( N, left, middle, right ). move( 0, _, _, _ ):- !. move( N, A, B, C ):- M is N-1, move( M, A, C, B ), inform( A, B ), move( M, C, B, A ). inform( X, Y ):- write( 'move a disk from ' ), write( X ), write( ' to ' ), writeln( Y ). I also have a C++ file written in VS2008 IDE: #include <iostream> #include <string> #include <stdio.h> #include <stdlib.h> using namespace std; #include "SWI-cpp.h" #include "SWI-Prolog.h" predicate_t phanoi; term_t t0; int main(int argc, char** argv) { long n = 5; int rval; if ( !PL_initialise(1, argv) ) PL_halt(1); PL_put_integer( t0, n ); phanoi = PL_predicate( "hanoi", 1, NULL ); rval = PL_call_predicate( NULL, PL_Q_NORMAL, phanoi, t0 ); system( "PAUSE" ); } How can I consult my Prolog source code (Hanoi.pl) from within my C++ code? Not from the Command Prompt - from the code, something like include or consult or compile? It is located in the same folder as my cpp file. Thanks,

    Read the article

  • How to avoid using the plld.exe utility in VS2008 (for linking C++ and Prolog codes)

    - by Joshua Green
    Here is my code in its entirety: Trying "listing." at the Prolog prompt that pops up when I run the program confirms that my Prolog source code has been loaded (consulted). #include <iostream> #include <fstream> #include <string> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <stdafx.h> using namespace std; #include "Windows.h" #include "ctype.h" #include "SWI-cpp.h" #include "SWI-Prolog.h" #include "SWI-Stream.h" int main(int argc, char** argv) { argc = 4; argv[0] = "libpl.dll"; argv[1] = "-G32m"; argv[2] = "-L32m"; argv[3] = "-T32m"; PL_initialise(argc, argv); if ( !PL_initialise(argc, argv) ) PL_halt(1); PlCall( "consult(swi('plwin.rc'))" ); PlCall( "consult('hello.pl')" ); PL_halt( PL_toplevel() ? 0 : 1 ); } So this is how to load a Prolog source code (hello.pl) at run time into VS2008 without having to use plld at the VS command prompt.

    Read the article

  • Factorial in Prolog and C++

    - by Joshua Green
    I would like to work out a number's factorial. My factorial rule is in a Prolog file and I am connecting it to a C++ code. Can someone tell me what is wrong with my C++ interface please? % factorial.pl factorial( 1, 1 ):- !. factorial( X, Fac ):- X > 1, Y is X - 1, factorial( Y, New_Fac ), Fac is X * New_Fac. // factorial.cpp # headerfiles term_t t1; term_t t2; term_t goal_term; functor_t goal_functor; int main( int argc, char** argv ) { argc = 4; argv[0] = "libpl.dll"; argv[1] = "-G32m"; argv[2] = "-L32m"; argv[3] = "-T32m"; PL_initialise(argc, argv); if ( !PL_initialise(argc, argv) ) PL_halt(1); PlCall( "consult(swi('plwin.rc'))" ); PlCall( "consult('factorial.pl')" ); cout << "Enter your factorial number: "; long n; cin >> n; PL_put_integer( t1, n ); t1 = PL_new_term_ref(); t2 = PL_new_term_ref(); goal_term = PL_new_term_ref(); goal_functor = PL_new_functor( PL_new_atom("factorial"), 2 ); PL_put_atom( t1, t2 ); PL_cons_functor( goal_term, goal_functor, t1, t2 ); PL_halt( PL_toplevel() ? 0 : 1 ); }

    Read the article

  • Are document-oriented databases any more suitable than relational ones for persisting objects?

    - by Owen Fraser-Green
    In terms of database usage, the last decade was the age of the ORM with hundreds competing to persist our object graphs in plain old-fashioned RMDBS. Now we seem to be witnessing the coming of age of document-oriented databases. These databases are highly optimized for schema-free documents but are also very attractive for their ability to scale out and query a cluster in parallel. Document-oriented databases also hold a couple of advantages over RDBMS's for persisting data models in object-oriented designs. As the tables are schema-free, one can store objects belonging to different classes in an inheritance hierarchy side-by-side. Also, as the domain model changes, so long as the code can cope with getting back objects from an old version of the domain classes, one can avoid having to migrate the whole database at every change. On the other hand, the performance benefits of document-oriented databases mainly appear to come about when storing deeper documents. In object-oriented terms, classes which are composed of other classes, for example, a blog post and its comments. In most of the examples of this I can come up with though, such as the blog one, the gain in read access would appear to be offset by the penalty in having to write the whole blog post "document" every time a new comment is added. It looks to me as though document-oriented databases can bring significant benefits to object-oriented systems if one takes extreme care to organize the objects in deep graphs optimized for the way the data will be read and written but this means knowing the use cases up front. In the real world, we often don't know until we actually have a live implementation we can profile. So is the case of relational vs. document-oriented databases one of swings and roundabouts? I'm interested in people's opinions and advice, in particular if anyone has built any significant applications on a document-oriented database.

    Read the article

  • Unhandled Exception error message

    - by Joshua Green
    Does anyone know why including a term such as: t = PL_new_term_ref(); would cause an Unhandled Exception error message: 0xC0000005: Access violation reading location 0x0000000c. (Visual Studio 2008) I have a header file: class UserTaskProlog : public ArAction { public: UserTaskProlog( const char* name = " sth " ); ~UserTaskProlog( ); AREXPORT virtual ArActionDesired *fire( ArActionDesired currentDesired ); private: term_t t; }; and a cpp file: UserTaskProlog::UserTaskProlog( const char* name ) : ArAction( name, " sth " ) { char** argv; argv[ 0 ] = "libpl.dll"; PL_initialise( 1, argv ); PlCall( "consult( 'myProg.pl' )" ); } UserTaskProlog::~UserTaskProlog( ) { } ArActionDesired *UserTaskProlog::fire( ArActionDesired currentDesired ) { cout << " something " << endl; t = PL_new_term_ref( ); } Without t=PL_new_term_ref() everything works fine, but when I start adding my Prolog code (declarations first, such as t=PL_new_term_ref), I get this Access Violation error message. I'd appreciate any help. Thanks,

    Read the article

  • Loop colours from variables for graphics.py [Python 3.2]

    - by user1056548
    I am creating a graphics program that draws 100 x 100 squares next to each other depending on the user-specified grid size. The user also inputs 4 colours for the squares to be coloured (e.g. if they enter red,green,blue,yellow the squares will be coloured in that order, repeating the colours). Is it possible to loop the colours from the variables the user has given? Here is what I have so far: def main(): print ("Please enter four comma seperated colours e.g.: 'red,green,blue,yellow'\n\ Allowed colours are: red, green, blue, yellow and cyan") col1, col2, col3, col4 = input("Enter your four colours: ").split(',') win = GraphWin ("Squares", 500, 500) colours = [col1, col2, col3, col4] drawSquare (win, col1, col2, col3, col4, colours) win.getMouse() win.close() def drawSquare(win, col1, col2, col3, col4, colours): for i in range (4): for j in range (len(colours)): colour = colours[j] x = 50 + (i * 50) circle = Circle (Point (x,50), 20) circle.setFill(colour) circle.draw(win) I think I should be using a list in some way, but can't work out exactly how to do it. Can anybody help?

    Read the article

  • C/C++ enum and char * array

    - by Eric M
    Ran accross the following code in an article and didn't think it was standard C/C++ syntax for the char* array. As a test, both Visual C++ (visual studio 2005) and C++ Builder Rad XE both reject the 2nd line. Without using #defines, anyone have any tricks/tips for keeping enums and a string array sort of in sync without resorting to STL ? More of a curiosity question. enum TCOLOR { RED, GREEN, BLUE }; char *TNCOLOR[] = { [RED]="Red", [GREEN]="Green", [BLUE]="Blue" }; as an aside, the article this came from is quite old and I believe this might work under GCC but have not tested.

    Read the article

  • Color blindness: Are you aware of it? Do you design for it?

    - by User
    I'm curious whether many of us who do design or take design decisions have ever heard of this problem. I'm aware there are dangerous color combinations, like green + red. This is probably one of the most popular cases of color blindness. If you have green text on a red background and vice versa some people won't see anything. I've also seen in practice that green text on a blue background was not seen by one guy. What other color compositions should be avoided, and how often these cases are to be expected? Let us make some ranging by encounter probability who has the numbers. Addition: I've just remembered one very bad example that causes problems to just about everyone - blue text on a black background. It's unreadable for all intents and purposes. Never could understand what could possibly compel a web master to use this color combination...

    Read the article

  • What is there so useful in the Decorator Pattern? My example doesn't work

    - by Green
    The book says: The decorator pattern can be used to extend (decorate) the functionality of a certain object I have a rabbit animal. And I want my rabbit to have, for example, reptile skin. Just want to decorate a common rabbit with reptile skin. I have the code. First I have abstract class Animal with everythig that is common to any animal: abstract class Animal { abstract public function setSleep($hours); abstract public function setEat($food); abstract public function getSkinType(); /* and more methods which for sure will be implemented in any concrete animal */ } I create class for my rabbit: class Rabbit extends Animal { private $rest; private $stomach; private $skinType = "hair"; public function setSleep($hours) { $this->rest = $hours; } public function setFood($food) { $this->stomach = $food; } public function getSkinType() { return $this->$skinType; } } Up to now everything is OK. Then I create abstract AnimalDecorator class which extends Animal: abstract class AnimalDecorator extends Animal { protected $animal; public function __construct(Animal $animal) { $this->animal = $animal; } } And here the problem comes. Pay attention that AnimalDecorator also gets all the abstract methods from the Animal class (in this example just two but in real can have many more). Then I create concrete ReptileSkinDecorator class which extends AnimalDecorator. It also has those the same two abstract methods from Animal: class ReptileSkinDecorator extends AnimalDecorator { public function getSkinColor() { $skin = $this->animal->getSkinType(); $skin = "reptile"; return $skin; } } And finaly I want to decorate my rabbit with reptile skin: $reptileSkinRabbit = ReptileSkinDecorator(new Rabbit()); But I can't do this because I have two abstract methods in ReptileSkinDecorator class. They are: abstract public function setSleep($hours); abstract public function setEat($food); So, instead of just re-decorating only skin I also have to re-decorate setSleep() and setEat(); methods. But I don't need to. In all the book examples there is always ONLY ONE abstract method in Animal class. And of course it works then. But here I just made very simple real life example and tried to use the Decorator pattern and it doesn't work without implementing those abstract methods in ReptileSkinDecorator class. It means that if I want to use my example I have to create a brand new rabbit and implement for it its own setSleep() and setEat() methods. OK, let it be. But then this brand new rabbit has the instance of commont Rabbit I passed to ReptileSkinDecorator: $reptileSkinRabbit = ReptileSkinDecorator(new Rabbit()); I have one common rabbit instance with its own methods in the reptileSkinRabbit instance which in its turn has its own reptileSkinRabbit methods. I have rabbit in rabbit. But I think I don't have to have such possibility. I don't understand the Decarator pattern right way. Kindly ask you to point on any mistakes in my example, in my understanding of this pattern. Thank you.

    Read the article

  • By-name repeated parameters

    - by Green Hyena
    How to pass by-name repeated parameters in Scala? The following code fails to work: scala> def foo(s: (=> String)*) = { <console>:1: error: no by-name parameter type allowed here def foo(s: (=> String)*) = { ^ Is there any other way I could pass a variable number of by name parameters to the method?

    Read the article

  • Float over two elements

    - by eWolf
    My problem is rather complex to explain, so I'll show you an example: http://ewolf.bplaced.de/misc/float.htm I want to have a floated element (the blue box) to be be placed over two other elements (red and green) and I want the whole thing to be fixed-width and centered (done by the box with the black border) while the background of the red and green box should fill the whole width. I'm actually not quite sure if the way I've done it now is XHTML/CSS valid, but it works - at least in Firefox. In IE6, the green box expands to fit the whole blue box - how can I fix this in IE6 or find another solution to show it correctly in all browsers?

    Read the article

  • MySQL: Count occurrences of known (or enumerated) distinct values

    - by Eilidh
    After looking at how to count the occurrences of distinct values in a field, I am wondering how to count the occurrences of each distinct value if the distinct values are known (or enumerated). For example, if I have a simple table - TrafficLight Colour ------------ ------ 1 Red 2 Amber 3 Red 4 Red 5 Green 6 Green where one column (in this case Colour) has known (or enumerated) distinct values, how could I return the count for each colour as a separate value, rather than as an array, as in the linked example. To return an array with a count of each colour (using the same method as in the linked example), the query would be something like SELECT Colour COUNT(*) AS ColourCount FROM TrafficLights GROUP BY Colour, and return an array - Colour ColourCount ------ ----------- Red 3 Amber 1 Green 2 What I would like to do is to return the count for each Colour AS a separate total (e.g. RedCount). How can I do this?

    Read the article

  • Separating an Array into a comma seperated string with quotes

    - by user548744
    I'm manually building an SQL query where I'm using an Array in the params hash for an SQL IN statement, like: ("WHERE my_field IN('blue','green','red')"). So I need to take the contents of the array and output them into a string where each element is single quoted and comma seperated (and with no ending comma). So if the array was: my_array = ['blue','green','red'] I'd need a string that looked like: "'blue','green','red'" I'm pretty new to Ruby/Rails but came up with something that worked: if !params[:colors].nil? @categories_array = params[:colors][:categories] @categories_string ="" for x in @categories_array @categories_string += "'" + x + "'," end @categories_string.chop! #remove the last comma end So, I'm good but curious as to what a proper and more consise way of doing this would look like? Thanks

    Read the article

  • Wrapper class for HttpGet / Post in Java?

    - by Tim Green
    Hi, Sorry, I'm quite new to Java. I've stumbled across HttpGet and HttpPost which seem to be perfect for my needs, but a little long winded. I have written a rather bad wrapper class, but does anyone know of where to get a better one? Ideally, I'd be able to do String response = fetchContent("http://url/", postdata); where postdata is optional. Thanks!

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >