Search Results

Search found 406 results on 17 pages for 'dry'.

Page 10/17 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • 0xDEADBEEF equivalent for 64-bit development?

    - by Peter Mortensen
    For C++ development for 32-bit systems (be it Linux, Mac OS or Windows, PowerPC or x86) I have initialised pointers that would otherwise be undefined (e.g. they can not immediately get a proper value) like so: int *pInt = reinterpret_cast<int *>(0xDEADBEEF); (To save typing and being DRY the right-hand side would normally be in a constant, e.g. BAD_PTR.) If pInt is dereferenced before it gets a proper value then it will crash immediately on most systems (instead of crashing much later when some memory is overwritten or going into a very long loop). Of course the behavior is dependent on the underlying hardware (getting a 4 byte integer from the odd address 0xDEADBEEF from a user process may be perfectly valid), but the crashing has been 100% reliable for all the systems I have developed for so far (Mac OS 68xxx, Mac OS PowerPC, Linux Redhat Pentium, Windows GUI Pentium, Windows console Pentium). For instance on PowerPC it is illegal (bus fault) to fetch a 4 byte integer from an odd address. What is a good value for this on 64-bit systems?

    Read the article

  • Can you define <=> in Ruby and then have ==, >, <, >=, and <= defined automatically?

    - by jeremy Ruten
    Here's part of my Note class: class Note attr_accessor :semitones, :letter, :accidental def initialize(semitones, letter, accidental = :n) @semitones, @letter, @accidental = semitones, letter, accidental end def <=>(other) @semitones <=> other.semitones end def ==(other) @semitones == other.semitones end def >(other) @semitones > other.semitones end def <(other) @semitones < other.semitones end end It seems to me like there should be a module that I could include that could give me my equality and comparison operators based on my <=> method. Is there one? I'm guessing a lot of people run into this kind of problem. How do you usually solve it? (How do you make it DRY?)

    Read the article

  • Using one LINQ statement with different parameters

    - by Brettski
    I have a pretty complex linq statement I need to access for different methods. Each of these methods may need to see the resulting data with different parameters. For one method it may be a project code, for another it may be language. The statement is pretty much the same it's just the where part which changes. I have not been able to figure out how to use different where statements without duplicating the entire linq statement, and that just isn't dry enough for me. For example (greatly simplified): var r = from c in customer where c.name == "some name" // or it may be var r = from c in customer where c.customerId == 8 Is there a way to have both of these in the same statement so I can use one or the other based on what I am doing? I tried an if statement to use one of the where statements or the other, and that didn't go over very well.

    Read the article

  • how to organize javascripts using rails and jquery

    - by VP
    Hi, i'm working in a big and rich rails web application using tons of javascript. I would like to know if anybody has a tip to organize the javascripts. Today i'm generating a new file named controller.js and adding it to my views using content_for. The problem is, some files are becoming big and sometimes, i need a function from one controller in another, so then in the end, i add a products.js to a details controller just to keep DRY. Is that solution good? Any other tip? I think the same pattern can be applied as well to css files?

    Read the article

  • Incorporate Wordpress into Kohana 3

    - by alex
    I now need to make a Kohana 3 site have a Wordpress blog. I've seen Kerkness' Kohana For Wordpress, but it seems to be the opposite of what I want. Here are the options I have thought of Style a template to look exactly like the Kohana site (time consuming, non DRY and may not work) Include the blog within an iframe (ugly as all hell) cURL the Wordpress pages in. This of course means I will need to create layers between comment posting, etc, which sounds like too much work. Is there any way I can include a Wordpress blog within an existing Kohana application? Do you have any suggestions? Thanks Update Forgot to mention I have already programmed a model in Kohana to open pages based on their slug. Now I want to put blog content in there, and have the comments and other bits work. I also have installed WP e-Commerce and am wondering if there is any chance I can get that to work.

    Read the article

  • View a git diff-tree in a reasonable format

    - by Josh
    Howdy, I'm about to do a git svn dcommit to our svn repo -- and as is recommended in a number of places, I wanted to figure out exactly what I was going to be committing with a dry run. As such I ran: git svn dcommit -n This produced output: Committing to http://somerepo/svn/branches/somebranch diff-tree 1b937dacb302908602caedf1798171fb1b7afc81~1 1b937dacb302908602caedf1798171fb1b7afc81 How do I view this in a format that I can consume as a human? A list of modified files comes to mind. This is probably easy, but running git diff-tree on those hashes gives me a reference to a directory and a some other hashes, as well as some numbers. Not quite sure what to make of it. Thanks very much, Josh

    Read the article

  • How can I use the same buildscript for Flash Builder 4 and Ant/Mvn?

    - by David Laing
    I'm setting up a build system for a Flash Builder 4 (Flex 4) based project; and I'm struggling to get a setup that compiles in the IDE the same as it does from the command line on the build server. I come from a C# background; and my expectation is that I'll be able to create a "solution" with a collection of "projects" that I can compile from the IDE, or from the command line on the build server. The best I've managed sofar is 2 separate build "scripts", a custom ant script for the build server, and the default Flash Builder IDE config based on a workspace; but this is making my DRY daemons jump around in fury. Please can someone point me in the right direction :)

    Read the article

  • Accessing the DI container from anywhere

    - by ChrisR
    I've implemented the Symfony2 Dependency Injection container in my Zend Framework project and it works fine in the MVC layer of my application. I've initialized the DIC in my bootstrap and can access it anywhere by calling: Zend_Controller_Front::getInstance()->getParam('bootstrap')->getDic() The problem is that there are some parts of my application that do not utilize the Zend Framework application/MVC layer. My CLI tools for example. I could perfectly initialize a new DIC there but that would just be some copy paste work from the Bootstrap file which is asking for trouble down the road (DRY principles, etc) Is it a better solution to make my DIC available in the Zend_Registry or as a singleton called by a static method DIC::getInstance() for example? I know Registry and singletons are considered bad things but the DIC is such a high level part of the application that I will probably never run into the problems that make it a bad thing. Is this a good solution or are there better ways of accomplishing a globally accessible DIC?

    Read the article

  • Use delegate for Projection in Linq to SQL

    - by Redeemed1
    I have code something like this in an IRepository implementation in Linq to Sql: var newlist = from h in list where h.StringProp1 == "1" select new MyBusinessBO{ firstProp = h.StringProp1, secondProp = h.StringProp2 }; The projection into MyBusinessBO is not difificult but when the Business Object has many properties the projection code becomes very lengthy. Also, as the projection can occur in several places in the Repository we break the DRY principle. Is there any way to abstract out the projection or replace it with a delegate? I.e. replace the code firstProp = h.StringProp1, secondProp = h.StringProp2 with something reusable?

    Read the article

  • Scaffold default files are the best practice?

    - by antpaw
    Hey, i have some experience with MVC. but I'm new to rails. I'm using the scaffold command to generate some default files. The model looks clean and nice, but the controller and the views aren't really dry. The contents of new.html.erb and edit.html.erb are almost the same and the methods new/edit and create/update are doing almost the same thing. In other frameworks i've used only one view for updating and creating new entries and also the same method in my controller by setting the id as an optional parameter. Do they use this structure to keep things RESTful (i have not much of a clue about rest :()? Is it the best practice to use this default stuff for crud?

    Read the article

  • Zend Framework - Database Table Singleton

    - by Sonny
    I have found myself doing this in my code to 'cache' the work done when instantiating my Zend_Db_Table models: if (Zend_Registry::isRegistered('x_table')) { $x_table = Zend_Registry::get('x_table'); } else { $x_table = new Default_Model_DbTable_X; Zend_Registry::set('x_table', $x_table); } It bothered me that this method isn't very DRY and it dawned on me today that a singleton pattern would probably be a better way to do this. Problem is, I've never written a singleton class. When I did some web searches, I found some offhand comments about Zend_Db_Table singletons, but no real examples. I already have meta-data caching configured. How do I make my Zend_Db_Table models singletons? Are there pitfalls or downsides?

    Read the article

  • Best way to structure AJAX for a Zend Framework application

    - by John Nall
    Sorry, but there's a lot of outdated and just plain bad information for Zend Framework, since it has changed so much over the years and is so flexible. I thought of having an AJAX module service layer, with controllers and actions that interact with my model. Easy, but not very extensible and would violate DRY. If I change the logistics of some process I'll have to edit the AJAX controllers and the normal controllers. So ideally I would load the exact same actions for both javascript and non-javascript users. I have thought about maybe checking for $_POST['ajax'], if it is set I would load a different (json'y) view for the data. Was wondering how/a good way to do this (front controller plugin I imagine?) or if someone can point me to an UP TO DATE tutorial that describes a really good way for building a larger ajax application. thx

    Read the article

  • What is the chance a CouchDB document update handler will get a revision conflict?

    - by jhs
    How likely is a revision conflict when using an update handler? Should I concern myself with conflict-handling code when writing a robust update function? As described in Document Update Handlers, CouchDB 0.10 and later allows on-demand server-side document modification. Update handlers can process non-JSON formats; but the other major features are these: An HTTP front-end to arbitrarily complex document modification code Similar code needn't be written for all possible clients—a DRY architecture Execution is faster and less likely to hit a revision conflict I am unclear about the third point. Executing locally, the update handler will run much faster and with lower latency. But in situations with high contention, that does not guarantee a successful update. Or does the update handler guarantee a successful update?

    Read the article

  • How to read tags out of m4a files in .NET?

    - by dkackman
    I've got some heavily modified code that ultimately came from the Windows Media SDK that works great for reading tags out of MP3 and WMV files. Somewhere along the line, Windows Media Player added support for .m4a files (was it in Windows 7?) but the Windows Media API doesn't seem to reflect that addition (or at least IWMMetadataEditor2::OpenEx pukes on an .m4a file). What would be some good C# code or links on how to dig meta data tags out of m4a files? (Google has come up dry on the C# front.) UPDATE AtomicParsley did indeed end being the best approach. Since that code is a command line tool however I ended up having to create a managed wrapper around some of its functionality in order to use in-process. It is posted on google code if anyone else needs such a thing.

    Read the article

  • Equivalent of Switch Statement in MySql 5

    - by Robert Gowland
    Using MySql 5, I have a task where I need to update one table based on the contents of another table. For example, I need to add 'A1' to table 'A' if table 'B' contains 'B1'. I need to add 'A2a' and 'A2b' to table 'A' if table 'B' contains 'B2', etc.. In our case, the value in table 'B' we're interested is an enum. Right now I have a stored procedure containing a series of statements like: INSERT INTO A SELECT 'A1' FROM B WHERE B.Value = 'B1'; --Repeat for 'B2' -> 'A2a', 'A2b'; 'B3' -> 'A3', etc... Is there a nicer more DRY way of accomplishing this?

    Read the article

  • Proxy object references in MVC code

    - by krystan honour
    Hi there, I am just figuring out best practice with MVC now I have a project where we have chosen to use it in anger. My question is. If creating a list view which is bound to an IEnumerable is this bad practise? Would it be better to seperate the code generated by the WCF Service reference into a datastructure which essentially holds the same data but abstracts further from the service, meaning that the UI is totally unaware of the service implementation beneath. or do people just bind to the proxy object types and have done with it ? My personal feeling is to create an abstraction but this seems to violate the DRY principle.

    Read the article

  • Get absolute (base) url in sinatra.

    - by berkes
    Right now, I do a get '/' do set :base_url, "#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}" # ... haml :index end to be able to use options.base_url in the HAML index.haml. But I am sure there is a far better, DRY, way of doing this. Yet I cannot see, nor find it. (I am new to Sinatra :)) Somehow, outside of get, I don't have request.env available, or so it seems. So putting it in an include did not work. How do you get your base url?

    Read the article

  • Rails Named Scope and overlapping conditions

    - by Tumtu
    Hi everyone, have a question about rails SQL generation: class Organization < ActiveRecord::Base has_many :people named_scope :active, :conditions => { :active => 'Yes' } end class Person < ActiveRecord::Base belongs_to :organization end Rails SQL for all active people in the first organiztion Organization.first.people.active.all [4;36;1mOrganization Load (0.0ms)[0m [0;1mSELECT TOP 1 * FROM [organizations] [0m [4;35;1mPerson Load (0.0ms)[0m [0mSELECT * FROM [people] WHERE ((([people].[active] = 'Yes') AND ([people].organization_id = 1)) AND ([people].organization_id = 1)) [0m Why Rails generates "[people].organization_id = 1" condition twice ? Does someone know how to make it DRY ? e.g. SELECT * FROM [people] WHERE (([people].[active] = 'Yes') AND ([people].organization_id = 1))

    Read the article

  • Is there a method I can use across controllers and if so, how do I use it?

    - by Angela
    I have several controllers that take an instance of different classes each (Email, Call, Letter, etc) and they all have to go through this same substitution: @email.message.gsub!("{FirstName}", @contact.first_name) @email.message.gsub!("{Company}", @contact.company_name) @email.message.gsub!("{Colleagues}", @colleagues.to_sentence) @email.message.gsub!("{NextWeek}", (Date.today + 7.days).strftime("%A, %B %d")) @email.message.gsub!("{ContactTitle}", @contact.title ) So, for example, @call.message for Call, @letter.message for Letter, etcetera. This isn't very dry. I'd like to have something like def messagesub(asset) @asset.message.gsub.... end or something like that so I can just use messagesub method in each controller.

    Read the article

  • What do you read?

    - by sixtyfootersdude
    I have almost finished reading all the articles on Joel on software. I am a new developer and hoping to get something interesting to read. Here is what is currently on my list: Java Concurrency in Practice by Brian Goetz sed & awk by Dougherty & Robbins (O'Reilly) The Pragmatic Programmer by Andrew Hunt and David Thomas Head First Design Patterns Can anyone suggest anything else? Would especially like something similar to Joel. Something that is a bit edgy but informative. Pragmatic programmer has some key concepts but is a bit dry.

    Read the article

  • Google App Engine - Document Editor Creation/Tap Into Google Docs?

    - by Josh Patton
    What is the best way to create a custom document editor in GAE? I'm making a website meant for a School Robotics Club (With support for any other organization - DRY). We currently use Google services for online collaboration, I'm wondering if there is a way to tap into Google Docs and allow users to edit a Google Document without using Google Accounts or the Google Doc interface. If that is not possible (I've researched and I don't think it is), what is the best way to make a document editor? I want it completely on the website I'm creating, so I'm assuming just some javascript editor like TinyMCE + Ajax + Datastore. Is their anything that replicates Google Doc's/Microsoft Offices's/OpenOffice.org's feature set as far as fonts, spacing, alignment, justification, etc.?

    Read the article

  • What's the right way to handle "One, Both, or None" logic?

    - by Stephen
    I have a logic situation that is best described as two "Teams" trying to win a task. The outcome of this task could be a single winner, a tie (draw), or no winner (stalemate). Currently, I'm using a nested if/else statement like so: // using PHP, but the concept seems language agnostic. if ($team_a->win()) { if ($team_b->win()) { // this is a draw } else { // team_a is the winner } } else { if ($team_b->win()) { // team_b is the winner } else { // This is a stalemate, no winner. } } This seems rather spaghetti-like and repetitive. Is there a more logical, DRY pattern I could use?

    Read the article

  • Is passing a Command object/Reader to a function a good idea?

    - by Cyril Gupta
    I've been getting some inexplicable errors (running out of connections from the connection pool) with MySql database with .Net 4 (C#). Till now all my attempts at finding a reason for this have been in vain. Now I also have a situation in which a lock on a table is not cleared for a long time even though all I have been doing is read operations from it. My code looks okay (I've put all readers and connections in using blocks). The only anomaly I have is that I've been passing MySqlCommand and MySqlDataReader objects as parameters to functions who work with them. That doesn't seem like a bad idea for me because it avoids some repetition (DRY!). But since I can't find any other explanation I have to suspect that this is causing the problem. What do you think?

    Read the article

  • Overriding the default error message for a ModelForm

    - by Jude Osborn
    Is there any way to override a error_message text for all the fields of a ModelForm's, without having to include all the field info in the ModelForm? For example, let's say I have a (very simple) model like this: People(models.Model): name = models.CharField(max_length=128, null=True, blank=True, help_text="Please type your name.") age = models.IntegerField(help_text="Please type your age.") I don't like the cut and dry default messages, such as, "Enter a whole number.", so I'd like to change them to something a bit nicer like "Please type a number." Ideally I'd be able to add an "error_message" property in the model, but the model does not support that property. So does that mean I have to basically duplicate all the model info in my ModelForm, or is there a way around that?

    Read the article

  • Creating a Better Tabbed Interface in Django

    - by ygd
    I've been trying to create a tabbed interface using Django. The current effort (which works fine) is having each template have the header hard-coded in, with the selected tab given the "selected" CSS attribute. Of course, this is a massive violation of DRY and I'm looking to remedy it. My current idea is adding a jQuery script to the page that looks at all the tabs and sets one to "selected" if it's text matches the beginning of the title for the page. Is there a better way to do this without using JavaScript and just pure CSS?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >