try {
    channel.send(eventMessage);
} catch (MessageHandlingException ex) {
    channel.send(eventMessage);
}
By Anonymous, 2019-03-29 08:53:50
if (isLink($content[$i][$j])) {

					if (isImageLink($content[$i][$j])) {

						$image_src = create_image($content[$i][$j], "img");

						$cell = <<<HTML
							<td>
								<img {$image_src} {$img_style}></td></img>
							</td>
HTML;
					} else if (isNestedLink($content[$i][$j])) {

						$links = explode("!", $content[$i][$j]);

						$cell = <<<HTML
							<td><a style="color: {$cards_button_bg_color};" href="{$links[1]}" $open_links_in >{$links[0]}</a></td>
HTML;
					} else {
						
						//Checking if it's a link or a button

							if ($j == $table_button_column) {
														
							//Button HTML
								$table_button_text = explode("-", $content[0][$j])[0];

								$cell = <<<HTML
									<td><a {$open_links_in} href="{$content[$i][$j]}" style="background-color: {$cards_button_bg_color}; color: {$cards_button_text_color};" class="btn">{$table_button_text}</a></td>
HTML;
							} else {
							
							// Link HTML			
								$cell = <<<HTML
									<td><a style="color: {$cards_button_bg_color};" href="{$content[$i][$j]}" $open_links_in >{$content[0][$j]}</a></td>
HTML;
							}
					}
By PHPhillip, 2020-06-09 23:28:49
case (RSel)
      4'b0000:begin
                R1e = 1'b0;   R2e = 1'b0;  R3e = 1'b0;  R4e = 1'b0;  
              end
      4'b0001:begin
                R1e = 1'b0;   R2e = 1'b0;  R3e = 1'b0;  R4e = 1'b1; 
              end
      4'b0010:begin
                R1e = 1'b0;   R2e = 1'b0;  R3e = 1'b1;  R4e = 1'b0; 
              end
      4'b0011:begin
                R1e = 1'b0;   R2e = 1'b0;  R3e = 1'b1;  R4e = 1'b1; 
              end
      4'b0100:begin
                R1e = 1'b0;   R2e = 1'b1;  R3e = 1'b0;  R4e = 1'b0;
              end
      4'b0101:begin
                R1e = 1'b0;   R2e = 1'b1;  R3e = 1'b0;  R4e = 1'b1;  
              end
      4'b0110:begin
                R1e = 1'b0;   R2e = 1'b1;  R3e = 1'b1;  R4e = 1'b0; 
              end
      4'b0111:begin
                R1e = 1'b0;   R2e = 1'b1;  R3e = 1'b1;  R4e = 1'b1;  
              end
      4'b1000:begin
                R1e = 1'b1;   R2e = 1'b0;  R3e = 1'b0;  R4e = 1'b0;  
              end
      4'b1001:begin
                R1e = 1'b1;   R2e = 1'b0;  R3e = 1'b0;  R4e = 1'b1;
              end
      4'b1010:begin
                R1e = 1'b1;   R2e = 1'b0;  R3e = 1'b1;  R4e = 1'b0; 
              end
      4'b1011:begin
                R1e = 1'b1;   R2e = 1'b0;  R3e = 1'b1;  R4e = 1'b1; 
              end
      4'b1100:begin
                R1e = 1'b1;   R2e = 1'b1;  R3e = 1'b0;  R4e = 1'b0; 
              end
      4'b1101:begin
                R1e = 1'b1;   R2e = 1'b1;  R3e = 1'b0;  R4e = 1'b1; 
              end
      4'b1110:begin
                R1e = 1'b1;   R2e = 1'b1;  R3e = 1'b1;  R4e = 1'b0; 
              end
      4'b1111:begin
                R1e = 1'b1;   R2e = 1'b1;  R3e = 1'b1;  R4e = 1'b1;
              end
     
    endcase
    
    case (TSel)
          4'b0000:begin
                    T1e = 1'b0;  T2e = 1'b0; T3e = 1'b0;  T4e = 1'b0;
                  end
          4'b0001:begin
                    T1e = 1'b0;  T2e = 1'b0; T3e = 1'b0;  T4e = 1'b1;
                  end
          4'b0010:begin
                    T1e = 1'b0;  T2e = 1'b0; T3e = 1'b1;  T4e = 1'b0;
                  end
          4'b0011:begin
                    T1e = 1'b0;  T2e = 1'b0; T3e = 1'b1;  T4e = 1'b1;
                  end
          4'b0100:begin
                    T1e = 1'b0;  T2e = 1'b1; T3e = 1'b0;  T4e = 1'b0;
                  end
          4'b0101:begin
                    T1e = 1'b0;  T2e = 1'b1; T3e = 1'b0;  T4e = 1'b1;
                  end
          4'b0110:begin
                    T1e = 1'b0;  T2e = 1'b1; T3e = 1'b1;  T4e = 1'b0;
                  end
          4'b0111:begin
                    T1e = 1'b0;  T2e = 1'b1; T3e = 1'b1;  T4e = 1'b1;
                  end
          4'b1000:begin
                    T1e = 1'b1;  T2e = 1'b0; T3e = 1'b0;  T4e = 1'b0;
                  end
          4'b1001:begin
                    T1e = 1'b1;  T2e = 1'b0; T3e = 1'b0;  T4e = 1'b1;
                  end
          4'b1010:begin
                    T1e = 1'b1;  T2e = 1'b0; T3e = 1'b1;  T4e = 1'b0;
                  end
          4'b1011:begin
                    T1e = 1'b1;  T2e = 1'b0; T3e = 1'b1;  T4e = 1'b1;
                  end
          4'b1100:begin
                    T1e = 1'b1;  T2e = 1'b1; T3e = 1'b0;  T4e = 1'b0;
                  end
          4'b1101:begin
                    T1e = 1'b1;  T2e = 1'b1; T3e = 1'b0;  T4e = 1'b1; 
                  end
          4'b1110:begin
                    T1e = 1'b1;  T2e = 1'b1; T3e = 1'b1;  T4e = 1'b0;
                  end
          4'b1111:begin
                    T1e = 1'b1;  T2e = 1'b1; T3e = 1'b1;  T4e = 1'b1;
                  end
        endcase

Just write assign {R1e, R2e, R3e, R4e} = Rsel assign {T1e, T2e, T3e, T4e} = Tsel

By dawidogg, 2023-04-01 16:40:34
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#

By Unknown, 2017-12-12 14:42:38
FOR x IN ( SELECT COUNT(*) cnt
            FROM DUAL
           WHERE EXISTS ( SELECT NULL FROM task
                           WHERE task.task_type_id = lib.task_type_check()
                             AND task.task_status_id = lib.task_status_open()
                             AND task.unit_id = in_unit_id
                             AND task.station_id = v_station_id
                        )
         )
LOOP
  IF( x.cnt = 1 ) THEN
    v_task_exist := TRUE;
  ELSE
    v_task_exist := FALSE;
  END IF;
END LOOP;
By Anonymous, 2019-08-01 15:25:36
class ExampleClass {
    public void DoSomething()
    {
       if (this != null) {
           //omitted
       }
    }
    
    public void DoSomething2()
    {
       if (this != null) {
           //omitted
       }
    }
    
}

Explanation: This can't be null in C# virtual instance methods - I was so confused by the widespread use of this check that I asked this question at SO: https://stackoverflow.com/questions/31747718/can-this-be-null-in-c-sharp-virtual-methods-what-happens-with-the-rest-of-ins

By Michail Michailidis, 2017-12-13 14:54:58
<h1 className="sidebar-text">
	<h1 className="sidebar-text">My Applauses</h1>
</h1>

How do you even miss this... the Console will literally complain in red to you...

By Mr Verster, 2022-04-07 16:53:40
#411 C# +13
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

By NN, 2019-10-29 12:59:14
local Plr = game.Players.LocalPlayer

for i,v in pairs(game.ReplicatedStorage.DataStorage[Plr.Name].Data["Slot1"].AccessoriesList:GetChildren()) do
v.Value = "Unlocked"
end
for i,v in pairs(game.ReplicatedStorage.DataStorage[Plr.Name].Data["Slot1"].StanceList:GetChildren()) do
v.Value = "Unlocked"
end
for i,v in pairs(game.ReplicatedStorage.DataStorage[Plr.Name].Data["Slot1"].RunningList:GetChildren()) do
v.Value = "Unlocked"
end
for i,v in pairs(game.ReplicatedStorage.DataStorage[Plr.Name].Data["Slot1"].FlyingList:GetChildren()) do
v.Value = "Unlocked"
end
for i,v in pairs(game.ReplicatedStorage.DataStorage[Plr.Name].Data["Slot1"].FightingStyles:GetChildren()) do
v.Value = "Unlocked"
end
for i,v in pairs(game.ReplicatedStorage.DataStorage[Plr.Name].Data["Slot1"].MoveList:GetChildren()) do
v.Value = "Unlocked"
end
for i,v in pairs(game.ReplicatedStorage.DataStorage[Plr.Name].Data["Slot1"].ClothingList:GetChildren()) do
v.Value = "Unlocked"
end

Bad unlock script for Roblox

By JayRain, 2020-03-14 03:01:24
StartCoroutine(Patrol());

public IEnumerator Patrol() {
    while(true) {
        dt.Walk();
        yield return new WaitForSeconds(reactionTime);
    }
}
By Mario, 2021-11-19 07:18:22
cd /some/directory
rm -rf *

I regularly see these two lines in Bash scripts I don't understand but some programmers think you need a CD command before any command, and they also don't know that paths can be part of parameters (which explains why they use many CD commands)

By Meeeeee, 2023-01-25 16:50:10
// Save the files for 100 timea in case failed

try {
    for (let i; i <= 100; i++) {
        File.save();
    }
} catch (e) {
    // Save the files for 100 timea since it already failed
    for (let i; i <= 100; i++) {
        File.save();
    }
}
By Anonymous, 2019-09-09 18:23:39
val weekEnd = DateTime.now.withDayOfWeek(5).plusDays(2)
By Anonymous, 2017-12-22 13:55:37
$url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22https%3A%2F%2Fwww.google.com%2Ffinance%3Fq%3D' . $stock_identifier . '%26fstype%3Dii%26ei%3DCFrdWImFNdiGe_atlegC%22%20and%20compat%3D%22html5%22%20and%20xpath%3D' . "'%2F%2Ftable%5Bcontains(%40class%2C%22gf-table%20rgt%22)%5D'" . '&format=json&diagnostics=true&callback=';

$json = json_decode($this->getJsonFromYql($url), true);
$json = $json["query"]["results"]["table"];

//If the value is red, that means there is an additional span class which needs to be checked through. 

$response["revanueValue"] = empty($json["1"]["tbody"]["tr"]["0"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["0"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["0"]["td"]["1"]["content"];
$response["costofRevanue"] = $json["1"]["tbody"]["tr"]["3"]["td"]["1"]["content"];
$response["operatingIncome"] = empty($json["1"]["tbody"]["tr"]["12"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["12"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["12"]["td"]["1"]["content"];
$response["netIncome"] = empty($json["1"]["tbody"]["tr"]["24"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["24"]["td"]["1"]["span"]["content"] : $json["0"]["tbody"]["tr"]["24"]["td"]["1"]["content"];
$response["dividendsPerShare"] = $json["1"]["tbody"]["tr"]["35"]["td"]["1"]["content"];
$response["dilutedNormalizedEps"] = empty($json["1"]["tbody"]["tr"]["48"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["48"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["48"]["td"]["1"]["content"];
$response["minorityInterest"] = $json["1"]["tbody"]["tr"]["18"]["td"]["1"]["content"];

Website --> Json --> PHP Parsing Beautiful.

By Great PHP User, 2018-01-01 01:58:30
	public static int findSplitVariable(LinkedList<ByteDataRow> matrix) {
		LinkedList<ByteDataRow> list = new LinkedList<ByteDataRow>();
		int maxNoOfZeros = 0;
		int maxNoOfOnes = 0;
		int varId = -1;
		int[] NoOfOnesInColumn = new int[matrix.get(0).getInVars().length];


		for (ByteDataRow bdr : matrix) {
			int tmpNoOfZeros = bdr.getNumberOfZeros();
			if (maxNoOfZeros < tmpNoOfZeros) {
				list.clear();
				list.add(bdr.clone());
				maxNoOfZeros = tmpNoOfZeros;
			} else if (maxNoOfZeros == tmpNoOfZeros) {
				list.add(bdr.clone());
			}
		}

		for (ByteDataRow bdr : list) {
			byte[] vars = bdr.getInVars();
			for (int i = 0; i < vars.length; i++) {
				NoOfOnesInColumn[i] = NoOfOnesInColumn[i]
						+ Byte.compare(vars[i], Byte.parseByte("0"));
				if (NoOfOnesInColumn[i] > maxNoOfOnes) {
					maxNoOfOnes = NoOfOnesInColumn[i];
					varId = i;
				}
			}
		}

		return varId;
	}

	public static int findSplitVariable(LinkedList<ByteDataRow> matrix, int varIdx) {
		LinkedList<ByteDataRow> list = new LinkedList<ByteDataRow>();
		int maxNoOfZeros = 0;
		int maxNoOfOnes = 0;
		int varId = -1;
		int[] NoOfOnesInColumn = new int[matrix.get(0).getInVars().length];

		// Wybierz kostkÍ z najwiÍkszπ liczbπ zer.
		for (ByteDataRow bdr : matrix) {
			int tmpNoOfZeros = bdr.getNumberOfZeros();
			if (maxNoOfZeros < tmpNoOfZeros) {
				list.clear();
				list.add(bdr.clone());
				maxNoOfZeros = tmpNoOfZeros;
			} else if (maxNoOfZeros == tmpNoOfZeros) {
				list.add(bdr.clone());
			}
		}

		for (ByteDataRow bdr : list) {
			byte[] vars = bdr.getInVars();
			for (int i = 0; i < vars.length; i++) {
				NoOfOnesInColumn[i] = NoOfOnesInColumn[i]
						+ Byte.compare(vars[i], Byte.parseByte("0"));
				if (NoOfOnesInColumn[i] > maxNoOfOnes) {
					maxNoOfOnes = NoOfOnesInColumn[i];
					varId = i;
				}
			}
		}

		return varId;
	}

There are two methods findSplitVariable. Second one takes extra parameter (varIdx) that is not used anywhere.

By Paul, 2018-02-17 14:47:37