Search Results - JustLinux Forums


Search:

Type: Posts; User: bwkaz

Page 1 of 2 1 2

Search: Search took 0.09 seconds.

  1. Replies
    278
    Views
    666,196

    Hey, look, another Useless Use Of Backticks! :p ...

    Hey, look, another Useless Use Of Backticks! :p Forget the backticks (especially when all they do is call echo), just use the value directly. ;)

    In this case, the problem seems to be that when...
  2. Replies
    278
    Views
    666,196

    Well, the matrix multiplication algorithm looks...

    Well, the matrix multiplication algorithm looks like:


    [ a b ] [ c d ] = [ ac+bg ad+bh ]
    [ e f ] [ g h ] = [ ec+fg ed+fh ] Now, I don't see any way to simplify this to three instructions -- at...
  3. Replies
    278
    Views
    666,196

    As long as *_a + *_b

    As long as *_a + *_b <= INT_MAX, anyway... ;)

    Er, well, wait, maybe it would still work.

    ...

    ...

    Yeah, it would, as long as *_a and *_b are both positive. If they're negative, you can...
  4. Replies
    278
    Views
    666,196

    fd = open("/dev/mem", O_RDWR); /* do stuff...

    fd = open("/dev/mem", O_RDWR);

    /* do stuff with fd */ Alternately:


    char *ptr = malloc(however_much_you_need);

    /* do stuff with ptr */ since all memory is "protected" as far as the Intel...
  5. Replies
    278
    Views
    666,196

    *involuntary shudder* :p Instead of using a...

    *involuntary shudder*

    :p

    Instead of using a floating point math function, here's what I'd do:


    unsigned char p = (unsigned char)(1 << i); ;)
  6. Replies
    278
    Views
    666,196

    Well, I won't do this, because I have a few other...

    Well, I won't do this, because I have a few other things going on at the moment, but it shouldn't be too hard to do. You should only need the Xtst libraries, and the <X11/Xtest.h> includes. Then...
  7. Replies
    278
    Views
    666,196

    Well... maybe, but it's not "code" per se. It's...

    Well... maybe, but it's not "code" per se. It's just one enormous regular expression that's meant to be applied to a string to determine whether the string is a valid RFC-822 address. AFAIK there...
  8. Replies
    278
    Views
    666,196

    Maybe, but I don't think there's any way I'll...

    Maybe, but I don't think there's any way I'll ever be able to decipher this one:

    http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html

    :p
  9. Replies
    278
    Views
    666,196

    Hrmm, let's see... sed -e...

    Hrmm, let's see...


    sed -e 's/[[:space:]]/\n/g' file.txt | sed -e 's/[^A-Za-z]//g' | cut -c 1 perhaps?
  10. Replies
    278
    Views
    666,196

    psych-major: find /path -name '*.mp3'...

    psych-major:

    find /path -name '*.mp3' >file.m3u

    will work, as long as none of the filenames or directories have newlines in them. (Which is actually legal in filenames, but I doubt that the...
  11. Replies
    278
    Views
    666,196

    I really should. It might make it "easier",...

    I really should.

    It might make it "easier", but there's the minor detail of how it also makes it "wrong". :D (At least, "wrong" in terms of what I believe the C++ committees want. I could be...
  12. Replies
    278
    Views
    666,196

    So in other words, you "factor" ax^3 + bx^2 + cx...

    So in other words, you "factor" ax^3 + bx^2 + cx + d into:

    (((ax + b)x + c)x + d

    It's not a true factorization, but it does reduce into n multiplications.

    (FWIW: This question was asked so...
  13. Replies
    278
    Views
    666,196

    /usr/games/fortune :p

    /usr/games/fortune

    :p
  14. Replies
    278
    Views
    666,196

    :D I can do it without an if, but I need a...

    :D

    I can do it without an if, but I need a dummy variable:


    int y = ((int)(x & 0x800000000u)) >> 31;
    /* y is all 1 bits now if x was negative, and 0 otherwise */

    x ^= y; /* either...
  15. Replies
    278
    Views
    666,196

    Well, actually no, I'm not positive. But the...

    Well, actually no, I'm not positive.

    But the jump table would be absolutely gigantic with a switch that looks like this:


    switch(tempvar) {
    case 0: break;
    case INT_MAX: break;
    }...
  16. Replies
    278
    Views
    666,196

    Um... no it isn't... ;) First, it would...

    Um... no it isn't... ;)

    First, it would require, at MINIMUM, 16 billion gigabytes of code space (since it'll be at least one byte for each value of a and b, that's 4 billion, squared,...
  17. Replies
    278
    Views
    666,196

    Well, you didn't say what language, I guess... ...

    Well, you didn't say what language, I guess...


    #!/bin/sh

    if [ $# -ne 1 ] ; then
    echo "Usage: $0 filename"
    exit 1
    fi
  18. Replies
    278
    Views
    666,196

    And make sure that the argument to ceil() is a...

    And make sure that the argument to ceil() is a float or double, not an integer. In other words, this:


    int x = 5, y = 22;

    printf("%lf\n", ceil(y/x)); won't work, it'll print 4. The reason is...
  19. Replies
    278
    Views
    666,196

    Re: Re: I have one...

    Aww, come on! I want to yell at you about it! (... or, uh, something...)

    :p

    http://rhols66.adsl.netsonic.fi/era/unix/award.html ;)
  20. Replies
    278
    Views
    666,196

    You don't even need to use cat for that (this is...

    You don't even need to use cat for that (this is one of the Useless Uses of Cat, congratulations! :p)

    You can do this instead:

    sed -e 's/[TAB]/[3 SPACES]/' <$file >$newfile

    Or, better yet,...
  21. Replies
    278
    Views
    666,196

    Strike: you don't even need the...

    Strike: you don't even need the range(int(math.sqrt(10000))). The square root of 10000 is 100, so you can just use range(100). :p

    (Of course, this doesn't negate the fact that x**2 is...
  22. Replies
    278
    Views
    666,196

    Yep, there's a dynamic programming algorithm to...

    Yep, there's a dynamic programming algorithm to do it.

    I don't remember what that algorithm is, of course ( :eek: ), but I do remember that it exists...
  23. Replies
    278
    Views
    666,196

    #!/bin/bash /usr/bin/wc "$@" You just have to...

    #!/bin/bash

    /usr/bin/wc "$@" You just have to give it the right options... ;)
  24. Replies
    278
    Views
    666,196

    Sure, just factor it. Oh, wait... not all...

    Sure, just factor it.

    Oh, wait... not all polynomials factor... :p


    int sum(int num1, int num2)
    {
    int result = 0;
    int i, carry = 0;
  25. Replies
    278
    Views
    666,196

    ( a + ib ) * ( c + id ) = ac - bd + i ( ad + bc )...

    ( a + ib ) * ( c + id ) = ac - bd + i ( ad + bc )

    So, I don't think I can figure a way to do it in less than four multiplications...

    Hmm, maybe this:

    ( a + ib ) c + ( a + ib ) id

    But...
Results 1 to 25 of 26
Page 1 of 2 1 2