Search Results

Search found 1524 results on 61 pages for 'elegant'.

Page 15/61 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • How do you make cin typesafe?

    - by cactusbin
    It is well known that cin is not typesafe (e.g. cin integer; and entering "fifty five" will cause it to flip out). I have seen many not-so-elegant ways to hand this, such as getlining a string and using sstream to convert it to a number, or looping with cin.fail() and clearing the stream and reentering it, etc. Is there any library or anyway to overload the inserter operator to make cin automatically typesafe?

    Read the article

  • How to catch an exception and email information about it in liferay portlet

    - by heikkim
    I have a custom portlet made for liferay and sometimes it throws an exception. Why it throws exceptions is irrelevant. How to catch exceptions thrown by portlet handler methods in order to email information about them? I know I could do try catching on every handler method but it would be a much more elegant and cleaner solution to catch the exception on a higher level and just email some information about the error. I'm using Spring Portlet MVC, so i got all spring-related niceties at hand.

    Read the article

  • Converting an empty string into nil in Ruby

    - by adi92
    I have a string called word and a function called infinitive such that word.infinitive would return another string on some occasions and an empty string otherwise I am trying to find an elegant ruby one line expression for the code-snippet below if word.infinitive == "" return word else return word.infinitive Had infinitive returned nil instead of "", I could have done something like (word.infinitive or word) But since it does not, I can't take advantage of the short-circuit OR Ideally I would want 1) a single expression that I could easily embed in other code 2) the function infinitive being called only once 3) to not add any custom gems or plugins into my code

    Read the article

  • Javascript Namespace Declaration

    - by objektivs
    What neat ways do you use for declaring JavaScript namespaces. I've come across this one: if (Foo == null || typeof(Foo) != "object") { var Foo = new Object();} Is there a more elegant or succinct way of doing this? Just a bit of fun...

    Read the article

  • Peek ahead when iterating an array in PHP 5.2

    - by pako
    Is it possible to "peek ahead" while iterating an array in PHP 5.2? For example, I often use foreach to manipulate data from an array: foreach($array as $object) { // do something } But I often need to peek at the next element while going through the array. I know I could use a for loop and reference the next item by it's index ($array[$i+1]), but it wouldn't work for associative arrays. Is there any elegant solution for my problem, perhaps involving SPL?

    Read the article

  • DataMapper: Create new record or update existing

    - by John Topley
    Does DataMapper provide a convenient way to create a new record when none exists or update an existing one? I couldn't find anything in the API documentation. This is what I have at the moment which doesn't seem very elegant: foo = Foo.get(id) if foo.nil? foo = Foo.create(#attributes...) else foo.update(#attributes...) end foo.save

    Read the article

  • How to iterate with Selenium RC over XPath results directly?

    - by Gj
    I'm currently resorting to first doing a get_xpath_count, and then creating a loop incrementing an index variable, which in turn I inject back into the original xpath to select the nth result... very awkward no doubt. Is there some simple, direct, elegant way to iterate directly over the xpath results? Thanks!

    Read the article

  • Get a random subset from a set in F#

    - by Cay
    I am trying to think of an elegant way of getting a random subset from a set in F# Any thoughts on this? Perhaps this would work: say we have a set of 2x elements and we need to pick a subset of y elements. Then if we could generate an x sized bit random number that contains exactly y 2n powers we effectively have a random mask with y holes in it. We could keep generating new random numbers until we get the first one satisfying this constraint but is there a better way?

    Read the article

  • awk/sed/bash to merge/concatenate data

    - by Kyle
    Trying to merge some data that I have. The input would look like so: foo bar foo baz boo abc def abc ghi And I would like the output to look like: foo bar baz boo abc def ghi I have some ideas using some arrays in a shell script, but I was looking for a more elegant or quicker solution.

    Read the article

  • Convert Int List Into Integer

    - by Kezzer
    This is a bit of an odd case I must admit, but I'm trying to find a succinct and elegant way of converting a List<int> into an actual int. For example, if my list contained entries 1, 2, and 3, then the final integer would be 123. The only other way I thought of doing it was converting the array to a string and then parsing the string. Any hints?

    Read the article

  • How significant are JPA lazy loading performance benefits?

    - by Robert
    I understand that this is highly specific to the concrete application, but I'm just wondering what's the general opinion, or at least some personal experiences on the issue. I have an aversion towards the 'open session in view' pattern, so to avoid it, I'm thinking about simply fetching everything small eagerly, and using queries in the service layer to fetch larger stuff. Has anyone used this and regretted it? And is there maybe some elegant solution to lazy loading in the view layer that I'm not aware of?

    Read the article

  • How do I make the "back button" work with jQuery hide/show functions?

    - by Walker
    I'm looking for a way to append text to the url with jQuery so that the back button is not broken when a user loads new content with jQuery. For example, I have a three step form - the first step is (www.xyz.com/form-1). When the user clicks next step, jQuery slides in the next page. I would like that page to be (www.xyz.com/form-2). I know websites like hypem.com do this, I'm just looking for an elegant way to handle it.

    Read the article

  • Sharing authentication between forum and main CMS in Rails

    - by Newy
    I have a Rails forum product that resides under the subdomains of my customers (i.e. http://forum.customer.com). Their main site has a CMS and an authentication system, and my forum product has a separate authentication system. Is there an elegant way to have "cross-signins" across these systems? I want someone already logged into the main CMS to seamlessly (as possible) transition into my product.

    Read the article

  • C++ to python communication. Multiple io streams?

    - by Dennis Kempin
    A python program opens a new process of the C++ program and is reading the processes stdout. No problem so far. But is it possible to have multiple streams like this for communication? I can get two if I misuse stderr too, but not more. Easy way to hack this would be using temporary files. Is there something more elegant that does not need a detour to the filesystem? PS: *nix specific solutions are welcome too

    Read the article

  • How do I set selection to Nothing when programming Excel using VBA?

    - by Curt
    When I create a graph after using range.copy and range.paste it leaves the paste range selected, and then when I create a graph a few lines later, it uses the selection as the first series in the plot. I can delete the series, but is there a more elegant way to do this? I tried Set selection = nothing but it won't let me set selection. I also tried selection.clear, but that just cleared the last cells that were selected, and still added an extra series to the plot. Curt

    Read the article

  • How to run an "empty" Windows Application that only has a NotifyIcon?

    - by devoured elysium
    I want to make an Application that only has a NotifyIcon. It doesn't need to have at all a "Main" Form. When I want to achieve something like this, I just create an invisible form and run it, but would there be a more "elegant" way of doing this, I'd like to know it. How do you generally do this? This application can't be a Windows Service, as having the NotifyIcon and its Context Menus is important (each one of them will run a different command). Thanks

    Read the article

  • how to separate debug and release mode code

    - by john
    during debug mode or while i am doing testing, i need to print lost of various information, so i use this method ifdef TESTING // code with lots of debugging info else // clean code only endif // TESTING` Is this the good method, or is there any other simple and elegant method. But this way, I am repating the same code in two places and if anything is to be changed later on in the code, I have to do it in both places, which is time consuming and error prone. Thanks. I am using MS Visual Studio.

    Read the article

  • Abstract attributes in Python

    - by deamon
    What is the shortest / most elegant way to implement the following Scala code with an abstract attribute in Python? abstract class Controller { val path: String } A subclass of Controller is enforced to define "path" by the Scala compiler. A subclass would look like this: class MyController extends Controller { override val path = "/home" }

    Read the article

  • autoloading folder ZendX_JQuery and others

    - by explorex
    Hi, I am trying to use ZendX_Jquery and i don't how know to autoload this file in bootstrap. I am doing require_once("ZendX/JQuery.php"); on my file Bootstrap.php i also tried $autoLoader = Zend_Loader_Autoloader::getInstance(); $autoLoader->registerNamespace('ZendX_'); but it did not work is there any elegant way of autoloading files in diretories? EDIT: Changed ZendX_jQuery to ZendX_JQuery (case sensitivity) on my bootstrap.php file

    Read the article

  • sql server - select top and bottom rows

    - by Adrian Faciu
    Hi, I'm using Sql Server 2005 and i'm trying to achieve something like: In the same select statement i want to get the first x rows and the last x rows. SELECT TOP(5) BOTTOM(5) Of course 'bottom' does not exist so i need other solution. I believe there is an easy and elegant solution that i'm not getting. Doing the select again with Group By Desc is not an option. Thanks.

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >