/** * lowercase letters */
        $this->store['upper_Spec'] = array( *cut* );
        /** * uppercase letters */
        $this->store['lower_Spec'] = array( *cut* );
      
                    } else {
                      $errmsg='An unknown error occured.';
                    }
                  } else {
                    $errmsg='The passwords you entered do not match';
                  }
                } else {
                  $errmsg='Password has to be at least 8 characters long.';
                }
              } else {
                $errmsg='The email you entered is already in our database.';
              }
            } else {
              $errmsg='Please enter your email address.';
            }
          } else {
            $errmsg='Please enter your first name and your last name.';
          }
        } else {
        (...)
      
        // Happy debugging, suckers
        # define true (rand() > 10)
      

anonymous

0

//This took me like 1.5 hours of research on my data, what keys might I have as duplicate

...
} catch (NullPointerException ex) {
  throw new DuplicateKeyException();
}
 

0

private static Map<String, Boolean> stringToBoolean = ImmutableMap.of("0", false, "1", true);

  public String convertToDatabaseColumn(Boolean attribute)
  {
    for (Entry<String, Boolean> entry : stringToBoolean.entrySet()) {
        if (entry.getValue() == attribute) {
            return entry.getKey();
        }
    }
    return null;
  }
 

0

map.put("MESSAGE", message == null ? null : message);
 

+1

def removeAllPunctuations(g):
    #cleaning
    g= g.replace("."," ")
    g= g.replace(","," ")
    g= g.replace("'","")
    g= g.replace("-"," ")
    g= g.replace("/"," ")
    g= g.replace(":"," ")
    g= g.replace(";"," ")
    g= g.replace('"',"")
    g= g.replace("*","")
    g= g.replace("?"," ")
    g= g.replace("&","and")
    g= g.replace("+"," ")
    g= g.replace("["," ")
    g= g.replace("]"," ")
    g= g.replace("("," ")
    g= g.replace(")"," ")
    g= g.replace("<"," ")
    g= g.replace(">"," ")
    g= g.replace("="," ")
    g= g.replace(","," ")
    g= re.sub( '\s+', ' ', g ).strip()
    g = g.lstrip()
    return g
 

+1

// Indentation was a total mess
// This is my first post!

if((znak == 'a') || 
     (znak == 'B') || 
     (znak == 'c') || 
     (znak == 'D') || 
     (znak == 'e') || 
     (znak == 'F') || 
     (znak == 'g') || 
     (znak == 'H') || 
     (znak == 'i') || 
     (znak == 'J') || 
     (znak == 'k') || 
     (znak == 'L') || 
     (znak == 'm') || 
     (znak == 'N') || 
     (znak == 'o') || 
     (znak == 'P') || 
     (znak == 'q') || 
     (znak == 'R') || 
     (znak == 's') || 
     (znak == 'T') || 
     (znak == 'u') || 
     (znak == 'V') || 
     (znak == 'w') || 
     (znak == 'X') || 
     (znak == 'y') || 
     (znak == 'Z'))
    {
        tab_a[i][j] = 0;
    }
else if((znak == 'A') || 
            (znak == 'b') || 
                (znak == 'C') || 
                (znak == 'd') || 
                (znak == 'E') || 
                (znak == 'f') || 
                (znak == 'G') || 
                (znak == 'h') || 
                (znak == 'I') || 
                (znak == 'j') || 
                (znak == 'K') || 
                (znak == 'l') || 
                (znak == 'M') || 
                (znak == 'n') || 
                (znak == 'O') || 
                (znak == 'p') || 
                (znak == 'Q') || 
                (znak == 'r') || 
                (znak == 'S') || 
                (znak == 't') || 
                (znak == 'U') || 
                (znak == 'v') || 
                (znak == 'W') || 
                (znak == 'x') || 
                (znak == 'Y') || 
                (znak == 'z'))
    {
        tab_a[i][j] = 1;
    }
 

anonymous

+1

using System;
using System.Collections;
using System.Collections.Generic;

namespace xyz
{
  public static partial class CommandInterpreter
  {
    private struct StrStrA
    {
      public string str;
      public string[] str_a;
    };

    private struct StrStrStrA
    {
      public string str1;
      public string str2;
      public string[] str_a;
    };

    private struct StrStrStrStrA
    {
      public string str1;
      public string str2;
      public string str3;
      public string[] str_a;
    };

    private struct StrStrStrStrStrA
    {
      public string str1;
      public string str2;
      public string str3;
      public string str4;
      public string[] str_a;
    };

    private struct StrStr
    {
      public string str1;
      public string str2;
    };

    private struct StrStrStr
    {
      public string str1;
      public string str2;
      public string str3;
    };


