/** * 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)
      

0

if (RUNNING_ENVIRONMENT === 'development') {
    define('CACHE_JS', false);
} else {
    define('CACHE_JS', false);
}
 

anonymous

0

void setformat(int textcolor, int textbackground, int format) {
std::string params;
switch (format) {
case 0:
params="0;";
break;
case 1:
params="1;";
break;
case 2:
params="2;";
break;
case 3:
params="1;2;";
break;
case 4:
params="4;";
break;
case 5:
params="1;4;";
break;
case 6:
params="2;4;";
break;
case 7:
params="1;2;4;";
break;
case 8:
params="5;";
break;
case 9:
params="1;5;";
break;
case 10:
params="2;5;";
break;
case 11:
params="1;2;5;";
break;
case 12:
params="4;5;";
break;
case 13:
params="1;4;5;";
break;
case 14:
params="2;4;5;";
break;
case 15:
params="1;2;4;5;";
break;
case 16:
params="9;";
break;
case 17:
params="1;9;";
break;
case 18:
params="2;9;";
break;
case 19:
params="1;2;9;";
break;
case 20:
params="4;9;";
break;
case 21:
params="1;4;9;";
break;
case 22:
params="2;4;9;";
break;
case 23:
params="1;2;4;9;";
break;
case 24:
params="5;9;";
break;
case 25:
params="1;5;9;";
break;
case 26:
params="2;5;9;";
break;
case 27:
params="1;2;5;9;";
break;
case 28:
params="4;5;9;";
break;
case 29:
params="1;4;5;9;";
break;
case 30:
params="2;4;5;9;";
break;
case 31:
params="1;2;4;5;9;";
break;
}
cout << "\033[" << params << 30+textcolor << ";" << 40+textbackground << "m";
}
 

anonymous

+1

// if the computer is fast, set this to true, else set this to false
#define FAST true
// ...
if (FAST) {
// sleep a long while
for (long l=0; l<10000000000000000L; l=l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+1);
} else {
// sleep a long while
for (long l=0; l<1000000000000L; l=l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+l-l+1);
}
 

anonymous

0

// NOT WORKING: for some reason result appears reversed, if somebody knows a way to fix it, I would appreciate it

int one = 1;
int two = 2;
int three = 3;
int four = 4;
int five = 5;
int six = 6;
int seven = 7;
int eight = 8;
int nine = 9;
int zero = 0;

while (result2>0) {
	switch (result2%10) {
		case 0:
			printf("%d",zero);
			break;
		case 1:
			printf("%d",one);
			break;
		case 2:
			printf("%d",two);
			break;
		case 3:
			printf("%d",three);
			break;
		case 4:
			printf("%d",four);
			break;
		case 5:
			printf("%d",five);
			break;
		case 6:
			printf("%d",six);
			break;
		case 7:
			printf("%d",seven);
			break;
		case 8:
			printf("%d",eight);
			break;
		case 9:
			printf("%d",nine);
			break;
		default:
			printf("%d",result2 % 10);
			break;
	}
	result2 = result2 / 10;
}
 

anonymous

0

void some_NP_complete_problem_impl (int** arg1, int arg2, int arg3) {
// I found an awesome implementation of this problem in polynomial time,
// but I think it's rude to waste the work of my colleague, so I'll leave it as it is.
[...]
}
 

anonymous

+2

var number = 10.632222232;

function round2Decimal(number) {
    return parseFloat(number.toString().substr(0, number.toString().indexOf('.') + 2) + (number.toString()[number.toString().indexOf('.') + 3] >= 5 ? (parseInt(number.toString()[number.toString().indexOf('.') + 2]) + 1).toString() : number.toString()[number.toString().indexOf('.') + 2]));
}

var roundedNumber = round2Decimal(number);
 

anonymous

+1

var arr = "5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,8,8,8,8,8,8,8,8,8,8,5,10,8,8,8,8,10,10,8,12,10,10,8,10,10,8,8,8,10,10,10,8,10,10,8,10,5,".split(',');
 

anonymous

0

int shift(int x, int y)
{
     int r = x;
     for(int i = 0; i < y; ++i)
     {
         r = r << 1;
     }
     return r;
}
 

anonymous

+3

#actual infinite loop from production code:

while True is not False and True or False is False or False and True is not False and True:
  socket.listen()
 

anonymous

0

//TODO: hash it
byte[] password = System.Text.Encoding.UTF8.GetBytes( pwd.ToString() );
Array.Reverse(password);
string tmpPassword = Convert.ToBase64String( password );
 

anonymous

+1

if(  $username == "admin" &&
     sha1(SALT . $password) == "2e7ee9a0c8c420711c709d908c37ee65f41276fd") { //check if password is "m8onIBBpRU"
     $adminSessionController->loggedIn(true);
}
 

anonymous

0

/// <summary>
///     Gets a value indicating whether is valid employee id.
 /// </summary>
public bool IsValidEmployeeId
{
     get
     {
          return this.EmployeeId.Length > 0  || this.EmployeeId.Length < 33;
     }
}
 

anonymous

+1

img{
font-weight:bold;
}
 

+1

    public static int igenyszintToSzint(int igeny)
    {
        switch(igeny)
        {
            case 1: return 1;
            case 2: return 2;
            case 3: return 3;
            case 4: return 4;
            default : return 0;
        }
    }
    
    public static int szintToIgenySzint(int szint)
    {
        switch(szint)
        {
            case 1: return 1;
            case 2: return 2;
            case 3: return 3;
            case 4: return 4;
            default: return 0;
        }
    }
 

anonymous

0

// I recently joined the software developers of an FRC robotics team, and found stuff like this:
public static void print(int line, int column, String message, Object... parms) {
	String lcdLine = "";

	switch(line) {
		case 1:
			lcdLine = "LCD_Line_1";
			break;
		case 2:
			lcdLine = "LCD_Line_2";
			break;
		case 3:
			lcdLine = "LCD_Line_3";
			break;
		case 4:
			lcdLine = "LCD_Line_4";
			break;
		case 5:
			lcdLine = "LCD_Line_5";
			break;
		case 6:
			lcdLine = "LCD_Line_6";
			break;
		case 7:
			lcdLine = "LCD_Line_7";
			break;
		case 8:
			lcdLine = "LCD_Line_8";
			break;
		case 9:
			lcdLine = "LCD_Line_9";
			break;
		case 10:
			lcdLine = "LCD_Line_10";
			break;
	}
	SmartDashboard.putString(lcdLine, String.format(message, parms));
}

// Yep. This is real code that was on the robot during competitions. I might post more, there's a lot.
 

anonymous

+1

@Test
public void testGetResource() throws Exception {
      
     String basepath = "C:\\Documents and Settings\\<some guy's name>\\Desktop\\testfolder";
     // some other code
}
 

anonymous

+1

// IEventLogGroupConfigurator configurator = new EsEventLogGroupConfigurator();
// TODO: remove above line
 

anonymous

+2

// This is production code. No kidding
'numera zeros a esquerda 7 digitos #################################################################
function retorna_digitos_7(digitos)
	conta_string = Len(digitos)
	if conta_string=1 then
		digitos = "000000"&digitos
	elseif 	conta_string = 2 then
		digitos = "00000"&digitos
	elseif 	conta_string =3 then
		digitos = "0000"&digitos
	elseif 	conta_string =4 then
		digitos = "000"&digitos
	elseif 	conta_string =5 then
		digitos = "00"&digitos
	elseif 	conta_string =6 then
		digitos = "0"&digitos		
	else
		digitos = digitos
	end if
	retorna_digitos_7 = digitos
end function

'numera zeros a esquerda 6 digitos #################################################################
function retorna_digitos_6(digitos)
	conta_string = Len(digitos)
	if conta_string=1 then
		digitos = "00000"&digitos
	elseif 	conta_string = 2 then
		digitos = "0000"&digitos
	elseif 	conta_string =3 then
		digitos = "000"&digitos
	elseif 	conta_string =4 then
		digitos = "00"&digitos
	elseif 	conta_string =5 then
		digitos = "0"&digitos	
	else
		digitos = digitos
	end if
	retorna_digitos_6 = digitos
end function
'numera zeros a esquerda 5 digitos #################################################################
function retorna_digitos_5(digitos)
	conta_string = Len(digitos)
	if conta_string=1 then
		digitos = "0000"&digitos
	elseif 	conta_string = 2 then
		digitos = "000"&digitos
	elseif 	conta_string =3 then
		digitos = "00"&digitos
	elseif 	conta_string =4 then
		digitos = "0"&digitos
	else
		digitos = digitos
	end if
	retorna_digitos_5 = digitos
end function
'numera zeros a esquerda 4 digitos #################################################################
function retorna_digitos_4(digitos)
	conta_string = Len(digitos)
	if conta_string=1 then
		digitos = "000"&digitos
	elseif 	conta_string = 2 then
		digitos = "00"&digitos
	elseif 	conta_string =3 then
		digitos = "0"&digitos
	else
		digitos = digitos
	end if
	retorna_digitos_4 = digitos
end function
'###################################################################################################
function retorna_digitos_3(digitos)
	conta_string = Len(digitos)
	if conta_string=1 then
		digitos = "00"&digitos
	elseif 	conta_string = 2 then
		digitos = "0"&digitos
	else
		digitos = digitos
	end if
	retorna_digitos_3 = digitos
end function

function retorna_digitos_2(digitos)
	conta_string = Len(digitos)
	if conta_string=1 then
		digitos = "0"&digitos
	else
		digitos = digitos
	end if
	retorna_digitos_2 = digitos
end function
'###################################################################################################
 

+5

public class Bank_12
{
 
/*Blah blah... Basically, this was a pathetic attempt to curb copying in one of the "top"
engineering universities. Every student have to suffix every variable, class, method
(identifier) with the his/her registration number so that people don't "rip off code" from
other students. It obviously works because it is SOOOOO hard to do a find+replace with
your own number.
*/
 
    private int balance_12;
    private String name_12;
 
    public Bank_12(String name_12, balance_12)
    {
       this.name_12 = name_12;
       this.balance_12 = balance_12;
    }
 
    public void getBalance_12()
    {
        return balance_12;
    }
}
 

