in_array($this->market, ["ru"])
There is an old mysterious legend, which says that those conditions are lightening fast which are using in_array($source, ["target"]) instead of just "==". Is says always that probably you never do code refactoring, and keep all shit alive
if ($this->getTestSku()) {
...
} elseif ($this->getTestOffset() >= 0 && $this->getTestLimit() > 0) {
...
} else {
Mage::throwException(sprintf("Invalid parameters for test mode: sku %s or offset %s and limit %s", $this->getTestSku(), $this->getTestOffset(), $this->getTestLimit()));
}
if((strtotime(date("Y-m-d"))-strtotime(date("Y-m-d", filemtime($filename))))/(3600)<=$config->hourDiff) return true; else return false;
please notice the brackets around 3600
//JSONObject input;
String givenName = input.get("propName") != null ? (String)input.get("propName") : null;
WHAT DA FUCK ASSHOLES
if student_id:
assignments = Assignment.objects.filter(week__in=weeks)
unenrolled_students = Wave.objects.filter(week__in=weeks).values_list('unenrolled_students', flat=True)
# Construct responses based on assignment type
Assignment.build_assignments_for_weeks(responses, assignments, students, unenrolled_students)
max_num_assessments = Assessment.build_assessments_for_weeks(responses)
Comment.build_comments_for_weeks(responses, weeks, students, unenrolled_students)
elif wave_id:
assignments = Assignment.objects.filter(week__in=weeks)
unenrolled_students = Wave.objects.filter(week__in=weeks).values_list('unenrolled_students', flat=True)
# Construct responses based on assignment type
Assignment.build_assignments_for_weeks(responses, assignments, students, unenrolled_students)
max_num_assessments = Assessment.build_assessments_for_weeks(responses)
Comment.build_comments_for_weeks(responses, weeks, students, unenrolled_students)
else:
# can't happen
pass
return isDisabled == false ? false : true;
string AllPDF = "";
int CountPDF = 0;
AllPDF = txtInput.Text;
string[] AllPDF2 = AllPDF.Split(';');
List<string> PDF = new List<string>();
PDF.AddRange(AllPDF2);
while (PDF.Count != CountPDF)
{
File.Delete(AllPDF2[0 + CountPDF] + ".pdf");
CountPDF++;
}
I believe, there are so many easier ways to do that
private void EnableGPSAutoMatically() {
GoogleApiClient googleApiClient = null;
if (googleApiClient == null) {
oogleApiClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API).addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).build();
/* about 50 lines of code were here ...
* all depends on this if statement ... !
* Actually the whole method depends on this if statement ! */
}
}
});
}
}
what if that mysterious power change it to be not null !! It gonna be a holly object and You should not "new" it anymore ?! damn ... :)))
set_locations(locations){
return new Promise((resolve, reject) => {
this.locations = locations;
resolve();
});
}
public bool IsTrue(bool value) {
return value.ToString().length() == 4;
}
request.get_something = (something_id) => {
return new Promise((resolve, reject) => {
database.find_all('something', { where: {something_id: something_id, is_deleted:0} }).then(function(res){
let result = {};
res = JSON.stringify(res);
res = JSON.parse(res);
res.forEach(function(element){
if(typeof element.is_deleted != "undefined"){
delete element.is_deleted;
}
let key = 'something_' + element.id;
result[key] = element;
});
resolve(result);
}, reject);
});
}
I LOVE MY JOB!
function edit_vehality: locality,
google_place_id: '1'
};
let opts = { 'method': 'put', 'route': '/border/' + border_id, 'status': status, 'account_access_token': saved_values.superadmin.account_access_token, 'params': params };
request(opts)
.then(function(res) {
resolve(res.result);
}).catch(reject);
})
}
function uploadimg(file) {
var ext = file.value.split('.').pop().toLowerCase();
var size = document.getElementById("uploadpic").files.item(0).size;
if (size > 3145728) {
$.messager.alert({
title: "Error",
msg: " image to large",
icon: "error"
});
return true;
}
return false;
}
var reader = new FileReader();
$("#uploadpic").change(function() {
var pdfcheck = this;
var ext = pdfcheck.value.split('.').pop().toLowerCase();
if (!($.inArray(ext, ['pdf']) == -1)) {
console.log('upload pdf start');
if (uploadPdf(pdfcheck)) {
$("#preview_img").attr("src", "");
$("#preview_img2").attr("src", "");
$("#uploadpic").prop("file", "");
$("#uploadpic").val("");
}
} else {
if (uploadimg(pdfcheck)) {//dude, I think the image you upload to check is your dick, only small enough you would rather keep going producing shitcode.
return false;
}
var upload_file = $("#uploadpic")[0].files[0];
if (upload_file != null) {
var chimgarr = ["image/png", "image/PNG", "image/jpg", "image/JPG", "image/jpeg", "image/JPEG", "image/gif", "image/GIF", "image/bmp", "image/BMP"];
if (chimgarr.indexOf(upload_file.type) != "-1") {
reader.readAsDataURL(upload_file);
reader.onload = function(e) {
$("#preview_img").attr("src", e.target.result);
$("#preview_img2").attr("src", e.target.result);
$("#pdf-contents").hide();
$("#pdf_name").val("");
$("#btn_pdf_view").hide();
$("#pic_name").val("");
}
} else {
$.messager.alert("Image format does not match");
$("#preview_img").attr("src", "");
$("#preview_img2").attr("src", "");
$("#uploadpic").prop("file", "");
$("#uploadpic").val("");
}
} else {
$("#preview_img").attr("src", "");
$("#preview_img2").attr("src", "");
}
}
});
The moment an important image ready to be uploaded It's really important that should be checked again and again.
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.