Search Results

Search found 1103 results on 45 pages for 'blah mcblah'.

Page 22/45 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • What's the best practice to "look up" Java Enums?

    - by Marcus
    We have a REST API where clients can supply parameters representing values defined on the server in Java Enums. So we can provide a descriptive error, we add this lookup method to each Enum. Seems like we're just copying code (bad). Is there a better practice? public enum MyEnum { A, B, C, D; public static MyEnum lookup(String id) { try { return MyEnum.valueOf(id); } catch (IllegalArgumentException e) { throw new RuntimeException("Invalid value for my enum blah blah: " + id); } } } Update: The default error message provided by valueOf(..) would be No enum const class a.b.c.MyEnum.BadValue. I would like to provide a more descriptive error from the API.

    Read the article

  • Asp.net mvc 2 and twitter authenticaton

    - by arinte
    I am using OAuth (linq2twitter and DotNetOpenAuth) to allow a user to post comments via their twitter account. So when you do the authorization twitter does a callback, so the way linq2twitter does it is to set the callback to the page that did the req. So if the req came from blah.com\twit it will redirect to blah.com\twit. This leads me to have code like this: public ActionResult Twit(){ var qString = Request.QueryString; if (qString.Count <= 0){ //do authorization } else{ //do authentication } } So I would like to split it to this(seemingly both of these calls are done via GET): public ActionResult Twit(){} public ActionResult Twit(string token1, string token2){} When I have this currently I get the .net yellow screen complaining about ambiguous action methods. How do I route this?

    Read the article

  • Use a template parameter in a preprocessor directive?

    - by Ranju V
    Is it possible to use a non-type constant template parameter in a preprocessor directive? Here's what I have in mind: template <int DING> struct Foo { enum { DOO = DING }; }; template <typename T> struct Blah { void DoIt() { #if (T::Doo & 0x010) // somecode here #endif } }; When I try this with something like Blah<Foo<0xFFFF>>, VC++ 2010 complains something about unmatched parentheses in the line where we are trying to use "#if". I am guessing the preprocessor doesn't really know anything about templates and this sort of thing just isn't in its domain. What say? Thanks!

    Read the article

  • Better way to write this Java code?

    - by Macha
    public void handleParsedCommand(String[] commandArr) { if(commandArr[0].equalsIgnoreCase("message")) { int target = Integer.parseInt(commandArr[1]); String message = commandArr[2]; MachatServer.sendMessage(target, this.conId, message); } else if(commandArr[0].equalsIgnoreCase("quit")) { // Tell the server to disconnect us. MachatServer.disconnect(conId); } else if(commandArr[0].equalsIgnoreCase("confirmconnect")) { // Blah blah and so on for another 10 types of command } else { try { out.write("Unknown: " + commandArr[0] + "\n"); } catch (IOException e) { System.out.println("Failed output warning of unknown command."); } } } I have this part of my server code for handling the types of messages. Each message contains the type in commandArr[0] and the parameters in the rest of commandArr[]. However, this current code, while working seems very unelegant. Is there a better way to handle it? (To the best of my knowledge, String values can't be used in switch statements, and even then, a switch statement would only be a small improvement.

    Read the article

  • Myself throwing NullReferenceException... needs help

    - by Amit Ranjan
    I know it might be a weird question and its Title too, but i need your help. I am a .net dev , working on platform for the last 1.5 years. I am bit confused on the term usually we say " A Good Programmer ". I dont know ,what are the qualities of a good programmer ? Is the guy who writes a bug free code? or Can develop applications solely? or blah blah blah...lots of points. I dont know... But as far i am concerned , I know I am not a good programmer, still in learning phase an needs a lot to learn in coming days. So you guys are requested to please help me with this two problems of mine My first problem is regarding the proper Error Handling, which is a most debatable aspect of programming. We all know we use ` try { } catch { } finally { } ` in our code to manage exception. But even if I use try { } catch(exception ex) { throw ex } finally { } , different guys have different views. I still dont know the good way to handle errors. I can write code, use try-catch but still i feel I lacks something. When I saw the codes generated by .net fx tools even they uses throw ex or `throw new Exception("this is my exception")`.. I am just wondering what will be the best way to achieve the above. All means the same thing but why we avoid something. If it has some demerits then it must be made obselete.Anyways I still dont have one [how to handle errors efficiently?]. I generally follow the try-catch(execoption ex){throw ex}, and usually got stucked in debates with leads why you follow this why not that... 2.Converting your entire code blocks in modules using Design patterns of some OOPs concepts. How do you guys decide what architeture or pattern will be the best for my upcoming application based on its working, flow etc. I need to know what you guys can see that I can't. Since I know , I dont have that much experience but I can say, with my experience that experience doesnot comes either from degree/certificates or success you made instead it cames from failures you faced or got stucking situations. Pleas help me out.

    Read the article

  • jQuery arange li order base on #ID

    - by Mircea
    Hi, I have the following code: <ul> <li id="project_25">Proj Something</li> <li id="project_26">Proj Blah</li> <li id="project_27">Proj Else</li> <li id="project_31">Proj More</li> ... </ul> Is there a way to arrange these LIs, reverse their order, based on the LI ID? Something like: <ul> <li id="project_31">Proj More</li> <li id="project_27">Proj Else</li> <li id="project_26">Proj Blah</li> <li id="project_25">Proj Something</li> ... </ul> Thank you.

    Read the article

  • How does one implement a truly asynchronous java thread

    - by Ritesh M Nayak
    I have a function that needs to perfom two operations, one which finishes fast and one which takes a long time to run. I want to be able to delegate the long running operation to a thread and I dont care when the thread finishes, but the threads needs to complete. I implemented this as shown below , but, my secondoperation never gets done as the function exits after the start() call. How I can ensure that the function returns but the second operation thread finishes its execution as well and is not dependent on the parent thread ? public void someFunction(String data) { smallOperation() Blah a = new Blah(); Thread th = new Thread(a); th.Start(); } class SecondOperation implements Runnable { public void run(){ // doSomething long running } }

    Read the article

  • Correct way to give users access to additional schemas in Oracle

    - by Jacob
    I have two users Bob and Alice in Oracle, both created by running the following commands as sysdba from sqlplus: create user $blah identified by $password; grant resource, connect, create view to $blah; I want Bob to have complete access to Alice's schema (that is, all tables), but I'm not sure what grant to run, and whether to run it as sysdba or as Alice. Happy to hear about any good pointers to reference material as well -- don't seem to be able to get a good answer to this from either the Internet or "Oracle Database 10g The Complete Reference", which is sitting on my desk.

    Read the article

  • Turning off ASP.Net WebForms authentication for one sub-directory

    - by Keith
    I have a large enterprise application containing both WebForms and MVC pages. It has existing authentication and authorisation settings that I don't want to change. The WebForms authentication is configured in the web.config: <authentication mode="Forms"> <forms blah... blah... blah /> </authentication> <authorization> <deny users="?" /> </authorization> Fairly standard so far. I have a REST service that is part of this big application and I want to use HTTP authentication instead for this one service. So, when a user attempts to get JSON data from the REST service it returns an HTTP 401 status and a WWW-Authenticate header. If they respond with a correctly formed HTTP Authorization response it lets them in. The problem is that WebForms overrides this at a low level - if you return 401 (Unauthorised) it overrides that with a 302 (redirection to login page). That's fine in the browser but useless for a REST service. I want to turn off the authentication setting in the web.config: <location path="rest"> <system.web> <authentication mode="None" /> <authorization><allow users="?" /></authorization> </system.web> </location> The authorisation bit works fine, but when I try to change the authentication I get an exception: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. I'm configuring this at application level though - it's in the root web.config How do I override the authentication so that all of the rest of the site uses WebForms authentication and this one directory uses none? This is similar to another question: 401 response code for json requests with ASP.NET MVC, but I'm not looking for the same solution - I don't want to just remove the WebForms authentication and add new custom code globally, there's far to much risk and work involved. I want to change just the one directory in configuration.

    Read the article

  • UISegmentedControl is hidden under the titleBar

    - by shay te
    i guess i am missing something with the UISegmentedControl and auto layout. i have a TabbedApplication (UITabBarController), and i created a new UIViewController to act as tab. to the new view i added UISegmentedControl, and place it to top using auto layout. i guess i don't understand completely something , cause the UISegmentedControl is hiding under the titleBar . can u help me understand what i am missing ? thank you . import Foundation import UIKit; class ViewLikes:UIViewController { override func viewDidLoad() { super.viewDidLoad() title = "some title"; var segmentControl:UISegmentedControl = UISegmentedControl(items:["blash", "blah blah"]); segmentControl.selectedSegmentIndex = 1; segmentControl.setTranslatesAutoresizingMaskIntoConstraints(false) self.view.addSubview(segmentControl) //Set layout var viewsDict = Dictionary <String, UIView>() viewsDict["segment"] = segmentControl; //controls self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-[segment]-|", options: NSLayoutFormatOptions.AlignAllCenterX, metrics: nil, views: viewsDict)) self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-[segment]", options: NSLayoutFormatOptions(0), metrics: nil, views: viewsDict)) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }

    Read the article

  • Add entry to list and remove first one in Python

    - by wagglewax
    I have a list of about 40 entries. And I frequently want to append an item to the start of the list (with id 0) and want to delete the last entry (with id 40) of the list. how do i do this the best? like: (example with 5 entries) [0] = "herp" [1] = "derp" [2] = "blah" [3] = "what" [4] = "da..." after adding "wuggah" and deleting last it should be like: [0] = "wuggah" [1] = "herp" [2] = "derp" [3] = "blah" [4] = "what" or appending one and deleting first. And I don't want to end up manually moving them one after another all of the entries to the next id.

    Read the article

  • Hibernate criteria with projection not performing query for @OneToMany mapping

    - by Josh
    I have a domain object, Expense, that has a field called initialFields. It's annotated as so: @OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL }, orphanRemoval = true) @JoinTable(blah blah) private final List<Field> initialFields; Now I'm trying to use Projections in order to only pull certain fields for performance reasons, but when doing so the initialFields field is always null. It's the only OneToMany field and the only field I am trying to retrieve with the projection that is behaving this way. If I use a regular HQL query initialFields is populated appropriately, but of course I can't limit the fields. Anyone ever seen anything like this?

    Read the article

  • Basic Client-Server Design for persistent connections?

    - by cam
    Here's as far as I understand it: Client & Server make connection Client sends server data Server interprets data, sends client data So on, and so forth, until client sends disconnect signal. I'm just wondering about implementation. Step 2 and 3 are confusing to me, maybe I'm over-complicating it. Is there anymore to interpreting the data than a giant switch statement? Any good books on client/server design? Specifically talking about multithreaded servers, scalability, and message design (byte 1 = header info, byte 2 = blah blah, etc)? Specifically geared towards C++.

    Read the article

  • Writing html tags in GWT client side

    - by arinte
    I have this code in my gwt client side: String out = result.getConsoleOutput().replaceAll("\n", "<br/>"); transOut.getElement().setInnerText(out); Basically what comes out of consoleoutput() is text from a telnet client and transOut is a HTMLPanel in a UiBinder. I want it to show up pretty so I tried to change all the \n to html , but when it shows up in firefox it looks like this on screen blah blahblah blah.... I am guessing gwt escapes the text somewhere how can I get it to write the real tag.

    Read the article

  • Android google.navigation Intent Modes?

    - by Patrick Mahoney
    I'm currently developing an application that will launch a navigation intent. I know that this isn't an official API, but it works perfectly the way I want it to. I allow the user to select driving, walking, and bus navigation to a location. The intent to launch directly into Google Maps Navigation looks like this: google.navigation:ll= + a latitude and longitude, then + &mode= then your mode of transportation. For example, to navigate using walking directions to a certain area: google.navigation:ll=blah,blah&mode=w Driving is default, or &mode=d, and biking is &mode=b, but I can't figure out bus (public transit). Has anyone done this before? Thanks! Edit: So far, I've found that mode=public gives bike directions, mode=transit gives driving, frustratingly, mode=bus also returns bike directions.

    Read the article

  • Operator Overloading with C# Extension Methods

    - by Blinky
    I'm attempting to use extension methods to add an operater overload to the C# StringBuilder class. Specifically, given StringBuilder sb, I'd like sb += "text" to become equivalent to sb.Append("text"); Here's the syntax for creating an extension method for StringBuilder: public static class sbExtensions { public static StringBuilder blah(this StringBuilder sb) { return sb; } } It successfully adds the "blah" extension method to the StringBuilder. Unfortunately, operator overloading does not seem to work: public static class sbExtensions { public static StringBuilder operator +(this StringBuilder sb, string s) { return sb.Append(s); } } Among other issues, the keyword 'this' is not allowed in this context. Are adding operator overloads via extension methods possible? If so, what's the proper way to go about it?

    Read the article

  • create_function with default parameter values?

    - by SoLoGHoST
    Ok, I'm looking into using create_function for what I need to do, and I don't see a way to define default parameter values with it. Is this possible? If so, what would be the best approach for inputting the params into the create_function function in php? Perhaps using addslashes? Well, for example, I have a function like so: function testing($param1 = 'blah', $param2 = array()) { if($param1 == 'blah') return $param1 else { $notblah = ''; if (count($param2) >= 1) { foreach($param2 as $param) $notblah .= $param; return $notblah; } else return 'empty'; } } Ok, so how would I use create_function to do the same thing, adding the parameters and their default values? The thing is, the parameters are coming from a TEXT file, as well as the function itself. So, wondering on the best approach for this using create_function and how exactly the string should be parsed. Thanks :)

    Read the article

  • PHP eval() code in between <?php ?> from database

    - by kr1zmo
    Some of you may be annoyed with this question, and claim it's unsafe blah blah. I want to be able to put php into the database and run it. I have to do this because I store page layouts in the database and each our different for each other, however in some cases I want to use dynamic content for some of the pages. assume $query_from_db is the string returned from the database. php should only eval() the code in between <?php and ?> $query_from_db = '<div> <?php //php to run function dosomething() { //bleh } ?> </div> '; php echo eval($query_from_db);

    Read the article

  • Anonymous functions in C#

    - by Maxim Gershkovich
    The following syntax is valid VB.NET code Dim myCollection As New List(Of Stock) myCollection.Add(New Stock(Guid.NewGuid, "Item1")) myCollection.Add(New Stock(Guid.NewGuid, "Item2")) Dim res As List(Of Stock) = myCollection.FindAll(Function(stock As Stock) As Boolean If stock.Description = "Item2" Then Return True End If Return False End Function) How can I accomplish the same thing in C#? I have tried... myCollection.FindAll(bool delegate(Stock stock) { if (blah blah) { } }); But it appears I have somehow structured it incorrectly as I get the following error. "Error 1 Invalid expression term 'bool'"

    Read the article

  • How to pass a class method as an argument for another function in C++ and openGL?

    - by tsubasa
    I know this thing works: void myDisplay() { ... } int main() { ... glutDisplayFunc(myDisplay) ... } so I tried to include myDisplay() function to a class that I made. Because I want to overload it in the future with a different class. However, the compiler complains that argument of type 'void (ClassBlah::)()' does not match 'void(*)()' . Here is the what I try to make: class ClassBlah { .... void myDisplay() .... } ...... int main() { ... ClassBlah blah glutDisplayFunc(blah.myDisplay) ... } Does anybody knows how to fix this problem? Many thanks.

    Read the article

  • Is there anyway to write the following as a C++ macro?

    - by anon
    my_macro << 1 << "hello world" << blah->getValue() << std::endl; should expand into: std::ostringstream oss; oss << 1 << "hello world" << blah->getValue() << std::endl; ThreadSafeLogging(oss.str()); Thanks! EDIT: the accepted answer is awesome. Can we upvote 8 more times and win this responder a badge? (The answer only needs 6 more upvotes). 4 more votes to go from 21 to 25. 3 more. :-) Victory. :-)

    Read the article

  • Disambiguating Named Entities in Java

    - by Alterscape
    I have a list of strings (company names, in this case), and a Java program that extracts a list of things that look like company names out of mostly-unstructured text. I need to match each element of extracted text to a string in the list. Caveat: the unstructured text has typos, things like "Blah, Inc." referred to as "Blah," etc. I've tried Levenshtein Edit Distance, but that fails for predictable reasons. Are there known best-practices ways of tackling this problem? Or am I back to manual data-entry?

    Read the article

  • How to create an attached-property to change a resource's property?

    - by king.net
    I have a DrawingBrush as a resource like this: <DrawingBrush x:Key="Calendar" Stretch="Uniform"> <DrawingBrush.Drawing> <DrawingGroup> <DrawingGroup.Children> <GeometryDrawing Geometry="F1 M 28.0917,2.13333C 42.4005,2.13333 54,13.7329 54,28.0417C 54,42.3504 42.4004,53.95 28.0917,53.95C 13.7829,53.95 2.18334,42.3504 2.18334,28.0417C 2.18334,13.7329 13.7829,2.13333 28.0917,2.13333 Z "> <GeometryDrawing.Pen> <Pen Thickness="4" LineJoin="Round" Brush="#FF000000"/> </GeometryDrawing.Pen> </GeometryDrawing> <GeometryDrawing Geometry="F1 M 16.9667,16.7083L 39.7167,16.7083L 39.7167,41.625L 16.9667,41.625L 16.9667,16.7083 Z "> <GeometryDrawing.Pen> <Pen Thickness="2.66667" StartLineCap="Square" EndLineCap="Square" MiterLimit="2.75" Brush="#FF000000"/> </GeometryDrawing.Pen> </GeometryDrawing> <GeometryDrawing Brush="#FF000000" Geometry="F1 M 15.6333,15.9583L 40.7167,15.9583L 40.7167,25.2917L 15.6333,25.2917L 15.6333,15.9583 Z "/> <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 18.2167,11.9583L 22.9667,11.9583L 22.9667,20.875L 18.2167,20.875L 18.2167,11.9583 Z "> <GeometryDrawing.Pen> <Pen Thickness="1.33333" StartLineCap="Square" EndLineCap="Square" MiterLimit="2.75" Brush="#FF000000"/> </GeometryDrawing.Pen> </GeometryDrawing> <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 33.7167,11.925L 38.4667,11.925L 38.4667,20.8417L 33.7167,20.8417L 33.7167,11.925 Z "> <GeometryDrawing.Pen> <Pen Thickness="1.33333" StartLineCap="Square" EndLineCap="Square" MiterLimit="2.75" Brush="#FF000000"/> </GeometryDrawing.Pen> </GeometryDrawing> <GeometryDrawing Brush="#FF000000" Geometry="F1 M 28.0154,36.2658L 28.0154,37.4894L 21.6254,37.4894C 21.6169,37.1934 21.6615,36.908 21.7592,36.6333C 21.915,36.1815 22.165,35.7425 22.5091,35.3162C 22.8533,34.8899 23.3617,34.4091 24.0344,33.8738C 25.0782,32.983 25.776,32.295 26.1279,31.81C 26.4799,31.3249 26.6558,30.8551 26.6558,30.4005C 26.6558,29.9473 26.4894,29.5653 26.1566,29.2544C 25.8238,28.9435 25.3904,28.7881 24.8565,28.7881C 24.2915,28.7881 23.8393,28.9442 23.5001,29.2565C 23.161,29.5688 22.9892,30.0018 22.985,30.5556L 21.7614,30.4196C 21.8449,29.5345 22.1576,28.86 22.6993,28.3962C 23.241,27.9323 23.9686,27.7004 24.882,27.7004C 25.8054,27.7004 26.5358,27.9596 27.0733,28.4779C 27.6107,28.9963 27.8795,29.6385 27.8795,30.4047C 27.8795,30.7942 27.8065,31.1769 27.6607,31.5529C 27.5148,31.9289 27.2726,32.3251 26.9341,32.7415C 26.5957,33.1579 26.0115,33.7215 25.1816,34.4325C 24.4692,35.0216 24.0008,35.4214 23.7763,35.6317C 23.5518,35.842 23.3667,36.0533 23.2208,36.2658L 28.0154,36.2658 Z "/> <GeometryDrawing Brush="#FF000000" Geometry="F1 M 33.3178,37.4894L 33.3178,35.1781L 28.9671,35.1781L 28.9671,33.9545L 33.5897,27.8364L 34.5414,27.8364L 34.5414,33.9545L 35.765,33.9545L 35.765,35.1781L 34.5414,35.1781L 34.5414,37.4894L 33.3178,37.4894 Z M 33.3178,33.9545L 33.3178,30.1774L 30.4648,33.9545L 33.3178,33.9545 Z "/> </DrawingGroup.Children> </DrawingGroup> </DrawingBrush.Drawing> </DrawingBrush> And I can use it like this: <Rectangle Fill="{DynamicResource Calender}" /> Now, my question is: how can I create an attached-property to change all brushes on my resource? e.g. I be able to create this: <Rectangle Fill="{DynamicResource Calendar}" attached:IconHelper.Foreground="Blue" /> on my Rectangle and in my resource, I can get: <DrawingBrush x:Key="Calendar" Stretch="Uniform"> <DrawingBrush.Drawing> <DrawingGroup> <DrawingGroup.Children> <GeometryDrawing Geometry="blah blah"> <GeometryDrawing.Pen> <Pen Brush={attached:ReadItFromAboveRectangle}/> </GeometryDrawing.Pen> </GeometryDrawing> <GeometryDrawing Geometry="blah blah"> <GeometryDrawing.Pen> <Pen Brush={attached:ReadItFromAboveRectangle}/> </GeometryDrawing.Pen> <!-- etc... --> Is there any way to read an attached-property on Rectangle in Calendar resource? Or is there any other way to do this? Thanks in advance.

    Read the article

  • Handling JSON and HTML templates in jQuery

    - by Toby Hede
    I have an ajax-enabled site that presents a lot of dynamic content by interpolating JSON values with HTML. This all works fine. BUT it means I have significant amounts of HTML all through my JavaScript. For example: var template = "<div>Foo: {bar}</div><div>Blah: {vtha}</div>"; template.interpolate({bar:"bar",blah:"vtha"}); I have cut this down a fair bit - some of my dynamic elements have quite a lot of HTML and a lot going on. I am using jQuery and I am building on Rails, so if there is something smart in either framework, that would be great. For reference, the String interpolation function used above is: String.prototype.interpolate = function (o) { return this.replace(/{([^{}]*)}/g, function (a, b) { var r = o[b]; return typeof r === 'string' || typeof r === 'number' ? r : a; } ); };

    Read the article

  • How to make Dajax callback into scoped object

    - by BozoJoe
    I cant seem to find a way to make django-dajaxice have its callback inside same scoped object from which made the initial call. MyViewport = Ext.extend(MyViewportUi, { initComponent: function() { MyViewport.superclass.initComponent.call(this); }, LoadRecordsCallback: function(data){ if(data!='DAJAXICE_EXCEPTION') { alert(data); } else { alert('DAJAXICE_EXCEPTION'); } }, LoadRecords: function(){ Dajaxice.Console.GetUserRecords(this.LoadRecordsCallback); } }); var blah = new MyViewport(); blah.LoadRecords(); I'm on django, and like the calling syntax to django-dajaxice. I'm using Extjs 3.2 and tried passing a Ext.createCallback but Dajax's returning eval seems to only want a string for the callback.

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >