Search Results

Search found 1323 results on 53 pages for 'eric ness'.

Page 34/53 | < Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >

  • Create Outlines around line.

    - by Eric Muller
    Hi SO community! I am drawing graphs into a WinForms Picturebox. Now I am searching for a possibility to 'duplicate' a line (an array of points), so that the two resulting lines are positioned a fixed distance away from the original one. Like in this picture, I have the red line and want to get the black ones: I thought about just moving the line a few pixels up/right/up-right, but that leads to strange overlapping lines. Is there any other approach that does what I want? Any ideas would be greatly appreciated. Thanks!

    Read the article

  • Optimize C# Code Fragment

    - by Eric J.
    I'm profiling some C# code. The method below is one of the most expensive ones. For the purpose of this question, assume that micro-optimization is the right thing to do. Is there an approach to improve performance of this method? Changing the input parameter to p to ulong[] would create a macro inefficiency. static ulong Fetch64(byte[] p, int ofs = 0) { unchecked { ulong result = p[0 + ofs] + ((ulong)p[1 + ofs] << 8) + ((ulong)p[2 + ofs] << 16) + ((ulong)p[3 + ofs] << 24) + ((ulong)p[4 + ofs] << 32) + ((ulong)p[5 + ofs] << 40) + ((ulong)p[6 + ofs] << 48) + ((ulong)p[7 + ofs] << 56); return result; } }

    Read the article

  • No route matches error with application_controller spec

    - by Eric M.
    I have an application_controller spec that is failing since I removed the controller/action route from routes.rb. I get the following error: No route matches {:controller=>"application", :action=>"index"} I had many tests fail in the same way, but was able to fix them by including the correct parameters in the get call. So for instance, if I wanted to get the standard show route for posts in my spec, I had to change get :show to get :show, :id => '1' Unfortunately, I'm not sure now what to pass along for the application controller specs. I've included my test below. describe ApplicationController do it "should find the latest published posts and assign them for the view" do Post.should_receive(:latest).and_return(@posts) get :index assigns[:posts].should == @posts end it "should find the latest approved comments and assign them for the view" do Comment.should_receive(:latest).and_return(@comments) get :index assigns[:comments].should == @comments end end

    Read the article

  • How can I group an array of rectangles into "Islands" of connected regions?

    - by Eric
    The problem I have an array of java.awt.Rectangles. For those who are not familiar with this class, the important piece of information is that they provide an .intersects(Rectangle b) function. I would like to write a function that takes this array of Rectangles, and breaks it up into groups of connected rectangles. Lets say for example, that these are my rectangles (constructor takes the arguments x, y, width,height): Rectangle[] rects = new Rectangle[] { new Rectangle(0, 0, 4, 2), //A new Rectangle(1, 1, 2, 4), //B new Rectangle(0, 4, 8, 2), //C new Rectangle(6, 0, 2, 2) //D } A quick drawing shows that A intersects B and B intersects C. D intersects nothing. A tediously drawn piece of ascii art does the job too: +-------+ +---+ ¦A+---+ ¦ ¦ D ¦ +-+---+-+ +---+ ¦ B ¦ +-+---+---------+ ¦ +---+ C ¦ +---------------+ Therefore, the output of my function should be: new Rectangle[][]{ new Rectangle[] {A,B,C}, new Rectangle[] {D} } The failed code This was my attempt at solving the problem: public List<Rectangle> getIntersections(ArrayList<Rectangle> list, Rectangle r) { List<Rectangle> intersections = new ArrayList<Rectangle>(); for(Rectangle rect : list) { if(r.intersects(rect)) { list.remove(rect); intersections.add(rect); intersections.addAll(getIntersections(list, rect)); } } return intersections; } public List<List<Rectangle>> mergeIntersectingRects(Rectangle... rectArray) { List<Rectangle> allRects = new ArrayList<Rectangle>(rectArray); List<List<Rectangle>> groups = new ArrayList<ArrayList<Rectangle>>(); for(Rectangle rect : allRects) { allRects.remove(rect); ArrayList<Rectangle> group = getIntersections(allRects, rect); group.add(rect); groups.add(group); } return groups; } Unfortunately, there seems to be an infinite recursion loop going on here. My uneducated guess would be that java does not like me doing this: for(Rectangle rect : allRects) { allRects.remove(rect); //... } Can anyone shed some light on the issue?

    Read the article

  • Entity Framework 4: C# !(ReferenceEquals()) vs !=

    - by Eric J.
    Unless a class specifically overrides the behavior defined for Object, ReferenceEquals and == do the same thing... compare references. In property setters, I have commonly used the pattern private MyType myProperty; public MyType MyProperty { set { if (myProperty != value) { myProperty = value; // Do stuff like NotifyPropertyChanged } } } However, in code generated by Entity Framework, the if statement is replaced by if (!ReferenceEquals(myProperty, value)) Using ReferenceEquals is more explicit (as I guess not all C# programmers know that == does the same thing if not overridden). Is there any difference that's escaping me between the two if-variants? Are they perhaps accounting for the possibility that POCO designers may have overridden ==? In short, if I have not overridden ==, am I save using != instead of ReferencEquals()?

    Read the article

  • C/C++ enum and char * array

    - by Eric M
    Ran accross the following code in an article and didn't think it was standard C/C++ syntax for the char* array. As a test, both Visual C++ (visual studio 2005) and C++ Builder Rad XE both reject the 2nd line. Without using #defines, anyone have any tricks/tips for keeping enums and a string array sort of in sync without resorting to STL ? More of a curiosity question. enum TCOLOR { RED, GREEN, BLUE }; char *TNCOLOR[] = { [RED]="Red", [GREEN]="Green", [BLUE]="Blue" }; as an aside, the article this came from is quite old and I believe this might work under GCC but have not tested.

    Read the article

  • Disable logging during manage.py test?

    - by Eric Palakovich Carr
    I utilize the standard python logging module. When I call python manage.py test I'd like to disable logging before all the tests are ran. Is there a signal or some other kind of hook I could use to call logging.disable? Or is there some other way to disable logging when python manage.py test is ran?

    Read the article

  • Indenting Paragraph With cout

    - by Eric
    Given a string of unknown length, how can you output it using cout so that the entire string displays as an indented block of text on the console? (so that even if the string wraps to a new line, the second line would have the same level of indentation) Example: cout << "This is a short string that isn't indented." << endl; cout << /* Indenting Magic */ << "This is a very long string that will wrap to the next line because it is a very long string that will wrap to the next line..." << endl; And the desired output: This is a short string that isn't indented. This is a very long string that will wrap to the next line because it is a very long string that will wrap to the next line... Edit: The homework assignment I'm working on is complete. The assignment has nothing to do with getting the output to format as in the above example, so I probably shouldn't have included the homework tag. This is just for my own enlightment. I know I could count through the characters in the string, see when I get to the end of a line, then spit out a newline and output -x- number of spaces each time. I'm interested to know if there is a simpler, idiomatic C++ way to accomplish the above.

    Read the article

  • New Facebook like button HTML validation

    - by Eric Di Bari
    After adding the new facebook like button to my page, it no longer validates using XHTML strict. The two errors I come across are: All of the "meta property" tags say that "there is no attribute "property"" All of the variables used in the like button line are listed that there are no attributes for it. The line is as follows: <fb:like href="http://www.pampamanta.org" layout="button_count" show_faces="false" width="120" action="like" font="arial" colorscheme="light"></fb:like>

    Read the article

  • refreshing javascript by renaming src attribute

    - by Eric Fortis
    I want to refresh the output of the script below. Is this json? Do I need to add a crossdomain policy in my site? <div id="nowplaying"> <script src="http://s4.total-streaming.com/xml.php?station=1269&get=js"></script> </div> Edit: This is what I'm trying based on @alexn advise, but still doesn't refresh. <div id="nowplaying"> <script id="nowplaying-script" src="http://s4.total-streaming.com/xml.php?station=1269&get=js"></script> <script> setInterval(function () { $('#nowplaying-script').attr('src', 'http://s4.total-streaming.com/xml.php?station=1269&get=js'); }, 1000); </script> </div> Note Firebug: Resource interpreted as script but transferred with MIME type text/html. xml.php:-1

    Read the article

  • How can I change or remove HttpRequest input arguments in a HttpModule

    - by Eric Gunn
    Is it possible to change or remove http request form inputs in an httpmodule? My goal is to create a security IHttpmodule that will check the request for reasonable values, such as limits on acceptable input and query parameter length, or use the AntiXSS Sanitizer to remove threats, log potential hack attempts, etc. before a request is passed on to a processor. Because this is a cross cutting concern I'd prefer to find a solution that applies to all requests and affects all ways request values could be accessed, Reqest.Form, Action(model), Action(FormCollection), HttpContext.Current.Request.Form, etc. I'm using MVC and have considered creating custom model binders to clean the data before creating the model instance. But that would be application specific, require remembering to register every model binder and only apply to Action(model).

    Read the article

  • Configuring Hadoop logging to avoid too many log files

    - by Eric Wendelin
    I'm having a problem with Hadoop producing too many log files in $HADOOP_LOG_DIR/userlogs (the Ext3 filesystem allows only 32000 subdirectories) which looks like the same problem in this question: http://stackoverflow.com/questions/2091287/error-in-hadoop-mapreduce My question is: does anyone know how to configure Hadoop to roll the log dir or otherwise prevent this? I'm trying to avoid just setting the "mapred.userlog.retain.hours" and/or "mapred.userlog.limit.kb" properties because I want to actually keep the log files. I was also hoping to configure this in log4j.properties, but looking at the Hadoop 0.20.2 source, it writes directly to logfiles instead of actually using log4j. Perhaps I don't understand how it's using log4j fully. Any suggestions or clarifications would be greatly appreciated.

    Read the article

  • win32 sdk: how to make the caption/border of a child window transparent

    - by Eric
    I'm creating a child window within the main window. I assigned these styles to the child window: WS_CHILDWINDOW | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | WS_SIZEBOX | WS_CAPTION The child window I get has a caption and a resizable border. However there's no close button in the caption, and the caption/border of the child window is not transparent (I'm using the aero theme in windows 7). Here is the screen snap: How to add close button to the caption? How can I make the caption/border transparent?

    Read the article

  • CSS3 Box Shadow Fade Out Effect

    - by Eric Bergman
    Is it possible to achieve a Fadeout effect with CSS3 Box Shadow? Here's what I have so far? This only adds inset shadow to the vertical sides but I need to achieve a fade out effect at the top. -moz-box-shadow: inset 5px 0 7px -5px #a4a4a4, inset -5px 0 7px -5px #a4a4a4; -webkit-box-shadow: inset 5px 0 5px -5px #a4a4a4, inset -5px 0 5px -5px #a4a4a4; box-shadow: inset 5px 0 7px -5px #a4a4a4, inset -5px 0 7px -5px #a4a4a4; See the image below to see the Expected Results and what I currently have.

    Read the article

  • XPathNavigator.Evaluate returning incorrect value?

    - by Eric
    I'm expecting this code to return true but it doesn't ? What am I missing here. string xml = @"<data><e id=""NUM_CPUS"">1</e><e id=""ACE_PRESENT"">1</e></data>"; XPathDocument doc = new XPathDocument(new StringReader(xml)); string expr = "(id('NUM_CPUS'))>=1 and (id('ACE_PRESENT'))=1"; XPathNavigator nav = doc.CreateNavigator(); XPathExpression query = nav.Compile(expr); object result = nav.Evaluate(query); bool b = bool.Parse(result.ToString()); if (!b) throw new Exception("Should be true");

    Read the article

  • How to give points for each indices of list

    - by Eric Jung
    def voting_borda(rank_ballots): '''(list of list of str) -> tuple of (str, list of int) The parameter is a list of 4-element lists that represent rank ballots for a single riding. The Borda Count is determined by assigning points according to ranking. A party gets 3 points for each first-choice ranking, 2 points for each second-choice ranking and 1 point for each third-choice ranking. (No points are awarded for being ranked fourth.) For example, the rank ballot shown above would contribute 3 points to the Liberal count, 2 points to the Green count and 1 point to the CPC count. The party that receives the most points wins the seat. Return a tuple where the first element is the name of the winning party according to Borda Count and the second element is a four-element list that contains the total number of points for each party. The order of the list elements corresponds to the order of the parties in PARTY_INDICES.''' #>>> voting_borda([['GREEN','NDP', 'LIBERAL', 'CPC'], ['GREEN','CPC','LIBERAL','NDP'], ['LIBERAL','NDP', 'CPC', 'GREEN']]) #('GREEN',[4, 6, 5, 3]) list_of_party_order = [] for sublist in rank_ballots: for party in sublist[0]: if party == 'GREEN': GREEN_COUNT += 3 elif party == 'NDP': NDP_COUNT += 3 elif party == 'LIBERAL': LIBERAL_COUNT += 3 elif party == 'CPC': CPC_COUNT += 3 for party in sublist[1]: if party == 'GREEN': GREEN_COUNT += 2 elif party == 'NDP': NDP_COUNT += 2 elif party == 'LIBERAL': LIBERAL_COUNT += 2 elif party == 'CPC': CPC_COUNT += 2 for party in sublist[2]: if party == 'GREEN': GREEN_COUNT += 1 elif party == 'NDP': NDP_COUNT += 1 elif party == 'LIBERAL': LIBERAL_COUNT += 1 elif party == 'CPC': CPC_COUNT += 1 I don't know how I would give points for each indices of the list MORE SIMPLY. Can someone please help me? Without being too complicated. Thank you!

    Read the article

  • Learn Fundamentals of Silverlight 4 Data Binding

    - by Eric J.
    I'm just starting to work with Silverlight (no WPF experience either) and am having a difficult time finding a source that provides a full explanation of Data Binding. There is absolutely no lack of tutorials (starting with the ones on Silverlight.net or Scott Gu's blogs), but everything I have found is "by example". Is there a resource that explains how data binding works in Silverlight, from a Fundamental/Conceptual perspective, and provides end-to-end coverage of data binding features? The desire for a more fundamental source of information is driven by a number of questions that came up this afternoon in reviewing tutorials and writing sample apps, such as: Why can't I bind the value of a slider like this?: Value="{Binding=Age, Mode=TwoWay}" where Age refers to an int property in the object data context I bind in code-behind (the Visual Studio error message is Expected '[]'. How do I use the DataContext property in VS 2010? What's a Path, Relative Source, Static Source, ...?

    Read the article

  • API to determine whether running on iPhone or iPad

    - by Eric
    Is there an API for checking at runtime whether you are running on an iPhone or an iPad? One way I can think of would be to use: [[UIDevice currentDevice] model]; And detect the existence of the string @"iPad" - which seems a bit fragile. In the 3.2 SDK, I see that UIDevice also has a property which is really what I'm looking for, but doesn't work for pre-3.2 (obviously): [[UIDevice currentDevice] userInterfaceIdiom]; Are there other ways than checking for the existence of @"iPad" for a universal app?

    Read the article

  • How do I use BCP or Sql Server Management Studio to get BLOB data our of Sql Server?

    - by Eric
    I'm sorry if this question has been asked already, but I couldn't find it anywhere. I have a table that stores files as BLOBS. The column that holds the file is an image datatype. I would like to be able to extract the binary data out of the column and turn it in to an actual file. I would ideally like to be able to do this with BCP or management studio if possible. I have tried BCP, but for some reason when I try and pull out an office document Word thinks it's corrupt. Here's what I've tried so far (obviously the values have been changed to protect the innocent :): bcp "select document_binary_data from database where id = 12345" queryout "c:\filename.doc" -n -S server -U username -P password This isn't working though? Any thoughts?

    Read the article

  • More elegant way to make a C++ member function change different member variables based on template p

    - by Eric Moyer
    Today, I wrote some code that needed to add elements to different container variables depending on the type of a template parameter. I solved it by writing a friend helper class specialized on its own template parameter which had a member variable of the original class. It saved me a few hundred lines of repeating myself without adding much complexity. However, it seemed kludgey. I would like to know if there is a better, more elegant way. The code below is a greatly simplified example illustrating the problem and my solution. It compiles in g++. #include <vector> #include <algorithm> #include <iostream> namespace myNS{ template<class Elt> struct Container{ std::vector<Elt> contents; template<class Iter> void set(Iter begin, Iter end){ contents.erase(contents.begin(), contents.end()); std::copy(begin, end, back_inserter(contents)); } }; struct User; namespace WkNS{ template<class Elt> struct Worker{ User& u; Worker(User& u):u(u){} template<class Iter> void set(Iter begin, Iter end); }; }; struct F{ int x; explicit F(int x):x(x){} }; struct G{ double x; explicit G(double x):x(x){} }; struct User{ Container<F> a; Container<G> b; template<class Elt> void doIt(Elt x, Elt y){ std::vector<Elt> v; v.push_back(x); v.push_back(y); Worker<Elt>(*this).set(v.begin(), v.end()); } }; namespace WkNS{ template<class Elt> template<class Iter> void Worker<Elt>::set(Iter begin, Iter end){ std::cout << "Set a." << std::endl; u.a.set(begin, end); } template<> template<class Iter> void Worker<G>::set(Iter begin, Iter end){ std::cout << "Set b." << std::endl; u.b.set(begin, end); } }; }; int main(){ using myNS::F; using myNS::G; myNS::User u; u.doIt(F(1),F(2)); u.doIt(G(3),G(4)); } User is the class I was writing. Worker is my helper class. I have it in its own namespace because I don't want it causing trouble outside myNS. Container is a container class whose definition I don't want to modify, but is used by User in its instance variables. doIt<F> should modify a. doIt<G> should modify b. F and G are open to limited modification if that would produce a more elegant solution. (As an example of one such modification, in the real application F's constructor takes a dummy parameter to make it look like G's constructor and save me from repeating myself.) In the real code, Worker is a friend of User and member variables are private. To make the example simpler to write, I made everything public. However, a solution that requires things to be public really doesn't answer my question. Given all these caveats, is there a better way to write User::doIt?

    Read the article

  • win32 sdk: problems with caption/border of child window

    - by Eric
    I'm creating a child window within the main window. I assigned these styles to the child window: WS_CHILDWINDOW | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | WS_SIZEBOX | WS_CAPTION The child window I get has a caption and a resizable border. However there's no close button in the caption, and the caption/border of the child window is not transparent (I'm using the aero theme in windows 7). How to add close button to the caption? How can I make the caption/border transparent?

    Read the article

< Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >