<?php
$now = time();

while ($now + 10 > time()) {
    
    // Just chill...smoke a blunt
}

echo "Done.\n";
By Sobak, 2015-07-21 12:30:55
zipped_file.extractall(f'{file_path}')
zipped_file.close()
By Anonymous, 2017-12-19 10:29:52
Console.WriteLine("|"+ Espace(x-1) + (h==3?" o":""));
Console.WriteLine("|"+ Espace(x-1) + (h==2?" o":(h==3?"/|\\":"")));
Console.WriteLine("|"+ Espace(x-1) + (h==1?" o":(h==2?"/|\\":(h==3?" |":""))));
Console.WriteLine("|"+ Espace(x-1) + (h==0?" o":(h==1?"/|\\":(h==2?" |":(h==3?"/ \\":"")))));
Console.WriteLine("|"+ Espace(x-1) + (h==0?"/|\\":(h==1?" |":(h==2?"/ \\":""))));
Console.WriteLine("|"+ Espace(x-1) + (h==0?" |":(h==1?"/ \\":"")));
Console.WriteLine("|"+ Espace(x-1) + (h==0?"/ \\" : ""));
By Caribou décoiffé, 2018-04-29 20:27:53
o.isInsured = function ()
{ return !!this.insured; }

Why don't be like normal people and use bool() cast?

By Anonymous, 2018-09-22 14:31:37
int t;

if ((t > 1) && (t < 2))
{
    errorString = errorBuffer;
	return -1;
}
By Anonymous, 2017-12-13 19:42:08
bool b = connection.isConnected() == true ? true : false;

My first internship presented me with this.

By Anonymous, 2017-12-12 09:39:54
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.


   O | O | O 
  -----------
   O | O | O 
  -----------
   O | O | O 
     

 */
package tictactoe;

import java.util.Scanner;

public class TicTacToe {

    /**
     * @param args the command line arguments
     * @throws java.lang.InterruptedException
     */
    public static void main(String[] args) throws InterruptedException {
        Scanner input = new Scanner(System.in);
        String a1 = "1";
        String a2 = "2";
        String a3 = "3";
        String a4 = "4";
        String a5 = "5";
        String a6 = "6";
        String a7 = "7";
        String a8 = "8";
        String a9 = "9";
        int inO;
        int inX = 0;
        boolean winner = false;
        PrintBoard(a1,a2,a3,a4,a5,a6,a7,a8,a9);
        System.out.printf("How to play - wait for your turn and when it comes write the number of the field that you want to draw in (from 1 to 9)\n");
        System.out.printf("Player O's turn: ");
        inO = input.nextInt();
        while (true) {
            switch (inO) {
                case 1:
                    if (a1 == "1") {
                        a1 = "O";
                    }
                    break;
                case 2:
                    if (a2 == "2") {
                    a2 = "O";
                    }
                    break;
                case 3:
                    if (a3 == "3") {
                    a3 = "O";
                    }
                    break;
                case 4:
                    if (a4 == "4") {
                    a4 = "O";
                    }
                    break;
                case 5:
                    if (a5 == "5") {
                    a5 = "O";
                    }
                    break;
                case 6:
                    if (a6 == "6") {
                    a6 = "O";
                    }
                    break;
                case 7:
                    if (a7 == "7") {
                    a7 = "O";
                    }
                    break;
                case 8:
                    if (a8 == "8") {
                    a8 = "O";                        
                    }
                    break;
                case 9:
                    if (a9 == "9") {
                    a9 = "O";
                    }
                    break;
                default:
                    System.out.printf("An error occured. Please accept it politely and restart the game.");
                    break;
            }
            System.out.printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
            if (null != Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9))switch (Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9)) {
                case "NONE":
                    if (a1 != "1" && a2 != "2" && a3 != "3" && a4 != "4" && a5 != "5" && a6 != "6" && a7 != "7" && a8 != "8" && a9 != "9") {
                        winner = true;
                        System.out.println("DRAW!");
                        Thread.sleep(3000);
                        break;
                    } else {
                    PrintBoard(a1,a2,a3,a4,a5,a6,a7,a8,a9);
                    System.out.printf("Player X's turn: ");
                    inX = input.nextInt();
                    break;
                    }
                case "X":
                    winner = true;
                    System.out.println("X HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                case "O":
                    winner = true;
                    System.out.printf("O HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                default:
                    break;
            }
            if (winner) {
                break;
            }
            switch (inX) {
                case 1:
                    if (a1 == "1") {
                    a1 = "X";
                    }
                    break;
                case 2:
                    if (a2 == "2") {
                    a2 = "X";
                    }
                    break;
                case 3:
                    if (a3 == "3") {
                    a3 = "X";
                    }
                    break;
                case 4:
                    if (a4 == "4") {
                    a4 = "X";
                    }
                    break;
                case 5:
                    if (a5 == "5") {
                    a5 = "X";
                    }
                    break;
                case 6:
                    if (a6 == "6") {
                    a6 = "X";
                    }
                    break;
                case 7:
                    if (a7 == "7") {
                    a7 = "X";
                    }
                    break;
                case 8:
                    if (a8 == "8") {
                    a8 = "X";
                    }
                    break;
                case 9:
                    if (a9 == "9") {
                    a9 = "X";
                    }
                    break;
                default:
                    System.out.printf("An error occured. Please accept it politely and restart the game.");
                    break;
            }
            System.out.printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
            if (null != Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9))switch (Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9)) {
                case "NONE":
                    if (a1 != "1" && a2 != "2" && a3 != "3" && a4 != "4" && a5 != "5" && a6 != "6" && a7 != "7" && a8 != "8" && a9 != "9") {
                        winner = true;
                        System.out.println("DRAW!");
                        Thread.sleep(3000);
                        break;
                    } else {
                    PrintBoard(a1,a2,a3,a4,a5,a6,a7,a8,a9);
                    System.out.printf("Player O's turn: ");
                    inO = input.nextInt();
                    break;
                    }
                case "X":
                    winner = true;
                    System.out.println("X HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                case "O":
                    winner = true;
                    System.out.println("O HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                default:
                    break;
            }
            if (winner) {
                break;
            }
        }    
    }
    
    public static void PrintBoard(String f1, String f2, String f3, String f4, String f5, String f6, String f7, String f8, String f9) {  
        System.out.printf("   %s | %s | %s \n",f1,f2,f3);
        System.out.printf("  ----------- \n");
        System.out.printf("   %s | %s | %s \n",f4,f5,f6);
        System.out.printf("  ----------- \n");
        System.out.printf("   %s | %s | %s \n",f7,f8,f9);
        System.out.printf(" \n");
    }
    
    public static String Winners(String f1, String f2, String f3, String f4, String f5, String f6, String f7, String f8, String f9) {
        if (f1 == f2 && f2 == f3 && f3 == "O") {
            return "O";
        } else if (f4 == f5 && f5 == f6 && f6 == "O") {
            return "O";
        } else if (f7 == f8 && f8 == f9 && f9 == "O") {
            return "O";
        } else if (f1 == f4 && f4 == f7 && f7 == "O") {
            return "O";
        } else if (f2 == f5 && f5 == f8 && f8 == "O") {
            return "O";
        } else if (f3 == f6 && f6 == f9 && f9 == "O") {
            return "O";
        } else if (f1 == f5 && f5 == f9 && f9 == "O") {
            return "O";
        } else if (f3 == f5 && f5 == f7 && f7 == "O") {
            return "O";
        } else if (f1 == f2 && f2 == f3 && f3 == "X") {
            return "X";
        } else if (f4 == f5 && f5 == f6 && f6 == "X") {
            return "X";
        } else if (f7 == f8 && f8 == f9 && f9 == "X") {
            return "X";
        } else if (f1 == f4 && f4 == f7 && f7 == "X") {
            return "X";
        } else if (f2 == f5 && f5 == f8 && f8 == "X") {
            return "X";
        } else if (f3 == f6 && f6 == f9 && f9 == "X") {
            return "X";
        } else if (f1 == f5 && f5 == f9 && f9 == "X") {
            return "X";
        } else if (f3 == f5 && f5 == f7 && f7 == "X") {
            return "X";
        } else {
            return "NONE";
        }
    }
}

There are so many problems with this...

