Search Results

Search found 332 results on 14 pages for 'baz'.

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

  • Apache - Include conf Files Relative to ServerConfigFile (-f arg)

    - by Synetech inc.
    Hi, I want to use the -f command-line option for the Apache server so that I can store the conf files in a separate place (a data diectory) from the server binaries. The problem is that I use the Include directive to separate and organize the configurations, but when I use a command like Include "addons/SVN.conf", it fails because Apache looks for addons/SVN.conf in relative to the ServerRoot directory instead of the ServerConfigFile directory. I can work around this by using absolute paths (eg Include "e:\foo\bar\baz\Apache\conf\addons\svn.conf", but I don’t like that since it means I would have to change each and every Include directive if I move the conf folder as opposed to simply changing the -f option. Does anyone know of a way to get the Include directive to work relative to the conf file that Apache is passed. I tried Include "./addons/SVN.conf", but that too was relative to the ServerRoot. This forced relative-to-ServerRoot Include behavior kind of defeats the whole purpose of specifying an alternate config file to the one in ServerRoot/conf. Thanks.

    Read the article

  • Bash: Variable substitution in variable name with default value

    - by krissi
    i have the following variables: # config file MYVAR_DEFAULT=123 MYVAR_FOO=456 #MYVAR_BAR unset # program USER_INPUT=FOO TARGET_VAR=<need to be set> If the USER_INPUT is "foo", I want TARGET_VAR to be the value of MYVAR_FOO (TARGET_VAR=456). If USER_INPUT is "bar" I want TARGET_VAR to be set to MYVAR_DEFAULT (123), because MYVAR_BAR is unset. I prefer it to be sh-compatible and as a substitution string. But it might also be bash compatible and/or in a function. I got these snippets: # Default values for variable (sh-compatible) echo ${MYVAR_FOO-$MYVAR_DEFAULT} # Uppercase (bash compatible) echo ${USER_INPUT^^} I would need something like this: TARGET_VAR="${MYVAR_${USER_INPUT^^}-$MYVAR_DEFAULT}" # or somecommand -foo "${MYVAR_${USER_INPUT^^}-$MYVAR_DEFAULT}" This is to switch a bunch of variables between multiple "profiles". In the example, FOO and BAR are profiles. New profiles should be added easily, in this example there would be an implicit profile named BAZ, too, all variables to their default values. Unfortunately it is not that easy. Do you have an idea to solve this? Thanks in advance, krissi

    Read the article

  • Is there ever a reason to do all an object's work in a constructor?

    - by Kane
    Let me preface this by saying this is not my code nor my coworkers' code. Years ago when our company was smaller, we had some projects we needed done that we did not have the capacity for, so they were outsourced. Now, I have nothing against outsourcing or contractors in general, but the codebase they produced is a mass of WTFs. That being said, it does (mostly) work, so I suppose it's in the top 10% of outsourced projects I've seen. As our company has grown, we've tried to take more of our development in house. This particular project landed in my lap so I've been going over it, cleaning it up, adding tests, etc etc. There's one pattern I see repeated a lot and it seems so mindblowingly awful that I wondered if maybe there is a reason and I just don't see it. The pattern is an object with no public methods or members, just a public constructor that does all the work of the object. For example, (the code is in Java, if that matters, but I hope this to be a more general question): public class Foo { private int bar; private String baz; public Foo(File f) { execute(f); } private void execute(File f) { // FTP the file to some hardcoded location, // or parse the file and commit to the database, or whatever } } If you're wondering, this type of code is often called in the following manner: for(File f : someListOfFiles) { new Foo(f); } Now, I was taught long ago that instantiated objects in a loop is generally a bad idea, and that constructors should do a minimum of work. Looking at this code it looks like it would be better to drop the constructor and make execute a public static method. I did ask the contractor why it was done this way, and the response I got was "We can change it if you want". Which was not really helpful. Anyway, is there ever a reason to do something like this, in any programming language, or is this just another submission to the Daily WTF?

    Read the article

  • URL to load resources from the classpath in Java

    - by Thilo
    In Java, you can load all kinds of resources using the same API but with different URL protocols: file:///tmp.txt http://127.0.0.1:8080/a.properties jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class This nicely decouples the actual loading of the resource from the application that needs the resource, and since a URL is just a String, resource loading is also very easily configurable. Is there a protocol to load resources using the current classloader? This is similar to the Jar protocol, except that I do not need to know which jar file or class folder the resource is coming from. I can do that using Class.getResourceAsStream("a.xml"), of course, but that would require me to use a different API, and hence changes to existing code. I want to be able to use this in all places where I can specify a URL for the resource already, by just updating a property file.

    Read the article

  • Django query if field value is one of multiple choices

    - by Nathan
    Say I want to model a system where a piece of data can have multiple tags (e.g. a question on a StackOverflow is the data, it's set of tags are the tags). I can model this in Django with the following: class Tag(models.Model): name = models.CharField(10) class Data(models.Model): tags = models.ManyToManyField(Tag) Given a set of strings, what's the best way to go about finding all Data objects that have one of these strings as the name of a tag in their tag list. I've come up with the following, but can't help thinking there is a more "Djangonic" way. Any ideas? tags = [ "foo", "bar", "baz" ] q_objects = Q( tags__name = tags[0] ) for t in tags[1:]: q_objects = q_objects | Q( tags__name = t ) data = Data.objects.filter( q_objects ).distinct()

    Read the article

  • URLEncoding a string with Objective-C

    - by Chris
    I'm trying to URL encode a string to form a GET request from objective-c. NSString *params = @"'Decoded data!'/foo.bar:baz"; NSRunAlertPanel( @"Error", [params urlEncoded], @"OK", nil, nil ); This is the category extending NSString -(NSString *) urlEncoded { NSString *encoded = (NSString *)CFURLCreateStringByAddingPercentEscapes( NULL, (CFStringRef)self, NULL, (CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ", kCFStringEncodingUTF8 ); return encoded; } So the first time I run it I get back 1606410046ecoded 1606410784ata2270.000000foo.bar0X1.001716P-1042baz from the dialog box. Immediately after I run it again I get this 1606410046ecoded 1606410944ata227369374562920703448982951250259562309742470533728899744288431318481119278377104028261651081181287077973859930826299575521579020410425419424562236383226511593137467590082636817579938932512039895040.000000foo.bar0X1.66E6156303225P+771baz Then if I run it AGAIN it goes back to the first one. It's really weird. If params is set to @"&" or @" " I just get back a "2" (w/o the quotes) in the dialog box. Also is there a way I can have the % signs be shown in the alert dialog? Thanks

    Read the article

  • testing SpringMVC controllers

    - by Don
    Hi, I'm unit-testing my SpringMVC (v. 2.5) controllers using code like the following: public void testParamValidation() { MyController controller = new MyController(); MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("foo", "bar"); request.addParameter("bar", baz"); ModelAndView mav = controller .handleRequest(request, new MockHttpServletResponse()); // Do some assertions on mav } This controller is a subclass of AbstractCommandController, so the parameters are bound to a command bean, and any binding or validation errors are stored in an object that implements the Errors interface. I can't seem to find any way to access this Errors from within the test, is this possible? Thanks, Don

    Read the article

  • NullPointerException with CallableStatement.getResultSet()

    - by Raj
    Hello, I have a stored proc in SQL Server 2005, which looks like the following (simplified) CREATE PROCEDURE FOO @PARAMS AS BEGIN -- STEP 1: POPULATE tmp_table DECLARE @tmp_table TABLE (...) INSERT INTO @tmp_table SELECT * FROM BAR -- STEP 2: USE @tmp_table FOR FINAL SELECT SELECT abc, pqr FROM BAZ JOIN @tmp_table ON some_criteria END When I run this proc from SQL Server Management Studio, things work fine. However, when I call the same proc from a Java program, using something like: cs = connection.prepareCall("exec proc ?,"); cs.setParam(...); rs = cs.getResultSet(); // BOOM - Null! while(rs.next()) {...} // NPE! I fail to understand why the first result set returned is NULL. Can someone explain this to me? As a workaround, if I check cs.getMoreResults() and if true, try another getResultSet() - THIS time it returns the proper result set. Any pointers please? (I'm using JTDS drivers, if it matters) Thanks, Raj

    Read the article

  • Filemaker - Getting field values from related table

    - by foobar
    I have the following setup in Filemaker Pro 10. Table1 with: id_table1, related_names Table2 with: id_table2, name, include and a joint-table with: id_table1, id_table2 Now I want either make related_names a calculated field or write a script that sets related_names to a comma separated list of all names which are connected through the joint-table and have Table2.include = True. So for example a data set could look like: Table1 id_table1, related_names 1, "foo,bar" 2, "foo" 3, "" joint-table id_table1, id_table2 1,1 1,2 1,3 2,1 Table2 id_table2, name, include 1, foo, True 2, bar, True 3, baz, False After searching the internet for a few hours the closest I came was a calculated field with list(join-table::id_table2) which gives me a list with a all the id_table2's. But now I would need to find the appropriate records in table2 and check the include field. I hope the problem is clear. any help is highly appreciated.

    Read the article

  • Cost of using repeated parameters

    - by Palimondo
    I consider refactoring few method signatures that currently take parameter of type List or Set of concrete classes --List[Foo]-- to use repeated parameters instead: Foo*. This would allow me to use the same method name and overload it based on the parameter type. This was not possible using List or Set, because List[Foo] and List[Bar] have same type after erasure: List[Object]. In my case the refactored methods work fine with scala.Seq[Foo] that results from the repeated parameter. I would have to change all the invocations and add a sequence argument type annotation to all collection parameters: baz.doStuffWith(foos:_*). Given that switching from collection parameter to repeated parameter is semantically equivalent, does this change have some performance impact that I should be aware of? Is the answer same for scala 2.7._ and 2.8?

    Read the article

  • C# ArrayList calling on a constructor class

    - by EvanRyan
    I'm aware that an ArrayList is probably not the way to go with this particular situation, but humor me and help me lose this headache. I have a constructor class like follows: class Peoples { public string LastName; public string FirstName; public Peoples(string lastName, string firstName) { LastName = lastName; FirstName = firstName; } } And I'm trying to build an ArrayList to build a collection by calling on this constructor. However, I can't seem to find a way to build the ArrayList properly when I use this constructor. I have figured it out with an Array, but not an ArrayList. I have been messing with this to try to build my ArrayList: ArrayList people = new ArrayList(); people[0] = new Peoples("Bar", "Foo"); people[1] = new Peoples("Quirk", "Baz"); people[2] = new Peopls("Get", "Gad"); My indexing is apparently out of range according to the exception I get.

    Read the article

  • createChildren Called Before Component's MXML Bracket Logic Is Evaluated

    - by Nalandial
    I have the following MXML: <mx:Script> var someBoolean:Boolean = determineSomeCondition(); </mx:Script> .... <foo:MyComponent somePropertyExpectingIDataRenderer="{ someBoolean ? new Component1ThatImplementsIDataRenderer() : new Component2ThatImplementsIDataRenderer() }"> </foo:MyComponent> I have also overridden the createChildren() function: override protected function createChildren():void { super.createChildren(); //do something with somePropertyExpectingIDataRenderer } My problem is: createChildren() is being called before the squiggly bracket logic is being evaluated, so in createChildren(), somePropertyExpectingIDataRenderer is null. However if I pass the component via MXML like this: <foo:MyComponent> <bar:somePropertyExpectingIDataRenderer> <baz:Component1ThatImplementsIDataRenderer/> </bar:somePropertyExpectingIDataRenderer> </foo:MyComponent> Then when createChildren() is called, that same property isn't null. Is this supposed to happen and if so, what other workarounds should I consider?

    Read the article

  • OutOfMemoryError calling XmlSerializer.Deserialize() - not related to XML size!

    - by Mike Atlas
    This is a really crazy bug. The following is throwing an OutOfMemoryException, for XML snippits that are very short (e.g., <ABC def='123'/>) of one type, but not for others of the same size but a different type: (e.g., <ZYX qpr='baz'/>). public static T DeserializeXmlNode<T>(XmlNode node) { try { return (T)new XmlSerializer(typeof(T)) .Deserialize(new XmlNodeReader(node)); } catch (Exception ex) { throw; // just for catching a breakpoint. } } I read in this MSDN article that if I were using XmlSerializer with additional parameters in the constructor, I'd end up generating un-cached serializer assemblies every it got called, causing an Assembly Leak. But I'm not using additional parameters in the constructor. It also happens on the first call, too, so the AppDomain is fresh. Worse yet, it is only thrown in release builds, not debug builds. What gives?

    Read the article

  • Racket regular-expression matching

    - by Inaimathi
    I'm trying to create a regex that matches the inverse of a certain string type (so, strings not ending in ".js", for example). According to the documentation, that should be the expression #rx"(?!\\.js$)", but it doesn't seem to work. To test it out, I have this function: (define (match-test regex) (map (lambda (text) (regexp-match? regex text)) '("foo.js" "bar.css" "baz.html" "mumble.gif" "foobar"))) (match-test #rx"\\.js$") returns (#t #f #f #f #f) as expected, but (match-test #rx"(?!\\.js$)") returns (#t #t #t #t #t), where I would expect (#f #t #t #t #t). What am I doing wrong, and how do I actually get a regex in Racket to express the idea "match anything which does not contain [x]"?

    Read the article

  • C#, DI, IOC using Castle Windsor

    - by humblecoder
    Hi! Am working on a design of a project. I would like to move the implementation away hence to decouple am using interfaces. interface IFoo { void Bar(); void Baz(); } The assemblies which implemented the above interface would be drop in some predefined location say "C:\Plugins" for eg: project: A class A : IFoo { } when compiled produces A.dll project: B class A : IFoo { } when compiled produced B.dll Now I would like to provide a feature in my application to enable end use to configure the assembly to be loaded in the database.say C:\Plugins\A.dll or C:\Plugins\B.dll How it can be achieved using Castle Windsor. container.AddComponent("identifier",load assembly from specified location as configured in DB); I would like to do something like this: IFoo foo =container.Resolve("identifier"); foo.Bar(); //invoke method. Any hint would be highly appreciated. Thanks, Hamed.

    Read the article

  • Messy bash variable

    - by Kyle
    I'm writing a script to ssh in to a list of machines and compare a variable to another value.. I've run into a problem (I have a couple workarounds, but at this point I'm just wondering why this method isn't working). VAR=ssh $i "awk -F: '/^bar/ {print \$2}' /local/foo.txt" ($i would be a hostname. The hosts are trusted, no password prompt is given) Example of foo.txt: foo:123456:abcdef bar:789012:ghijkl baz:345678:mnopqr I'm assuming it's a problem with quotes, or \'s needed somewhere. I've tried several methods (different quoting, using $() instead of ``, etc) but can't seem to get it right. My script is working correctly using the following: VAR=ssh $i "grep bar /local/foo.txt" | awk -F: '{print \$2}' Like I said, just a curiousity, any response is appreciated.

    Read the article

  • PHP Fizzbuzz Challenge

    - by Pez Cuckow
    Someone at work as poised the challenge to create a script that prints the FizzBuzz game in as few likes as possible using PHP The challenge Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”. My attempt: foreach(range(1,100) as $i) { $val = ($i % 3 == 0 ? "Fizz" : "").($i % 5 == 0 ? "Buzz" : ""); echo (empty($val) ? $i : $val) . '<br />'; } Someone's Pythons attempt [ ("Fizz" if not i % 3 else "") + ("Buzz" if not i % 5 else "") + ("Baz" if not i % 7 else "") if _ else "" for i in range(0, 100) ] Can you see how to make this better/improve it? Or even do it better? Thanks for your time

    Read the article

  • C# programatically using a string as object name when instantiating an object

    - by emk
    This is a contrived example, but lets say I have declared objects: CustomObj fooObj; CustomObj barObj; CustomObj bazObj; And I have an string array: string[] stringarray = new string[] {"foo","bar","baz"}; How can I programatically access and instantiate those objects using the string array, iterating using something like a foreach: foreach (string i in stringarray) { `i`Obj = new CustomObj(i); } Hope the idea I'm trying to get across is clear. Is this possible in C#? Thanks in advance.

    Read the article

  • rewrite URLs in CSS files

    - by Don
    Hi, I'm writing a Maven plugin that merges CSS files together. So all the CSS files that match /foo/bar/*.css might get merged to /foo/merged.css. A concern is that in a file such as /foo/bar/baz.css there might be a property such as: background: url("images/pic.jpg") So when the file is merged into /foo/merged.css this will need to be changed to background: url("bar/images/pic.jpg") The recalculated URL obviously depends on 3 factors: original URL original CSS file location merged CSS file location Assuming that the original and merged CSS files are both on the same filesystem, is there a general formula (or Java library) that can be used to calculate the new url given these 3 inputs? Thanks, Don

    Read the article

  • Sending elements of an array as arguments to a method call

    - by Bryce
    I have a method that accepts the splat operator: def hello(foo, *bar) #... do some stuff end I have an array with a variable length that I'd like to send into this hello method: arr1 = ['baz', 'stuff'] arr2 = ['ding', 'dong', 'dang'] I'd like to call the method with arr1 and arr2 as arguments to that method but I keep getting hung up in that *bar is being interpreted as an array instead of individual arguments. To make things more fun, I can't change the hello method at all. I'm looking for something similar to this SO question but in ruby.

    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

  • C# extension method doesn't seem to exist

    - by blahblah
    I can't seem to get the following extension method to be found in another class in the same namespace (MyProject.Util). using System.Collections.Specialized; namespace MyProject.Util { public static class Extensions { public static string Get( this NameValueCollection me, string key, string def ) { return me[key] ?? def; } } } As you can see it's basically another version of foo[bar] ?? baz, but I still don't understand why VS2008 fails to compile telling me that no version of Get takes two arguments. Any ideas?

    Read the article

  • Rack::ResponseHeaders in rackup for Sinatra

    - by sevennineteen
    I think this is a very easy one, but I can't seem to get it right. Basically, I'm trying to use Rack middleware to set a default Cache-Control header into all responses served by my Sinatra app. It looks like Rack::ResponseHeaders should be able to do exactly what I need, but I get an error when attempting to use the syntax demonstrated here in my rackup file: use Rack::ResponseHeaders do |headers| headers['X-Foo'] = 'bar' headers.delete('X-Baz') end I was able to get Rack::Cache to work successfully as follows: use Rack::Cache, :default_ttl => 3600 However, this doesn't achieve exactly the output I want, whereas Rack::ResponseHeaders gives fine-grained control of the headers. FYI, my site is hosted on Heroku, and the required Rack gems are specified in my .gems manifest. Thanks! Update: After doing some research, it looks like the first issue is that Rack::ResponseHeaders is not found in the version of rack-contrib (0.9.2) which was installed. I'll start by looking into that.

    Read the article

  • mod_rewrite in conjunction with "options indexes"

    - by Travis
    I have a directory ("files") where sub-directories and files are going to be created and stored over time. The directories also need to deliver a directory listing, using "options indexes", but only if a user is authenticated, and authorized. I have that part built, and working, by doing the following: <Directory /var/www/html/files> Options Indexes IndexOptions FancyIndexing SuppressHTMLPreamble HeaderName /includes/autoindex/auth.php </Directory> Now I need to take care of file delivery. To force authentication for files, I have built the following: RewriteCond %{REQUEST_URI} -f RewriteRule /files/(.*) /auth.php I also tried: RewriteCond %{REQUEST_URI} !-d RewriteRule /files/(.*) /auth.php Both directives are redirecting to auth.php when I request: foo.com/files/bar/ foo.com/files/bar/baz I am outputting the SERVER global on auth.php during testing and it is showing the requests as I made them (I thought Apache may have been doing something behind the scenes by adding something like "index.html" to the end with "Options Indexes" being on). Ideas?

    Read the article

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