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

// enum - full enumeration of knapsack solutions
// (C) Joshua Knowles

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

FILE *fp;  // file pointer for reading the input files
int Capacity;     // capacity of the knapsack (total weight that can be stored)
int Nitems;    // number of items available
int *item_weights;  // vector of item weights
int *item_values;  // vector of item profits or values
int *temp_indexes;  // list of temporary item indexes for sorting items by value/weight
int QUIET=0; // this can be set to 1 to suppress output

extern void read_knapsack_instance(char *filename);
extern void print_instance();
extern void sort_by_ratio();
extern int check_evaluate_and_print_sol(int *sol,  int *total_value, int *total_weight);
void enumerate();
int next_binary(int *str, int Nitems);

int main(int argc, char *argv[])
{
  read_knapsack_instance(argv[1]);
  print_instance();
  enumerate();
  return(0);
}

void enumerate()
{
  // Do an exhaustive search (aka enumeration) of all possible ways to pack
  // the knapsack.
  // This is achieved by creating every binary solution vector of length Nitems.
  // For each solution vector, its value and weight is calculated.


  int i;  // item index
  int solution[Nitems+1];   // (binary) solution vector representing items packed
  int best_solution[Nitems+1];  // (binary) solution vector for best solution found
  int best_value; // total value packed in the best solution
  double j=0;
  int total_value, total_weight; // total value and total weight of current knapsack solution
  int infeasible;  // 0 means feasible; -1 means infeasible (violates the capacity constraint)

  // set the knapsack initially empty
  for(i=1;i<=Nitems;i++)
    {
      solution[i]=0;
    }
  QUIET=1;
  best_value=0;

 while(!(next_binary(&solution[1], Nitems)))
    {

      /* ADD CODE IN HERE TO KEEP TRACK OF FRACTION OF ENUMERATION DONE */

          // calculates the value and weight and feasibility:
      infeasible=check_evaluate_and_print_sol(solution, &total_value, &total_weight);  
      /* ADD CODE IN HERE TO KEEP TRACK OF BEST SOLUTION FOUND*/

    }
 /* ADD CODE TO PRINT OUT BEST SOLUTION */

}


int next_binary(int *str, int Nitems)
{
  // Called with a binary string of length Nitems, this 
  // function adds "1" to the string, e.g. 0001 would turn to 0010.
  // If the string overflows, then the function returns 1, else it returns 0.
  int i=Nitems-1;
  while(i>=0)
    {
      if(str[i]==1)
	{
	  str[i]=0;
	  i--;
	}
      else
	{
	  str[i]=1;
	  break;
	}
    }
  if(i==-1)
    {
      return(1);
    }
  else
    {
      return(0);
    }
}

A genuine UoM lab.

By Joshua Knowles, 2018-02-23 10:58:03
#define private public
#define protected public
#define class struct

#include "your_private_parts.hpp"
// ...

#undef class
#undef protected
#undef private

// ...

Fails miserably if template <class>, template <template <class> class> or their variations are found anywhere inside your header. :(

By 2 + 2 = 3.99999999999999999999999999999999999, 2021-11-08 07:59:05
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='';	
}
By javascriptowiec, 2020-06-30 21:29:57
        public static bool ValidateEmailAddress(string emailAddress)
        {
            string pattern = "^((?>[a-zA-Z\\d!#$%&'*+\\-/=?^_`{|}~]+\x20*|\"((?=[\x01-\x7f])[^\"\\]|\\[\x01-\x7f])*\"\x20*)*(?<angle><))?((?!\\.)(?>\\.?[a-zA-Z\\d!#$%&'*+\\-/=?^_`{|}~]+)+|\"((?=[\x01-\x7f])[^\"\\]|\\[\x01-\x7f])*\")@(((?!-)[a-zA-Z\\d\\-]+(?<!-)\\.)+[a-zA-Z]{2,}|\\[(((?(?<!\\[)\\.)(25[0-5]|2[0-4]\\d|[01]?\\d?\\d)){4}|[a-zA-Z\\d\\-]*[a-zA-Z\\d]:((?=[\x01-\x7f])[^\\\\[\\]]|\\[\x01-\x7f])+)\\])(?(angle)>)$";

            if (!String.IsNullOrEmpty(emailAddress) && !(Regex.Match(emailAddress.Trim(), pattern, RegexOptions.IgnoreCase)).Success)
            {
                return false;
            }
            return true;
        }
By Anonymous, 2019-07-17 23:47:20
#include <stdio.h>
#include<stdlib.h>
#include<time.h>

void randy(int array[] ){
int i = 0  , d = 0;
		for(i = 1 ; i <= 23 ; i++){
			
			array[i] =  1 + (rand() % 365 ); 
		}
	}

int compare (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}



int find (int arr[]){
 int d = 0;
 	
 	for(d = 1  ;d <=23 ; d++ ){
 		
		 if(arr[d] == 	 arr[d + 1]){
		 	return 1;
		 }
	 }
	
	return 0;
}

int main(void){
	 double count_birthday = 0;
	int  people[24];
  
	srand(time(NULL));
	
	int c = 0 ;
	long double ip = 0;
	
	
	
	while(ip++ <= 1000000 ){
		

		randy(people);
		qsort (people, 25, sizeof(int), compare);
		if(find (people) == 1 ){
			count_birthday++;
		}

	}

printf("%.2lf", 	count_birthday  / 10000  );
return 0;
}
By lazy_8, 2020-03-04 13:14:05
if (cookiesBannerHeight !== 0 && isMobile) {
      style = {
        top: cookiesBannerHeight === 0 ? 0 : cookiesBannerHeight
      }
}
By Kubus, 2018-02-28 11:00:11
StartCoroutine(Patrol());

public IEnumerator Patrol() {
    while(true) {
        dt.Walk();
        yield return new WaitForSeconds(reactionTime);
    }
}
By Mario, 2021-11-19 07:18:22
        if (!rtrId.isPresent()) {
            ...
        } else if (identityId.isPresent() && rtrId.isPresent()) {
            ...
        }
        

A treasured knife protects

By Dunia, 2018-09-18 10:34:19
#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )";

export KUBECONFIG="${DIR}/my_secret_stuff/kube.conf";

Example on how to get location of the script right

By Piotr, 2020-05-11 12:45:57
double zuida(std::vector<double> vec) {
	std::vector<double> temp;
	for(int i = 0; i < vec.size(); i++)
		temp.push_back(vec[i]);
notend:
	if(temp.size() > 0) {
		if(temp.size() < 2) {
			double tmp = *(&temp[0]);
			return tmp;
		}
		else if(temp.size() >= 2) {
			double mini = temp[0];
			int ind = 0;
			for(int i = 0; i < temp.size(); i++)
				if(temp[i] < mini) {
					mini = temp[i];
					ind = i;
				}
			temp.erase(temp.begin() + ind);
			goto notend;
		}
	}
}

The beauty is that every case is the best (also worst) case!

By Anonymous, 2019-10-12 10:42:23
let verificaAdmin_Role = (req, res, next) => {

    let usuario = req.usuario;

    if (usuario.role === 'ADMIN_ROLE') {
        next();
    } else {
        return res.status(409).json({
            ok: false,
            err: {
                message: 'El usuario no es administrador.'
            }
        })
    }

};

By rootweiller, 2020-06-18 18:30:41
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

By L., 2021-05-17 11:20:12
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

By Anonymous, 2020-11-04 18:28:11
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