@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
set_locations(locations){
    return new Promise((resolve, reject) => {
        this.locations = locations;
        resolve();
    });
}
By Anonymous, 2018-04-04 14:44:45
let length str =
    let len = String.length str in
    
    let rec length_helper str curr = 
    if str = "" then 0 else 1 + length_helper (String.sub str 1 (len - curr - 1)) (curr + 1)
    
    in length_helper str 0;;

We use this code internally at Google. JFC.

By Mark, 2018-04-21 21:51:57
div.body:first-child:nth-last-child(n+12),
div.body:first-child:nth-last-child(n+12) ~ div.body {
  padding: 3px 5px 2px !important;

  div.rect {
    top: 6px !important;
  }

  div.legend-action {
    top: 3px !important;
  }
}
By Anonymous, 2018-06-04 10:46:38
import cv2
import numpy as np

cap = cv2.VideoCapture(0)

while (1):

    _, frame = cap.read()

    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

    lower_green = np.array([40, 50, 50])
    upper_green = np.array([80, 102, 200])

    # Threshold the HSV image to get only green colors
    mask = cv2.inRange(hsv, lower_green, upper_green)

    total_pixels = mask.shape[0] * mask.shape[1]
    print "Number of pixels: %", total_pixels

    pixel_counter = 0
    x_counter = 0
    y_counter = 0
    for y in xrange(640):
        for x in xrange(480):
            pixel = mask[x, y]
            if pixel == 255:
                pixel_counter += 1
                x_counter += x
                y_counter += y
    x_center = x_counter / pixel_counter
    y_center = y_counter / pixel_counter
    print x_center, y_center

    cv2.line(frame, (x_center+15, y_center), (x_center+2, y_center), (235, 218, 100), 1)
    cv2.line(frame, (x_center-15, y_center), (x_center-2, y_center), (235, 218, 100), 1)
    cv2.line(frame, (x_center, y_center+15), (x_center, y_center+2), (235, 218, 100), 1)
    cv2.line(frame, (x_center, y_center-15), (x_center, y_center-2), (235, 218, 100), 1)

    cv2.circle(frame, (x_center, y_center), 4, (235, 218, 100), 2)

    cv2.imshow('frame', frame)

    k = cv2.waitKey(5) & 0xFF
    if k == 27:
        break

cv2.destroyAllWindows()

track the green color

By Vik.victory, 2017-06-23 19:10:32
let showDots = typeof project.showDots === 'boolean' ? project.showDots : false;

if (showDots) {
    // Somecode ...
}

Why, just why??

By Anonymous, 2017-08-08 11:41:49
	// Check if marked for deletion and run finalizers
	if k8sutil.IsMarkedForDeletion(instance.ObjectMeta) {
		return r.checkFinalizers(ctx, log, instance)
	}
By Anonymous, 2019-12-31 15:25:32
for (const order of orders) {
    for (const resultItem of results) {
        if (resultItem.machine != "TRANSFER") {
            shiftsLoop: for (const shift of resultItem.shifts) {
                if (shift.products) {
                    for (const product of shift.products) {
                        if (product.product == order.product) {
                            for (const routing of routings) {
                                if (routing.output == order.product) {
                                    const machinePlant = findMachinePlant(resultItem.machine, machines)
                                    if (routing.type == "ODP") {
                                        if (machinePlant == order.plant) {
                                            const msg = createMessage(order, shift, resultItem.machine, CHOR)
                                            requests.push(buildRequest(msg))
                                        } else {
                                            //CHEE CHIE CHEI
                                        }
                                        break shiftsLoop
                                    } else if (routing.type == "OCL" || routing.type == "RCL") {
                                        const msg = createMessage(order, shift, resultItem.machine, CHCL)
                                        requests.push(buildRequest(msg))
                                        //CHCL
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
By sgaloppo, 2021-08-28 20:28:59
latest_tag = "0.0.0"
    for tag in tags:
        if tag.name.startswith( 'v' ):
            if tag.name.replace('v','').replace('.','') > latest_tag.replace('.',''):
                latest_tag = tag.name.replace('v','')
By Anonymous, 2021-04-30 08:18:17
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
function uberURLREPLACER(dtTEXTVALUE,boolVALUE){
    
// If statement? what's that?? 
// Naming conventions? Of course not! 
// true/false keywords? I never heard it.
boolVALUE != !1 && dtTEXTVALUE.indexOf('http://') != -1 && (dtTEXTVALUE = dtTEXTVALUE.replace('http://','')) && dtTEXTVALUE.indexOf('.aspx') == -1 && (dtTEXTVALUE += '.aspx');

return dtTEXTVALUE;

}

Here's the weirdest way to create if statement with terrible naming conventions. Its based on real events and production code.

By I've no idea, 2019-02-16 13:16:07
    @Override
    public String toString() {
        List<Integer> accountLevels = new ArrayList<>();
        List<String> accountIds = new ArrayList<>();

        for (SelectedHierarchyLevel selectedHierarchyLevel : selectedHierarchyLevels) {
            accountLevels.add(selectedHierarchyLevel.getLevel());
            accountIds.add(selectedHierarchyLevel.getAccountRowId());
        }

        vetoAreValidIds(accountIds);
        StringBuilder converterString = new StringBuilder();

        convert(accountLevels, converterString);
        converterString.append("$");
        convert(accountIds, converterString);

        return converterString.toString();
    }

Just because you can, doesn’t mean you should.

By Anonymous, 2019-04-12 10:55:17
boolean isUserAuthorized = user.isSuperAdmin();
if (!isUserAuthorized) {
    isUserAuthorized = isUserAdminOfEntity1();
}
if (!isUserAuthorized) {
    isUserAuthorized = isUserAdminOfEntity2();
}
if (!isUserAuthorized) {
    throw new AccessDeniedException("Authenticated user is not admin ");
}
By tralaladidou, 2019-05-07 16:37:32
// var array = retrieveArrayValue();
var filteredArray = array.filter(function (element, index, array) {
    return array.indexOf(element) == index;
});
// processArray(filteredArray);
By Anonymous, 2020-08-20 11:24:51
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