@define
class DedupConfig:
    columns_to_dedup_by: Optional[List]
    time_range_in_minutes: Optional[int]
    timestamp_column_name: Optional[str]
    leave_deduped_samples_in_time_range: Optional[int] = field(default=1)

    def __attrs_post_init__(self):
        if not self.timestamp_column_name:
            raise ValueError(f"timestamp_column_name parameter must be provided")
        if not self.columns_to_dedup_by:
            raise ValueError(f"columns_to_dedup_by parameter must be provided")
        if not self.time_range_in_minutes:
            raise ValueError(f"time_range_in_minutes parameter must be provided")
By Anonymous, 2022-06-12 22:09:32
<table class="table table-sm o_main_table" style="width='100%'">
    <!-- ... thanks ...-->    
</table>

Found that on a customer's project, wonder if my employee knows about inline css

By Anonymous, 2022-06-10 11:39:58
const rola = (usr: IUserData) => {
    let student = "student"
    let edukator = "edukator"
    let dziekanat = "dziekanat"
    let admin = "admin"
    if(usr.type===1){
        return student
    }
    else if(usr.type===2){
        return edukator
    }
    else if(usr.type===3){
        return dziekanat
    }
    else if(usr.type===4){
        return admin
    }
}
By Anonymous, 2022-06-06 14:02:08
public static Integer find(List<String> list, String name, int i) {
    if(list.get(i).equals(name)) {
        return i;
    }
    else return find(list, name, i+1)
}
By s0m31, 2022-06-03 15:54:11
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
<?php

// This code supposed to find adjacent items of a specific one
// $list is an array of ids
// $itemToSearch is an id that might be in the $list

foreach ($list as $item) {
    next($list);
    if ($item == $itemToSearch) {
        break;
    }
    $previousItem = $item;
}
$nextItem = current($list);

The $list variable is a list of ids, e.g [1, 2, 3, 4, 5] The $itemToSearch is an id that might be in $list

By baueri, 2022-05-31 17:30:21

//https://gist.github.com/nim4n136/7fa38467181130f5a2270c39d495101e

function decrypt($msg_encrypted_bundle, $password){
	$password = sha1($password);

	$components = explode( ':', $msg_encrypted_bundle );
	$iv            = $components[0];
	$salt          = hash('sha256', $password.$components[1]);
	$encrypted_msg = $components[2];

	$decrypted_msg = openssl_decrypt(
	  $encrypted_msg, 'aes-256-cbc', $salt, null, $iv
	);

	if ( $decrypted_msg === false )
		return false;
	return $decrypted_msg;
}
By Anonymous, 2022-05-30 18:28:02
          //////////////////////////////////////////
          // Add ROI coordinates into Environment
          //////////////////////////////////////////
          AddROIcoordinatesIntoEnvironment();

It really helped me understand the code.

By Anonymous, 2022-05-30 00:49:45
 # 5-level loop, forgive me...
        for xi, xs in enumerate(X):
            for yi, ys in enumerate(Y):
                for zi, zs in enumerate(Z):
                    lx, ly, lz = len(xs), len(ys), len(zs)
                    # construct points
                    xx, yy, zz = custom_meshgrid(xs, ys, zs)
                    world_xyzs = (
                        torch.cat(
                            [xx.reshape(-1, 1), yy.reshape(-1, 1), zz.reshape(-1, 1)],
                            dim=-1,
                        )
                        .unsqueeze(0)
                        .to(count.device)
                    )  # [1, N, 3]

                    # cascading
                    for cas in range(self.cascade):
                        bound = min(2**cas, self.bound)
                        half_grid_size = bound / resolution
                        # scale to current cascade's resolution
                        cas_world_xyzs = world_xyzs * (bound - half_grid_size)

                        # split batch to avoid OOM
                        head = 0
                        while head < B:
                            tail = min(head + S, B)

                            # world2cam transform (poses is c2w, so we need to transpose it. Another transpose is needed for batched matmul, so the final form is without transpose.)
                            cam_xyzs = cas_world_xyzs - poses[
                                head:tail, :3, 3
                            ].unsqueeze(1)
                            cam_xyzs = cam_xyzs @ poses[head:tail, :3, :3]  # [S, N, 3]

                            # query if point is covered by any camera
                            mask_z = cam_xyzs[:, :, 2] > 0  # [S, N]
                            mask_x = (
                                torch.abs(cam_xyzs[:, :, 0])
                                < cx / fx * cam_xyzs[:, :, 2] + half_grid_size * 2
                            )
                            mask_y = (
                                torch.abs(cam_xyzs[:, :, 1])
                                < cy / fy * cam_xyzs[:, :, 2] + half_grid_size * 2
                            )
                            mask = (
                                (mask_z & mask_x & mask_y).sum(0).reshape(lx, ly, lz)
                            )  # [N] --> [lx, ly, lz]

                            # update count
                            count[
                                cas,
                                xi * S : xi * S + lx,
                                yi * S : yi * S + ly,
                                zi * S : zi * S + lz,
                            ] += mask
                            head += S
