User Profile

Collapse

Profile Sidebar

Collapse
jabbah
jabbah
Last Activity: Jan 13 '12, 08:42 PM
Joined: Nov 29 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • jabbah
    replied to Run windows batch file from unix
    what precisely do you want to automate. can you describe the intended workflow?

    is sicaries tip not the answer to your problem?


    regarding ssh:

    if you install a ssh server on your windows machine then you can connect to it with ssh and you can execute console programs on the windows machine. it's been a while that i used that, but cygwin sshd worked well for me.

    btw, an ssh server...
    See more | Go to post
    Last edited by jabbah; Jan 13 '12, 03:57 PM. Reason: overlooked sicaries answer at first

    Leave a comment:


  • jabbah
    replied to Running xclock - Setting the Display in Linux
    are you sure you have to set the DISPLAY variable on the server? my experience with windows is a bit dusty but sitting at my linux desktop i only do
    Code:
    joe@desktop:~$ ssh -Y user@server
    [user@server ~] $ echo $DISPLAY 
    localhost:22.0
    [user@server ~] $ xclock
    and it works fine. every time i do this i get a different DISPLAY number so i guess ssh (or putty in your case) is taking care of this.
    ...
    See more | Go to post

    Leave a comment:


  • feels to me as if this would be tough in bash, but i guess it should be doable in perl. just as a rough concept:
    read the file line by line and store the current paragraph in some temp variable and check for the keyword. once the paragraph has ended either discard it or print it
    See more | Go to post

    Leave a comment:


  • jabbah
    started a topic can't call a shell script from within awk

    can't call a shell script from within awk

    i can execute echo from within awk like so:
    Code:
    echo asdf jkl asdf \
    | awk ' /jkl/ { sub(/jkl/,echo "X(&)") } {print}'
    asdf X(jkl) asdf
    but if i want to execute another shell script
    Code:
    cat ~/bin/doit
    #!/bin/bash
    echo -n KKK
    like so:
    Code:
    echo asdf jkl asdf \
    | awk ' /jkl/ { sub(/jkl/,doit) } {print}'
    asdf  asdf
    it doesnt work. ...
    See more | Go to post

  • jabbah
    replied to I see std::plus<T>, but where is std::assign<T>
    in C
    yes, i could write my own. i was just wondering why there is none and whether i should take that as an indicator to look for another "stl way" of proceeding.

    using transform, i would end up with
    Code:
    transform( 
      List.begin(), 
      List.end(), 
      std::bind2nd( std::assign<double>(), 0.0 )
    );
    wouldnt i?

    ahh std::fill didnt see that.

    thanks to...
    See more | Go to post

    Leave a comment:


  • jabbah
    started a topic I see std::plus<T>, but where is std::assign<T>
    in C

    I see std::plus<T>, but where is std::assign<T>

    hi,

    i find a std::plus<T> but what if i just want to assign all elements in my container a certain value. Im thinking of something along the lines of

    Code:
    std::list<double> List;
    std::for_each( 
      List.begin(), 
      List.end(), 
      std::bind2nd( std::assign<double>(), 0.0 )
    );
    but obviously there is no such thing as std::assign<T>
    ...
    See more | Go to post

  • jabbah
    replied to is that safe: V.push_back( V[0] );
    in C
    yak.

    seems that (the implementation of stl that i use) does one reallocation for each call of
    v.reserve( v.size() + 1 );
    i.e. it doesnt grow in the same way as v.push_back() does, but it actually increases the capa by exactly 1.

    im getting bored. maybe i give in to the extra temp copy
    See more | Go to post
    Last edited by jabbah; Dec 17 '09, 12:16 PM. Reason: clarification: its not that _i_ have implemented stl

    Leave a comment:


  • jabbah
    replied to How to write std::list into a file?
    in C
    what about something like this.

    [CODE=c]
    ostream& operator<<( ostream& out, const MyClass& x )
    {
    out << x.a << " " << x.b ..... ;
    return out;
    }
    [/CODE]

    now you can iterate over your list and use <<
    See more | Go to post

    Leave a comment:


  • jabbah
    replied to Need help in pointer
    in C
    Maybe the problem lies in this line:



    are you sure you didnt want to:

    int i = 100;
    int* p = &i;...
    See more | Go to post

    Leave a comment:


  • jabbah
    replied to is that safe: V.push_back( V[0] );
    in C
    sounds good. thanks banfa
    See more | Go to post

    Leave a comment:


  • jabbah
    replied to is that safe: V.push_back( V[0] );
    in C
    agreed.




    I was afraid that this would be your answer. Thanks a lot for clarifying this, Banfa!



    That brings up another idea.

    Suppose I make sure that there is always at least _one_ element free (because I call V.reserve( V.size() + 1 ) _after_ each push_back). Is that enough?

    In other words can I be sure, that reallocation will only happen if V.capacity()...
    See more | Go to post

    Leave a comment:


  • jabbah
    replied to is that safe: V.push_back( V[0] );
    in C
    BUMPING ... anybody??...
    See more | Go to post

    Leave a comment:


  • jabbah
    replied to is that safe: V.push_back( V[0] );
    in C
    huh?!
    has a message from me just disappeared?!

    Im pretty sure that the thread went:

    jabbah: Hi, I just found, ....
    banfa: Here is the problem...
    jabbah:ok, I understand....
    banfa: That should work...
    jabbah: I thought vector....
    jabbah: < This Message Seems To Have Disappeard >
    banfa: It doesn't matter...

    can that be?! hm well


    ...
    See more | Go to post

    Leave a comment:


  • jabbah
    replied to is that safe: V.push_back( V[0] );
    in C
    I thought vector would double the capacity anyway whenever it is about to be exceeded.

    so suppose befor i take action, we have
    V.capacity()==V .size()==a

    then I do one of:
    V.resize( V.size()+1 ), or
    V.resize( V.size()*2 )

    no matter, afterwards we will have
    V.capacity() == 2 * a...
    See more | Go to post

    Leave a comment:


  • jabbah
    replied to is that safe: V.push_back( V[0] );
    in C
    ok, I understand. thanks banfa.

    regarding the tmp copy: what about

    V.reserve( V.size()+1 );
    V.push_back( V[0] );
    See more | Go to post

    Leave a comment:


  • jabbah
    replied to Exchange 1st & last letter in string
    in C
    have you read this
    http://bytes.com/faq.php?faq=posting..._or_coursework

    and do you have a question?...
    See more | Go to post

    Leave a comment:


  • jabbah
    started a topic is that safe: V.push_back( V[0] );
    in C

    is that safe: V.push_back( V[0] );

    Hi, I just found, that code that ran under Visual Studio 8 doesnt run under 9 anymore and now im seeking confirmation of whether my code is unsafe and just accidentially worked or what one can expect from a standard conforming implementation of STL.

    The basic thing is that, given a vector V with some elements in it, I want to push_back one of these elements, like this:

    [CODE=c]#include <iostream>
    #include...
    See more | Go to post

  • jabbah
    replied to beginners question on unary_function<>
    in C
    interessting.

    thanks.
    See more | Go to post

    Leave a comment:


  • jabbah
    replied to beginners question on unary_function<>
    in C
    speaking of terminology, i notice that you emphasise the terms "adaptable functors" and "function adapters". whats behind that?

    my guess is
    - functor is a class with an operator()
    - its called adaptable, if its derived from std::unary_func tion (or binary), ie has typedefs for args and returntypes

    correct me if im wrong. and whats a function adapter?
    See more | Go to post

    Leave a comment:


  • jabbah
    replied to beginners question on unary_function<>
    in C
    alright!
    thanks. of course

    so now i do:
    Code:
    template< typename PREDICATE >
    int doit ( 
    	const int* a, 
    	unsigned int size,
    	PREDICATE predicate ) 
    {
    	int sum = 0;
    	for ( unsigned int i =0 ; i < size; ++i )
    	{
    		if ( predicate(a[i]) )
    			sum += a[i];
    	}
    	return sum;
    }
    which does what i want. thanks banfa
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...