Daily Archives

Articles indexed Friday April 2 2010

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

  • Programming pattern to flatten deeply nested ajax callbacks?

    - by chiborg
    I've inherited JavaScript code where the success callback of an Ajax handler initiates another Ajax call where the success callback may or may not initiate another Ajax call. This leads to deeply nested anonymous functions. Maybe there is a clever programming pattern that avoids the deep-nesting and is more DRY. jQuery.extend(Application.Model.prototype, { process: function() { jQuery.ajax({ url:myurl1, dataType:'json', success:function(data) { // process data, then send it back jQuery.ajax({ url:myurl2, dataType:'json', success:function(data) { if(!data.ok) { jQuery.ajax({ url:myurl2, dataType:'json', success:mycallback }); } else { mycallback(data); } } }); } }); } });

    Read the article

  • FluentNHibernate Overrides: UseOverridesFromAssemblyOf non-generic version

    - by ThiagoAlves
    Hi, I have a repository class that inherits from a generic implementation: public namespace RepositoryImplementation { public class PersonRepository : Web.Generics.GenericNHibernateRepository<Person> } The generic repository implementation uses Fluent NHibernate conventions. They're working fine. One of those conventions is that all properties are not nullable. Now I need to define that specific properties may be nullable outside the conventions. Fluent NHibernate has an interesting override mechanism: public namespace RepositoryImplementation { public class PersonMappingOverride : IAutoMappingOverride<Person> { public void Override(FluentNHibernate.Automapping.AutoMapping<Funcionario> mapping) { mapping.Map(x => x.PhoneNumber).Nullable(); } } } Now I need to register the override class into Fluent NHibernate. I have the following code in the Web.Generics.GenericNHibernateRepository generic class: AutoMap.AssemblyOf<Person>() .Where(type => type.Namespace == "Entities") .UseOverridesFromAssemblyOf<PersonMappingOverride>(); The problem is: UseOverridesFromAssemblyOf is a generic method, and I can't do something like that: .UseOverridesFromAssemblyOf<PersonMappingOverride>(); Because that would cause a circular reference. I don't want the generic repository to know the either repository or the mapping override class, because they vary from project to project. I see another solution: in the GenericNHibernateRepository class I can do this.GetType() and get the repository implementation type (e.g.: PersonRepository). However I can't call UseOverridesFromAssemblyOf() passing a type. Is there another way to configure overrides in FluentNHibernate? If not, how could I call UseOverridesFromAssemblyOf<T> without making the generic repository depend upon the repository implementation or the mapping override class? (Source: http://wiki.fluentnhibernate.org/Auto_mapping#Overrides)

    Read the article

  • Updating multiple related tables in SQLite

    - by PerryJ
    Just some background, sorry so long winded. I'm using the System.Data.SQLite ADO.net adapter to create a local sqlite database and this will be the only process hitting the database, so I don't need to worry about concurrency. I'm building the database from various sources and don't want to build this all in memory using datasets or dataadapters or anything like that. I want to do this using SQL (DdCommands). I'm not very good with SQL and complete noob in sqlite. I'm basically using sqlite as a local database / save file structure. The database has a lot of related tables and the data has nothing to do with People or Regions or Districts, but to use a simple analogy, imagine: Region table with auto increment RegionID, RegionName column and various optional columns. District table with auto increment DistrictID, DistrictName, RegionId, and various optional columns Person table with auto increment PersonID, PersonName, DistrictID, and various optional columns So I get some data representing RegionName, DistrictName,PersonName, and other Person related data. The Region, District and/or Person may or may not be created at this point. Once again, not being the greatest with this, my thoughts would be something like: Check to see if Region exists and if so get the RegionID else create it and get RegionID Check to see if District exists and if so get the DistrictID else create it adding in RegionID from above and get DistrictID Check to see if Person exists and if so get the PersonID else create it adding in DistrictID from above and get PersonID Update Person with rest of data. In MS SQL Server I would create a stored procedure to handle all this. Only way I can see to do this with sqlite is a lot of commands. So I'm sure I'm not getting this. I've spent hours looking around on various sites but just don't feel like I'm going down the right road. Any suggestions would be greatly appreciated.

    Read the article

  • How can I test Xcode Project on iPhone ?

    - by Khawar
    I have developed a view based project in XCode. It is successfully running in iPhone Simulator. But I want to test this project on real iPhone device to check the behavior of application. Is there any way I can test my application on iPhone device without buying Apple Developer's License? Thanks in advance.

    Read the article

  • Converting HTML to plain text in PHP for e-mail

    - by jstayton
    I use TinyMCE to allow minimal formatting of text within my site. From the HTML that's produced, I'd like to convert it to plain text for e-mail. I've been using a class called html2text, but it's really lacking in UTF-8 support, among other things. I do, however, like that it maps certain HTML tags to plain text formatting — like putting underscores around text that previously had <i> tags in the HTML. Does anyone use a similar approach to converting HTML to plain text in PHP? And if so: Do you recommend any third-party classes that I can use? Or how do you best tackle this issue? Thanks!

    Read the article

  • Element 1.1 for home theater PCs

    <b>LWN.net:</b> "Element is a lightweight Linux distribution for use on a home theater PC (HTPC). It comes with most of the same video-playback applications one would find in a modern desktop distribution, but the development team has put considerable effort into wrapping the applications in an environment that is easy to navigate from across the room..."

    Read the article

  • Question for Vim search and peck typists

    - by mike
    I'm trying to write a Vim tutorial and I'd like to start by dismissing a few misconceptions, as well as giving some recommendations. I don't know if I should dismiss touch-typing as a misconception, or include it as a recommended prerequisite. At the time I learned the editor, I had already been touch typing for a couple of years, so I have absolutely no idea what would be the experience of a two-fingered typist in Vim. Are you a vim two-fingered typist? what has your experience been like? EDIT: I'm not sure if my question was clear enough. Maybe it's my fault, I don't know. I get mixed replies and other questions (why do you write this? what does one have to do with the other?), instead of empirical info (I don't touch type and it's been (fine|hell)). Some programmers touch-type others search and peck. In the middle, there's Vim which requires a certain affinity with keys to do various operations. I am a touch typist and I have no clue what my experience would have been like with the editor if I wasn't. I can't honestly picture myself pecking some of these combos. But like I said, I don't know what it is like. Before telling someone to start using Vim, I'd like to know if I should dismiss touch-typing as a misconceived requirement. So, I'll rephrase the question, have you felt that not being a touch-typist has impeded on your experience with Vim?

    Read the article

  • ASP.NET MVC Custom Profile Provider

    - by Ben Griswold
    It’s been a long while since I last used the ASP.NET Profile provider. It’s a shame, too, because it just works with very little development effort: Membership tables installed? Check. Profile enabled in web.config? Check. SqlProfileProvider connection string set? Check.  Profile properties defined in said web.config file? Check. Write code to set value, read value, build and test. Check. Check. Check.  Yep, I thought the built-in Profile stuff was pure gold until I noticed how the user-based information is persisted to the database. It’s stored as xml and, well, that was going to be trouble if I ever wanted to query the profile data.  So, I have avoided the super-easy-to-use ASP.NET Profile provider ever since, until this week, when I decided I could use it to store user-specific properties which I am 99% positive I’ll never need to query against ever.  I opened up my ASP.NET MVC application, completed steps 1-4 (above) in about 3 minutes, started writing my profile get/set code and that’s where the plan broke down.  Oh yeah. That’s right.  Visual Studio auto-generates a strongly-type Profile reference for web site projects but not for ASP.NET MVC or Web Applications.  Bummer. So, I went through the steps of getting a customer profile provider working in my ASP.NET MVC application: First, I defined a CurrentUser routine and my profile properties in a custom Profile class like so: using System.Web.Profile; using System.Web.Security; using Project.Core;   namespace Project.Web.Context {     public class MemberPreferencesProfile : ProfileBase     {         static public MemberPreferencesProfile CurrentUser         {             get             {                 return (MemberPreferencesProfile)                     Create(Membership.GetUser().UserName);             }         }           public Enums.PresenceViewModes? ViewMode         {             get { return ((Enums.PresenceViewModes)                     ( base["ViewMode"] ?? Enums.PresenceViewModes.Category)); }             set { base["ViewMode"] = value; Save(); }         }     } } And then I replaced the existing profile configuration web.config with the following: <profile enabled="true" defaultProvider="MvcSqlProfileProvider"          inherits="Project.Web.Context.MemberPreferencesProfile">        <providers>     <clear/>     <add name="MvcSqlProfileProvider"          type="System.Web.Profile.SqlProfileProvider, System.Web,          Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"          connectionStringName="ApplicationServices" applicationName="/"/>   </providers> </profile> Notice that profile is enabled, I’ve defined the defaultProvider and profile is now inheriting from my custom MemberPreferencesProfile class.  Finally, I am now able to set and get profile property values nearly the same way as I did with website projects: viewMode = MemberPreferencesProfile.CurrentUser.ViewMode; MemberPreferencesProfile.CurrentUser.ViewMode = viewMode;

    Read the article

  • How do I check if my program has data piped into it.

    - by monkeyking
    Im writing a program that should read input via stdin, so I have the following contruct. FILE *fp=stdin; But this just hangs if the user hasn't piped anything into the program, how can I check if the user is actually piping data into my program like gunzip -c file.gz |./a.out #should work ./a.out #should exit program with nice msg. thanks

    Read the article

  • How bad is code using std::basic_string<t> as a contiguous buffer?

    - by BillyONeal
    I know technically the std::basic_string template is not required to have contiguous memory. However, I'm curious how many implementations exist for modern compilers that actually take advantage of this freedom. For example, if one wants code like the following it seems silly to allocate a vector just to turn around instantly and return it as a string: DWORD valueLength = 0; DWORD type; LONG errorCheck = RegQueryValueExW( hWin32, value.c_str(), NULL, &type, NULL, &valueLength); if (errorCheck != ERROR_SUCCESS) WindowsApiException::Throw(errorCheck); else if (valueLength == 0) return std::wstring(); std::wstring buffer; do { buffer.resize(valueLength/sizeof(wchar_t)); errorCheck = RegQueryValueExW( hWin32, value.c_str(), NULL, &type, &buffer[0], &valueLength); } while (errorCheck == ERROR_MORE_DATA); if (errorCheck != ERROR_SUCCESS) WindowsApiException::Throw(errorCheck); return buffer; I know code like this might slightly reduce portability because it implies that std::wstring is contiguous -- but I'm wondering just how unportable that makes this code. Put another way, how may compilers actually take advantage of the freedom having noncontiguous memory allows? Oh: And of course given what the code's doing this only matters for Windows compilers.

    Read the article

  • Looking for an automated logging tool/library for .NET!

    - by tsocks
    Hello, I'm looking for an library/tool for .NET that logs almost everything that happens in my C# application (Windows Form). The problem is that I'm delivering an application to a client (Windows XP) and after doing some task, that classic Microsoft error window appears: "ApplicationName has encountered a problem and needs to close. We are sorry for the inconvenience" I'm currently handling my application exceptions, but this is something external and I can't get anything from that error, so I would like any automated library that helps me with that. It would work if it logs each line of code executed, orr just log what line was executing before that error appeared, or something that could give me more info about that error. Thank you! P.S: It's a multithreaded application, and have to Timer controls (one for watching a folder every 5secs, and another for watching thread list...). I'm using Windows 7 here and everything seems to work ok.

    Read the article

  • How can I successfully perform hidden line removal after pass through FBO?

    - by Brett
    Hi All, I'm trying to perform hidden line removal using polygon offset fill. The code works perfectly if I render directly to the window buffer but fails to draw the lines when passed through a FBO as shown below The code I use to draw the objects void drawCubes (GLboolean removeHiddenLines) { glLineWidth(2.0); glPushMatrix(); camera.ApplyCameraTransform(); for(int i = 0; i < 50; i ++){ glPushMatrix(); cube[i].updatePerspective(); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glColor3f(1.0,1.0,1.0); cube[i].draw(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if(removeHiddenLines){ glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1.0, 1.0); glColor3f(1.0, 0.0, 0.0); //fill polygons for hidden line removal cube[i].draw(); glDisable(GL_POLYGON_OFFSET_FILL); } glPopMatrix(); } glPopMatrix(); } For this example, the first pass involves rendering to both the window buffer and a FBO. void firstPass() { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, fboWidth, fboHeight); glEnable(GL_DEPTH_TEST); glDisable(GL_TEXTURE_2D); drawParticleView(GL_TRUE); glDisable(GL_DEPTH_TEST); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID[0]); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, fboWidth, fboHeight); glEnable(GL_DEPTH_TEST); glDisable(GL_TEXTURE_2D); drawParticleView(GL_TRUE); glDisable(GL_DEPTH_TEST); } Second pass renders FBO back to window buffer. void secondPass() { glEnable(GL_TEXTURE_2D); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glBindTexture(GL_TEXTURE_2D, renderTextureID[0]); glViewport(fboWidth, 0, fboWidth, fboHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBegin(GL_QUADS); glTexCoord2i(0, 0); glVertex2f(-1.0f, -1.0f); glTexCoord2i(1, 0); glVertex2f(1.0f, -1.0f); glTexCoord2i(1, 1); glVertex2f(1.0f, 1.0f); glTexCoord2i(0, 1); glVertex2f(-1.0f, 1.0f); glEnd(); glDisable(GL_TEXTURE_2D); } I don't understand why the two views wouldn't be the same? Am I missing something (obviously I am)? Thanks

    Read the article

  • Win32 call order

    - by DD
    Hi all, I have two windows that I send scripted input to. The procedure goes as this BringWindowToTop( window1 ); i = Build input structures( window1 ); SendInput(i); BringWindowToTop( window2 ); i = Build input structures( window2 ); SendInput(i); I was having trouble with inputs not being sent and the correct time. I put delays after each call and saw that input from the first SendInput() was processed after window2 is brought to top. Same thing at the end of the loop as well. Are SendInput calls buffered? If so, how can I make sure of a serial execution of this code? Thanks

    Read the article

  • What things on a job listing should be avoided?

    - by Earlz
    Hello, I'm looking at trying my hand at a bit of freelancing. And looking at some of the listings, I can tell some of them are definitely, obviously wrong. "A web application mimicking youtube. Project must be completed in 2 weeks. Flat payment of $200. If you are not willing to do things this fast paced then do not apply" But some of them are more subtle and they give me a red flag inside, but I'm not sure to avoid them. What are some things in job listings to avoid for freelance programming jobs? What is the reason for avoiding that?

    Read the article

  • Does overloading Grails static 'mapping' property to bolt on database objects violate DRY?

    - by mikesalera
    Does Grails static 'mapping' property in Domain classes violate DRY? Let's take a look at the canonical domain class: class Book {      Long id      String title      String isbn      Date published      Author author      static mapping = {             id generator:'hilo', params:[table:'hi_value',column:'next_value',max_lo:100]      } } or: class Book { ...         static mapping = {             id( generator:'sequence', params:[sequence_name: "book_seq"] )     } } And let us say, continuing this thought, that I have my Grails application working with HSQLDB or MySQL, but the IT department says I must use a commercial software package (written by a large corp in Redwood Shores, Calif.). Does this change make my web application nobbled in development and test environments? MySQL supports autoincrement on a primary key column but does support sequence objects, for example. Is there a cleaner way to implement this sort of 'only when in production mode' without loading up the domain class?

    Read the article

  • how could application installations/configurations be easier in linux? [closed]

    - by ajsie
    although you can do anything in linux it tends to require a lot of tweaking in config files and reading a lot of manuals/tutorials before you can have it running in your way. i know that it gets a lot easier by time, and the apt-get installations with ubuntu/debian is heading the right way. but how can linux be more userfriendly for us in the future? i thought that if more is automated like an IDE environment, eg. typing svn will give us all the commands and description about each command when you move between commands with your keyboard. that would be great. but that's just one example. another is the navigation in the terminal between folders. now you have to type a lot just to jump from/to different folders. would be great with some more automatization here too. i know that these extra features will slow down the server, but its 2010 now, and these features are not that heavy for the cpu, but makes it more userfriendly and encourage maintainance of a server, not frighten u off. what do you think about this? should/could we have more user friendly linux environment in servers, something that has annoyed you a lot? a lot of things are done in the unix way, but maybe we should reinvent the wheel in some areas, cause apparently, its so...repeatingly today and difficult to do easy tasks. it should be easier i think..

    Read the article

  • how could application installations/configurations be easier in linux?

    - by ajsie
    although you can do anything in linux it tends to require a lot of tweaking in config files and reading a lot of manuals/tutorials before you can have it running in your way. i know that it gets a lot easier by time, and the apt-get installations with ubuntu/debian is heading the right way. but how can linux be more userfriendly for us in the future? i thought that if more is automated like an IDE environment, eg. typing svn will give us all the commands and description about each command when you move between commands with your keyboard. that would be great. but that's just one example. another is the navigation in the terminal between folders. now you have to type a lot just to jump from/to different folders. would be great with some more automatization here too. i know that these extra features will slow down the server, but its 2010 now, and these features are not that heavy for the cpu, but makes it more userfriendly and encourage maintainance of a server, not frighten u off. what do you think about this? should/could we have more user friendly linux environment in servers, something that has annoyed you a lot? a lot of things are done in the unix way, but maybe we should reinvent the wheel in some areas, cause apparently, its so...repeatingly today and difficult to do easy tasks. it should be easier i think..

    Read the article

  • Downloading file from server (asp.net) to IE8 Content-Disposition problem with file name

    - by David
    I am downloading a file from the server/database via aspx page. When using the content-disposition inline the document opens in correct application but the file name is the same as the web page. I want the document to open in say MS Word but with the correct file name. Here is the code that I am using Response.Buffer = true; Response.ClearContent(); Response.ClearHeaders(); Response.Clear(); Response.ContentType = MimeType(fileName); //function to return the correct MIME TYPE Response.AddHeader("Content-Disposition", @"inline;filename=" + fileName); Response.AddHeader("Content-Length", image.Length.ToString()); Response.BinaryWrite(image); Response.Flush(); Response.Close(); So again, I want the file to open in MS Word with the correct document file name so that the user can properly save/view. Ideas? thanks

    Read the article

  • How to create a CMS web site using OFBiz

    I need a simple how-to tutorial on developing a simple CMS web site using the OFBiz CMS framework. There are absolutely no documentation of how OFBiz CMS works. Whatever is there in the official website is only about the data model used in OFBiz CMS application. If somebody can illustrate just a "Hello World" like application in OFBiz CMS, it will great help for me. Or can guide me to similar documents in web.

    Read the article

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