Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Coding Horror

18911131422

Comments

  • Registered Users, Registered Users 2 Posts: 7,878 ✭✭✭The_B_Man


    I've spent the last while working on an old app thats still used today. Mostly maintenance.
    Any time I open the IDE, I'm met with the most ridiculous of ridiculous coding horror. Its like it was written by a first year.

    For example, there were around 50 classes that were copy and pasted from the same class, with a few lines changed. I couldnt, in good conscience, let it go unfixed so spent ages moving the common logic into a base class. That cleared up a few thousand lines of code!

    Then there's the stuff like "if (whateverBoolean == true)" instead of just "if (whateverBoolean)", and the random if() statements, with about 20 conditions in them, but no body!!

    The more I work on it, the more I keep finding exact copy and paste problems. Like I'll find a problem, and have to go and fix it in about 20 files, minimum. Its atrocious and needs a complete rewrite tbh.

    Oh and this isnt even taking into account the database logic. The norm would be to have one database manager class and every request goes through that, so it can properly schedule/queue the requests. The way this was written, any time theres a DB request, a new instance of the DB is created, and the request sent in whenever it feels like it. This throws up some interesting exceptions with the database being locked, and various other errors.

    By far the worst code I've ever worked on, and the customer is a household name!! :eek::eek:

    (I should point out that we inherited the code, we didnt write it! :p)


  • Registered Users, Registered Users 2 Posts: 6,523 ✭✭✭daymobrew


    I have just inherited a WordPress/WooCommerce site. It is horrible.

    The "offshore" team took the TwentyTwelve theme, copied the directory to "new" instead of making a child theme.
    For WooCommerce they copied the entire WooCommerce 2.2.8 plugin into a 'woocommerce' subdirectory. This means that they copied all the override templates too and I have to go through them step by step to see which ones were actually customised and delete those that weren't.

    In the functions.php they disabled update notifications.
    [php]function remove_core_updates(){
    global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
    }
    add_filter('pre_site_transient_update_core','remove_core_updates');
    add_filter('pre_site_transient_update_plugins','remove_core_updates');
    add_filter('pre_site_transient_update_themes','remove_core_updates');[/php]
    I didn't know about this code until I installed InfiniteWP plugin and saw 9 plugin updates in the InfiniteWP dashboard.

    80 errors when I ran the home page through W3C Validator (most were bad closing html comment i.e.
    > instead of -->).

    As I said, I have "just inherited" the site. I expect to find a lot more stuff.


  • Registered Users, Registered Users 2 Posts: 7,498 ✭✭✭BrokenArrows


    A customer reported that their login screen kept closing when they tried to login. They said that the uploaded a new xml language file. This language file allows customers to define the text/language of certain buttons/labels etc.
    They sent me the file and i couldnt see anything wrong with it.

    Decided to open up the code to have a quick look.
    private void buttonHOSTESS_Click(object sender, EventArgs e)
            {
                if( buttonHOSTESS.Text == "OK")
                {
                    this.Dispose();
                }
                else
                {// Does the normal work here}
            }
    

    The customer had changed the login button from Ok to OK.


  • Registered Users, Registered Users 2 Posts: 14,345 ✭✭✭✭jimmycrackcorm


    Decided to open up the code to have a quick look. Code: private void buttonHOSTESS_Click(object sender, EventArgs e) { if( buttonHOSTESS.Text == "OK") { this.Dispose(); } else {// Does the normal work here} } The customer had changed the login button from Ok to OK.

    I can't understand this thing about string comparison issues surrounding case sensitivity. It seems crazy from a human perception that we easily acknowledge OK = ok but we don't carry that assumption into our programming.


  • Registered Users, Registered Users 2 Posts: 190 ✭✭NeutralHandle


    It would increase how much the computer has to do to compare strings significantly, and it would not always be desirable behaviour from a functional point of view.

    If you want to do case-neutral string comparison just use something like this: string1.ToUpper().Equals(string2.ToUpper)


  • Technology & Internet Moderators Posts: 28,820 Mod ✭✭✭✭oscarBravo


    The point that's being missed is that performing an action based on the text on a button - especially in a system that allows for localisation - is insanely, stupidly broken.


  • Registered Users, Registered Users 2 Posts: 190 ✭✭NeutralHandle


    I didn't miss that; was just responding to the previous comment :)


  • Registered Users, Registered Users 2 Posts: 7,498 ✭✭✭BrokenArrows


    oscarBravo wrote: »
    The point that's being missed is that performing an action based on the text on a button - especially in a system that allows for localisation - is insanely, stupidly broken.

    And also I have no idea why that was ever there. There is no reason to dispose the whole thing if the button was ok. :)


  • Registered Users, Registered Users 2 Posts: 13,080 ✭✭✭✭Maximus Alexander


    And also I have no idea why that was ever there. There is no reason to dispose the whole thing if the button was ok. :)

    That's exactly what I was thinking. I'm sitting here wondering why nobody else mentioned that part, and thinking I'm a dummy who has missed something. :pac:


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    believe it or not, there's programmers out there that have and will never come across localisation :eek:


  • Registered Users Posts: 311 ✭✭JackHeuston


    I developed a very simple framework for our company to speed up a bit the development of online surveys, which our R&D department do quite often. I took a few days off one time, but a survey happened and had to be published asap. The "developer" in that department took my framework and worked with it then. It's all good, that's what a framework is for and it's intended to be used.

    The whole framework has only the core, plus some modules coming from past surveys in case they need to be re-used (also this happens very often), you just need to extend stuff, add/remove modules as you see fit, without touching a single line of the framework itself.

    When I came back, I checked out how the guy was doing, I was also requested to "give a hand" asap because the survey was still worked on.

    What I found:
    • The framework folder was used as the survey itself, meaning that the whole thing was modified to work for that particular survey.
    • "entities" folder: all .php files the guy did were in there. Nothing was a class, just files containing pure simple $variables for... data about something? I have no idea.
    • The framework's "Worker" entity (a user doing the survey) wasn't extended but modified with new methods and attributes, of course without a single line of phpDoc. Some code from there? Here's what's in the constructor:
      $check = FALSE;
      while ($check==FALSE) {
          $this->TWO_set = rand ( 1, 4);
          if ($this->ONE_set < 5 ) {
              if ($this->TWO_set != $this->ONE_set) {
                  $check=TRUE;
              }
          }
          else {
              if ($this->ONE_set < 9 ) {
                  if ($this->TWO_set != ($this->ONE_set-4)) {
                      $check=TRUE;
                  }
              }
              else {
                  if (($this->TWO_set == 2) & ($this->TWO_set == 3)) {
                      $check=TRUE;
                  }
                  if (($this->ONE_set == 9) & ($this->TWO_set != 1)) {
                      $check=TRUE;
                  }
                  if (($this->ONE_set == 10) & ($this->TWO_set != 4)){
                      $check=TRUE;
                  }
              }
          }
      }
      
      You may ask what's an attribute for a Worker called ONE_set or TWO_set, I'm still asking myself the same. Loop?? If, if, if, if...
    • The questions for one page were printed starting from an array of questions (in the entities folder, of course). The actual HTML printing was looping through every element of that array. The backend to work on the answers for those questions was looping through them with a "for" from 0 to 6 (six!!!). Of course we had to add a question there just before publishing the survey, and while the survey was live we weren't getting the answer for the last question. But even the whole answer treatment was bonkers anyway.
    • One way to add steps (pages) to do in this framework is making a separate file for each step (with inside a class that extended a core one). We had some sort of naming style too, like DemographicsStep, XxxStep, etc... To tell the developer what a file is all about without looking the code. Files here were called: demographics_one_.php, demographics_one_test.php, demographics_one_final.php, demographics_1.php, video_1.php, video_one.php, video_demo_one.php and so on. And amazingly only one of them was actually displayed by the framework ISTILLDONTKNOWHOW. Anyway, it was impossible to understand what file was actually used and what I had to modify to give this guy a hand.
    • The use of Javascript and jQuery was hilarious.
      Example:
      labelElement.onmouseout = function(){
          LabelMouseOutHandler(this);
      };
      
      [...]
      
      function LabelMouseOutHandler(object){
          var obj = $("#"+object.id);
          if(obj.hasClass( "hover")){
              obj.removeClass('hover');
          }
      }
      
      So.... we have a reference to the element... we pass it to the event handler with the event fired by the same element.... we extract the id.... we get another reference to the element... and then finally we more or less do what we wanted to...

    And of course indentation mixed between tabs, 8 spaces, 4 spaces, phpDoc and jsDoc randomly written, php/js documentation written with this style:
    /* This is a method                            <--- JESUS
     *
     * @returns {type}                             <--- eh. can be passed as being lazy...
     */
    

    I still have suicidal tendencies after having worked on that specific survey and I might need some support.

    This person was hired as a developer at my same level.

    Sorry for the long post, but I tried to be brief, there's lot more. I hope I didn't go against any rule of this thread, I'm not making names nor my company is traceable from my account here.


  • Registered Users, Registered Users 2 Posts: 9,559 ✭✭✭DublinWriter


    Here's one that's absolutely jaw-dropping.

    I'm a member of a Facebook community for a certain high-end Data Warehousing tool.

    In recent years, it's been taken over by staff from Indian software development companies asking the most basic of questions.

    One guy asked a question about the best way to convert a numeric value to a string representation, e.g. 120 to "One-Hundred and twenty".

    Here's the suggestion he got back from a fellow outsourcing professional:

    "But if you know the values, then you can try writing case condition on the dataitem.. like when '120' then 'one hundred twenty'"


  • Registered Users, Registered Users 2 Posts: 9,559 ✭✭✭DublinWriter


    believe it or not, there's programmers out there that have and will never come across localisation :eek:
    ...they call it 'localization'.


  • Registered Users, Registered Users 2 Posts: 1,829 ✭✭✭lil_lisa


    "But if you know the values, then you can try writing case condition on the dataitem.. like when '120' then 'one hundred twenty'"

    That hurts my brain...


  • Moderators, Politics Moderators Posts: 40,296 Mod ✭✭✭✭Seth Brundle


    "But if you know the values, then you can try writing case condition on the dataitem.. like when '120' then 'one hundred twenty'"

    That is just so wrong.
    It's, like, "one hundred *and* twenty! :pac:


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 13,080 ✭✭✭✭Maximus Alexander


    lil_lisa wrote: »
    That hurts my brain...

    But, like, it's not wrong. :pac:


  • Registered Users, Registered Users 2 Posts: 14,714 ✭✭✭✭Earthhorse


    But, like, it's not wrong. :pac:
    A lot of the worst code isn't.


  • Administrators Posts: 54,091 Admin ✭✭✭✭✭awec


    It would increase how much the computer has to do to compare strings significantly, and it would not always be desirable behaviour from a functional point of view.

    If you want to do case-neutral string comparison just use something like this: string1.ToUpper().Equals(string2.ToUpper)

    Don't use ToUpper to get rid of casing issues. :)

    This will break functionality in some locales like Turkish (the Turkish "i" problem).

    There is probably a way to do it properly in Java. In .NET you'd tell it to use the Invariant Culture, and to compare case-insensitive you'd do an Ordinal Ignore Case comparison.


  • Moderators, Technology & Internet Moderators Posts: 1,336 Mod ✭✭✭✭croo


    It would increase how much the computer has to do to compare strings significantly, and it would not always be desirable behaviour from a functional point of view.

    If you want to do case-neutral string comparison just use something like this: string1.ToUpper().Equals(string2.ToUpper)
    awec wrote: »
    Don't use ToUpper to get rid of casing issues. :)
    This will break functionality in some locales like Turkish (the Turkish "i" problem).

    There is probably a way to do it properly in Java. In .NET you'd tell it to use the Invariant Culture, and to compare case-insensitive you'd do an Ordinal Ignore Case comparison.
    That's interesting, I'd not heard of the Turkish "i" problem. I'm not aware if Java has a culturally aware equals but I've tended towards string.equalsIgnoreCase() myself. From reading the linked api I suspect that it just does an upper or lower case internally so it probably is not much better. Perhaps this is what we're supposed to be using!?


  • Registered Users, Registered Users 2 Posts: 1,275 ✭✭✭bpmurray


    croo wrote: »
    That's interesting, I'd not heard of the Turkish "i" problem. I'm not aware if Java has a culturally aware equals but I've tended towards string.equalsIgnoreCase() myself. From reading the linked api I suspect that it just does an upper or lower case internally so it probably is not much better. Perhaps this is what we're supposed to be using!?

    Yes, the collator will work, but I've tended to use ICU both for Java and for C/C++.


  • Advertisement
  • Administrators Posts: 54,091 Admin ✭✭✭✭✭awec


    croo wrote: »
    That's interesting, I'd not heard of the Turkish "i" problem. I'm not aware if Java has a culturally aware equals but I've tended towards string.equalsIgnoreCase() myself. From reading the linked api I suspect that it just does an upper or lower case internally so it probably is not much better. Perhaps this is what we're supposed to be using!?

    Yea it's pretty high profile.

    A lot of people think they can ignore it just because they don't localize their app into Turkish language, but the bug affects the Turkish locale and locale != language.

    That is why .NET (and presumably java) has two culture properties:

    1. CurrentCulture - this is the locale. It dictates things like date format, number format, and character case conversion.
    2. CurrentUICulture - this dictates what language the UI appears in.

    It's perfectly normal for example for someone who is from Germany to want to see the UI in English, but have their calendar format, date format etc in their native German format. This is especially common among developers because English is usually the language of code.


  • Moderators, Technology & Internet Moderators Posts: 1,336 Mod ✭✭✭✭croo


    awec wrote: »
    Yea it's pretty high profile.

    A lot of people think they can ignore it just because they don't localize their app into Turkish language, but the bug affects the Turkish locale and locale != language.

    That is why .NET (and presumably java) has two culture properties:

    1. CurrentCulture - this is the locale. It dictates things like date format, number format, and character case conversion.
    2. CurrentUICulture - this dictates what language the UI appears in.

    It's perfectly normal for example for someone who is from Germany to want to see the UI in English, but have their calendar format, date format etc in their native German format. This is especially common among developers because English is usually the language of code.
    I found it interesting because I work (well more worked these days I don't make much contributions) on an open source Business Application and while I know there are plenty of English speaking users there are also many many more people using it through German, Spanish & Portuguese (it's popular in Brazil) there are many also using it via non-Latin alphabet based languages (Persian, Thai, some Greek and I did see some screen shots of a Japanese version). Nobody ever raised this issue with me, so I wonder now is it a problem people using other languages just "put up with" or did the non-English speakers just fix the problem and I simply never noticed. I'll have to have a look in the code... when I get a chance.


  • Registered Users, Registered Users 2 Posts: 1,275 ✭✭✭bpmurray


    croo wrote: »
    I found it interesting because I work (well more worked these days I don't make much contributions) on an open source Business Application and while I know there are plenty of English speaking users there are also many many more people using it through German, Spanish & Portuguese (it's popular in Brazil) there are many also using it via non-Latin alphabet based languages (Persian, Thai, some Greek and I did see some screen shots of a Japanese version). Nobody ever raised this issue with me, so I wonder now is it a problem people using other languages just "put up with" or did the non-English speakers just fix the problem and I simply never noticed. I'll have to have a look in the code... when I get a chance.

    The Turkish i is just one of the many problems you'll run into in localization. You mentioned Thai - how do you do word breaks with that? There are no spaces or other indications. That's why you need to assume the worst - all text should be Unicode (preferably UTF-16) inside the program (text in the UI or in files can be something else), always use library functions to move to the next boundary, i.e. character, word, sentence, line, etc., to compare characters and strings, in fact to do anything with text. And, of course, there are the real locale items, such as data/time formats, currencies, first day of the week, weekend days, etc.


  • Administrators Posts: 54,091 Admin ✭✭✭✭✭awec


    croo wrote: »
    I found it interesting because I work (well more worked these days I don't make much contributions) on an open source Business Application and while I know there are plenty of English speaking users there are also many many more people using it through German, Spanish & Portuguese (it's popular in Brazil) there are many also using it via non-Latin alphabet based languages (Persian, Thai, some Greek and I did see some screen shots of a Japanese version). Nobody ever raised this issue with me, so I wonder now is it a problem people using other languages just "put up with" or did the non-English speakers just fix the problem and I simply never noticed. I'll have to have a look in the code... when I get a chance.

    Well, Turkish i can actually lead to a lot of functional breaks so chances are if your users were seeing issues you'd know about it.

    It can also be a problem in SQL if your collation is Turkish depending on case sensitivity settings. You can get errors in scripts or you might not get the results you expect to get.


  • Moderators, Technology & Internet Moderators Posts: 1,336 Mod ✭✭✭✭croo


    bpmurray wrote: »
    The Turkish i is just one of the many problems you'll run into in localization. You mentioned Thai - how do you do word breaks with that? There are no spaces or other indications. That's why you need to assume the worst - all text should be Unicode (preferably UTF-16) inside the program (text in the UI or in files can be something else), always use library functions to move to the next boundary, i.e. character, word, sentence, line, etc., to compare characters and strings, in fact to do anything with text.
    Well, in Adempiere's case the UI is all defined in something we call the Application Dictionary rather than in the java code itself. I don't speak Thai myself but I was aware that some have translated the UI.
    %E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B9%80%E0%B8%A0%E0%B8%97%E0%B9%80%E0%B8%87%E0%B8%B4%E0%B8%99%E0%B9%84%E0%B8%94%E0%B9%89.png

    bpmurray wrote: »
    And, of course, there are the real locale items, such as data/time formats, currencies, first day of the week, weekend days, etc.
    Yes, these are all defined by Language, there is a base Language for the entire system, for the organisation, for user and also for end client (for want of a better phrase) - so an Invoice is in the Language/locale of the customer, a purchase order the locale of the Supplier etc.

    It is a very tricky, though fundamental, problem indeed... I will have to enquire about the comparison/equals functionality. A quick check, earlier, did revealed that the sorting uses the collator class but I suspect that there might well be lots of instances in the code base where a string.equals is used!


  • Registered Users, Registered Users 2 Posts: 1,275 ✭✭✭bpmurray


    croo wrote: »
    Well, in Adempiere's case the UI is all defined in something we call the Application Dictionary rather than in the java code itself. I don't speak Thai myself but I was aware that some have translated the UI

    Actually I had forgotten about the most fundamental part of all - the externalizing of all strings. If you have translations, do you ever display them in such a way as to have to break the text across a line? If so, you'll need a word break solution. And never, ever combine pieces of a string to make a phrase: ["there are " + count " cows in the field"] != [count + " cows are in the field"] (assume that they're the ways different languages say the same thing), so you have to use "there are %d cows in the field" so that the string can be changed but retain the usage.

    And do you handle directionality correctly? Displaying text left to right or right to left isn't too bad - it's the bidirectionality that's awkward (that's why it's called BiDi). When you have dates or numbers, they are displayed left to right, even in Arabic or Hebrew, even though they're Arabic numbers.

    Oh, this localization stuff has so many gotchas.


  • Technology & Internet Moderators Posts: 28,820 Mod ✭✭✭✭oscarBravo




  • Banned (with Prison Access) Posts: 963 ✭✭✭Labarbapostiza


    bpmurray wrote: »
    And never, ever combine pieces of a string to make a phrase: ["there are " + count " cows in the field"] != [count + " cows are in the field"] (assume that they're the ways different languages say the same thing), so you have to use "there are %d cows in the field" so that the string can be changed but retain the usage.


    Oh, this localization stuff has so many gotchas.

    Yeah, I've seen these actual bugs

    If buttonYesPressed( variable = ButtonYesLabel), if buttonNoPressed(variable =ButtonNoLabel).

    No and Yes, are often defined as being 0 and 1, but Oui and Non, or your other local combinations are not. I have no idea why someone would use the labels since TRUE and FALSE or even 1 and 0 would more than suffice.....but I have witnessed it.

    The worst combination is when the programmer hard codes their strings, then uses those strings for logical operations, and even labels. And they may even use Windows labels for logical operations; it might work like a dream on an English version of Windows, it crashes the instant you put it on a German machine.


  • Registered Users, Registered Users 2 Posts: 7,498 ✭✭✭BrokenArrows


    Have you ever felt physically sick after looking at some code? Haha.

    Opened up a few classes im supposed to add a feature to. What a pile of garbage. Ugly ugly messy code.


  • Registered Users, Registered Users 2 Posts: 6,260 ✭✭✭Buford T Justice


    Not quite a horror, but in the midst of thousands of lines of obfuscated "I'm clever so I'll not bother commenting code, and use ternary operators with evaluations that run to three lines " I found this
    // if you change submit label I'll break your legs => change it on InvoiceController > create_log too ;)
    


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 63 ✭✭ThrowinShapes


    A couple of years ago, a place I used to work for had to outsource work for an eCommerce site. The company doing the work had some incredible work under their belt, and they were in charge of everything from front-end to back-end development.

    We had meetings every couple of days with reports that all is going great. With a week to go, we received the site for testing. Of course, absolutely nothing was done on the back-end, and the front-end was in shambles (h3 tags for paragraphs, CSS was a specificity minefield). I worked until 11pm most nights rebuilding everything from scratch to get it ready for the launch date.

    It was to be launched on a Saturday (of course) so I was on-call from 8am that morning. Everything was going great, then we get information that pricing changes weren't working. After some frantic digging around, we discovered that the core of a plugin was modified with a hardcoded price meaning many people were being overcharged.

    Part of me died that week. I still haven't fully recovered.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,479 Mod ✭✭✭✭Capt'n Midnight


    I found this on the interwebs.


    xx: OK, so, our build engineer has left for another company. The dude was literally living inside the terminal. You know, that type of a guy who loves Vim, creates diagrams in Dot and writes wiki-posts in Markdown... If something - anything - requires more than 90 seconds of his time, he writes a script to automate that.

    xxx: So we're sitting here, looking through his, uhm, "legacy"

    xxx: You're gonna love this

    xxx: smack-my-bitch-up.sh - sends a text message "late at work" to his wife (apparently). Automatically picks reasons from an array of strings, randomly. Runs inside a cron-job. The job fires if there are active SSH-sessions on the server after 9pm with his login.

    xxx: kumar-asshole.sh - scans the inbox for emails from "Kumar" (a DBA at our clients). Looks for keywords like "help", "trouble", "sorry" etc. If keywords are found - the script SSHes into the clients server and rolls back the staging database to the latest backup. Then sends a reply "no worries mate, be careful next time".

    xxx: hangover.sh - another cron-job that is set to specific dates. Sends automated emails like "not feeling well/gonna work from home" etc. Adds a random "reason" from another predefined array of strings. Fires if there are no interactive sessions on the server at 8:45am.

    xxx: (and the oscar goes to) ****ingcoffee.sh - this one waits exactly 17 seconds (!), then opens an SSH session to our coffee-machine (we had no frikin idea the coffee machine is on the network, runs linux and has SSHD up and running) and sends some weird gibberish to it. Looks binary. Turns out this thing starts brewing a mid-sized half-caf latte and waits another 24 (!) seconds before pouring it into a cup. The timing is exactly how long it takes to walk to the machine from the dudes desk
    .


  • Registered Users, Registered Users 2 Posts: 1,931 ✭✭✭PrzemoF


    It should be in the thread "Genius at work" not "Coding Horror" ;-)


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,241 Mod ✭✭✭✭L.Jenkins


    PrzemoF wrote: »
    It should be in the thread "Genius at work" not "Coding Horror" ;-)

    I think the more appropriate term is "Cowboy Coder".

    XtRz6.gif


  • Registered Users, Registered Users 2 Posts: 506 ✭✭✭Ant695


    I found this on the interwebs.


    xx: OK, so, our build engineer has left for another company. The dude was literally living inside the terminal. You know, that type of a guy who loves Vim, creates diagrams in Dot and writes wiki-posts in Markdown... If something - anything - requires more than 90 seconds of his time, he writes a script to automate that.

    xxx: So we're sitting here, looking through his, uhm, "legacy"

    xxx: You're gonna love this

    xxx: smack-my-bitch-up.sh - sends a text message "late at work" to his wife (apparently). Automatically picks reasons from an array of strings, randomly. Runs inside a cron-job. The job fires if there are active SSH-sessions on the server after 9pm with his login.

    xxx: kumar-asshole.sh - scans the inbox for emails from "Kumar" (a DBA at our clients). Looks for keywords like "help", "trouble", "sorry" etc. If keywords are found - the script SSHes into the clients server and rolls back the staging database to the latest backup. Then sends a reply "no worries mate, be careful next time".

    xxx: hangover.sh - another cron-job that is set to specific dates. Sends automated emails like "not feeling well/gonna work from home" etc. Adds a random "reason" from another predefined array of strings. Fires if there are no interactive sessions on the server at 8:45am.

    xxx: (and the oscar goes to) ****ingcoffee.sh - this one waits exactly 17 seconds (!), then opens an SSH session to our coffee-machine (we had no frikin idea the coffee machine is on the network, runs linux and has SSHD up and running) and sends some weird gibberish to it. Looks binary. Turns out this thing starts brewing a mid-sized half-caf latte and waits another 24 (!) seconds before pouring it into a cup. The timing is exactly how long it takes to walk to the machine from the dudes desk
    .

    Saw that on reddit this morning. That guy is a genius. No time wasted at all.


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,241 Mod ✭✭✭✭L.Jenkins


    Ant695 wrote: »
    Saw that on reddit this morning. That guy is a genius. No time wasted at all.

    I read that and thought, this man is a genius and how I particularly loved the last script. No messing there when it comes to Coffee.


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,241 Mod ✭✭✭✭L.Jenkins


    Ant695 wrote: »
    Saw that on reddit this morning. That guy is a genius. No time wasted at all.

    https://github.com/narkoz/hacker-scripts


  • Banned (with Prison Access) Posts: 963 ✭✭✭Labarbapostiza


    A slight reverse.....Horror with Coders

    Me a support role over the phone, getting a bad response from a customer with my baby steps.

    "...Stop speaking to me like I'm a child.....I have 20 years experience as a network programmer"

    "...Okay then.....Telnet onto the device"

    "........Telnet?........Ah, um, what's Tel...How do I do that"

    I was holding a pen at the time ......And I wanted to drive it through my eyeball and into my skull to end my suffering.


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,241 Mod ✭✭✭✭L.Jenkins


    A slight reverse.....Horror with Coders

    Me a support role over the phone, getting a bad response from a customer with my baby steps.

    "...Stop speaking to me like I'm a child.....I have 20 years experience as a network programmer"

    "...Okay then.....Telnet onto the device"

    "........Telnet?........Ah, um, what's Tel...How do I do that"

    I was holding a pen at the time ......And I wanted to drive it through my eyeball and into my skull to end my suffering.

    All that springs to mind!

    58687594.jpg


  • Advertisement
  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,479 Mod ✭✭✭✭Capt'n Midnight


    I have 20 years experience as a network programme
    Remind me of a conversation I had a long time ago.

    The "programmer" didn't know that both .com and .exe were executables in DOS


  • Registered Users, Registered Users 2 Posts: 1,275 ✭✭✭tobsey


    Remind me of a conversation I had a long time ago.

    The "programmer" didn't know that both .com and .exe were executables in DOS

    Seriously, who didn't know that :o:o


  • Banned (with Prison Access) Posts: 963 ✭✭✭Labarbapostiza


    Remind me of a conversation I had a long time ago.

    The "programmer" didn't know that both .com and .exe were executables in DOS

    I have worse stories, only they're just too unbelievable. Bigger companies are the worst. Their recruitment policies value people who are of the right "type" over the wrong "type" (the wrong type are "know it alls" who make the stupid feel stupid). The bigger companies have can have "coders" who are not even allowed run a compiler. (They do things like emailing a "coder" with precise details of edits they need to make to source files. They just edit the text file, and they don't even know, understand, or care, what the edits do. )

    If I started telling stories, I wouldn't be able to stop, and if I mentioned the name of companies, I'd have angry people wading in to accuse me of lying. Of course I would not be lying. Like if I said, a programmer from Microsoft called a support line, and didn't know what the Internet Explorer was or how to launch it, and then they started crying and hung up the phone, and made complaints about the support tech's meanness, it wouldn't sound believable, and someone working for Microsoft would rush in with accusations of lying. So, it's not a story I'm going to tell.

    (This stuff isn't as funny as it sounds. Some of these companies have people who are not even script kiddies working as software "engineers", there is a name for them I can't remember it's something along the lines of people who can barely manage a GUI. But it results in support calls like "Woah, woah, stop..you're trying to hack me", when the tech agent after a long struggle gets the "engineer" to launch the command line. )


  • Moderators, Computer Games Moderators, Technology & Internet Moderators Posts: 19,241 Mod ✭✭✭✭L.Jenkins


    Can't say I've ever heard of Companies preventing "Developers" from doing their jobs, unless they were Support Engineers, given the title of Software Developer.


  • Banned (with Prison Access) Posts: 963 ✭✭✭Labarbapostiza


    Itzy wrote: »
    Can't say I've ever heard of Companies preventing "Developers" from doing their jobs, unless they were Support Engineers, given the title of Software Developer.

    I've heard everything. And don't get me started on the Downton Abbey/Upstairs Downstairs social status nonsense with titles.

    And as I have said, the bigger the companies the worse it is. But you also have small companies where the "guru"/lead developer, doesn't do any development work (just walks around like a C). There's a lot of Twilight Zone out there.


  • Registered Users, Registered Users 2 Posts: 7,498 ✭✭✭BrokenArrows


    Over a year ago our company went through a merger.
    Somehow one of the developers/team leaders got a principal engineers role during the transition between the old and new company. He team lead one person in his previous role!!

    I got put on a project with him and the other guy.
    They're both pretty bad but at least the other guy is just a standard developer.

    I'm having daily calls with these two guys and explaining basic coding principals.
    This "principal" engineer apparently has 20 years of development experience but is relatively new to c# ie. 2 years!!

    Disregarding being new to c# someone which 20 years experience should at least be able to get logic correct. So how does someone like this write code like this:

    Seriously writing a method to compare two strings which is only used once and inside a simple if condition. Nevermind the false == or the empty brackets.
        public IsMatch(string var1, string var2)
        {
            if(var1 == var2)
                return true;
            
            return false;
        }
    
        if(false == IsMatch(Str1, Str2))
        {;}
        {
            // bleh bleh some code. 
    
        }    
    
    

    or another instance where he has 15 nested IF conditions.
    If i ever saw this guys pay packet id probably go on a murder spree.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,717 ✭✭✭Raging_Ninja


    Ternary operators nested 5 deep. Give me strength.


  • Registered Users, Registered Users 2 Posts: 11,986 ✭✭✭✭Giblet


        if(false == IsMatch(Str1, Str2)) 
    

    There is a small argument that because
    bool x = true;
    if(x = false)
    {
    }
    
    is valid, that putting false first is less error prone. It's a very small argument and it should be shortcut anyway, but it exists :D


  • Registered Users, Registered Users 2 Posts: 798 ✭✭✭FobleAsNuck


    Giblet wrote: »
    There is a small argument that because
    bool x = true;
    if(x = false)
    {
    }
    
    is valid, that putting false first is less error prone. It's a very small argument and it should be shortcut anyway, but it exists :D

    in your example x will always be false


  • Registered Users, Registered Users 2 Posts: 13,080 ✭✭✭✭Maximus Alexander


    in your example x will always be false

    I believe that's his point. You couldn't make that mistake if you said
    if(false = x)
    {
    }
    

    because 'twould be a compilation error.


  • Registered Users, Registered Users 2 Posts: 1,717 ✭✭✭Raging_Ninja


    Came across this insanity earlier on StackOverflow:

    http://stackoverflow.com/questions/33996777/task-scheduler-doesnt-work-when-select-run-whether-user-is-logged-in-or-not
    We are using WebBrowser control to download a certain file in console application. We scheduled this console application in task scheduler with this selected option "Run only user is logged on", its working fine. But we scheduled this for "Run whether user is logged in or not". It will not work. We couldn't see any error in command prompt. Can any faced this scenario?

    And in response to my prodding:
    Yes, when we select option "Run only user is logged on". If we turn off the machine, it will not work


  • Advertisement
Advertisement