Search Results

Search found 324 results on 13 pages for 'dean barnes'.

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

  • Importing Conditionally Compiled Functions From a Perl Module

    - by Robert S. Barnes
    I have a set of logging and debugging functions which I want to use across multiple modules / objects. I'd like to be able to turn them on / off globally using a command line switch. The following code does this, however, I would like to be able to omit the package name and keep everything in a single file. This is related to two previous questions I asked, here and here. #! /usr/bin/perl -w use strict; use Getopt::Long; { package LogFuncs; use threads; use Time::HiRes qw( gettimeofday ); # provide tcpdump style time stamp sub _gf_time { my ( $seconds, $microseconds ) = gettimeofday(); my @time = localtime($seconds); return sprintf( "%02d:%02d:%02d.%06ld", $time[2], $time[1], $time[0], $microseconds ); } sub logerr; sub compile { my %params = @_; *logerr = $params{do_logging} ? sub { my $msg = shift; warn _gf_time() . " Thread " . threads->tid() . ": $msg\n"; } : sub { }; } } { package FooObj; sub new { my $class = shift; bless {}, $class; }; sub foo_work { my $self = shift; # do some foo work LogFuncs::logerr($self); } } { package BarObj; sub new { my $class = shift; my $data = { fooObj => FooObj->new() }; bless $data, $class; } sub bar_work { my $self = shift; $self->{fooObj}->foo_work(); LogFuncs::logerr($self); } } my $do_logging = 0; GetOptions( "do_logging" => \$do_logging, ); LogFuncs::compile(do_logging => $do_logging); my $bar = BarObj->new(); LogFuncs::logerr("Created $bar"); $bar->bar_work();

    Read the article

  • Boost.Thread Linking - boost_thread vs. boost_thread-mt

    - by Robert S. Barnes
    It's not clear to me what linking options exist for the Boost.Thread 1.34.1 library. I'm on Ubuntu 8.04 and I've found that using eitherr boost_thread or boost_thread-mt during linking both compile and run, but I don't see any documentation on these or any other linking options in above link. What Boost.Thread linking options are available and what do the mean?

    Read the article

  • Magento Checkout options

    - by graham barnes
    Hi I want to add some options to my magento, lets say i print on clothing, a customer buys some t-shirts, shirts and jackets from me, it totals to £60+ VAT on the checkout area where i signup and not before I need to add an option where I can add a text box and upload option, can i do this? I ideally then want to add some pricing options if the user has chosen to add some branding to a product or multiple products e.g. if the branding was on the top right of the shirt it will cost £5.00, if on the back it costs £7.00 etc all if possible to be done via the admincp. I also want an option so when they upload their logo for the first time they are charged a one off charge, like a setup fee but If the customer has allready sent in there logo then no charge applies. thanks Graham

    Read the article

  • Perl When is using AUTOLOAD OK?

    - by Robert S. Barnes
    In "Perl Best Practices" the very first line in the section on AUTOLOAD is: Don't use AUTOLOAD However all the cases he describes are dealing with OO or Modules. I have a stand alone script in which some command line switches control which versions of particular functions get defined. Now I know I could just take the conditionals and the evals and stick them naked at the top of my file before everything else, but I find it convenient and cleaner to put them in AUTOLOAD at the end of the file. Is this bad practice / style? If you think so why, and is there a another way to do it?

    Read the article

  • [Perl] Testing for EAGAIN / EWOULDBLOCK on a recv

    - by Robert S. Barnes
    I'm testing a socket to see if it's still open: my $dummy = ''; my $ret = recv($sock, $dummy, 1, MSG_DONTWAIT | MSG_PEEK); if (!defined $ret || (length($dummy) == 0 && $! != EAGAIN && $! != EWOULDBLOCK )) { logerr("Broken pipe? ".__LINE__." $!"); } else { # socket still connected, reuse logerr(__LINE__.": $!"); return $sock; } I'm passing this code a socket I know for certain is open and it's always going through the first branch and logging "Broken pipe? 149 Resource temporarily unavailable". I don't understand how this is happening since "Resource temporarily unavailable" is supposed to correspond to EAGAIN as far as I know. I'm sure there must be something simple I'm missing. And yes, I know this is not a full proof way to test and I account for that.

    Read the article

  • Generating a reasonable ctags database for Boost

    - by Robert S. Barnes
    I'm running Ubuntu 8.04 and I ran the command: $ ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/stdlibcpp /usr/include/c++/4.2.4/ to generate a ctags database for the standard C++ library and STL ( libstdc++ ) on my system for use with the OmniCppComplete vim script. This gave me a very reasonable 4MB tags file which seems to work fairly well. However, when I ran the same command against the installed Boost headers: $ ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/boost /usr/include/boost/ I ended up with a 1.4 GB tags file! I haven't tried it yet, but that seems likes it's going to be too large to be useful. Is there a way to get a slimmer, more usable tags file for my installed Boost headers? Edit Just as a note, libstdc++ includes TR1, which has allot of Boost libs in it. So there must be something weird going on for libstdc++ to come out with a 4 MB tags file and Boost to end up with a 1.4 GB tags file.

    Read the article

  • Empty UIView with minimal drawRect: overhead

    - by Benjohn Barnes
    Hi, I have an application that has three nested views that are mechanically important, but have no visual elements: A vanila UIView that doesn't have any content of its own, and is simply used as a host for CALayers. A UIScrollView (that is queried for it's origin and used to position CALayers in 3d: I really only use this view to faithfully replicate the scroll view's "mechanics"), The scroll view's contents: a UIView subclass. It simply picks up touch events and passes them to a delegate - all that is important are its UIResponder machinery. The UIView hosting CALayers is a sibling of a UIImageView that is a background image over which the CALayers are drawn. I'd really like to ensure that none of these empty UIViews have any drawing or compositing overhead (in time, or storage) associated with them, or if that's not possible, to get this overhead as small as possible, and to understand it so that I can perhaps decide if I should try a different approach. In interface builder, I've set all of the views to not clear their context before drawing. I've not set them to be opaque though, because they definitely are not opaque - they are completely transparent. I've found that I need to give the scroll view contents a transparent clear colour (again in IB by setting the background colour's opacity to zero), and this suggests that it is being drawn, which I don't want. So, in short, I've not got much idea of what is and isn't getting drawn (anyone know of a tool like Quartz Debug for iPhone / simulator?), or how to go about stopping things from getting drawn. Advice would be very welcome! Thanks, Benjohn

    Read the article

  • Is anyone else experiencing weird debug + crash behavior with Silverlight?

    - by Scott Barnes
    I have noticed that after awhile of debug/tweakcode/debug etc that eventually Silverlight starts to crash all of my browsers (i.e. doesn't matter which i fire, they all just crash). If i then go to a site that has Silverlight, it works fine? so it has something to do with debugger + Silverlight not getting along? I then reboot and the problem goes away? Is anyone else experiencing this kind of weird behaviour? I have noticed though that if i put breakpoints on the code they all seem to halt, in that it appears that it can instantiate the said .xap etc ok, but just can't seem to render it to screen without a crash? (There's nothing in the log files and i've tried to attach a seperate VS2008 instance to both IE, Devenv and Blend etc trying to see if i can catch what's causing this to occur?)

    Read the article

  • Vim + OmniCppComplete: Completing on Class Members which are STL containers

    - by Robert S. Barnes
    Completion on class members which are STL containers is failing. Completion on local objects which are STL containers works fine. For example, given the following files: // foo.h #include <string> class foo { public: void set_str(const std::string &); std::string get_str_reverse( void ); private: std::string str; }; // foo.cpp #include "foo.h" using std::string; string foo::get_str_reverse ( void ) { string temp; temp.assign(str); reverse(temp.begin(), temp.end()); return temp; } /* ----- end of method foo::get_str ----- */ void foo::set_str ( const string &s ) { str.assign(s); } /* ----- end of method foo::set_str ----- */ I've generated the tags for these two files using: ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q . When I type temp. in the cpp I get a list of string member functions as expected. But if I type str. omnicppcomplete spits out "Pattern Not Found". I've noticed that the temp. completion only works if I have the using std::string; declaration. How do I get completion to work on my class members which are STL containers? Edit I found that completion on members which are STL containers works if I make the follow modifications to the header: // foo.h #include <string> using std::string; class foo { public: void set_str(const string &); string get_str_reverse( void ); private: string str; }; Basically, if I add using std::string; and then remove the std:: name space qualifier from the string str; member and regenerate the tags file then OmniCppComplete is able to do completion on str.. It doesn't seem to matter whether or not I have let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] set in the .vimrc. The problem is that putting using declarations in header files seems like a big no-no, so I'm back to square one.

    Read the article

  • Vim + OmniCppComplete and completing members of class members

    - by Robert S. Barnes
    I've noticed that I can't seem to complete members of class members using OmniCppComplete. For example, given the following files: // foo.h #include <string> class foo { public: void set_str(const std::string &); std::string get_str_reverse( void ); private: std::string str; }; // foo.cpp #include "foo.h" using std::string; string foo::get_str_reverse ( void ) { string temp; temp.assign(str); reverse(temp.begin(), temp.end()); return temp; } /* ----- end of method foo::get_str ----- */ void foo::set_str ( const string &s ) { str.assign(s); } /* ----- end of method foo::set_str ----- */ I've set up tags for stdlibc++ and generated the tags for these two files using: ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q . When I type temp. in the cpp I get a list of string member functions as expected. But if I type str. omnicomplete spits out "Pattern Not Found". I've noticed that the temp. completion only works if I have the using std::string; declaration. How do I get completion to work on my class members?

    Read the article

  • strerror_r returns trash when I manually set errno during testing

    - by Robert S. Barnes
    During testing I have a mock object which sets errno = ETIMEDOUT; The object I'm testing sees the error and calls strerror_r to get back an error string: if (ret) { if (ret == EAI_SYSTEM) { char err[128]; strerror_r(errno, err, 128); err_string.assign(err); } else { err_string.assign(gai_strerror(ret)); } return ret; } I don't understand why strerror_r is returning trash. I even tried calling strerror_r(ETIMEDOUT, err, 128) directly and still got trash. I must be missing something. It seems I'm getting the gnu version of the function not the posix one, but that shouldn't make any difference in this case.

    Read the article

  • make include directive and dependency generation with -MM

    - by Robert S. Barnes
    I want a build rule to be triggered by an include directive if the target of the include is out of date or doesn't exist. Currently the makefile looks like this: program_NAME := wget++ program_H_SRCS := $(wildcard *.h) program_CXX_SRCS := $(wildcard *.cpp) program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o} program_OBJS := $(program_CXX_OBJS) DEPS = make.deps .PHONY: all clean distclean all: $(program_NAME) $(DEPS) $(program_NAME): $(program_OBJS) $(LINK.cc) $(program_OBJS) -o $(program_NAME) clean: @- $(RM) $(program_NAME) @- $(RM) $(program_OBJS) @- $(RM) make.deps distclean: clean make.deps: $(program_CXX_SRCS) $(program_H_SRCS) $(CXX) $(CPPFLAGS) -MM $(program_CXX_SRCS) > make.deps include $(DEPS) The problem is that it seems like the include directive is executing before the rule to build make.deps which effectively means make either getting no dependency list if make.deps doesn't exist or always getting the make.deps from the previous build and not the current one. For example: $ make clean $ make makefile:32: make.deps: No such file or directory g++ -MM addrCache.cpp connCache.cpp httpClient.cpp wget++.cpp > make.deps g++ -c -o addrCache.o addrCache.cpp g++ -c -o connCache.o connCache.cpp g++ -c -o httpClient.o httpClient.cpp g++ -c -o wget++.o wget++.cpp g++ addrCache.o connCache.o httpClient.o wget++.o -o wget++

    Read the article

  • "Socket operation on non-socket" error due to strange syntax

    - by Robert S. Barnes
    I ran across the error Socket operation on non-socket in some of my networking code when calling connect and spent a lot of time trying to figure out what was causing it. I finally figured out that the following line of code was causing the problem: if ((sockfd = socket( ai->ai_family, ai->ai_socktype, ai->ai_protocol) < 0)) { See the problem? Here's what the line should look like: if ((sockfd = socket( ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) { What I don't understand is why the first, incorrect line doesn't produce a warning. To put it another way, shouldn't the general form: if ( foo = bar() < baz ) do_something(); look odd to the compiler, especially running with g++ -Wall -Wextra? If not, shouldn't it at least show up as "bad style" to cppcheck, which I'm also running as part of my compile?

    Read the article

  • Pros and Cons of Different macro function / inline methods in C

    - by Robert S. Barnes
    According to the C FAQ, there are basically 3 practical methods for "inlining" code in C: #define MACRO(arg1, arg2) do { \ /* declarations */ \ stmt1; \ stmt2; \ /* ... */ \ } while(0) /* (no trailing ; ) */ or #define FUNC(arg1, arg2) (expr1, expr2, expr3) To clarify this one, the arguments are used in the expressions, and the comma operator returns the value of the last expression. or using the inline declaration which is supported as an extension to gcc and in the c99 standard. The do { ... } while (0) method is widely used in the Linux kernel, but I haven't encountered the other two methods very often if at all. I'm referring specifically to multi-statement "functions", not single statement ones like MAX or MIN. What are the pros and cons of each method, and why would you choose one over the other in various situations?

    Read the article

  • OmniCppComplete: Completing on Class Members which are STL containers

    - by Robert S. Barnes
    Completion on class members which are STL containers is failing. Completion on local objects which are STL containers works fine. For example, given the following files: // foo.h #include <string> class foo { public: void set_str(const std::string &); std::string get_str_reverse( void ); private: std::string str; }; // foo.cpp #include "foo.h" using std::string; string foo::get_str_reverse ( void ) { string temp; temp.assign(str); reverse(temp.begin(), temp.end()); return temp; } /* ----- end of method foo::get_str ----- */ void foo::set_str ( const string &s ) { str.assign(s); } /* ----- end of method foo::set_str ----- */ I've generated the tags for these two files using: ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q . When I type temp. in the cpp I get a list of string member functions as expected. But if I type str. omnicppcomplete spits out "Pattern Not Found". I've noticed that the temp. completion only works if I have the using std::string; declaration. How do I get completion to work on my class members which are STL containers?

    Read the article

  • Recreating "presentModalViewController"?

    - by Benjohn Barnes
    I'm using a UIImagePickerController set up as a camera with an overlay view. I want to present a modal view controller on top on this. When I do so, though, the camera view "closes". This would be okay, but when I dismissModalViewControllerAnimated, I see the closed camera, and there is a long and annoying delay before it reopens. I would like to avoid this. Unless someone has a better approach, I am planning to simply perform the transition that presentModalViewController would perform myself. However, if I take my modal view from it's controller and add it as a sub view of the camera overlay view, like this: [[_imagePickerController cameraOverlayView] addSubview: [viewController view]]; then the modal view doesn't show up at all, and the application crashes with an EXC_BAD_ACCESS in my "modal" view's layoutSubViews. Where as, if I present it with presentModalViewController, everything works fine. Clearly, presentModalViewController is also doing some other stuff. Does anyone know what this is so that I can recreate it?

    Read the article

  • SOAP security in Salesforce

    - by Dean Barnes
    I am trying to change the wsdl2apex code for a web service call header that currently looks like this: <env:Header> <Security xmlns="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd"> <UsernameToken Id="UsernameToken-4"> <Username>test</Username> <Password>test</Password> </UsernameToken> </Security> </env:Header> to look like this: <soapenv:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken-4" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:Username>Test</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Test</wsse:Password> </wsse:UsernameToken> </wsse:Security> </soapenv:Header> One problem is that I can't work out how to change the namespaces for elements (or even if it matters what name they have). A secondary problem is putting the Type attribute onto the Password element. Can any provide any information that might help? Thanks

    Read the article

  • Android date/time displaying 0 instead of 12

    - by bEtTy Barnes
    I wonder what's wrong with my code below: // Assign hour set in the picker c.set( Calendar.HOUR, selectedHour ); c.set( Calendar.MINUTE, selectedMinute ); // For alternative times c.add( Calendar.HOUR, SUB_SIX_HOUR ); c.add( Calendar.MINUTE, SUB_FLAT_MINUTE ); hour = c.get( Calendar.HOUR ); minute = c.get( Calendar.MINUTE ); hour = c.get( Calendar.HOUR_OF_DAY ); StringBuilder sb4 = new StringBuilder(); if(hour>=12){ sb4.append(hour-12).append( ":" ).append(minute).append(" PM"); }else if(hour == 0){ sb4.append( "12" ).append( ":" ).append(minute).append( "AM" ); }else{ sb4.append(hour).append( ":" ).append(minute).append(" AM"); } alternative.setText( "Alternative times: " + sb3 + " (9 hours)" + sb4 + " (6 hours)" ); Please help me figure out how to display 12 instead of 0 when the calculated time is 12:00 midnight. Thanks!

    Read the article

  • Advice on Mocking System Calls

    - by Robert S. Barnes
    I have a class which calls getaddrinfo for DNS look ups. During testing I want to simulate various error conditions involving this system call. What's the recommended method for mocking system calls like this? I'm using Boost.Test for my unit testing.

    Read the article

  • How to handle building and parsing HTTP URL's / URI's / paths in Perl

    - by Robert S. Barnes
    I have a wget like script which downloads a page and then retrieves all the files linked in img tags on that page. Given the URL of the original page and the the link extracted from the img tag in that page I need to build the URL for the image file I want to retrieve. Currently I use a function I wrote: sub build_url { my ( $base, $path ) = @_; # if the path is absolute just prepend the domain to it if ($path =~ /^\//) { ($base) = $base =~ /^(?:http:\/\/)?(\w+(?:\.\w+)+)/; return "$base$path"; } my @base = split '/', $base; my @path = split '/', $path; # remove a trailing filename pop @base if $base =~ /[[:alnum:]]+\/[\w\d]+\.[\w]+$/; # check for relative paths my $relcount = $path =~ /(\.\.\/)/g; while ( $relcount-- ) { pop @base; shift @path; } return join '/', @base, @path; } The thing is, I'm surely not the first person solving this problem, and in fact it's such a general problem that I assume there must be some better, more standard way of dealing with it, using either a core module or something from CPAN - although via a core module is preferable. I was thinking about File::Spec but wasn't sure if it has all the functionality I would need.

    Read the article

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