By umnikos, 2017-12-12 17:38:50
if ($getCount) {
    foreach ($all_items as $item) {
        $item_arr[$item->id] = 0;
    }
    
    return count($item_arr);
}
By Anonymous, 2020-01-08 22:15:04
// GetModelStruct get value's model struct, relationships based on struct and tag definition
func (scope *Scope) GetModelStruct() *ModelStruct {
	var modelStruct ModelStruct
	// Scope value can't be nil
	if scope.Value == nil {
		return &modelStruct
	}

	reflectType := reflect.ValueOf(scope.Value).Type()
	for reflectType.Kind() == reflect.Slice || reflectType.Kind() == reflect.Ptr {
		reflectType = reflectType.Elem()
	}

	// Scope value need to be a struct
	if reflectType.Kind() != reflect.Struct {
		return &modelStruct
	}

	// Get Cached model struct
	isSingularTable := false
	if scope.db != nil && scope.db.parent != nil {
		scope.db.parent.RLock()
		isSingularTable = scope.db.parent.singularTable
		scope.db.parent.RUnlock()
	}

	hashKey := struct {
		singularTable bool
		reflectType   reflect.Type
	}{isSingularTable, reflectType}
	if value, ok := modelStructsMap.Load(hashKey); ok && value != nil {
		return value.(*ModelStruct)
	}

	modelStruct.ModelType = reflectType

	// Get all fields
	for i := 0; i < reflectType.NumField(); i++ {
		if fieldStruct := reflectType.Field(i); ast.IsExported(fieldStruct.Name) {
			field := &StructField{
				Struct:      fieldStruct,
				Name:        fieldStruct.Name,
				Names:       []string{fieldStruct.Name},
				Tag:         fieldStruct.Tag,
				TagSettings: parseTagSetting(fieldStruct.Tag),
			}

			// is ignored field
			if _, ok := field.TagSettingsGet("-"); ok {
				field.IsIgnored = true
			} else {
				if _, ok := field.TagSettingsGet("PRIMARY_KEY"); ok {
					field.IsPrimaryKey = true
					modelStruct.PrimaryFields = append(modelStruct.PrimaryFields, field)
				}

				if _, ok := field.TagSettingsGet("DEFAULT"); ok && !field.IsPrimaryKey {
					field.HasDefaultValue = true
				}

				if _, ok := field.TagSettingsGet("AUTO_INCREMENT"); ok && !field.IsPrimaryKey {
					field.HasDefaultValue = true
				}

				indirectType := fieldStruct.Type
				for indirectType.Kind() == reflect.Ptr {
					indirectType = indirectType.Elem()
				}

				fieldValue := reflect.New(indirectType).Interface()
				if _, isScanner := fieldValue.(sql.Scanner); isScanner {
					// is scanner
					field.IsScanner, field.IsNormal = true, true
					if indirectType.Kind() == reflect.Struct {
						for i := 0; i < indirectType.NumField(); i++ {
							for key, value := range parseTagSetting(indirectType.Field(i).Tag) {
								if _, ok := field.TagSettingsGet(key); !ok {
									field.TagSettingsSet(key, value)
								}
							}
						}
					}
				} else if _, isTime := fieldValue.(*time.Time); isTime {
					// is time
					field.IsNormal = true
				} else if _, ok := field.TagSettingsGet("EMBEDDED"); ok || fieldStruct.Anonymous {
					// is embedded struct
					for _, subField := range scope.New(fieldValue).GetModelStruct().StructFields {
						subField = subField.clone()
						subField.Names = append([]string{fieldStruct.Name}, subField.Names...)
						if prefix, ok := field.TagSettingsGet("EMBEDDED_PREFIX"); ok {
							subField.DBName = prefix + subField.DBName
						}

						if subField.IsPrimaryKey {
							if _, ok := subField.TagSettingsGet("PRIMARY_KEY"); ok {
								modelStruct.PrimaryFields = append(modelStruct.PrimaryFields, subField)
							} else {
								subField.IsPrimaryKey = false
							}
						}

						if subField.Relationship != nil && subField.Relationship.JoinTableHandler != nil {
							if joinTableHandler, ok := subField.Relationship.JoinTableHandler.(*JoinTableHandler); ok {
								newJoinTableHandler := &JoinTableHandler{}
								newJoinTableHandler.Setup(subField.Relationship, joinTableHandler.TableName, reflectType, joinTableHandler.Destination.ModelType)
								subField.Relationship.JoinTableHandler = newJoinTableHandler
							}
						}

						modelStruct.StructFields = append(modelStruct.StructFields, subField)
					}
					continue
				} else {
					// build relationships
					switch indirectType.Kind() {
					case reflect.Slice:
						defer func(field *StructField) {
							var (
								relationship           = &Relationship{}
								toScope                = scope.New(reflect.New(field.Struct.Type).Interface())
								foreignKeys            []string
								associationForeignKeys []string
								elemType               = field.Struct.Type
							)

							if foreignKey, _ := field.TagSettingsGet("FOREIGNKEY"); foreignKey != "" {
								foreignKeys = strings.Split(foreignKey, ",")
							}

							if foreignKey, _ := field.TagSettingsGet("ASSOCIATION_FOREIGNKEY"); foreignKey != "" {
								associationForeignKeys = strings.Split(foreignKey, ",")
							} else if foreignKey, _ := field.TagSettingsGet("ASSOCIATIONFOREIGNKEY"); foreignKey != "" {
								associationForeignKeys = strings.Split(foreignKey, ",")
							}

							for elemType.Kind() == reflect.Slice || elemType.Kind() == reflect.Ptr {
								elemType = elemType.Elem()
							}

							if elemType.Kind() == reflect.Struct {
								if many2many, _ := field.TagSettingsGet("MANY2MANY"); many2many != "" {
									relationship.Kind = "many_to_many"

									{ // Foreign Keys for Source
										joinTableDBNames := []string{}

										if foreignKey, _ := field.TagSettingsGet("JOINTABLE_FOREIGNKEY"); foreignKey != "" {
											joinTableDBNames = strings.Split(foreignKey, ",")
										}

										// if no foreign keys defined with tag
										if len(foreignKeys) == 0 {
											for _, field := range modelStruct.PrimaryFields {
												foreignKeys = append(foreignKeys, field.DBName)
											}
										}

										for idx, foreignKey := range foreignKeys {
											if foreignField := getForeignField(foreignKey, modelStruct.StructFields); foreignField != nil {
												// source foreign keys (db names)
												relationship.ForeignFieldNames = append(relationship.ForeignFieldNames, foreignField.DBName)

												// setup join table foreign keys for source
												if len(joinTableDBNames) > idx {
													// if defined join table's foreign key
													relationship.ForeignDBNames = append(relationship.ForeignDBNames, joinTableDBNames[idx])
												} else {
													defaultJointableForeignKey := ToColumnName(reflectType.Name()) + "_" + foreignField.DBName
													relationship.ForeignDBNames = append(relationship.ForeignDBNames, defaultJointableForeignKey)
												}
											}
										}
									}

									{ // Foreign Keys for Association (Destination)
										associationJoinTableDBNames := []string{}

										if foreignKey, _ := field.TagSettingsGet("ASSOCIATION_JOINTABLE_FOREIGNKEY"); foreignKey != "" {
											associationJoinTableDBNames = strings.Split(foreignKey, ",")
										}

										// if no association foreign keys defined with tag
										if len(associationForeignKeys) == 0 {
											for _, field := range toScope.PrimaryFields() {
												associationForeignKeys = append(associationForeignKeys, field.DBName)
											}
										}

										for idx, name := range associationForeignKeys {
											if field, ok := toScope.FieldByName(name); ok {
												// association foreign keys (db names)
												relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, field.DBName)

												// setup join table foreign keys for association
												if len(associationJoinTableDBNames) > idx {
													relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, associationJoinTableDBNames[idx])
												} else {
													// join table foreign keys for association
													joinTableDBName := ToColumnName(elemType.Name()) + "_" + field.DBName
													relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, joinTableDBName)
												}
											}
										}
									}

									joinTableHandler := JoinTableHandler{}
									joinTableHandler.Setup(relationship, many2many, reflectType, elemType)
									relationship.JoinTableHandler = &joinTableHandler
									field.Relationship = relationship
								} else {
									// User has many comments, associationType is User, comment use UserID as foreign key
									var associationType = reflectType.Name()
									var toFields = toScope.GetStructFields()
									relationship.Kind = "has_many"

									if polymorphic, _ := field.TagSettingsGet("POLYMORPHIC"); polymorphic != "" {
										// Dog has many toys, tag polymorphic is Owner, then associationType is Owner
										// Toy use OwnerID, OwnerType ('dogs') as foreign key
										if polymorphicType := getForeignField(polymorphic+"Type", toFields); polymorphicType != nil {
											associationType = polymorphic
											relationship.PolymorphicType = polymorphicType.Name
											relationship.PolymorphicDBName = polymorphicType.DBName
											// if Dog has multiple set of toys set name of the set (instead of default 'dogs')
											if value, ok := field.TagSettingsGet("POLYMORPHIC_VALUE"); ok {
												relationship.PolymorphicValue = value
											} else {
												relationship.PolymorphicValue = scope.TableName()
											}
											polymorphicType.IsForeignKey = true
										}
									}

									// if no foreign keys defined with tag
									if len(foreignKeys) == 0 {
										// if no association foreign keys defined with tag
										if len(associationForeignKeys) == 0 {
											for _, field := range modelStruct.PrimaryFields {
												foreignKeys = append(foreignKeys, associationType+field.Name)
												associationForeignKeys = append(associationForeignKeys, field.Name)
											}
										} else {
											// generate foreign keys from defined association foreign keys
											for _, scopeFieldName := range associationForeignKeys {
												if foreignField := getForeignField(scopeFieldName, modelStruct.StructFields); foreignField != nil {
													foreignKeys = append(foreignKeys, associationType+foreignField.Name)
													associationForeignKeys = append(associationForeignKeys, foreignField.Name)
												}
											}
										}
									} else {
										// generate association foreign keys from foreign keys
										if len(associationForeignKeys) == 0 {
											for _, foreignKey := range foreignKeys {
												if strings.HasPrefix(foreignKey, associationType) {
													associationForeignKey := strings.TrimPrefix(foreignKey, associationType)
													if foreignField := getForeignField(associationForeignKey, modelStruct.StructFields); foreignField != nil {
														associationForeignKeys = append(associationForeignKeys, associationForeignKey)
													}
												}
											}
											if len(associationForeignKeys) == 0 && len(foreignKeys) == 1 {
												associationForeignKeys = []string{scope.PrimaryKey()}
											}
										} else if len(foreignKeys) != len(associationForeignKeys) {
											scope.Err(errors.New("invalid foreign keys, should have same length"))
											return
										}
									}

									for idx, foreignKey := range foreignKeys {
										if foreignField := getForeignField(foreignKey, toFields); foreignField != nil {
											if associationField := getForeignField(associationForeignKeys[idx], modelStruct.StructFields); associationField != nil {
												// source foreign keys
												foreignField.IsForeignKey = true
												relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, associationField.Name)
												relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, associationField.DBName)

												// association foreign keys
												relationship.ForeignFieldNames = append(relationship.ForeignFieldNames, foreignField.Name)
												relationship.ForeignDBNames = append(relationship.ForeignDBNames, foreignField.DBName)
											}
										}
									}

									if len(relationship.ForeignFieldNames) != 0 {
										field.Relationship = relationship
									}
								}
							} else {
								field.IsNormal = true
							}
						}(field)
					case reflect.Struct:
						defer func(field *StructField) {
							var (
								// user has one profile, associationType is User, profile use UserID as foreign key
								// user belongs to profile, associationType is Profile, user use ProfileID as foreign key
								associationType           = reflectType.Name()
								relationship              = &Relationship{}
								toScope                   = scope.New(reflect.New(field.Struct.Type).Interface())
								toFields                  = toScope.GetStructFields()
								tagForeignKeys            []string
								tagAssociationForeignKeys []string
							)

							if foreignKey, _ := field.TagSettingsGet("FOREIGNKEY"); foreignKey != "" {
								tagForeignKeys = strings.Split(foreignKey, ",")
							}

							if foreignKey, _ := field.TagSettingsGet("ASSOCIATION_FOREIGNKEY"); foreignKey != "" {
								tagAssociationForeignKeys = strings.Split(foreignKey, ",")
							} else if foreignKey, _ := field.TagSettingsGet("ASSOCIATIONFOREIGNKEY"); foreignKey != "" {
								tagAssociationForeignKeys = strings.Split(foreignKey, ",")
							}

							if polymorphic, _ := field.TagSettingsGet("POLYMORPHIC"); polymorphic != "" {
								// Cat has one toy, tag polymorphic is Owner, then associationType is Owner
								// Toy use OwnerID, OwnerType ('cats') as foreign key
								if polymorphicType := getForeignField(polymorphic+"Type", toFields); polymorphicType != nil {
									associationType = polymorphic
									relationship.PolymorphicType = polymorphicType.Name
									relationship.PolymorphicDBName = polymorphicType.DBName
									// if Cat has several different types of toys set name for each (instead of default 'cats')
									if value, ok := field.TagSettingsGet("POLYMORPHIC_VALUE"); ok {
										relationship.PolymorphicValue = value
									} else {
										relationship.PolymorphicValue = scope.TableName()
									}
									polymorphicType.IsForeignKey = true
								}
							}

							// Has One
							{
								var foreignKeys = tagForeignKeys
								var associationForeignKeys = tagAssociationForeignKeys
								// if no foreign keys defined with tag
								if len(foreignKeys) == 0 {
									// if no association foreign keys defined with tag
									if len(associationForeignKeys) == 0 {
										for _, primaryField := range modelStruct.PrimaryFields {
											foreignKeys = append(foreignKeys, associationType+primaryField.Name)
											associationForeignKeys = append(associationForeignKeys, primaryField.Name)
										}
									} else {
										// generate foreign keys form association foreign keys
										for _, associationForeignKey := range tagAssociationForeignKeys {
											if foreignField := getForeignField(associationForeignKey, modelStruct.StructFields); foreignField != nil {
												foreignKeys = append(foreignKeys, associationType+foreignField.Name)
												associationForeignKeys = append(associationForeignKeys, foreignField.Name)
											}
										}
									}
								} else {
									// generate association foreign keys from foreign keys
									if len(associationForeignKeys) == 0 {
										for _, foreignKey := range foreignKeys {
											if strings.HasPrefix(foreignKey, associationType) {
												associationForeignKey := strings.TrimPrefix(foreignKey, associationType)
												if foreignField := getForeignField(associationForeignKey, modelStruct.StructFields); foreignField != nil {
													associationForeignKeys = append(associationForeignKeys, associationForeignKey)
												}
											}
										}
										if len(associationForeignKeys) == 0 && len(foreignKeys) == 1 {
											associationForeignKeys = []string{scope.PrimaryKey()}
										}
									} else if len(foreignKeys) != len(associationForeignKeys) {
										scope.Err(errors.New("invalid foreign keys, should have same length"))
										return
									}
								}

								for idx, foreignKey := range foreignKeys {
									if foreignField := getForeignField(foreignKey, toFields); foreignField != nil {
										if scopeField := getForeignField(associationForeignKeys[idx], modelStruct.StructFields); scopeField != nil {
											foreignField.IsForeignKey = true
											// source foreign keys
											relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, scopeField.Name)
											relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, scopeField.DBName)

											// association foreign keys
											relationship.ForeignFieldNames = append(relationship.ForeignFieldNames, foreignField.Name)
											relationship.ForeignDBNames = append(relationship.ForeignDBNames, foreignField.DBName)
										}
									}
								}
							}

							if len(relationship.ForeignFieldNames) != 0 {
								relationship.Kind = "has_one"
								field.Relationship = relationship
							} else {
								var foreignKeys = tagForeignKeys
								var associationForeignKeys = tagAssociationForeignKeys

								if len(foreignKeys) == 0 {
									// generate foreign keys & association foreign keys
									if len(associationForeignKeys) == 0 {
										for _, primaryField := range toScope.PrimaryFields() {
											foreignKeys = append(foreignKeys, field.Name+primaryField.Name)
											associationForeignKeys = append(associationForeignKeys, primaryField.Name)
										}
									} else {
										// generate foreign keys with association foreign keys
										for _, associationForeignKey := range associationForeignKeys {
											if foreignField := getForeignField(associationForeignKey, toFields); foreignField != nil {
												foreignKeys = append(foreignKeys, field.Name+foreignField.Name)
												associationForeignKeys = append(associationForeignKeys, foreignField.Name)
											}
										}
									}
								} else {
									// generate foreign keys & association foreign keys
									if len(associationForeignKeys) == 0 {
										for _, foreignKey := range foreignKeys {
											if strings.HasPrefix(foreignKey, field.Name) {
												associationForeignKey := strings.TrimPrefix(foreignKey, field.Name)
												if foreignField := getForeignField(associationForeignKey, toFields); foreignField != nil {
													associationForeignKeys = append(associationForeignKeys, associationForeignKey)
												}
											}
										}
										if len(associationForeignKeys) == 0 && len(foreignKeys) == 1 {
											associationForeignKeys = []string{toScope.PrimaryKey()}
										}
									} else if len(foreignKeys) != len(associationForeignKeys) {
										scope.Err(errors.New("invalid foreign keys, should have same length"))
										return
									}
								}

								for idx, foreignKey := range foreignKeys {
									if foreignField := getForeignField(foreignKey, modelStruct.StructFields); foreignField != nil {
										if associationField := getForeignField(associationForeignKeys[idx], toFields); associationField != nil {
											foreignField.IsForeignKey = true

											// association foreign keys
											relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, associationField.Name)
											relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, associationField.DBName)

											// source foreign keys
											relationship.ForeignFieldNames = append(relationship.ForeignFieldNames, foreignField.Name)
											relationship.ForeignDBNames = append(relationship.ForeignDBNames, foreignField.DBName)
										}
									}
								}

								if len(relationship.ForeignFieldNames) != 0 {
									relationship.Kind = "belongs_to"
									field.Relationship = relationship
								}
							}
						}(field)
					default:
						field.IsNormal = true
					}
				}
			}

			// Even it is ignored, also possible to decode db value into the field
			if value, ok := field.TagSettingsGet("COLUMN"); ok {
				field.DBName = value
			} else {
				field.DBName = ToColumnName(fieldStruct.Name)
			}

			modelStruct.StructFields = append(modelStruct.StructFields, field)
		}
	}

	if len(modelStruct.PrimaryFields) == 0 {
		if field := getForeignField("id", modelStruct.StructFields); field != nil {
			field.IsPrimaryKey = true
			modelStruct.PrimaryFields = append(modelStruct.PrimaryFields, field)
		}
	}

	modelStructsMap.Store(hashKey, &modelStruct)

	return &modelStruct
}
By Anonymous, 2019-06-12 20:07:03
private boolean check_if_valid_login(Login login) {
    boolean validLogin = false;
    if (login.isValid(login)) {
        validLogin = true;
    }
    
    if (!(login.isValid(login) == true)) {
        validLogin = false;
    }
    
    return validLogin ? true : false;
}
By Anonymous, 2021-07-06 20:22:47
if (logger.isDebugEnabled()) {
			logger.debug("process (FollettPojo) - start");	
		}
