nohup find dump_events/* -type f -name "*.jpg" -exec bash -c "cp -v {} \"backup_events/\`ls {} --full-time --time-style="+%Y-%m-%d_%H-%M-%S" | cut -d ' ' -f 6 \`_\`md5sum {} | cut -d ' ' -f 1\`.jpg\";" \; &
Let's do this... I may also add this... And this... And that... And the other thing there... Then calculate how flat the earth is... But in one line!
const [glossaries, prompts] = [await getGlossaries(), await getPromps()];
// instead of
// const [glossaries, prompts] = await Promise.all([getGlossaries(), getPrompts()]);
When I was writing the code, I thought for a moment that getGlossaries() and getPrompts() will be executed in parallel
@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.
//////////////////////////////////////////
// Add ROI coordinates into Environment
//////////////////////////////////////////
AddROIcoordinatesIntoEnvironment();
It really helped me understand the code.
Path path = FileSystems.getDefault().getPath("../../../../../../../../../../EmailResults.csv");
Files.deleteIfExists(path);
def dow_to_dict_from_self(self):
# res = {'name': self.name, 'enabled': self.enabled }
res = {'sun': 0, 'mon': 0, 'tue': 0, 'wed': 0, 'thr': 0, 'fri': 0,
'sat': 0,
'enabled': 0, 'dow': 0, 'name': 'untitled'}
if (int(self.days_of_week) & 0x01) == 0x01: # sun
res['sun'] = 1
if (int(self.days_of_week) & 0x02) == 0x02: # mon
res['mon'] = 1
if (int(self.days_of_week) & 0x04) == 0x04: # tue
res['tue'] = 1
if (int(self.days_of_week) & 0x08) == 0x08: # wed
res['wed'] = 1
if (int(self.days_of_week) & 0x10) == 0x10: # thr
res['thr'] = 1
res['thu'] = 1 # '%a' returns thu for Thursday
if (int(self.days_of_week) & 0x20) == 0x20: # fri
res['fri'] = 1
if (int(self.days_of_week) & 0x40) == 0x40: # sat
res['sat'] = 1
if (int(
self.days_of_week) & 0x40) == 0x80: # enabled # new enable#
# flag -- duplicate in db
res['enabled'] = 1
res['enabled'] = self.enabled # remove this
res['dow'] = self.days_of_week
res['name'] = self.name
return res
kept the original comments - they're very helpful
if(!strncmp(pcTagName,strlim,(int)strlen(strlim))) return "";
public static MyClass {
private static volatile ProcessManager singleton = null;
public static ProcessManager getInstance() throws Exception {
if (singleton == null) {
synchronized (MyClass.class) {
if (singleton == null) {
singleton = new ProcessManager();
}
}
}
return singleton;
}
}
The double-checking was invented prior to Java5.
The purpose is if the field isn't null, you don't have to synchronize. But since the java memory model specification was cleaned up and Synchronize/Volatile were given much better specification and semantics it is totally useless boilerplate that you should only write if you have to support Java4. There is a Google Tech Talk that covers this.
/// <summary>
/// Returns true if any component of of Vector3 v is negative
/// </summary>
public static bool Ext_IsNegative(this Vector3 v)
{
return v.x < 0f && v.y < 0f && v.z < 0f;
}
Either the description is wrong or the method in itself
try{
//...
getMyDataFromServer();
//...
}catch(Excepion e){
// :D
}
HMM FIXED BUG!
$options.splice($options.indexOf('option7'), 1);
$options.splice($options.indexOf('option5'), 1);
$options.splice($options.indexOf('option4'), 1);
$options.splice($options.indexOf('option3'), 1);
$options.splice($options.indexOf('option2'), 1);
$options.splice($options.indexOf('option1'), 1);
<?
if (ini_get('register_globals') != 1){
if ((isset($_POST) == true) && (is_array($_POST) == true)) extract($_POST, EXTR_OVERWRITE);
if ((isset($_GET) == true) && (is_array($_GET) == true)) extract($_GET, EXTR_OVERWRITE);}
if HOST == 'AdaLovelace' or HOST == 'vbu' or HOST == 'asus':
urlpatterns += patterns('',
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': MEDIA_ROOT}),
)
//shit code 80 lvl
void getMessageAndChannel(char*buffer,char*message,char*channel)
{
if(strstr(buffer, "PRIVMSG") != NULL )
{
while(*buffer !='#')*buffer++;
while(*buffer!=' ' && *buffer)
*channel++=*buffer++;
while(*buffer!=':' && *buffer)*buffer++;
while(*buffer!='\n' && *buffer)
*message++=*buffer++;
}///
}