By Anonymous, 2022-05-13 14:03:28
fn second_word(s: &String) -> &str {
    let bytes = s.as_bytes();
    let mut k = 0;
    let mut n =0;
    for (i, &item) in bytes.iter().enumerate() {
        if item == b' ' {
            k = k + 1;
            if k == 1 {
                n = i;
            }
            else if k == 2 {
                return &s[1+n..i];
            }

        }
    }

    &s[..]
}

the code looks like shit

By big_shaq123, 2022-05-10 15:27:32
function deleteConfirm() {
    var result = confirm("Are you sure to delete this customer ?");
    if (result) {
        return true;
    } else {
        return false;
    }
}
By SuperNova, 2022-05-07 08:15:19
String zeroPad(int number) {
  return number < 10 ? "0" + number : String.valueOf(number);
}

You could just have done String.format("%02d", number);

By Anonymous, 2022-04-30 10:50:20
namespace network
{
    class ip
    {
        uint _IP;
        public ushort this[int i]
        {
            get
            {
                switch(i)
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                        return (ushort)(_IP>>(i*8));
                    default:
                    throw new IndexOutOfRangeException();
                }
            }
            set
            {
                switch(i)
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                        _IP=(((uint)value)<<i*8);
                        break;
                    default:
                    throw new IndexOutOfRangeException();
                }
            }
        }
    }
}

I have no idea what this does

By Anonymous, 2022-04-26 16:20:05
createPhoneNumber([0,1,2,3,4,5,6,7,8,9]);

