StartCoroutine(Patrol());
public IEnumerator Patrol() {
while(true) {
dt.Walk();
yield return new WaitForSeconds(reactionTime);
}
}
let already_in = True;
while (already_in) {
let random_index = Math.floor(arr.length * Math.random());
let already_in = False;
for (ex of exs) {
if (ex.id === arr[random_index].id) {
already_in = True;
}
}
}
Yes, this is JavaScript, and yes it didn't work. Found while reviewing some code
pageEndReached() {
if (!this.endOfResults) {
//load more pages
this.page++;
this.getPosts();
followerCount: null,
postCount: null,
measurementKeys: ["a", "b", "c", "d", "e"],
showDrafts: false,
};
},
nani
elsif ( $att =~ m/!!ARRAY!!/ ) { # Updated to allow us to get data from an Array -
&Debug("get_value_from_hash:: parsing the ARRAY attribute - $att");
my ( $key1, $key2, $key3, $key4, $key5, $key6 ) = split( /\./, $att );
#&Debug("get_value_from_hash:: key1=$key1, key2=$key2, key3=$key3, key4=$key4, key5=$key5");
if ( defined $key6 ) {
if ( $key5 =~ m/!!ARRAY!!/ ) {
for my $item ( @{ $hash->{$key1}->{$key2}->{$key3}->{$key4} } ) { $value = $item->{$key6}; }
}
elsif ( $key4 =~ m/!!ARRAY!!/ ) {
for my $item ( @{ $hash->{$key1}->{$key2}->{$key3} } ) { $value = $item->{$key5}->{$key6}; }
}
elsif ( $key3 =~ m/!!ARRAY!!/ ) {
for my $item ( @{ $hash->{$key1}->{$key2} } ) { $value = $item->{$key4}->{$key5}->{$key6}; }
}
elsif ( $key2 =~ m/!!ARRAY!!/ ) {
for my $item ( @{ $hash->{$key1} } ) { $value = $item->{$key3}->{$key4}->{$key5}->{$key6}; }
}
elsif ( $key1 =~ m/!!ARRAY!!/ ) {
for my $item ( @{$hash} ) { $value = $item->{$key2}->{$key3}->{$key4}->{$key5}->{$key6}; }
}
}
elsif ( defined $key5 ) {
if ( $key4 =~ m/!!ARRAY!!/ ) {
for my $item ( @{ $hash->{$key1}->{$key2}->{$key3} } ) { $value = $item->{$key5}; }
}
elsif ( $key3 =~ m/!!ARRAY!!/ ) {
for my $item ( @{ $hash->{$key1}->{$key2} } ) { $value = $item->{$key4}->{$key5}; }
}
elsif ( $key2 =~ m/!!ARRAY!!/ ) {
for my $item ( @{ $hash->{$key1} } ) { $value = $item->{$key3}->{$key4}->{$key5}; }
}
elsif ( $key1 =~ m/!!ARRAY!!/ ) {
for my $item ( @{$hash} ) { $value = $item->{$key1}->{$key3}->{$key4}->{$key5}; }
}
}
elsif ( defined $key4 ) {
if ( $key3 =~ m/!!ARRAY!!/ ) {
for my $item ( @{ $hash->{$key1}->{$key2} } ) { $value = $item->{$key4}; }
}
elsif ( $key2 =~ m/!!ARRAY!!/ ) {
for my $item ( @{ $hash->{$key1} } ) { $value = $item->{$key3}->{$key4}; }
}
elsif ( $key1 =~ m/!!ARRAY!!/ ) {
for my $item ( @{$hash} ) { $value = $item->{$key1}->{$key3}->{$key4}; }
}
}
elsif ( defined $key3 ) {
if ( $key2 =~ m/!!ARRAY!!/ ) {
for my $item ( @{ $hash->{$key1} } ) { $value = $item->{$key3}; }
}
elsif ( $key1 =~ m/!!ARRAY!!/ ) {
for my $item ( @{$hash} ) { $value = $item->{$key3}; }
}
}
elsif ( defined $key2 ) {
if ( $key1 =~ m/!!ARRAY!!/ ) {
for my $item ( @{$hash} ) { $value = $item->{$key2}; }
}
}
}
elsif ( $att =~ m/!!HITS\[\d+\]!!/ ) {
&Debug("get_value_from_hash:: parsing the HITS attribute - $att");
my $id = $att;
$id =~ s/!!HITS\[(\d+)\]!!.*/$1/;
$att =~ s/!!HITS\[\d+\]!!\.//;
&Debug("get_value_from_hash:: parsing the attribute - $att");
my ( $key1, $key2, $key3, $key4, $key5, $key6 ) = split( /\./, $att );
#&Debug("get_value_from_hash:: id=$id, key1=$key1, key2=$key2, key3=$key3, key4=$key4, key5=$key5");
if ( defined $key6 ) {
$value = $$hash{hits}{hits}[$id]{$key1}{$key2}{$key3}{$key4}{$key5}{$key6};
}
elsif ( defined $key5 ) {
$value = $$hash{hits}{hits}[$id]{$key1}{$key2}{$key3}{$key4}{$key5};
}
elsif ( defined $key4 ) {
$value = $$hash{hits}{hits}[$id]{$key1}{$key2}{$key3}{$key4};
}
elsif ( defined $key3 ) {
$value = $$hash{hits}{hits}[$id]{$key1}{$key2}{$key3};
}
elsif ( defined $key2 ) {
$value = $$hash{hits}{hits}[$id]{$key1}{$key2};
}
}
elsif ( $att =~ m/!!DELIMITER!!.+!!/ ) {
&Debug("get_value_from_hash:: parsing the DELIMITER attribute - $att");
my $delimiter = $att;
$delimiter =~ s/!!DELIMITER!!(.*)!!.*/$1/;
$att =~ s/!!DELIMITER!!.+!!//;
&Debug("get_value_from_hash:: parsing the attribute - $att");
my ( $key1, $key2, $key3, $key4, $key5, $key6 ) = split( $delimiter, $att );
# &Debug("get_value_from_hash:: key1=$key1, key2=$key2, key3=$key3, key4=$key4, key5=$key5, key6=$key6");
if ( defined $key6 ) {
$value = $$hash{$key1}{$key2}{$key3}{$key4}{$key5}{$key6};
}
elsif ( defined $key5 ) {
$value = $$hash{$key1}{$key2}{$key3}{$key4}{$key5};
}
elsif ( defined $key4 ) {
$value = $$hash{$key1}{$key2}{$key3}{$key4};
}
elsif ( defined $key3 ) {
$value = $$hash{$key1}{$key2}{$key3};
}
elsif ( defined $key2 ) {
$value = $$hash{$key1}{$key2};
}
}
else {
&Debug("get_value_from_hash:: parsing the attribute - $att");
my ( $key1, $key2, $key3, $key4, $key5, $key6 ) = split( /\./, $att );
#&Debug("get_value_from_hash:: key1=$key1, key2=$key2, key3=$key3, key4=$key4, key5=$key5");
if ( defined $key6 ) {
$value = $$hash{$key1}{$key2}{$key3}{$key4}{$key5}{$key6};
}
elsif ( defined $key5 ) {
$value = $$hash{$key1}{$key2}{$key3}{$key4}{$key5};
}
elsif ( defined $key4 ) {
$value = $$hash{$key1}{$key2}{$key3}{$key4};
}
elsif ( defined $key3 ) {
$value = $$hash{$key1}{$key2}{$key3};
}
elsif ( defined $key2 ) {
$value = $$hash{$key1}{$key2};
}
}
When you try to debug, why value is not filled, and find this...
def get_verified_infos(request):
try:
# request logic here
return data
except Exception:
logger.error(
'Request to XXX was unsuccessful, '
'Will retry till max recursion! Retrying...'
)
return get_verified_infos(request)
Used for OpenID authentication
public override List<Value> Values
{
get
{
if (_values == null && shouldLoadLazily)
{
_values = _lazerLoader.LoadValues<Value>()
}
return _values;
}
set
{
throw new InvalidOperationException("Values are actually readonly- please set in constructor")
}
}
How to create immutable fields in c#
if (date.Training != null)
{
var training = date.Training;
var status = new TrainingStatus();
var refresher = new Training();
if (training.Trainings != null)
refresher = training.Trainings;
bool hasTakenRefresher = false;
status.Value = date.Date.AddDays(
TrainingHelper.CalculateValidityDays(training.Validity ?? 0, training.ValidityType ?? 0));
status.Name = training.TrainingName;
status.ID = training.TrainingID;
status.Category = training.CategoryTraining != null ? training.CategoryTraining.Name : "Other";
status.IsTrained = _validityUtilsService.IsValid(training, date.Date);
if (status.IsTrained)
{
status.IsExpiring = _validityUtilsService.IsExpiring(training, date.Date,
TrainingHelper.CalculateValidityDays(
training.ExpirationWarningValidity ?? 0,
training.ExpirationWarningValidityType ?? 0));
}
if (refresher.ID != 0)
{
hasTakenRefresher = employee.Dates
.Count(x => x.Training != null
&& x.TrainingID == refresher.ID) > 1;
if (hasTakenRefresher && (status.IsExpiring || !status.IsTrained))
{
status.IsExpiring = false;
var trainingWithNewValidity = new Training();
status.Value = date.Date.AddDays(
TrainingHelper.CalculateValidityDays(training.ValidityRefresher ?? 0,
training.ValidityRefresherType ?? 0));
trainingWithNewValidity.Validity = training.ValidityRefresher;
trainingWithNewValidity.ValidityType = training.ValidityRefresherType;
status.IsTrained = _validityUtilsService.IsValid(trainingWithNewValidity, date.Date);
if (status.IsTrained)
{
status.IsExpiring = _validityUtilsService.IsExpiring(trainingWithNewValidity, date.Date,
TrainingHelper.CalculateValidityDays(
refresher.ExpirationWarningValidity ?? 0,
refresher.ExpirationWarningValidityType ?? 0));
}
}
}
if (status.IsTrained && !status.IsExpiring)
status.Status = TrainingStatuses.Trained;
else if (status.IsTrained && status.IsExpiring)
status.Status = TrainingStatuses.Expiring;
else if (!status.IsTrained && !status.IsExpiring)
status.Status = TrainingStatuses.Expired;
status.EmpID = employee.ID;
return status;
}
test
foreach ($desired_components as $name => $junk) {
list($component_value, $component_comments) = self::unpackPair($desired_components[$name]);
$desired_components[$name] = self::packPair(round($component_value, 2), $component_comments);
}
/**
* Creates hash of client/customer password
* @param string $password The actual password
* @return string MD5 hash of password with salt
*/
public static function hashPassword($password)
{
return md5($password . $password. 'SOME-SECRET-STRING' . $password);
}
function resetfields_simple()
{
pole1=document.getElementById('dataOd');
pole1.value='';
pole2=document.getElementById('dataDo');
pole2.value='';
pole3=document.getElementById('trescKom');
pole3.value='';
pole4=document.getElementById('katId');
pole4.value='';
}
function resetfields()
{
pole1=document.getElementById('dataOd');
pole1.value='';
pole2=document.getElementById('dataDo');
pole2.value='';
pole3=document.getElementById('trescKom');
pole3.value='';
pole4=document.getElementById('dokId');
pole4.value='';
pole5=document.getElementById('katId');
pole5.value='';
pole6=document.getElementById('currId');
pole6.value='';
}
function resetfields_arch()
{
pole1=document.getElementById('dataOd');
pole1.value='';
pole2=document.getElementById('dataDo');
pole2.value='';
pole3=document.getElementById('trescKom');
pole3.value='';
pole4=document.getElementById('dokId');
pole4.value='';
pole5=document.getElementById('katId');
pole5.value='';
}
SELECT
tblPosts.idPost,
tblPosts.postTitle,
tblPosts.postCode,
tblPostsStatus.scsTitle,
concat(code, '<br>', pTitle) AS pTitle, (CASE WHEN postResult = 1 THEN 'yes' ELSE 'no' END) AS postResult ,
concat(date_format(postStartedDate, '%d.%m.%Y'), '<br>', date_format(postStartedDate, '%H:%i')) AS dateStart,
date_format(tblPosts.updated_at, '%d.%m.%Y %H:%i') AS dtUpdated, tblPerson.mobile, tblPerson.mail, tblPerson.isoLang, tblPostsReason.surname,
concat(coalesce(clientFName, ''), ' ', coalesce(clientName, '')) AS client,
concat(coalesce(concat(tblGender.gender, ' '), ''), coalesce(eFName, ''), ' ', coalesce(eName, '')) AS pers,
(CASE WHEN tblPosts.idCollab is NULLTHEN '' ELSE concat(coalesce(tblCol.cFName, ''), ' ', coalesce(tblCol.cName, '')) END) AS starter,
concat("<img src='img/status_", tblPosts.status, ".png' height='12px' border='1' />") AS displaystat,
concat("<a href='index.php?arg=posts&id=", tblPosts.idPost, "&idAccess=", coalesce(tblAccess.idAccess, ''), "' title='Prepare Interface'><img src='../DG/styles/flat/images/edit.gif' style='height:14px; width:32px;' border='0'></a>") AS elink,
concat("<a href='email.php?frame=1&idPost=", tblPosts.idPost, "&source=PERS&idSrc=", tblPerson.idPerson, "&lang=", tblPerson.isoLang, "&from=", ";;SENDER", "&to=", tblPerson.persMail, "&idTperslate=CLI_diff_joindre_can,PERS_demande_contact,PERS_demande_CV&title=", replace(replace(replace(coalesce(pTitle, ''), "'", ";;APO"), "(", ";;PLT"), ")", ";;PGT"), "' title='", concat(coalesce(persName, ''), ' ', coalesce(persFname, '')), "' class='fancybox fancybox.iframe'><img src='img/email.png' height='12px' border='1' title='Messages' ></a>") AS mailink,
concat("<a href='post_email.php?frame=1&op=resend&idPosts=", tblPosts.idPost, "&idPerson=", tblPerson.idPerson, "&lang=", tblPerson.isoLang, "&idAccess=", coalesce(tblAccess.idAccess, ''), "&title=", replace(replace(replace(coalesce(pTitle, ''), "'", ";;APO"), "(", ";;PLT"), ")", ";;PGT"), "' title='", concat(coalesce(perName, ''), ' ', coalesce(perFName, '')), "' class='fancybox fancybox.iframe'><img src='img/emailNew.png' height='12px' border=1 title='New Posts' ></a>") AS newlink,
concat("<a href='comment.php?idPosts=", tblPosts.idPost, "&idPostsElem=-1&idClient=", tblPosts.idClient, "&frame=1&title=", replace(replace(replace(pTitle, "'", ";;APO"), "(", ";;PLT"), ")", ";;PGT"), "' title='", concat(coalesce(persName, ''), ' ', coalesce(persFName, '')), "' class='fancyboxstepreload fancybox.iframe'><div id='divBadgeComm", tblPosts.idPost, "' class='divBadge'>", (select count(*) from tblComment where idPosts=tblPosts.idPost and idElem is NULLand visibleClient=1), "</div><img src='img/comment.png' height='12px' border='1' title='Comments' /></a>") AS comments,
concat("<a href='docs.php?frame=1&idPosts=", tblPosts.idPost, "&title=", replace(replace(replace(pTitle, "'", ";;APO"), "(", ";;PLT"), ")", ";;PGT"), "' title='", concat(coalesce(persName, ''), ' ', coalesce(persFname, '')), "' class='fancyboxstep fancybox.iframe'><div id='divBadgeDocument", tblPosts.idPost, "' class='divBadge'>", (select count(*) from tblDocs where idPosts=tblPosts.idPost and docFileName <> '' and status=1), "</div><img src='img/dir.png' height='12px' border='1' title='Docs' /></a>") AS documents,
FROM tblPosts
-- lots of LEFT JOIN
WHERE 1;
Maybe he didn't know how to do it in PHP ?
ierr = pxmlIn->GetData(pcTag, *pTData);
*pbDataValid = bool((ierr==0)&&(iLen>0)); // enabled if: not empty string and vaild (number?)
if (*pbDataValid) iErr += ierr;
<Image source={ this.props.pickupOrDropoff == "pickup"
? i.pickup
? iconBlue
: iconWhite
: i.dropoff
? iconBlue
: iconWhite} style={{
height:this.props.pickupOrDropoff == "pickup"
? i.pickup
? 30
: i.sign === 'D' ? 30 : 35
: i.dropoff
? 30
: i.sign === 'D' ? 30 : 35,
marginRight:10 ,
width: this.props.pickupOrDropoff == "pickup"
? i.pickup
? 40
: 40
: i.dropoff
? 40
: 40
,resizeMode:'contain'}}/>
I love when the code is neat...
filterForProvincia() {
console.log('ciao');
}
The last line of code of a parting Developer
/*
* 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 sooo many problems with this...