String dnum = StringUtil.toCapitalizedString(pojo.getDnum().toString()); 
pojo.setDnum(new String(dnum));
	    
if (logger.isDebugEnabled()) {
    logger.debug("process (FollettPojo) - middle ");
}

String rawI = StringUtil.toCapitalizedString(pojo.getRawInput().trim().toString()); 
pojo.setRawInput(new String(rawI));

if (logger.isDebugEnabled()) {
	logger.debug("process (FollettPojo) - end ");
}
		
		
/* And you may ask what is this toCapitalizedString? Well here you go a separate class to boot */
	public static String toCapitalizedString(String string){
		StringBuilder strb = new StringBuilder();
		if(string != null && string.trim().length() > 0
				&& Character.isLetter(string.charAt(0))
				&& Character.isLowerCase(string.charAt(0))){

			strb.append(string.substring(0,1).toUpperCase()).append(string.substring(1));
			return strb.toString();
		}
		return string;

	}

SpringBatch this is the processor for each record...dnum example D00000000

By Albert, 2017-12-15 23:53:41
if((substr($onefile, -4) == ".Mp3") OR 
    (substr($onefile, -4) == ".ogg") OR 
    (substr($onefile, -4) == ".OGG") OR 
    (substr($onefile, -4) == ".oGG") OR 
    (substr($onefile, -4) == ".OGg") OR 
    (substr($onefile, -4) == ".Ogg") OR 
    (substr($onefile, -4) == ".OgG") OR 
    (substr($onefile, -4) == ".mP3") OR 
    (substr($onefile, -4) == ".MP3") OR 
    (substr($onefile, -4) == ".mp3")){
    
    // do stuff
} 

gotta make sure you account for capitalization

By Kyuunex, 2018-07-02 04:58:09
Double value = item.getPrice() * loyaltyPointMultiplier;
String[] s = String.split(value.toString(), "\\.");
points = Integer.parseInt(s[0]);
if(Integer.parseInt(s[1]) > 0) {
    points++;
}
    
return points;

Want to round up? Math.ceil() uses too little memory! Use this instead!

By phytyca, 2017-12-12 05:02:48

if let _ = detailInformation {
     loadDetailInformation()
}

when optionals are killing yourself

By gc, 2017-12-13 00:19:02
<?php

if ($_GET['csrfstopper'] !== 1){
    exit();
}

Please don't judge my friend trying to stop CSRF Attacks he's still learning.

By Lunorian, 2017-12-14 04:37:45