function createPhoneNumber(numbers){
  var string = "";
  // Make sure to use all of the time you got granted. Never waste time which is entitled to you!!!!
  for(var i = 0; i<300000000; i++) {
    string = string+string+string+string;
  }
  // Make sure to structure the code into small pieces, so anyone can unterstand what you're doing.
  // Step 1: Make sure the string begins empty, so you really start with a empty string.
  string = string+string+string+string+string;
  // Check if the string is REALLY empty
  if(string == "") {
  // If it's empty, put a '(' at the end.
  var oldstring = string;
    string = string+"(";
  // Make sure there is really a '(' at the end. If not, repeat!
  if(string == oldstring+"(") {
    // If everything is fine, add the first number.
    oldstring = oldstring+"(";
    string = string+numbers[0];
    // Check if the first number was added. If not, repeat!
    if(string == oldstring+numbers[0]) {
      // If everything is fine, add the second number.
      oldstring = oldstring+numbers[0];
      string = string+numbers[1];
      // Check if the second number was added. If not, repeat!
      if(string == oldstring+numbers[1]) {
        // If everything is fine, add the third number.
        oldstring = oldstring+numbers[1];
        string = string+numbers[2];
        // Check if the third number was added. If not, repeat!
        if(string == oldstring+numbers[2]) {
          // If everything is fine, add the ')'.
          oldstring=oldstring+numbers[2];
          string = string+")";
          // Check if the ')' was added. If not, repeat!
          if(string == oldstring+")") {
            // If everything is fine, add the ' '.
            oldstring=oldstring+")";
            string = string+" ";
            // Check if the ' ' was added. If not, repeat!
            if(string == oldstring+" ") {
              // If everything is fine, add the fourth number.
              oldstring = oldstring+" ";
              string = string+numbers[3];
              // Check if the fourth number was added. If not, repeat!
              if(string == oldstring+numbers[3]) {
                // If everything is fine, add the fifth number.
                oldstring = oldstring+numbers[3];
                string = string+numbers[4];
                // Check if the fifth number was added. If not, repeat!
                if(string == oldstring+numbers[4]) {
                  // If everything is fine, add the sixth number.
                  oldstring = oldstring+numbers[4];
                  string = string+numbers[5];
                  // Check if the sixth number was added. If not, repeat!
                  if(string == oldstring+numbers[5]) {
                    // If everything is fine, add the "-".
                    oldstring = oldstring+numbers[5];
                    string = string+"-";
                    // Check if the "-" was added. If not, repeat!
                    if(string == oldstring+"-") {
                      // If everything is fine, add the seventh number.
                      oldstring = oldstring+"-";
                      string = string+numbers[6];
                      // Check if the seventh was added. If not, repeat!
                      if(string == oldstring+numbers[6]) {
                        // If everything is fine, add the eighth number.
                        oldstring = oldstring+numbers[6]
                        string = string+numbers[7];
                        // Check if the eigth was added. If not, repeat!
                        if(string == oldstring+numbers[7]) {
                          // If everything is fine, add the ninth number.
                          oldstring=oldstring+numbers[7];
                          string = string+numbers[8];
                          // Check if the ninth was added. If not, repeat!
                          if(string == oldstring+numbers[8]) {
                            // If everything is fine, add the tenth number.
                            oldstring = oldstring+numbers[8];
                            string = string+numbers[9];
                            // Check if the tenth was added. If not, repeat!
                            if(string == oldstring+numbers[9]) {
                              // If everything is fine, return the string!
                              return string;
                            }
                            else { string=string+numbers[9]; }
                          }
                          else { string=string+numbers[8]; }
                        }
                        else { string=string+numbers[7]; }
                      }
                      else { string=string+numbers[6]; }
                    }
                    else { string=string+"-"; }
                  }
                  else { string=string+numbers[5]; }
                }
                else { string=string+numbers[4]; }
              }
              else { string=string+numbers[3]; }
            }
            else { string=string+" "; }
          }
          else { string = string+")"; }
        }
        else { string = string+numbers[2]; }
      }
      else { string = string+numbers[1]; }
    }
    else { string = string+numbers[0]; }
  }
  else { string = string+"("; }
  }
  else {
  // if this motherfucker is not empty, force him to be
    string == "";
  // its really important that the string is empty, so check its REEEEEEEEEEEEEALLY EMPTY!!!!!!!!!!!
    for(var i = 0; i<700000000; i++) {
      string = string+string+string+string;
    }
  }
}

Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number.

Example createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890"

By user636355, 2022-04-18 08:58:47
 const configs = {
    employeeObject: {
      // tab 0
      firstName: "",
      middleName: "",
      nickname: "",
      lastName: "",
      gender: "",
      race: "",
      title: "",
      dob: "",
      employeeIDNo: "",
      // tab 1
      userName: "",
      permissionRole: 0,
      employeeNo: "",
      phoneExt: "",
      startDate: "",
      company: "",
      division: "",
      jobDescription: "",
      businessUnit: "",
      regionId: "",
      participantStatus: "",
      costCentre: "",
      personType: "",
      comments: "",
      // tab 2
      phone1: "",
      phone2: "",
      phone3: "",
      address1: "",
      address2: "",
      address3: "",
      address4: "",
      postalCode: "",
      email: "",
    },

Why add another object with a title when you can just add a comment saying... well... nothing really...

By Mr Verster, 2022-04-08 14:19:12