Search Results

Search found 7418 results on 297 pages for 'argument passing'.

Page 209/297 | < Previous Page | 205 206 207 208 209 210 211 212 213 214 215 216  | Next Page >

  • What is the best, python or bash for selectively concatenating lots of files?

    - by Werner
    Hi, I have around 20000 files coming from the output of some program, and their names follow the format: data1.txt data2.txt ... data99.txt data100.txt ... data999.txt data1000.txt ... data20000.txt I would like to write a script that gets as input argument the number N. Then it makes blocks of N concatenated files, so if N=5, it would make the following new files: data_new_1.txt: it would contain (concatenated) data1.txt to data5.txt (like cat data1.txt data2.txt ... data_new_1.txt ) data_new_2.txt: it would contain (concatenated) data6.txt to data10.txt ..... I wonder what do you think would be the best approach to do this, whether bash, python or another one like awk, perl, etc. The best approach I mean in terms of simplest code. Thanks

    Read the article

  • How to make the first invocation of a macro different from all the next ones ?

    - by LB
    Hi, that may be really simple but i'm unable to find a good answer. How can I make a macro representing first a certain value and then a different one ? I know that's nasty but i need it to implicitly declare a variable the first time and then do nothing. This variable is required by other macros that i'm implementing. Should i leverage "argument prescan" ? thanks for the answers. EDIT To make things clearer. Suppose i have a macro FOO, and I do something like FOO FOO FOO I would like the result to be foo bar bar I don't want the actual code to be cluttered by ifndef. The programmer should only have to write macro invocations.

    Read the article

  • JUnit Theories: Why can't I use Lists (instead of arrays) as DataPoints?

    - by MatrixFrog
    I've started using the new(ish) JUnit Theories feature for parameterizing tests. If your Theory is set up to take, for example, an Integer argument, the Theories test runner picks up any Integers marked with @DataPoint: @DataPoint public static Integer number = 0; as well as any Integers in arrays: @DataPoints public static Integer[] numbers = {1, 2, 3}; or even methods that return arrays like: @DataPoints public static Integer[] moreNumbers() { return new Integer[] {4, 5, 6};}; but not in Lists. The following does not work: @DataPoints public static List<Integer> numberList = Arrays.asList(7, 8, 9); Am I doing something wrong, or do Lists really not work? Was it a conscious design choice not to allow the use Lists as data points, or is that just a feature that hasn't been implemented yet? Are there plans to implement it in a future version of JUnit?

    Read the article

  • g++: how to specify preference of library path?

    - by Heinrich Schmetterling
    I'm compiling a c++ program using g++ and ld. I have a .so library I want to be used during linking. However, a library of the same name exists in /usr/local/lib, and ld is choosing that library over the one I'm directly specifying. How can I fix this? For the examples below, my library file is /my/dir/libfoo.so.0. Things I've tried that don't work: my g++ command is "g++ -g -Wall -o my_binary -L/my/dir -lfoo bar.cpp" adding /my/dir to the beginning or end of my $PATH env variable adding /my/dir/libfoo.so.0 as an argument to g++ Thanks.

    Read the article

  • How to test that invalid arguments raise an ArgumentError exception using RSpec?

    - by John Topley
    I'm writing a RubyGem that can raise an ArgumentError if the arguments supplied to its single method are invalid. How can I write a test for this using RSpec? The example below shows the sort of implementation I have in mind. The bar method expects a single boolean argument (:baz), the type of which is checked to make sure that it actually is a boolean: module Foo def self.bar(options = {}) baz = options.fetch(:baz, true) validate_arguments(baz) end def self.validate_arguments(baz) raise(ArgumentError, ":baz must be a boolean") unless valid_baz?(baz) end def self.valid_baz?(baz) baz.is_a?(TrueClass) || baz.is_a?(FalseClass) end end

    Read the article

  • I'm trying to use a PHP code for panel visibility in a Panels3 based on Friendlist

    - by user366902
    I'm trying to gain a truth value to gain panel visibility. I have a view in place in a panel to display a listing of heartbeat messages that belong to a user. The display works but I cannot figure out how to restrict access to the panel based on the user who is viewing the panel. Goal is I want the panel to only be visible to friends and some people with certain roles. The roles I can handle but I don't know enough about PHP to get it working based on friendship status. I vaguely guess it would be something like: logged user is twoway with user being viewed based on current uid argument. I know my example is nothing like the actual code but as I said I don't have much to go on here.

    Read the article

  • Why can't I project ToString() in VB?

    - by Martinho Fernandes
    If you try to compile the query below in Visual Basic .NET, it fails. From x In {1, 2} Select x.ToString() The error given by the compiler is: Range variable name cannot match the name of a member of the 'Object' class. There is nothing wrong with the equivalent C# query, though: from x in new[]{1, 2} select x.ToString() This does not happen with the ToString overload that takes a format (it is a member of Int32, not Object). It does happen with other members of Object, as long as they don't take an argument: with GetType and GetHashCode it fails; with Equals(object) it compiles. Why is this restriction in place, and what alternatives can I use?

    Read the article

  • mysql fetch error

    - by Luke
    <? $res = $database->userLatestStatus($u); while($row=mysql_fetch_assoc($res)){ $status=$row['status']; echo "$status"; } ?> This is the code on my page, which is throwing up the following error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource.... The database function: function userLatestStatus($u) { $q = "SELECT status FROM ".TBL_STATUS." WHERE userid = '$u' DESC LIMIT 1"; return mysql_query($q, $this->connection); } Any ideas what the problem is?

    Read the article

  • Referencing an array to a pointer

    - by james
    I want to refer a pointer to an array by another pointer. Example: void exp() { double var[2]; exp1(&var[0]); printf("\n varvalue is %lf\n",var[0]); } void exp1(double *var) { //updating the value *var[0]=4.0; exp2(&var[0]); } void exp2(double *var) { *var[0]=7.0; } This should update the value as 7.0(the last update).I am getting an array like invalid argument type of unary(*) . How can i correct this?where i am going wrong here?

    Read the article

  • Magento - createBlock() in controller, can I access this in layout.xml?

    - by pspahn
    I have an index controller with a view action that does the following: echo $this->getLayout() ->createBlock('core/template','builder') ->setTemplate('pages/builder/view.phtml') ->setHeaderText($extra->getHeaderText()) ->setFooterText($extra->getFooterText()) ->setProducts($collection) ->toHtml(); Based on this, I am trying to perform layout updates in builder.xml (which is being set in the module's config.xml). However, I am not sure if you can target blocks instantiated in this manner. Based on the above block creation, am I able to perform the following: <layout version="0.1.0"> <builder_index_view> <!-- shouldn't this reference the createBlock() name argument? --> <reference name="builder"> <block type="page/html_header" name="builder.header" as="builder.header" template="pages/builder/header.phtml"/> </reference> </builder_index_view> </layout>

    Read the article

  • Cartesian Plane

    - by NuNu
    I'm trying to define a function in Haskell that takes an integer argument c and returns the list of all points on the cartesian plane of the form (x/c,y/c) where x and y are integers. x/c is between -2 and 1 and y/r is between -1 and 1 This is what I've gotten so far which I'm almost sure is right but I'm getting a parse error on input = when I run it particularly at this line: cart xs ys c = [(y/c,x/c) | x <- xs, y <- ys] plane :: Int -> [a] plane c = cart [-1*c .. 1*c] [-2*c .. 1*c] c cart xs ys c = [(y/c,x/c) | x <- xs, y <- ys] A sample output would be: plane 1 would generate: [(-2.0, -1.0), (-1.0, -1.0), ( 0.0, -1.0), ( 1.0, -1.0), (-2.0, 0.0), (-1.0, 0.0), ( 0.0, 0.0), ( 1.0, 0.0), (-2.0, 1.0), (-1.0, 1.0), ( 0.0, 1.0), ( 1.0, 1.0)] Anyone have any idea how I can fix this! Thanks

    Read the article

  • boost test case for function taking user input

    - by oadams
    I have a function that takes in user input via std::cin: std::getline(std::cin, in); and creates a corresponding data structure by matching it with a regular expression. The function then returns this data structure. I'm using boost.test and I want to create a unit test to check that the output data type is correct given some inputs. However I don't know how to go about it since the input isn't passed as an argument to the function. EDIT: Is there a simple way to create a boost test case that feeds the function a string via standard input?

    Read the article

  • How do I convert a number (as a String) to an array of bytes in Java?

    - by user1795595
    I'm creating a method specific method for a java project i'm working on. The UML given specifies the return type to be of static byte[] that accepts the arguments (String, byte) So far, looks like this: public static byte[] convertNumToDigitArray(String number, byte numDigits) { } This method is supposed to convert a number (as a String) to an array of bytes. The ordering must go from most to least significant digits. For example, if the number String is “732” then index 0 of the array should contain 7. The last argument (numDigits) should match the length of the string passed in. How do I do this?

    Read the article

  • TypeError while using django Form in editing an Entry

    - by damon
    I have an Entry model which can belong to a Category.I am providing a CategoryChoicesForm sothat the user can choose from various Categorys (from a dropdown list)when an Entry is created or edited. I am having trouble with the CategoryChoicesForm while editing the Entry.It throws a TypeError.. If somebody can make out what is happening..please advise me how to correct this. int() argument must be a string or a number, not 'QueryDict' /home/Django-1.4/django/db/models/fields/__init__.py in get_prep_value, line 537 ...views.py in edit_entry category_choices_form = CategoryChoicesForm(form_data) ... ...forms.py in __init__ self.fields['categoryoption'].queryset = Category.objects.filter(creator=self.creator) Here is the form class CategoryChoicesForm(forms.Form): categoryoption = forms.ModelChoiceField( queryset = Category.objects.none(), required=False,label='Category') def __init__(self, categorycreator,*args, **kwargs): super(CategoryChoicesForm, self).__init__(*args, **kwargs) self.creator=categorycreator self.fields['categoryoption'].queryset = Category.objects.filter(creator=self.creator) The edit_entry view is as follows @login_required @transaction.commit_on_success def edit_entry(request,id,template_name,page_title): form_data = get_form_data(request) entry = get_object_or_404(Entry,pk=id,author=request.user) ... category_choices_form = CategoryChoicesForm(form_data) ...

    Read the article

  • How to split the definition of template friend funtion within template class?

    - by ~joke
    The following example compiles fine but I can't figure out how to separate declaration and definition of operator<<() is this particular case. Every time I try to split the definition friend is causing trouble and gcc complains the operator<<() definition must take exactly one argument. #include <iostream> template <typename T> class Test { public: Test(const T& value) : value_(value) {} template <typename STREAM> friend STREAM& operator<<(STREAM& os, const Test<T>& rhs) { os << rhs.value_; return os; } private: T value_; }; int main() { std::cout << Test<int>(5) << std::endl; }

    Read the article

  • PHP __call vs method_exists

    - by neo
    The Project I'm working on contains something like a wrapper for call_user_func(_array) which does some checks before execution. One of those checks is method_exists (In Case the supplied first argument is an instance of a class and the second is a method name) The other is_callable. The function will throw an exception if one of those checks fails. My Code contains an array with function names (setFoo, setBar, etc.) and the php magic function for overloading (__call) which handles setting, replacing and deletion of certain variables (better certain array elements). The Problem: method_exists will return false if the function is not defined. Do I have any chance to get a true if the __call function does proper handling of the request?

    Read the article

  • Membership provider to use or not to use?????

    - by Shekhar_Pro
    Hi every one , Wish u all a Happy New Year. I am developing a website that uses facebook. Now for managing user i thought Using membrship provider. and choose'd to develop a Custom membership provider. Now my problem is that My data base schema dosn't match the Standred membership schema and the functions provided to Override take different argument than i expect. Like membership uses username as a username to log in. But i haev to use User email ID as the user name, also its searching functions is based on using Username as way to serach but i want it to search by UserID. Same Goes for User insertion, deletion, Updation.. please help me .... Edit Its just an idea, Would it be feasible to forcefully pass my values in the arguments and then handle them in my code.

    Read the article

  • PHP, better to set the variable before if or use if/else?

    - by DssTrainer
    So a simple one that I just never could find a straight answer on. What is better (performance or otherwise): $var = false; If ($a == $b) { $var = true; } or If ($a == $b) { $var = true; } else { $var = false; } I've heard arguments for both ways. I find the first cleaner to ensure I have it set, and a little less code too. The pro being that you may only need to set it once without conditional. But the con being that if the argument is true, it gets set twice. I am assuming the second way is probably best practice

    Read the article

  • Is this the right way of handling command line arguments?

    - by shadyabhi
    ask_username = True ask_password = True ask_message = True ask_number = True def Usage(): print '\t-h, --help: View help' print '\t-u, --username: Username' print '\t-p, --password: Password' print '\t-n, --number: numbber to send the sms' print '\t-m, --message: Message to send' sys.exit(1) opts, args = getopt(sys.argv[1:], 'u:p:m:n:h',["username=","password=","message=","number=","help"]) print opts, args for o,v in opts: if o in ("-h", "--help"): Usage() elif o in ("-u", "--username"): username = v ask_username = False elif o in ("-p", "--password"): passwd = v ask_password = False elif o in ("-m", "--message"): message = v ask_message = False elif o in ("-n", "--number"): number = v ask_number = False #Credentials taken here if ask_username: username = raw_input("Enter USERNAME: ") if ask_password: passwd = getpass() if ask_message: message = raw_input("Enter Message: ") if ask_number: number = raw_input("Enter Mobile number: ") I dont think it is, because I am using 4 objects just for checking if command line argument was provided... Guide me with the best way of doing it..

    Read the article

  • Throwing special type of exception to terminate unit test

    - by trendl
    Assume I want to write a unit test to test a particular piece of functionality that is implemented within a method. If I wanted to execute the method completely, I would have to do some extra set up work (mock objects expectations etc.). Instead of doing that I use the following approach: - I set up the expectations I'm interested in verifying and then make the tested method throw a special type of exception (e.g. TerminateTestException). - Further down in the unit test I catch the exception and verify the mock object expectations. It works fine but I'm not sure it is good practice. I do not do this regularly, only in cases where it saves me time and effort. One thing that comes to mind as an argument against using this is that throwing exceptions takes long time so the tests execute slower than if I used a different approach.

    Read the article

  • Problem in List<double[,]> (C#3.0)

    - by Newbie
    What is wrong with List<double> x = new List<double> { 0.0330, -0.6463, 0.1226, -0.3304, 0.4764, -0.4159, 0.4209, -0.4070, -0.2090, -0.2718, -0.2240, -0.1275, -0.0810, 0.0349, -0.5067, 0.0094, -0.4404, -0.1212 }; List<double> y = new List<double> { 0.4807, -3.7070, -4.5582, -11.2126, -0.7733, 3.7269, 2.7672, 8.3333, 4.7023,0,0,0,0,0,0,0,0,0 }; List z = new List{x,y}; Error: Argument '1': cannot convert from 'System.Collections.Generic.List' to 'double[,]' Help neded.(C#3.0)

    Read the article

  • this pointer to base class constructor?

    - by Rolle
    I want to implement a derived class that should also implement an interface, that have a function that the base class can call. The following gives a warning as it is not safe to pass a this pointer to the base class constructor: struct IInterface { void FuncToCall() = 0; }; struct Base { Base(IInterface* inter) { m_inter = inter; } void SomeFunc() { inter->FuncToCall(); } IInterface* m_inter; }; struct Derived : Base, IInterface { Derived() : Base(this) {} FuncToCall() {} }; What is the best way around this? I need to supply the interface as an argument to the base constructor, as it is not always the dervied class that is the interface; sometimes it may be a totally different class. I could add a function to the base class, SetInterface(IInterface* inter), but I would like to avoid that.

    Read the article

  • Vim plugin only works when file is provided as arg to launch command

    - by nsfyn55
    I am using the plugin java_getset.vim. The issue is that the plugin's commands are only available when I launch vim with the file as an argument. user@machine~: vim myfile.java If launch vim and use command-t or NerdTree to open the file in a buffer the plugin's commands are not accessible. All the filetype detection stuff is configured and working(I have syntax highlighting and indentation). The plugin source appears to be written to the letter according the the vim docs for a filetype plugin. Can anyone help me understand what changes a can make so that I can use this plugin in conjunction with Command-t?

    Read the article

  • CodeContracts: Possibly calling a method on a null reference

    - by dtb
    I'm having an argument with the CodeContracts static analysis tool. My code: class Foo { private static Foo instance = new Foo(); private string bar; public Foo() { bar = "Hello World"; } public static int BarLength() { return instance.bar.Length; // <<-- } } The tool tells me that instance.bar may be a null reference. I believe the opposite. Who is right? How can I prove it wrong?

    Read the article

  • Parameter pack aware std::is_base_of()

    - by T. Carter
    Is there a possibility to have a static assertion whether a type provided as template argument implements all of the types listed in the parameter pack ie. a parameter pack aware std::is_base_of()? template <typename Type, typename... Requirements> class CommonBase { static_assert(is_base_of<Requirements..., Type>::value, "Invalid."); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ parameter pack aware version of std::is_base_of() public: template <typename T> T* as() { static_assert(std::is_base_of<Requirements..., T>::value, "Invalid."); return reinterpret_cast<T*>(this); } };

    Read the article

< Previous Page | 205 206 207 208 209 210 211 212 213 214 215 216  | Next Page >