Search:

Type: Posts; User: johnl; Keyword(s):

Page 1 of 10 1 2 3 4

Search: Search took 0.05 seconds.

  1. Replies
    1
    Views
    384

    Re: Wierd performance on python bot

    Hi,

    I noticed right away one major problem with your code.



    def run(self):
    print irc.recv(4096)
    irc.send ( 'NICK ' + botname + '\r\n' )
    irc.send ( 'USER lsb lsb...
  2. Replies
    8
    Views
    342

    Re: [PHP] Single Variable Database

    You could also use redis, which has php bindings, for example predis, which doesn't require any SQL or schema.
  3. Thread: Can't use strsep

    by johnl
    Replies
    3
    Views
    2,603

    [SOLVED] Re: Can't use strsep

    Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

    strsep(): _BSD_SOURCE

    ....


    CONFORMING TO
    4.4BSD.
  4. Replies
    8
    Views
    514

    [SOLVED] Re: Basic Questions about for loops in C

    This syntax:



    for(int i = 0; i < 100; ++i) {

    }


    Is part of the C99 standard. Your compiler will need to support C99 (or have an extension for this behavior) to use it. Prior to C99,...
  5. Replies
    9
    Views
    2,034

    Re: Can't create socket

    Try this.


    include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h> /* IPPROTO_TCP */
    #include <stdio.h> /* printf() */
    #include <unistd.h> /* close() */

    int main(int argc,...
  6. Replies
    3
    Views
    375

    Re: Shortcut for compiling and linking

    Here's a sample makefile for you with some comments. I hope this helps.



    TARGET = myprogram # this is the name your final executable

    AS = as # assembler
    ASFLAGS = -gstabs #...
  7. Replies
    2
    Views
    287

    Re: Newbie Segmentation fault question.

    You are not terminating your program correctly.

    You need something like the following at the end.


    movl $1, %eax ;; syscall 1 is exit()
    movl $0, %ebx ;; argument to exit
    int $0x80 ;; do...
  8. Re: specifying new directory in /etc/ld.so.conf does not seem to work

    Sorry, that was unclear; what I meant was:


    pass_dash_L_to_ld && (specify_LD_LIBRARY_PATH || add_entry_to_ld.so.conf)

    You need to do both the first step and one of the latter steps.
  9. Re: specifying new directory in /etc/ld.so.conf does not seem to work

    At compile time, the compile-time linker, ld, needs to know where to find shared libraries to link to. This is specified, as you noticed, with the -L/path/to/lib argument to ld. You can view the...
  10. Replies
    28
    Views
    4,052

    Re: Obfuscated GPL'd code a violation?

    Javascript is often compressed in the way you described to reduce file size and download time for the user's browser. It would be unusual not to provide a well-formatted version, though.
  11. Replies
    25
    Views
    1,318

    Re: Fastest way to split strings?

    You could probably do it quickly and easily in awk, perl, sed, or a variety of other languages.

    Here's a quick C program which does it.



    /* usage: "./program out1.txt out2.txt < input.txt"...
  12. Replies
    28
    Views
    1,055

    Re: What is a static variable-function?

    You need to de-couple the idea of "static lifetime" and "static linkage."

    Confusingly, in C, you use the same keyword (static) for both of them.

    As previously mentioned,



    int f(void) {...
  13. Replies
    9
    Views
    1,188

    Re: c++ doubly linked list challenge

    I think you're mistaken; traversing the list means that the time to run is dependent on the number of items in the list -- i.e., O(n)?
  14. Replies
    6
    Views
    365

    Re: calloc or malloc ?

    If you want to zero-initialize the memory, use calloc.

    If you don't care about the memory contents or you are planning to overwrite the memory immediately with some (mostly non-zero) data, use...
  15. Re: How to set user-defined colours on a command line screen?

    My comment was that setting TERM=xterm-256color, at least for me in gnome-terminal, will cause can_change_color() to return true.

    When can_change_color() returns true, you can create a color:

    ...
  16. Re: Moving file from hugetlbfilesystem to normal filesystem

    the strace you posted is from mv, right? Look at what happens:

    It tries to call rename(), which fails:


    rename("/mnt/huge/check.txt", "./check.txt") = -1 EXDEV (Invalid cross-device link)

    ...
  17. Thread: gcc compiler

    by johnl
    Replies
    4
    Views
    1,336

    Re: gcc compiler

    C# is a .NET language. gcc is a C compiler, which is not related to C# or .NET.

    You can use mono or monodevelop (the IDE) to compile and run C# code under Linux, assuming it doesn't use...
  18. Re: Moving file from hugetlbfilesystem to normal filesystem

    Why don't you do the following:



    strace mv /mnt/huge/check.txt /where/ever/else.txt


    and see which system calls mv is doing to accomplish this?

    Secondly, I would check the return value...
  19. Re: How to set user-defined colours on a command line screen?

    Try doing:



    TERM=xterm-256color ./run-your-program


    Using gnome-terminal, with this set, you get 256 colors which you can redefine as you want.
  20. Replies
    17
    Views
    1,634

    [SOLVED] Re: Question About Dynamic Arrays Using ReAlloc()

    if (i == 0)
    {
    array = malloc(array_len * sizeof(struct pointxy));
    }
    else
    {
    array = realloc(array, array_len * sizeof(struct pointxy));
    }
  21. Replies
    6
    Views
    12,336

    Re: unix C api to get pid by passin a process name

    You can check the cmdline entries in /proc.

    Something like this:



    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <unistd.h>
  22. Replies
    7
    Views
    1,672

    Re: operator precedence related question

    I suspect that you are running into 'undefined behavior' territory.



    warning: operation on `b` may be undefined [-Wsequence-point]


    Read about sequence points to figure out what's going on...
  23. [SOLVED] Re: C preprocessor and C continuation character \

    Try passing -traditional-cpp (see here). This seems to work for me, but you may need to dig through the document i linked to figure out why. I suspect it is because in valid C code whitespace...
  24. Replies
    8
    Views
    748

    [SOLVED] Re: Testing super user

    Can you tell us why you want to check if the user is root? You might be able to accomplish what you want to do in an alternate manner, like checking if the current user has the capability...
  25. Replies
    19
    Views
    2,494

    Re: how does fgets works

    Please explain what security issues there are with fgets. The issue with gets is obvious and well-known, but I have never heard anyone claim there is a problem with fgets.
Results 1 to 25 of 250
Page 1 of 10 1 2 3 4