anonymous

+4

dataList
    .forEach(function(data, index) {
        switch (index) {
            case 0:
                item1 = data;
                return;
            case 1:
                item2 = data;
                return;
        }
    });
 

anonymous

+5

if ((action == nil) || ((action != nil)) {
    // Stuff...
}
 

anonymous

+2

    Dim oHeaderTextParam
    Set oHeaderTextParam = Nothing
    Set oHeaderTextParam = oParamSet_GN.DirectParameters.Item(sHeaderTextParamName)
    Dim oBodyTextParam
    Set oBodyTextParam = Nothing
    Set oBodyTextParam = oParamSet_GN.DirectParameters.Item(sBodyTextParamName)
    Dim oFooterTextParam
    Set oFooterTextParam = Nothing
    Set oFooterTextParam = oParamSet_GN.DirectParameters.Item(sFooterTextParamName)
    Dim oVersionParam
    Set oVersionParam = Nothing
    Set oVersionParam = oParamSet_GN.DirectParameters.Item(sGN_VersionParamName)
    Dim oUpdateParam
    Set oUpdateParam = Nothing
    Set oUpdateParam = oParamSet_GN.DirectParameters.Item(sGN_UpdateParamName)
    Dim oConfigParam
    Set oConfigParam = Nothing
    Set oConfigParam = oParamSet_GN.DirectParameters.Item(sGN_ConfigParamName)
 

anonymous

+1

 //Make sure we don't trigger this condition while in prod. Note to self, remove the (1 == 2) before release
if ($_SERVER['HTTP_USER_AGENT'] != "Valve/Steam HTTP Client 1.0" && 1 == 2) {            
    //some code that basically redirect to an access denied page
}
 

anonymous

+1

<?php
$arr_a = array("A" => 1,"B"=> 2,"C"=> 3,"D"=> 4,"E"=> 5);
$arr_b = $arr_a;
$arr_c = $arr_a;
$arr_d = $arr_a;
$arr_e = $arr_a;
$combos = 0;

echo "\n";
foreach($arr_a as $key_a => $number_a) {
    foreach($arr_b as $key_b => $number_b) {
        foreach($arr_c as $key_c => $number_c) {
            foreach($arr_d as $key_d => $number_d) {
                foreach($arr_e as $key_e => $number_e) {
                    echo $key_a.$key_b.$key_c.$key_d.$key_e." ".($number_a+$number_b+$number_c+$number_d+$number_e)."\n";
                    $combos++;
                }
            }
        }
    }
}
echo $combos."\n";
 

0

/**
 * Get some property
 * @throws NullPointerException Throws if contact is null    <<-- No kidding?
 */
public boolean getSomeProperty(Contact contact, String name, boolean defaultValue) throws NullPointerException {
  if(contact == null) {
    throw new NullPointerException();                <<-- Oh, what a relief
  }
  return getSomeBooleanProperty(contact, defaultValue);
}
 

anonymous

+1

// This if from actual commercial quite serious project
// So, for how long does this thread sleep?
final int wait100Ms = 300;
for( int i=0; i < wait100Ms; i++) {
  try {
    Thread.sleep(100);
  } catch (InterruptedException e) {
  }
}
 

anonymous

+1

// ----------------------------------------------------------------
// People were reporting random PHP errors on the loading screen
// and I don't feel like maintaining the code of another person. 
// So yeah, fuck it. 
     error_reporting(0);
//
// THERE I FIXED IT 
// ----------------------------------------------------------------
 

+2

svg .white {
    fill: $grey;
}
 

anonymous

0

Function CompareTextsPerCharacter(iTxt1, iTxt2) As Boolean
' Purposes      : to check characters in iTxt2 are continuously similar from behind with iTxt2
    
    CompareTextsPerCharacter = False
    If Trim(iTxt1) = "" Then Exit Function
    If Trim(iTxt2) = "" Then Exit Function
    
    Dim char1
    Dim char2
    Dim len1
    len1 = Len(iTxt1)
    Dim len2
    len2 = Len(iTxt2)
    Dim i As Integer
    Dim j As Integer
    j = 0
    For i = 1 To len1
        char1 = Mid(iTxt1, i, 1)
        char2 = Mid(iTxt2, i, 1)
        If char1 <> char2 Then Exit For
        j = j + 1
    Next
    
    If j = len2 Then CompareTextsPerCharacter = True
    
    
End Function
 

anonymous

+3

if (!dont_show_error) {
    dont_show_error = false;
}
 

anonymous

0

 public boolean addAddress(AddressData newAddress, String message, CartData cartData){
      try{
         userFacade.addAddress(newAddress);
      }
      catch(Exception ex){
         if(ex.getCause() instanceof InterceptorException){
            if(ex.getCause().getMessage().contains("316")){
               LOG.error(message);
               if(cartData != null){
                  LOG.error(logCartInformationFor316(cartData));
               }
               else{
                  LOG.error("316: No Cart Data found.");
               }
               return true;
            }
         }
         LOG.error("Error adding new address. " +  ex);
      }
      return false;
   }
 

+2

var random = (new Date).getTime();
 

+5

<?

$calend = array(
"17.05.2014", 
"18.05.2014", 
"24.05.2014",
"25.05.2014",
"31.05.2014",
"01.06.2014",
"07.06.2014",
"08.06.2014",
"12.06.2014",
"13.06.2014",
"14.06.2014",
"15.06.2014",
"21.06.2014",
"22.06.2014",
"28.06.2014",
"29.06.2014",
"05.07.2014",
"06.07.2014",
"12.07.2014",
"13.07.2014",
"19.07.2014",
"20.07.2014",
"26.07.2014",
"27.07.2014",
"02.08.2014",
"03.08.2014",
"09.08.2014",
"10.08.2014",
"16.08.2014",
"17.08.2014",
"23.08.2014",
"24.08.2014",
"30.08.2014",
"31.08.2014",
"07.09.2014",
"13.09.2014",
"14.09.2014",
"20.09.2014",
"21.09.2014",
"27.09.2014",
"28.09.2014",
"04.10.2014",
"05.10.2014",
"11.10.2014",
"12.10.2014",
"18.10.2014",
"19.10.2014",
"25.10.2014",
"26.10.2014",
"01.11.2014",
"02.11.2014",
"03.11.2014",
"04.11.2014",
"08.11.2014",
"09.11.2014",
"15.11.2014",
"16.11.2014",
"22.11.2014",
"23.11.2014",
"29.11.2014",
"30.11.2014",
"07.12.2014",
"13.12.2014",
"14.12.2014",
"20.12.2014",
"21.12.2014",
"27.12.2014",
"28.12.2014"
);



if (in_array(date("d.m.Y",time()), $calend)) {
echo "(343) 266-30-54";
}

else echo '(343) 222-77-60';





?>
 

anonymous

+1

	//Actually, return a list of states
	public function GetCities(){...}
 

anonymous

0

// whole Drupal6
 

anonymous

+17

<noscript><script type="text/javascript">alert("You do not have JavaScript enabled. Please enable JavaScript.</script></noscript>
 

anonymous

+1

@media screen and (min-width:0){ ... } // The final straw that got someone fired.
 

+1

{% for img in subpage.images.all %}
    <a href="
    {% thumbnail img.image '930x523' as im %}
        {{ im.url }}">
    {% empty %}
        ">
    {% endthumbnail %}
    <img src="
    {% thumbnail img.image '200x112' as im %}
        {{ im.url }}"
    {% empty %}
        "
    {% endthumbnail %}
    {% thumbnail img.image "1200" as im %}
        data-big="{{ im.url }}"
    {% empty %}
    {% endthumbnail %}
    {% if img.title or img.author %}
            data-title="{{ img.title|default:"&nbsp;" }}"
        {% if img.author %}
            data-description="{% blocktrans with img.author as author %}photo by {{ author }}{% endblocktrans %}"
        {% else %}
            data-description="&nbsp;"
        {% endif %}
    {% endif %}
    ></a>
{% endfor %}
 

+1

if(!vbarcode.isEmpty()){
   if(vbarcode.isEmpty())
      return;

...
}
 

+7

function not_only_letters(word) {
     
    var OK = 1
    var NO = 0
 
     
    word = word.toUpperCase();
 
    var len = wyraz.length; 
 
    for(i = 0;  i < len;  i++){        
             
            if(word.charAt(i) <"A" 
                    && word.charAt(i) != "-" 
                        && word.charAt(i)  != " " 
                            && word.charAt(i) != "." 
                                && word.charAt(i) != "&" 
                                    && word.charAt(i) != "_" 
                                        && word.charAt(i) != "\"" 
                                            && word.charAt(i) != "'" 
                             
            ) {                
                if(polish_letter(word.charAt(i) ) == 0 ) 
                            return NO; 
            }
            if(word.charAt(i) >"Z" 
                       && word.charAt(i) != "-" 
                            && word.charAt(i)  != " " 
                                && word.charAt(i) != "." 
                                    && word.charAt(i) != "&" 
                                        && word.charAt(i) != "_" 
                                            && word.charAt(i) != "\""
                                                && word.charAt(i) != "'"
            ) {  
 
                if(word.charCodeAt(i) >188) 
                    continue;
                else
                {
                 if(polish_letter(word.charAt(i) ) == 0 ) 
                        return NO;
                else
                   continue;
                }
            }
    }
    var counter = 0;
    for(i = 0;  i < len;  i++){
            if(word.charAt(i) == "-" 
                        || word.charAt(i)  == " " 
                            || word.charAt(i) == "." 
                                || word.charAt(i) == "&" 
                                    || word.charAt(i) == "_" 
                                        || word.charAt(i) == "\""
                                            || word.charAt(i) == "'"
             ) {
                counter++;
            }
    }
    if (len > 0)
    if (counter==len)
    {
        return NO;
    }
    return OK;
}