Describe your best "computer nerd" moment

  • Posted by a hidden member.
    Log in to view his profile

    Feb 12, 2009 10:10 PM GMT
    So I thought I'd be a jackass and throw this into a section of code that authenticates users... To sum it up, this sets the error message when multiple user accounts have the same user name, which should never happen due to unique key constraints in the database.


    <?php
    // we found our user
    if( $record_count_row['record_count'] == 1 )
    {
    ...
    }
    // there was more than one record found--THIS SHOULD NEVER HAPPEN
    elseif( $record_count_row['record_count'] > 1 )
    {
    // no user id determined
    $user_info['user_id'] = 0;

    // user is not authenticated
    $user_info['authenticated'] = false;

    // authentication failed as follows...
    $user_info['authentication_detail'] = 'Authentication Failed: Some jackass decided ';
    $user_info['authentication_detail'] .= 'to eliminate any sense of referential ';
    $user_info['authentication_detail'] .= 'integrity in the database so now we have ';
    $user_info['authentication_detail'] .= 'multiple records identified with the same ';
    $user_info['authentication_detail'] .= 'UNIQUE value and now it's all fucked up and ';
    $user_info['authentication_detail'] .= 'anyone with the username ';
    $user_info['authentication_detail'] .= '"' . $_SESSION['username'] . '" is gonna think ';
    $user_info['authentication_detail'] .= 'we're a bunch of blithering idiots because ';
    $user_info['authentication_detail'] .= 'of that fucking jackass. ';
    }
    // no record found
    else
    {
    ...
    }
    ?>
  • MikePhilPerez

    Posts: 4357

    Feb 12, 2009 10:17 PM GMT
    What's the code for when someone is told to report someone and he jumps to attention and does it icon_question.gificon_confused.gif Just wondering icon_lol.gif
  • Posted by a hidden member.
    Log in to view his profile

    Feb 12, 2009 10:27 PM GMT
    It'd probably look like...

    <?php
    $Logan = Logan::Get_Instance();
    $Generic_User = Generic_User::Get_Instance();

    if( $Generic_User -> Is_Pain_in_the_Ass() == true
    && $Logan -> Dislikes_User( $Generic_User ) == true )
    {
    do
    {
    $User_Report = $Logan -> Create_User_Report();

    $User_Report -> Set_User( $Generic_User );
    $User_Report -> Set_Type( RPT_USER_ABUSE );

    $User_Report -> Set_Content(
    $Generic_User -> Get_Name() . ' is a real pain in the ass. ' . "\n"
    . 'He should be deleted because he\'s a pain in the ass.' . "\n"
    );

    $Logan -> Deliver_User_Report( $User_Report );
    }
    while( $Generic_User -> Is_Pain_in_the_Ass() );
    }
    else
    {
    $Logan -> Roll_a_Fattie();
    }
    ?>
  • Posted by a hidden member.
    Log in to view his profile

    Feb 12, 2009 10:31 PM GMT
    Referential integrity / database integrity can be so much fun, huh, Chris, Logan, and geeks? LOL!!!

    Note that we write our PHP in a self-documenting way. Logan is Mr. OOP today. LOL. (geekspeak for those of us in the know.)

    Here's an "easter egg" for those of you who have seen one.

    It's the Elmer Fudd egg from Google.

    http://www.google.com/intl/xx-elmer/

    elmer_fudd_google.jpg
  • Posted by a hidden member.
    Log in to view his profile

    Feb 12, 2009 10:47 PM GMT
    I guess it was my first python script to implement a shell command replace with this description:
    -------------------------------------------------------------------------------------------

    replace -x regularExpression [-s string -f -a] [file1] [file2]

    -f replaces the first match on each line of the input(optional)
    -a replaces all matches and overrides -f(optional)
    -s the replacing string(optional)
    -x regular expression(mandatory)

    if file1 exists then its copied with the substitutions to file2 if
    it exists, otherwise its print out to the terminal.

    if file1 doesnt exist, then I move the user to enter his input
    into the terminal

    It is not fully optimize but it prevents most of the possible errors
    and anyway i had fun with it, which is what really matters. Here is
    the code:
    -------------------------------------------------------------------------------------------


    #!/usr/local/bin/python
    import sys, re, os, getopt

    def printError(error, value):
    print >> sys.stderr, error
    sys.exit(value)

    def openFile(fileName, mode):
    try:
    the_file = open(fileName, mode)
    except(IOError), e:
    printError('Can't open file '+ fileName, 1)
    else:
    return the_file

    def main():

    if sys.argv[1] == "help":
    sys.exit(1)

    optF = 0
    optA = 0
    string = ''
    regularExpression = ''
    number = 1
    singleMatch = 0

    valid = 0

    Output = sys.stdout
    Input = sys.stdin

    try:
    opts, rest = getopt.getopt(sys.argv[1:], 'x:s:fa')
    except getopt.GetoptError, err:
    printError(str(err), 1)

    if len(rest) > 2:
    printError('too many extra arguments(files) - limit:2', 1)

    if rest:
    if not os.path.exists(rest[0]) or not os.path.isfile(rest[0]):
    printError(rest[0] + ' doesn't exist or it is a directory', 1)
    else:
    Input = openFile(rest[0], "r")

    if len(rest) == 2:
    if os.path.exists(rest[1]):
    printError(rest[1] + ' already exists in the current directory',1)
    Output = openFile(rest[1], "w")

    for (opt, arg) in opts:
    if opt == '-x':
    valid = 1
    regularExpression = arg
    elif opt == '-s': string = arg
    elif opt == '-f': optF = 1
    elif opt == '-a': optA = 1

    if optA : number = -1
    elif not optF: singleMatch = 1

    if not valid:
    printError('[-x:] option is necessary to execute this command', 1)

    try:
    pattern = re.compile(regularExpression)
    except re.error, err:
    printError(str(err),1)

    control = 1
    for line in Input:
    expression = pattern.search(line)
    if expression and control:
    Output.write(line.replace(expression.group(), string, number))
    if singleMatch: control = 0
    else:
    Output.write(line)

    if Input != sys.stdin : Input.close()
    if Output != sys.stdout: Output.close()

    if __name__ == "__main__": main()


    -------------------------------------------------------------------------------------------------------

    Now testing this command it goes like

    replace -x "w*s" -s "Realjock" -f

    this is amazing
    and is full of weird comments
    it still needs them to survive
    everyone says thats a lie.

    output:

    Realjock is amazing
    Realjock is full of weird comments
    Realjock still needs them to survive
    Realjock says thats a lie.
  • Posted by a hidden member.
    Log in to view his profile

    Feb 12, 2009 11:04 PM GMT
    For those who don't know: python is not typically considered a "shell" in the sense that ksh, bash, csh, rsh, DOS CMD / bat, and so on, are. Instead, python, more correctly, is considered a interpreted programming language. It's in the same category as PHP, PERL, (although PERL can be compiled with perl2cc, and Zend complies PHP to byte code.)

    Some interpreted languages, like PERL, Python, TCL, WSH, have CLIs (command line interfaces) but not all do, such as BASIC. A cli interface allows a user to write scripts that run from the command line. Generally, a "shell" is the interface that sits between the terminal session and the operating system. These languages are some times referred to as just-in-time compilation.

    Other languages like C, C++, RPG, COBOL, FORTRAN, can be compiled to a run time image, and to do even a test run, they have to be compiled. That's why interpreted languages are sometimes preferred for rapid development.

    Some language platforms, like JAVA, compile into byte code, but don't have a CLI, and run in a "sandbox", which adds an extra layer of software. (That's why JAVA slugs along.)

    In almost every instance, python is NOT used as a login, or non-interactive, shell, in terms of user interaction. Viewing PYTHON as an interpreted language is more correct. python is often used to teach entry level programmers the nuances of OOP (Object Oriented Programming) in an open source environment, while not having to deal with a compiler.

    I'm afraid charlitos is in error.
  • Posted by a hidden member.
    Log in to view his profile

    Feb 12, 2009 11:28 PM GMT
    chuchy(sounds better than your real nick) please im falling asleep....ill give you a very good idea, so you can have some fun, run my script in Unix or Windows, or Mac or whenever you like it should work in theory in any platform as long as you change the first line to locate the python interpreter. Once you run it put something like

    replace -x"[bBxXpP]"

    cxphbucbhxbPy neBxpeBdbs tBxpo gbetxP lBpaxxidP

    have fun icon_wink.gif


  • Posted by a hidden member.
    Log in to view his profile

    Feb 12, 2009 11:36 PM GMT
    When I made a dinky boardgame using nothing more but the very basic commands in C++ (Our teacher didn't teach us anything more, my course sucked, tbh). To be specific the header file is only conio.h icon_razz.gif They were quite impressed I made one, considering we were expected to do nothing more but point-of-sales thingies using the shit they taught. Hehe

    Here's a snippet of the code (The section that places a square on the board, and changes adjacent squares based on the rules):

    PLACER:
    if(z[a]!=1&&z[a]!=2&&z[a]==0){z[a]=pturn;}
    else if(z[a]==3){cprintf("Error! Program will now end");getch();goto END;}
    else{goto GAME;}
    //transforms nearby enemy squares
    TRANSFORMER:
    if(py==2){//upper border
    if(px==2){//upper left
    if(z[a+1]==eturn){z[a+1]=pturn;}
    if(z[a+30]==eturn){z[a+30]=pturn;}
    if(z[a+31]==eturn){z[a+31]=pturn;}
    goto STORE;
    }
    else if(px==21){//upper right
    if(z[a-1]==eturn){z[a-1]=pturn;}
    if(z[a+30]==eturn){z[a+30]=pturn;}
    if(z[a+29]==eturn){z[a+29]=pturn;}
    goto STORE;
    }
    else{
    if(z[a-1]==eturn){z[a-1]=pturn;}
    if(z[a+1]==eturn){z[a+1]=pturn;}
    if(z[a+30]==eturn){z[a+30]=pturn;}
    if(z[a+29]==eturn){z[a+29]=pturn;}
    if(z[a+31]==eturn){z[a+31]=pturn;}
    goto STORE;
    }}
    else if(py==21){//lower border
    if(px==2){//lower left
    if(z[a+1]==eturn){z[a+1]=pturn;}
    if(z[a-30]==eturn){z[a-30]=pturn;}
    if(pz[z-29]==eturn){z[a-29]=pturn;}
    goto STORE;
    }
    else if(px==21){//lower right
    if(z[a-1]==eturn){z[a-1]=pturn;}
    if(z[a-30]==eturn){z[a-30]=pturn;}
    if(z[a-31]==eturn){z[a-31]=pturn;}
    goto STORE;
    }
    else{
    if(z[a+1]==eturn){z[a+1]=pturn;}
    if(z[a-1]==eturn){z[a-1]=pturn;}
    if(z[a-30]==eturn){z[a-30]=pturn;}
    if(z[a-31]==eturn){z[a-31]=pturn;}
    if(z[a-29]==eturn){z[a-29]=pturn;}
    goto STORE;
    }}
    else if(px==2&&py<21&&py>2){//left border
    if(z[a+1]==eturn){z[a+1]=pturn;}
    if(z[a-30]==eturn){z[a-30]=pturn;}
    if(z[a-29]==eturn){z[a-29]=pturn;}
    if(z[a+30]==eturn){z[a+30]=pturn;}
    if(z[a+31]==eturn){z[a+31]=pturn;}
    goto STORE;
    }
    else if(px==21&&py<21&&py>2){//right border
    if(z[a-1]==eturn){z[a-1]=pturn;}
    if(z[a-30]==eturn){z[a-30]=pturn;}
    if(z[a+29]==eturn){z[a+29]=pturn;}
    if(z[a+30]==eturn){z[a+30]=pturn;}
    if(z[a-31]==eturn){z[a-31]=pturn;}
    goto STORE;
    }
    else{//not beside borders. "normal"
    if(z[a-1]==eturn){z[a-1]=pturn;}
    if(z[a-30]==eturn){z[a-30]=pturn;}
    if(z[a+29]==eturn){z[a+29]=pturn;}
    if(z[a+30]==eturn){z[a+30]=pturn;}
    if(z[a-31]==eturn){z[a-31]=pturn;}
    if(z[a+1]==eturn){z[a+1]=pturn;}
    if(z[a-29]==eturn){z[a-29]=pturn;}
    if(z[a+31]==eturn){z[a+31]=pturn;}
    goto STORE;
    }


    Full code can be seen here: http://dpaste.com/119960/ (P.S. my teammates did nothing to help make this... AT ALL)
  • Posted by a hidden member.
    Log in to view his profile

    Feb 12, 2009 11:38 PM GMT
    chuckystud saidNote that we write our PHP in a self-documenting way. Logan is Mr. OOP today. LOL. (geekspeak for those of us in the know.)


    Object-oriented programming is about the best way to burn up your computer's resources. I only do it so I can put it on my resume because people are dumb and think it's a good idea.

    It's only a good idea in the sense of an upsell: it takes three times as long to write it than it does in procedural, and when you wanna do maintenance and upgrades, it takes five times as long! Two times for finding the spot that needs upgrading, and three times to write backwards-compatibility functions.
  • Posted by a hidden member.
    Log in to view his profile

    Feb 12, 2009 11:40 PM GMT
    flex89 said
    chuckystud saidNote that we write our PHP in a self-documenting way. Logan is Mr. OOP today. LOL. (geekspeak for those of us in the know.)


    Object-oriented programming is about the best way to burn out your computer's processors. I only do it so I can put it on my resume because people are dumb and think it's a good idea.


    its a good idea, for big projects, it might be a waste of time for small projects.
  • Posted by a hidden member.
    Log in to view his profile

    Feb 12, 2009 11:44 PM GMT
    charlitos said
    flex89 said
    chuckystud saidNote that we write our PHP in a self-documenting way. Logan is Mr. OOP today. LOL. (geekspeak for those of us in the know.)


    Object-oriented programming is about the best way to burn out your computer's processors. I only do it so I can put it on my resume because people are dumb and think it's a good idea.


    its a good idea, for big projects, it might be a waste of time for small projects.


    To a point. After a while the script's execution gets noticeably slower, which is a major problem if you want a scalable application.

    Either way, I like doing it in encapsulated procedural code because it's easier, takes less time to write, and it's speedy.
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 1:26 AM GMT
    Hi Charlitos icon_wink.gif

    Carry on icon_lol.gif
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 1:30 AM GMT
    I think I need to get BASIC with everyone.

    icon_twisted.gif

  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 3:34 AM GMT
    flex89 said
    charlitos said
    flex89 said
    chuckystud saidNote that we write our PHP in a self-documenting way. Logan is Mr. OOP today. LOL. (geekspeak for those of us in the know.)


    Object-oriented programming is about the best way to burn out your computer's processors. I only do it so I can put it on my resume because people are dumb and think it's a good idea.


    its a good idea, for big projects, it might be a waste of time for small projects.


    To a point. After a while the script's execution gets noticeably slower, which is a major problem if you want a scalable application.

    Either way, I like doing it in encapsulated procedural code because it's easier, takes less time to write, and it's speedy.


    You are right about that, but OOP is not about typing code that runs faster but typing code that is easier to maintain, debug, reuse and integrate. If you dont follow an OOP model for big projects then whoever needs to update and make any changes to the code will find himself doing repetitive taks that will just increase the probability of errors in the code, this person will also have access to functions and variables that probably he is not supposed to have access to from an specific location but there's nothing there to tell him it is illegal.

    OOP is beautiful, yet slow, but faster computers are being built every single day, this code will perform faster, and the human beings working in the code will be able to perform efficiently and faster as well. The alternative should be considered only in specific situations.
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 3:41 AM GMT
    I have many computer nerd moments ... but one of my favorites was the time during my computer security class when I wanted to see how quickly a malicious program could render a computer useless.

    I managed to write a self-replicating rabbit program, about 10 lines of code, that consumed all the resources on my computer in less than a second. And, because I was brilliant and put it into the auto-start folder, rebooting did no good as the computer would die before it even fully logged on ...

    I ended up having to use an emergency boot disk, boot to DOS, and remove it using the command line in order to get the computer running again. That was fun ... and also something I never, ever, did again!
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 3:51 AM GMT
    At the end of the day, you have code that does one of several things.
    1. Runs sequential
    2. Branches (if then else)
    3. Runs during a condition (do while)

    Whether you say
    item.update
    item.remove

    or

    item_update();
    item_remove();

    is really kind of silly.

    A class is simply a collection of functions exposed via a different notation that can be institated and so on. A class has an advantage of being reusuable, but, so does a function file.

    In either case you have to learn the functions to call (either via a method, or a function call)

    In many situations, let's say where you're dumping data to the standard output of web server, OOP doesn't gain you much, and costs you a lot.

    It's true that there ARE more resources to waste / burn and Windoze is a classic example of where that process leads. It doesn't necessarily encourage better code. Bad code is bad code, whether written in a conventional / procedural manner, or an OOPS manner. The differences are mainly in notation, with additonal overhead incurred in the management of the objects.

    Any good CTO can tell that there are many cases where OOP makes no sense. It's simply takes way more time and expense to develop and maintain.

    That being said, OOP has a place, and it's been taught to folks for a while now, and it's where there comfort zone is. It doesn't mean it's the best solution. It can sometimes be a good solution but for fast-running apps, with rapid development, procedural code with global scope, makes a lot of sense.

    E.g.

    object.property

    or

    item in list of C structure = value

    or name{value}

    are really just different ways of notating a name value pair with the latter not incurring the overhead of a function in a class. That's why procedural code can be so MUCH faster to develop, easier to maintain, and so MUCH less resource intensive and scale so much better. The former involves way more code, and more space in the name table, much more housekeeping, in general; more cpu. For scaling, the procedural code makes a lot more sense. M$ teaches a good lesson of how OOP can break computing resources with each iteration of their software.

    Nowadays, because memory is cheap and Moore's law with regard to CPU is staying ahead, folks can write really bad code and it runs, without bringing a box down. Just because one can write bad code, it doesn't mean they should.

    In a real world scenario, scalability and performance will often trump OOP at any cost.

    It wrong to say that OOP will perform faster. OOP, rarely, if ever, will perform faster than procedural code because of the obvious additional overhead of the management of the objects, name table, copies, and so on. It can take up to 70% longer to develop, and run up to 30% slower. Optimizing compiling can fix this some, but, no matter what OOP adds plenty of additional overhead.

    The more you learn, the more you realize how little you know.

    As some of the viewers develop a more learned position with regard to computer data processing I'm hoping that they'll modify their view to more realistic ones.

    Youthful belligerence doesn't change the facts of how computers work.
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 3:53 AM GMT
    me falling asleep again....
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 3:57 AM GMT
    My best computer moment?

    Teaching my mother how to "cut and paste"
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 4:00 AM GMT
    charlitosOOP is beautiful, yet slow, but faster computers are being built every single day, this code will perform faster, and the human beings working in the code will be able to perform efficiently and faster as well. The alternative should be considered only in specific situations.


    In short: faster computers means you're able to write sloppy code. But let's face it, if you can right clean, easy to maintain code, AND it runs faster than anyone else's, you've got yourself a guaranteed job!

    Object-oriented programming is nothing more than another way of noting functions and variables. At the end of the day, programming gets down to nothing more than if/else and do/while constructors and anything more than that rarely adds value beyond more time on your next pay period.

    With OOP, you add unnecessary overhead to your applications, which slows your computer, you add extra subroutines to your applications, which slows your computer, and when you program in "pure" objects, you end up loading so much garbage into memory it slows your computer to a snail's crawl. Ever wonder why Windows hangs?

    Sure OOP looks cool, sure it's an invigorating mental stretch to write it, but it's hard to make the argument that an object is really necessary for an exclusively single instance of a subroutine within your entire application. What happens if you decide you want to do a second instance, but it has different properties or methods? Well, you extend the object and add even more overhead and memory requirements to your application, and you slow down your computer even more.

    A CTO of any respectable company with an Internet presence would know top priorities would be to ensure longevity of hardware hosting the company's applications, ensure near-100% uptime of the company's hardware, and ensure a pleasant customer experience. OOP hogs up so many resources that your servers can't handle large numbers of visitors, your processes run much slower, and you run the risk of hardware damage due to overheating and stress. If you were overseeing this kind of development, you'd get fired!

    And if this wasn't enough to make a dent, think of it this way: Objects are broken up bits of procedural code buried in wrapping paper and fluff. Doesn't add any value.
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 4:03 AM GMT
    cjcscuba1984 saidMy best computer moment?

    Teaching my mother how to "cut and paste"


    I think we've all been there LOL!
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 4:14 AM GMT
    Flex you might be right to some extent, but the fact the everything is an object is just a powerful security layer you add to your project. OOP is more secure and theres no way you can replace OOP model and concept without recreating an OOP model. It is a fact, and it pissed me off when I decided to adapt my mentality to the concept. What you are trying to do is just stick to one concept, I can just argue your comment by saying that it would be better if I use assembly for desktop apps since itll run way faster than any Programming Language out there. Yet it is just a waste of time and effort in most cases, however in other situations might be the best alternative.

    The thing is like this: some applications will require C, some applications will require C++, some others will need some PHP scripting or Perl and some big Projects might need a combination of all of the above. Every technology and concept that's survived till today has something it is really good at. You have to identify what your priorities are in a short and a long term when you want to build software, and then what are the right tools to do it the best way possible so it satisfies these priorities.

    summarizing: I agree with you, depending on the project itself.
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 4:16 AM GMT
    flex89 said
    cjcscuba1984 saidMy best computer moment?

    Teaching my mother how to "cut and paste"


    I think we've all been there LOL!


    LMFAO, probably everyone in this generation has been there as flex said. The difference when you are a computer scientist is that if they ask you where is some option in Word or Power Point and you are like "I have no clue" the answer goes like "and you are a computer scientist?" icon_rolleyes.gif
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 4:54 AM GMT
    How about a facepalm/nerd moment? I was explaining to a lady what HTML meant and she was convinced I was lying to her...

    I'm really losing my patience with senile individuals. icon_mad.gif
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 5:00 AM GMT
    charlitos said
    flex89 said
    cjcscuba1984 saidMy best computer moment?

    Teaching my mother how to "cut and paste"


    I think we've all been there LOL!


    LMFAO, probably everyone in this generation has been there as flex said. The difference when you are a computer scientist is that if they ask you where is some option in Word or Power Point and you are like "I have no clue" the answer goes like "and you are a computer scientist?" icon_rolleyes.gif


    Yeah I've got one client who swings between "Well, you should know this you specialize in it" and "What the hell do you know? You're only 19" yet he manages to fuck up every solution I've ever made for him and can't normalize a database to fit even 1NF.
  • Posted by a hidden member.
    Log in to view his profile

    Feb 13, 2009 5:13 AM GMT
    Mine was writing some assembly code for a PIC chip that I used to interface my doorbells to my network (via sending xPL network messages in response to the doorbells being used).

    It wasn't the assembly language (love it), or the PIC chips (use them all the time for custom projects) or the xPL interface (I'm a big contributor to the xPL project), but explaining why I was putting my doorbells onto my local network to my non-tech friends. Forgetting the technical side of it, they just couldn't understand why I'd want to do it and after fumbling around for 30 minutes, I just decided it was "because...."

    I won't even get into the entire side-business I got into designing and selling controllers for full-spectrum LEDs just so I could get a batch of PC boardss created in Thailand for cheap.