Daily Archives

Articles indexed Wednesday April 14 2010

Page 7/122 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • creating managed objects using code in xcode & core-data

    - by themadpeacock
    New to objective-c xcode and core-data so sorry for the remedial question. I have set up a very simple data model: Entity1 and Entity2, both contain a single attribute (String) and a one-to-many relationship with the other. I want to scan Entity1 and depending on the results of the scan create one or more Entity2 objects that link to Entity1. How can I do this? I don’t understand how I create Entity2 type objects in code and how I would define the relationship to the Entity1 object they are related to. I come from a SQL programming background where inserting elements into the Entity2 table with the ID of the related Entiry1 entry is easy. I can’t get my head around the xcode core-data abstraction and would appreciate any help.

    Read the article

  • Divide and conquer method to compute roots [SOLVED]

    - by hellsoul153
    Hello, Knowing that we can use Divide-and-Conquer algorithm to compute large exponents, for exemple 2 exp 100 = 2 exp(50) * 2 exp(50), which is quite more efficient, is this method efficient using roots ? For exemple 2 exp (1/100) = (2 exp(1/50)) exp(1/50) ? In other words, I'm wondering if (n exp(1/x)) is more efficient to (n exp(1/y)) for x < y and where x and y are integers.

    Read the article

  • Problem with Authlogic and Unit/Functional Tests in Rails

    - by mmacaulay
    I'm learning how unit testing is done in Rails, and I've run into a problem involving Authlogic. According to the Documentation there are a few things required to use Authlogic stuff in your tests: test_helper.rb: require "authlogic/test_case" class ActiveSupport::TestCase setup :activate_authlogic end Then in my functional tests I can login users: UserSession.create(users(:tester)) The problem seems to stem from the setup :activate_authlogic line in test_helper.rb, whenever that is included, I get the following errors when running functional tests: NoMethodError: undefined method `request=' for nil:NilClass authlogic (2.1.3) lib/authlogic/controller_adapters/abstract_adapter.rb:63:in `send' authlogic (2.1.3) lib/authlogic/controller_adapters/abstract_adapter.rb:63:in `method_missing' If I remove setup :activate_authlogic and add instead Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self) to test_helper.rb, my functional tests seem to work but now my unit tests fail: NoMethodError: undefined method `params' for ActiveSupport::TestCase:Class authlogic (2.1.3) lib/authlogic/controller_adapters/abstract_adapter.rb:30:in `params' authlogic (2.1.3) lib/authlogic/session/params.rb:96:in `params_credentials' authlogic (2.1.3) lib/authlogic/session/params.rb:72:in `params_enabled?' authlogic (2.1.3) lib/authlogic/session/params.rb:66:in `persist_by_params' authlogic (2.1.3) lib/authlogic/session/callbacks.rb:79:in `persist' authlogic (2.1.3) lib/authlogic/session/persistence.rb:55:in `persisting?' authlogic (2.1.3) lib/authlogic/session/persistence.rb:39:in `find' authlogic (2.1.3) lib/authlogic/acts_as_authentic/session_maintenance.rb:96:in `get_session_information' authlogic (2.1.3) lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `each' authlogic (2.1.3) lib/authlogic/acts_as_authentic/session_maintenance.rb:95:in `get_session_information' /test/unit/user_test.rb:23:in `test_should_save_user_with_email_password_and_confirmation' What am I doing wrong?

    Read the article

  • MVC Portable Areas Enhancement &ndash; Embedded Resource Controller

    - by Steve Michelotti
    MvcContrib contains a feature called Portable Areas which I’ve recently blogged about. In short, portable areas provide a way to distribute MVC binary components as simple .NET assemblies where the aspx/ascx files are actually compiled into the assembly as embedded resources. This is an extremely cool feature but once you start building robust portable areas, you’ll also want to be able to access other external files like css and javascript.  After my recent post suggesting portable areas be expanded to include other embedded resources, Eric Hexter asked me if I’d like to contribute the code to MvcContrib (which of course I did!). Embedded resources are stored in a case-sensitive way in .NET assemblies and the existing embedded view engine inside MvcContrib already took this into account. Obviously, we’d want the same case sensitivity handling to be taken into account for any embedded resource so my job consisted of 1) adding the Embedded Resource Controller, and 2) a little refactor to extract the logic that deals with embedded resources so that the embedded view engine and the embedded resource controller could both leverage it and, therefore, keep the code DRY. The embedded resource controller targets these scenarios: External image files that are referenced in an <img> tag External files referenced like css or JavaScript files Image files referenced inside css files Embedded Resources Walkthrough This post will describe a walkthrough of using the embedded resource controller in your portable areas to include the scenarios outlined above. I will build a trivial “Quick Links” widget to illustrate the concepts. The portable area registration is the starting point for all portable areas. The MvcContrib.PortableAreas.EmbeddedResourceController is optional functionality – you must opt-in if you want to use it.  To do this, you simply “register” it by providing a route in your area registration that uses it like this: 1: context.MapRoute("ResourceRoute", "quicklinks/resource/{resourceName}", 2: new { controller = "EmbeddedResource", action = "Index" }, 3: new string[] { "MvcContrib.PortableAreas" }); First, notice that I can specify any route I want (e.g., “quicklinks/resources/…”).  Second, notice that I need to include the “MvcContrib.PortableAreas” namespace as the fourth parameter so that the framework is able to find the EmbeddedResourceController at runtime. The handling of embedded views and embedded resources have now been merged.  Therefore, the call to: 1: RegisterTheViewsInTheEmmeddedViewEngine(GetType()); has now been removed (breaking change).  It has been replaced with: 1: RegisterAreaEmbeddedResources(); Other than that, the portable area registration remains unchanged. The solution structure for the static files in my portable area looks like this: I’ve got a css file in a folder called “Content” as well as a couple of image files in a folder called “images”. To reference these in my aspx/ascx code, all of have to do is this: 1: <link href="<%= Url.Resource("Content.QuickLinks.css") %>" rel="stylesheet" type="text/css" /> 2: <img src="<%= Url.Resource("images.globe.png") %>" /> This results in the following HTML mark up: 1: <link href="/quicklinks/resource/Content.QuickLinks.css" rel="stylesheet" type="text/css" /> 2: <img src="/quicklinks/resource/images.globe.png" /> The Url.Resource() method is now included in MvcContrib as well. Make sure you import the “MvcContrib” namespace in your views. Next, I have to following html to render the quick links: 1: <ul class="links"> 2: <li><a href="http://www.google.com">Google</a></li> 3: <li><a href="http://www.bing.com">Bing</a></li> 4: <li><a href="http://www.yahoo.com">Yahoo</a></li> 5: </ul> Notice the <ul> tag has a class called “links”. This is defined inside my QuickLinks.css file and looks like this: 1: ul.links li 2: { 3: background: url(/quicklinks/resource/images.navigation.png) left 4px no-repeat; 4: padding-left: 20px; 5: margin-bottom: 4px; 6: } On line 3 we’re able to refer to the url for the background property. As a final note, although we already have complete control over the location of the embedded resources inside the assembly, what if we also want control over the physical URL routes as well. This point was raised by John Nelson in this post. This has been taken into account as well. For example, suppose you want your physical url to look like this: 1: <img src="/quicklinks/images/globe.png" /> instead of the same corresponding URL shown above (i.e., “/quicklinks/resources/images.globe.png”). You can do this easily by specifying another route for it which includes a “resourcePath” parameter that is pre-pended. Here is the complete code for the area registration with the custom route for the images shown on lines 9-11: 1: public class QuickLinksRegistration : PortableAreaRegistration 2: { 3: public override void RegisterArea(System.Web.Mvc.AreaRegistrationContext context, IApplicationBus bus) 4: { 5: context.MapRoute("ResourceRoute", "quicklinks/resource/{resourceName}", 6: new { controller = "EmbeddedResource", action = "Index" }, 7: new string[] { "MvcContrib.PortableAreas" }); 8:   9: context.MapRoute("ResourceImageRoute", "quicklinks/images/{resourceName}", 10: new { controller = "EmbeddedResource", action = "Index", resourcePath = "images" }, 11: new string[] { "MvcContrib.PortableAreas" }); 12:   13: context.MapRoute("quicklink", "quicklinks/{controller}/{action}", 14: new {controller = "links", action = "index"}); 15:   16: this.RegisterAreaEmbeddedResources(); 17: } 18:   19: public override string AreaName 20: { 21: get 22: { 23: return "QuickLinks"; 24: } 25: } 26: } The Quick Links portable area results in the following requests (including custom route formats): The complete code for this post is now included in the Portable Areas sample solution in the latest MvcContrib source code. You can get the latest code now.  Portable Areas open up exciting new possibilities for MVC development!

    Read the article

  • Une nouvelle version de Google Docs arrive, axée sur le travail collaboratif en temps réel

    Mise à jour du 13.04.2010 par Katleen Une nouvelle version de Google Docs arrive, axée sur le travail collaboratif en temps réel Google Enterprise a annoncé ce matin une refonte de l'infrastructure de Google Documents lui permettant d'offrir des fonctionnalités plus riches plus rapidement, telles que les fonctionnalités de mise en page (fidélité de l'import d'un document). Cette mise à jour signe l'arrivée de la collaboration en temps réel pour le traitement de texte, ainsi que d'un tableur plus réactif et d'un nouvel éditeur de dessins. La suite bureautique en ligne intègre désormais un module de messagerie instantanée et un système de modification en temps réel dans son traite...

    Read the article

  • Do You Care How Fast Your Business Website is? Google Does

    Google - the biggest player in the internet search engine business by far - have many ways that they determine how a certain website ranks within their listing and those criteria keep changing all the time. If you have done a little SEO homework you know that content - fresh, original content - is king but Google have thrown another factor into the mix that you may not think too much about.

    Read the article

  • Custom validator not invoked when using Validation Application Block through configuration

    - by Chris
    I have set up a ruleset in my configuration file which has two validators, one of which is a built-in NotNullValidator, the other of which is a custom validator. The problem is that I see the NotNullValidator hit, but not my custom validator. The custom validator is being used to validate an Entity Framework entity object. I have used the debugger to confirm the NotNull is hit (I forced a failure condition so I saw it set an invalid result), but it never steps into the custom one. I am using MVC as the web app, so I defined the ruleset in a config file at that layer, but my custom validator is defined in another project. However, I wouldn't have thought that to be a problem because when I use the Enterprise Library Configuration tool inside Visual Studio 2008 it is able to set the type properly for the custom validator. As well, I believe the custom validator is fine as it builds ok, and the config tool can reference it properly. Does anybody have any ideas what the problem could be, or even what to do/try to debug further? Here is a stripped down version of my custom validator: [ConfigurationElementType(typeof(CustomValidatorData))] public sealed class UserAccountValidator : Validator { public UserAccountValidator(NameValueCollection attributes) : base(string.Empty, "User Account") { } protected override string DefaultMessageTemplate { get { throw new NotImplementedException(); } } protected override void DoValidate(object objectToValidate, object currentTarget, string key, ValidationResults results) { if (!currentTarget.GetType().Equals(typeof(UserAccount))) { throw new Exception(); } UserAccount userAccountToValidate = (UserAccount)currentTarget; // snipped code ... this.LogValidationResult(results, "The User Account is invalid", currentTarget, key); } } Here is the XML of my ruleset in Validation.config (the NotNull rule is only there to force a failure so I could see it getting hit, and it does): <validation> <type defaultRuleset="default" assemblyName="MyProj.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MyProj.Entities.UserAccount"> <ruleset name="default"> <properties> <property name="HashedPassword"> <validator negated="true" messageTemplate="" messageTemplateResourceName="" messageTemplateResourceType="" tag="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.NotNullValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Not Null Validator" /> </property> <property name="Property"> <validator messageTemplate="" messageTemplateResourceName="" messageTemplateResourceType="" tag="" type="MyProj.Entities.UserAccountValidator, MyProj.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="Custom Validator" /> </property> </properties> </ruleset> </type> </validation> And here is the stripped down version of the way I invoke the validation: var type = entity.GetType() var validator = ValidationFactory.CreateValidator(type, "default", new FileConfigurationSource("Validation.config")) var results = validator.Validate(entity) Any advice would be much appreciated! Thanks, Chris

    Read the article

  • Is the DataTypeAttribute validation working in MVC2?

    - by Wayne
    As far as I know the System.ComponentModel.DataAnnotations.DataTypeAttribute not works in model validation in MVC v1. For example, public class Model { [DataType("EmailAddress")] public string Email {get; set;} } In the codes above, the Email property will not be validated in MVC v1. Is it working in MVC v2? Thanks in advance.

    Read the article

  • PHP strtotime() looks like it is expecting a Euro format

    - by Jason Rhodes
    I've been using PHP's strtotime() method to accept a date field on a form. I love how powerful it is, in how it will accept "Tomorrow", "Next Thursday", or (supposedly) any date representation and convert it to the Unix timestamp. It's been working great -- until yesterday. Someone entered "2-4-10" and instead of logging Feb 4th, 2010, it logged April 10, 2002! So it expected Y-M-D instead of M-D-Y. I thought maybe the problem was just using a 2-digit year, so we tried again with "2-4-2010". That logged April 2nd, 2010! At that point I just don't understand what strtotime() is doing. PHP.net says it expects a US English date format. Why then would it assume D-M-Y? Is there a way around this? Or do I have to stop using strtotime()? Note: I just now did a test. When you use slashes instead of hyphen/dashes, it works fine, even with 2/4/10. Why on earth does that matter? And if that's all it is, should I just run str_replace("-", "/", $input) on the form input before passing it to strtotime()?

    Read the article

  • Python: OSX Library for fast full screen jpg/png display

    - by Parand
    Frustrated by lack of a simple ACDSee equivalent for OS X, I'm looking to hack one up for myself. I'm looking for a gui library that accommodates: Full screen image display High quality image fit-to-screen (for display) Low memory usage Fast display Reasonable learning curve (the simpler the better) Looks like there are several choices, so which is the best? Here are some I've run across: PyOpenGL PyGame PyQT wxpython I don't have any particular experience with any of these, nor any strong desire to become an expert - I'm looking for the simplest solution. What do you recommend? [Update] For those not familiar with ACDSee, here's what it does that I care about: Simple list/thubmnail display of images in a directory Sort by name/size/type Ability to view images full screen Single-key delete while viewing full screen Move to next/previous image while viewing full screen Ability to select a group of images for: move to / copy to directory delete resize ACDSee has a bunch of niceties as well, such as remembering directories you've moved images to in the past, remembering your resize settings, displaying the total size of the images you've selected, etc. I've tried most of the options I could find (including Xee) and none of them quite get there. Please keep in mind that this is a programming/library question, not a criticism of any of the existing tools.

    Read the article

  • How can I overwrite a System.Drawing.Bitmap onto an existing GDI bitmap?

    - by MusiGenesis
    If I have a .Net Bitmap, I can create from it a GDI bitmap by calling the Bitmap's GetHbitmap() method. Bitmap bmp = new Bitmap(100, 100); IntPtr gdiBmp = bmp.GetHbitmap(); This works fine, but every time you call GetHbitmap, Windows has to allocate new memory for the object that gdiBmp references. What I'd like to do - if possible - is write a function (I know PInvoke will be necessary here) that also generates a GDI bitmap copy of a Bitmap, but that uses an existing object instead of allocating a new one. So it would look something like this (if it were an extension method of Bitmap): //void OverwriteHbitmap(IntPtr gdi) Bitmap bmp1 = new Bitmap(100, 100); IntPtr gdi1 = bmp1.GetHbitmap(); Bitmap bmp2 = new Bitmap(100, 100); bmp2.OverwriteHbitmap(gdi1); How can I do this? I assume I'll need to know the structure of a GDI bitmap, and probably I can use LockBits and BitmapData for this, but I'm not sure exactly how.

    Read the article

  • Versioning SharePoint binary Workflow ASPX task forms

    - by Janis Veinbergs
    Hello. As noted by some developers, workflow versioning is somekind of headache in SharePoint. I`m wondering is there a way I can version my aspx forms? For sure, i can version code behind assemblies, but if markup changes for any of my files in LAYOUTS folder? Is there versioning available for files or do i have to choose new filename for my form? Sorry, i should have been more specific. Yes, i have files under version control (i can restore previous versions etc), but i`m not talking about this kind of version control. But by deploying new Workflow Version, i must not delete old one, because it is still running on many items in SharePoint, but rather , as noted in previous links, deploy new one so i don't break execution of workflows. But workflows will still break if i don't preserve old aspx forms used by users to interact with workflows. So i must ensure that Assemblies with old version numbers used by old workflow exists (this one is ok, i just changed assembly version number and deployed to GAC) I must ensure that old workflow still uses old aspx form used users to interact with workflow, but new workflow version should use new aspx form with more options (how to do this?).

    Read the article

  • how to get the http header in asynchronous request mode using ASIHHTTP

    - by user262325
    Hello everyone I hope to display the download file size by reading http header. I know there is way do this: ASIHTTPRequest request = [ASIHTTPRequest requestWithURL:url]; [request startSynchronous]; NSString poweredBy = [[request responseHeaders] objectForKey:@"X-Powered-By"]; NSString *contentType = [[request responseHeaders] objectForKey:@"Content-Type"]; but this is Synchronous mode, in Asynchronous mode it can be done as below: (void)requestFinished:(ASIHTTPRequest *)request { unsigned long long contentLength = [request contentLength]; } but 'requestFinished' is at the end of download. Is there an event to get the http header info at the beginning of download? Thank interdev

    Read the article

  • RS-232 confusion under C++

    - by rock
    What's the problem in given code? Why it is not showing the output for rs232 when we connect it by the d-9 connector with the short of pin number 2 & 3 in that? #include <bios.h> #include <conio.h> #define COM1 0 #define DATA_READY 0x100 #define SETTINGS ( 0x80 | 0x02 | 0x00 | 0x00) int main(void) { int in, out, status; bioscom(0, SETTINGS, COM1); /*initialize the port*/ cprintf("Data sent to you: "); while (1) { status = bioscom(3, 0, COM1); /*wait until get a data*/ if (status & DATA_READY) if ((out = bioscom(2, 0, COM1) & 0x7F) != 0) /*input a data*/ putch(out); if (kbhit()) { if ((in = getch()) == 27) /* ASCII of Esc*/ break; bioscom(1, in, COM1); /*output a data*/ } } return 0; }

    Read the article

  • C++ Greatest Number Verification

    - by Daniel
    Hey guys, I was assigned to create a program that creates n arrays composed by 10 random integers. The the program should sum all the integers and display the result. After, it has to verify which of the sums is the greatest and it has to display that array and the result. Im having troubles getting it done and would like to get some help! Thanks once again. Here is my code so far: #include <iostream> #include <iomanip> #include <cmath> using namespace std; double random(unsigned int &seed); unsigned int seed = 5; void generateData(int set[10]); int sumData(int set[10]); void checkData(int sumResult, int arrayNumber); int main (int argc, char * const argv[]) { int arrayNumber, sumResult; int set[10]; do { cout << "Number of Arrays to Compare: " << endl; cin >> arrayNumber; } while (arrayNumber < 0); for (int i = 0; i < arrayNumber; ++i) { generateData(set); sumResult = sumData(set); cout << "Sum --> " << sumResult << endl; checkData(sumResult, arrayNumber); } return 0; } double random(unsigned int &seed) { const int MODULUS = 15749; const int MULTIPLIER = 69069; const int INCREMENT = 1; seed = ((MULTIPLIER * seed) + INCREMENT) % MODULUS; return double(seed) / double(MODULUS); } void generateData(int set[10]) { for (int i = 0; i < 10; ++i) { set[i] = int (5 + 6 * random(seed)); cout << set[i] << " || "; } } int sumData(int set[10]) { int sumTotal = 0; for (int i = 0; i < 10; ++i) sumTotal = sumTotal + set[i]; return sumTotal; } void checkData(int sumResult, int arrayNumber) { int largerNumber; int tempSet[2]; for (int i = 0; i < arrayNumber; ++i) { if (sumResult > largerNumber) { tempSet[i] = sumResult; } } }

    Read the article

  • How do I draw a proper parallelogram that can be animated on iPhone?

    - by Robert Kosara
    I'm trying to do something very simple: I need some parallelograms in my program. These are attached to other objects, all of which are UIViews. It's important that I be able to animate these, since the objects they are attached to can also be animated. I've figured out how to use the transform in UIView/CALayer to do this, but the problem is that these sheared UIViews don't look very nice: there is no anti-aliasing of the edges. Is there some other way to do this? I would like to use UIViews, since I also use them for user interaction and animation is so much easier than drawing by hand. I don't want to use OpenGL for this.

    Read the article

  • Tip 16 : Open Multiple Documents within Single Application Instance Using C#

    - by StanleyGu
    1.       Using Microsoft Word 2007 as an example, you can open test1.docx and test2.docx at same time. The two documents are opened within single instance of the word application. World application supports command line argument of passing multiple documents. 2.       Again, Using Microsoft Word 2007 as an example, you can open test1.docx first and then test2.docx. The two documents are opened within single instance of the Word application. Word application supports Multiple Document Interface (MDI). 3.       Using Notepad as an example, you receive error message of “The filename, directory name, or volume label syntax is incorrect” if you want to open two documents at the same time. Notepad does not support command line argument of passing multiple documents 4.       Again, using Notepad as an example, you can open test1.txt first and then test2.txt. The two documents are opened to two different instances of Notepad application. Notepad does not support Multiple Document Interface (MDI). 5.       In conclusion, there is nothing you can do trying to rely on System.Diagnostics.Process class to open multiple documents within a single instance of an application because it is controlled by the application itself. The best approach is to read any developer or user guide of the application and make sure: 1. The application supports Multiple Document Interface (MDI) 2. The application provides command line argument of passing multiple documents. Then, you can use Process class and the command line argument syntax to open multiple documents for the application.  

    Read the article

  • How do I export calendar events in Mozilla lightning

    - by Andrew Grimm
    How do I export calendar events in Mozilla Lightning? I'm using Thunderbird 3.0.4. (Sorry for such a basic question, but clicking on "Help contents" takes me to http://support.mozillamessaging.com/en-US/kb/ , and searching the knowledge base for lightning export got zero hits, and searching for export only got one irrelevant hit)

    Read the article

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