    private static StrStrA GetStringStringArray(string[] tcl_params)
    {
      StrStrA p = new StrStrA();
      if (tcl_params.Length > 1)
      {
        p.str = tcl_params[1];
        p.str_a = new string[tcl_params.Length - 2];
        Array.Copy(tcl_params, 2, p.str_a, 0, tcl_params.Length - 2);
      }

      return p;
    }

    private static StrStrStrA GetStringStringStringArray(string[] tcl_params)
    {
      StrStrStrA p = new StrStrStrA();
      if (tcl_params.Length > 1)
        p.str1 = tcl_params[1];
      if (tcl_params.Length > 2)
      {
        p.str2 = tcl_params[2];
        p.str_a = new string[tcl_params.Length - 3];
        Array.Copy(tcl_params, 3, p.str_a, 0, tcl_params.Length - 3);
      }

      return p;
    }

    private static StrStrStrStrA GetStringStringStringStringArray(string[] tcl_params)
    {
      StrStrStrStrA p = new StrStrStrStrA();
      if (tcl_params.Length > 1)
        p.str1 = tcl_params[1];
      if (tcl_params.Length > 2)
        p.str2 = tcl_params[2];
      if (tcl_params.Length > 3)
      {
        p.str3 = tcl_params[3];
        p.str_a = new string[tcl_params.Length - 4];
        Array.Copy(tcl_params, 4, p.str_a, 0, tcl_params.Length - 4);
      }

      return p;
    }

    private static StrStrStrStrStrA GetStringStringStringStringStringArray(string[] tcl_params)
    {
      StrStrStrStrStrA p = new StrStrStrStrStrA();
      if (tcl_params.Length > 1)
        p.str1 = tcl_params[1];
      if (tcl_params.Length > 2)
        p.str2 = tcl_params[2];
      if (tcl_params.Length > 3)
        p.str3 = tcl_params[3];
      if (tcl_params.Length > 4)
      {
        p.str4 = tcl_params[4];
        p.str_a = new string[tcl_params.Length - 5];
        Array.Copy(tcl_params, 5, p.str_a, 0, tcl_params.Length - 5);
      }

      return p;
    }

    private static string GetString(string[] tcl_params)
    {
      if (tcl_params.Length > 1)
        return tcl_params[1];
      else
        return String.Empty;
    }

    private static StrStr GetStringString(string[] tcl_params)
    {
      StrStr s = new StrStr();
      if (tcl_params.Length > 1)
        s.str1 = tcl_params[1];
      if (tcl_params.Length > 2)
        s.str2 = tcl_params[2];

      return s;
    }

    private static StrStrStr GetStringStringString(string[] tcl_params)
    {
      StrStrStr s = new StrStrStr();
      if (tcl_params.Length > 1)
        s.str1 = tcl_params[1];
      if (tcl_params.Length > 2)
        s.str2 = tcl_params[2];
      if (tcl_params.Length > 3)
        s.str3 = tcl_params[3];

      return s;
    }

    private static bool IsNumber(string value)
    {
      int test;
      return Int32.TryParse(value, out test);
    }

    private static Dictionary<string, string> GetKeyValueParameters(string[] pargs)
    {
      Dictionary<string, string> dictionary = new Dictionary<string, string>();
      string paramChache = "";
      for (int i = 0; i < pargs.Length; i++)
      {//Elfogadott paraméterformátum: -paraméterAzonosító paraméterÉrték
        if (paramChache.Length > 0 && paramChache[0] == Globals.Instance.ParamDelimiter)
        {
          if (pargs[i].Length > 0)
          {
            if (pargs[i][0] != Globals.Instance.ParamDelimiter ||
              (pargs[i][0] == Globals.Instance.ParamDelimiter && pargs[i].Length == 1) ||
              (pargs[i][0] == Globals.Instance.ParamDelimiter && CommandInterpreter.IsNumber(pargs[i])))
            {
              dictionary.Add(paramChache.Substring(1), pargs[i]);
            }
          }
          else
            dictionary.Add(paramChache.Substring(1), String.Empty);
        }
        paramChache = pargs[i];
      }

      return dictionary;
    }


  }

}
 

+2

// my coworker is excited about the Java 8 stream api, so he uses it anywhere it's possible

if (list.stream().count() > 0) {
    // do something
}
 

anonymous

0

//This does not need any further explanation. Found on a large project I've inherited.

success = success && true;
 

+2

public Optional<User> getCurrentUser() {
  ...
  if (user != null) {
    return Optional.of(user);
  }
  return null;
}
 

anonymous

+2

// found today in some large system, simplified

// veryImportantFile.cpp
#define HALF (arg/2)

// ... a lot of code ....

int veryImportantFunction(int arg)
{
  return HALF;
}