foreach($bookings as $booking) {
	$status = $apiController->getBookingStatus($booking);
	if($status->error == 1) {
		switch($status->message) {
			case "FIND_PRV_KO": continue; //Wrong parameters
			case "ERR_PREN_NOTFOUND": continue; //Request booking cannot be found
			case "ERR_PRV_NOTFOUND": continue; //Check-in not carried out
			default: continue;
		};
		continue;
	}
	//DO SOME STUFF...
}

Found this on a production website

By Samuel, 2021-03-29 17:52:33
isCreatedUser : !this.isEdit ? true : false

Vue.js project, someone wanted to verify if the user was being edited or created...

By rat, 2021-10-21 17:11:54
  @Override
    public ResponseEntity<AuditLogPagedResults> getLogEntries(
    		@ApiParam(value = "Environment ID", required = true) @PathVariable("environmentId") Long environmentId,
	   	  	@ApiParam(value = "ID of the queue manager to browse") @Valid @RequestParam(value = "queueManager", required = false) Long queueManager,
	   	  	@ApiParam(value = "ID of the queue to browse") @Valid @RequestParam(value = "queue", required = false) Long queue,
	   	  	@ApiParam(value = "Browse for messages newer than a date/time") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @RequestParam(value = "from", required = false) @Valid LocalDateTime from,
	   	  	@ApiParam(value = "Correlation ID to browse for") @Valid @RequestParam(value = "correlationId", required = false) String correlationId,
	   	  	@ApiParam(value = "Page of results to return") @Valid @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(value = "Number of results in a page") @Valid @RequestParam(value = "pagesize", required = false) Integer pagesize) {
        Pageable pageable = PageRequest.of(page != null ? page : 0, pagesize != null ? pagesize : defaultPageSize, new Sort(Sort.Direction.DESC, Audit.MSG_PUT_TIMESTAMP_FIELD));
        Page<Audit> auditEntries = null;
        Timestamp msgPut = (from != null ? Timestamp.valueOf(from) : null);

        /*
         * Environemnt is always supplied.  If we have queue or queue manager, assume that's what the caller wants.
         * We may also have some optional parameters - put timestamp, correlation ID
         */
        if (queue != null) {
        	//retrieve queue name
        	String queueName = null;
        	Optional<WMQQueue> queueEntity = wmqQueueRepository.findById(queue.intValue());
        	queueName = queueEntity.get().getQ_name();
        	
        	//see if we have timestamp or correlation ID
			if (msgPut != null) {
				if (correlationId != null) {
					auditEntries = auditRepository.findByQNameAndCorrelIdAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, correlationId, pageable);
				} else {
					auditEntries = auditRepository.findByQNameAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, pageable);
				}
			} else {
				if (correlationId != null) {
					auditEntries = auditRepository.findByQNameAndCorrelId(queueName, correlationId, pageable);
				} else {
					auditEntries = auditRepository.findByQName(queueName, pageable);
				}
			}
        } else if (queueManager != null) {
            List<Integer> managerIds = Arrays.asList(queueManager.intValue());
        	//see if we have timestamp or correlation ID
			if (msgPut != null) {
				if (correlationId != null) {
                    auditEntries = auditRepository.findByManagerIdsAndCorrelIdAndMsgPutTimestampGreaterThanEqual(managerIds, msgPut, correlationId, pageable);
				} else {
                    auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
				}
			} else {
				if (correlationId != null) {
                    auditEntries = auditRepository.findByManagerIdsAndCorrelId(managerIds, correlationId, pageable);
				} else {
                    auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
				}
			}
throw new java.lang.UnsupportedOperationException("Implementations does not exist");
        } else {
	        List<Integer> managerIds = findManagerIds(environmentId);
	
	        if(managerIds.isEmpty()) {
	            //No QueueManager so no possible log entries
	            return ResponseEntity.ok().body(null);
	        }
	
	        if (msgPut != null) {
	            auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
	        } else {
	            auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
	        }
        }
        
        
        /*
        if (correlationId != null && msgPut != null) {
            auditEntries = auditRepository.findByCorrelIdAndMsgPutTimestampGreaterThanEqual(correlationId, msgPut, pageable);
        } else if (queueName != null && msgPut != null) {
            auditEntries = auditRepository.findByQNameAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, pageable);
        } else if (queueName != null) {
            auditEntries = auditRepository.findByQName(queueName, pageable);
        } else if (correlationId != null) {
            auditEntries = auditRepository.findByCorrelId(correlationId, pageable);
        } else {
            List<Integer> managerIds = findManagerIds(environmentId);

            if(managerIds.isEmpty()) {
                //No QueueManager so no possible log entries
                return ResponseEntity.ok().body(null);
            }

            if (msgPut != null) {
                auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
            } else {
                auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
            }
        }
*/
        if (auditEntries != null) {
	        AuditLogPagedResults results = new AuditLogPagedResults();
	        results.setPageNumber(pageable.getPageNumber());
	        results.setPageSize(pageable.getPageSize());
	        results.setPages(auditEntries.getTotalPages());
	        results.setResults(mapperFacade.mapAsList(auditEntries.getContent(), AuditLogEntry.class));
	        return ResponseEntity.ok().body(results);
        } else {
        	throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Not found");
        }
    }

    
    /* (non-Javadoc)
	 * @see com.arcelormittal.springTemplate.web.MessagesApi#getLogEntry(java.lang.Long, java.lang.Long)
	 */
	@Override
	public ResponseEntity<AuditLogEntry> getLogEntry(Long environmentId, Long logId) {
		Optional<Audit> entry = auditRepository.findById(logId);
		if (entry.isPresent()) {
			return ResponseEntity.ok().body(mapperFacade.map(entry.get(), AuditLogEntry.class));
		} else {
			throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Not found");
		}
	}

End pint to do a dynamic query in JPA.

By Anonymous, 2019-10-02 23:31:22
Select * from Order  --doesn't work
select * from [order] --works
--it's planning module in our system...

I think, it's really bad idea to use reserved words in names of tables. I'm surprised, that this db doesn't contain table named like [select]...

By solbrain, 2017-12-28 08:04:28
if ($this->getTestSku()) {
   ...
} elseif ($this->getTestOffset() >= 0 && $this->getTestLimit() > 0) {
   ...
} else {
   Mage::throwException(sprintf("Invalid parameters for test mode: sku %s or offset %s and limit %s", $this->getTestSku(), $this->getTestOffset(), $this->getTestLimit()));
}
By Anonymous, 2018-03-13 13:56:56
private readonly FooType _foo = new FooType();

/// <summary>
/// Gets the controller of this component
/// </summary>
private FooType Foo
{
    get
    {
        return _foo;
    }
}
By Anonymous, 2018-07-25 13:55:26
# Weird list cleanup
product = "{0}".format(list(product))
product = re.sub(r"\), \(+", "], [", product)
product = re.sub(r"\(+", "[", product)
product = product.replace(")]", "]]").replace(")", "")
product = ast.literal_eval(product)

I don't know why I get this strange fomat for this array of objects... Ok let's do it fast: 1 - Convert array in string 2 - Clean up string 3 - Convert string in array

By Anonymous, 2018-09-05 23:51:16
boolean isUserAuthorized = user.isSuperAdmin();
if (!isUserAuthorized) {
    isUserAuthorized = isUserAdminOfEntity1();
}
if (!isUserAuthorized) {
    isUserAuthorized = isUserAdminOfEntity2();
}
if (!isUserAuthorized) {
    throw new AccessDeniedException("Authenticated user is not admin ");
}
By tralaladidou, 2019-05-07 16:37:32
def get_schema(self, schema: object) -> object:
    """Get the Schema class
    """
    if isinstance(schema, str):
        Schema = getattr(self.request["operation"], schema, None)
    else:
        Schema = schema
    if Schema is None:
        Schema = getattr(self, schema, None)
        if Schema is None:
            raise web.HTTPNotImplemented
    return Schema

I don't even know what to say

By why, 2019-05-23 20:19:52
 # Better off alone 
 use_bmp 137
 
 live_loop :drumrolls do 
   sample : drum_splash_soft, rate: 0.775, finsh: 0.75, amp: 0.75 
   use_synth :pnosie
   with_fx :1x1_techno, phase: 8, phase_offset: 0.4,cutoff_min: 79, cutoff
    with_fx :fhpf, cutoff: 115, res: 0.8, reps: 18 do 
      play  :E1, release: 0.125
      sleep 0.25
   end 
 end
 sleep 47.5
 with_fx :ixi_techno, phase: 29 res: 0.5 re
 use_rx_synth :mod_dsaw
 live_loop :wierd_synth do re mi
 Do sleep 0.3 then sample :sn_dolf, :amp 0.2 start 0.1 next finish: 1.5 do
 
 
 
 
 
 
 
 
 
 
 
 










By #2323The B, 2019-10-02 03:22:03
public class Main {
    public static void main(String[] args) {
        try {
            //code goes here
        } catch (Exception e) {
            System.exit(0);
        }
    }
}
By s0m31, 2022-06-03 15:46:49
/**
 * Stringify a JSON object
 * @param {*} value JSON value to stringify
 * @returns {string} stringify JSON
 */
function stringify(value) {
    var result = {};
    try {
        result = JSON.stringify(value);
    } catch (e) {
        Logger.error('Error while trying to stringify ' + e);
        result = JSON.stringify(result);
    }
    return result;
}

Stringify a JSON object

By Ihor Did, 2023-04-12 19:36:08
        if (CATEGORY_NORMAL.equalsIgnoreCase(categorie)) {
            return assignGroupStartWithPrefix(assignmentGroups);
        } else if (CATEGORY_EXTERNAL.equalsIgnoreCase(categorie)) {
            return assignGroupStartWithPrefix(assignmentGroups);
        } 
By Anon, 2019-05-14 13:58:23
auto settingsFileSize = static_cast<int>(sizeof(_settings));

This was in release branch for a month. Casting wasn't even necessary.

By Your favourite co-worker., 2019-06-04 09:05:15
@register.filter
def rangocinco(obj_id, limit):
    if (obj_id+5) > limit:
        if not (limit-4) == obj_id:
            # print((limit-4), obj_id, flush=True)
            return range((limit-4), (limit+1))
        else:
            # print('SI NO', flush=True)
            return range((obj_id-2), (obj_id+3))
    else:
        # print('NO', flush=True)
        if (obj_id-4) < 2:
            # print('NO SI', flush=True)
            return range(obj_id, (obj_id+5))
        else:
            # print('NO NO', flush=True)
            return range((obj_id-4), (obj_id+1))

Fuck

By rootweiller, 2020-03-11 21:17:16