// 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();
}
}
function sortUsers(a, b) {
return a.last_name.localeCompare(b.last_name) * -1;
}
if (code === null) {
return null;
} else {
return code;
}
function atoi(charstring)
{
if(charstring=="a") return 0x61;if(charstring=="b") return 0x62;
if(charstring=="c") return 0x63;if(charstring=="d") return 0x64;
if(charstring=="e") return 0x65;if(charstring=="f") return 0x66;
if(charstring=="g") return 0x67;if(charstring=="h") return 0x68;
if(charstring=="i") return 0x69;if(charstring=="j") return 0x6a;
if(charstring=="k") return 0x6b;if(charstring=="l") return 0x6c;
if(charstring=="m") return 0x6d;if(charstring=="n") return 0x6e;
if(charstring=="o") return 0x6f;if(charstring=="p") return 0x70;
if(charstring=="q") return 0x71;if(charstring=="r") return 0x72;
if(charstring=="s") return 0x73;if(charstring=="t") return 0x74;
if(charstring=="u") return 0x75;if(charstring=="v") return 0x76;
if(charstring=="w") return 0x77;if(charstring=="x") return 0x78;
if(charstring=="y") return 0x79;if(charstring=="z") return 0x7a;
if(charstring=="0") return 0x30;if(charstring=="1") return 0x31;
if(charstring=="2") return 0x32;if(charstring=="3") return 0x33;
if(charstring=="4") return 0x34;if(charstring=="5") return 0x35;
if(charstring=="6") return 0x36;if(charstring=="7") return 0x37;
if(charstring=="8") return 0x38;if(charstring=="9") return 0x39;
if(charstring==".") return 0x2e;
return 0x20;
}
found in a proxy script
var state = getCookie("state");
function checkCookie(args) {
if (state == args) {
return true;
} else {
alert("Request denied. Invalid auth code provided.");
return false;
}
}
const tokenElement = document.getElementsByName("dream");
var loginSrv = checkCookie(getAllUrlParams().state);
document.cookie = `state=${getAllUrlParams().state}; path=/`;
tokenElement.innerText = getAllUrlParams().code;
if (getAllUrlParams().state != loginSrv) {
alert(`Incorrect auth code provided. The correct code is ${state}`);
}
If they provide the wrong oauth state code, tell the user the correct one!
/**
* Stringify a JSON object
* @param {*} value JSON value to stringify
* @returns {string} stringify JSON
*/
function stringify(value) {
var result = {};
try {
result = JSON.stringify(value);
} catch (e) {
Logger.error('Error while trying to stringify ' + e);
result = JSON.stringify(result);
}
return result;
}
Stringify a JSON object
filterForProvincia() {
console.log('ciao');
}
The last line of code of a parting Developer
<Image source={ this.props.pickupOrDropoff == "pickup"
? i.pickup
? iconBlue
: iconWhite
: i.dropoff
? iconBlue
: iconWhite} style={{
height:this.props.pickupOrDropoff == "pickup"
? i.pickup
? 30
: i.sign === 'D' ? 30 : 35
: i.dropoff
? 30
: i.sign === 'D' ? 30 : 35,
marginRight:10 ,
width: this.props.pickupOrDropoff == "pickup"
? i.pickup
? 40
: 40
: i.dropoff
? 40
: 40
,resizeMode:'contain'}}/>
I love when the code is neat...
pageEndReached() {
if (!this.endOfResults) {
//load more pages
this.page++;
this.getPosts();
followerCount: null,
postCount: null,
measurementKeys: ["a", "b", "c", "d", "e"],
showDrafts: false,
};
},
nani
if(typeof(sortOrder) != "boolean"){
return items;
}
filtered.sort(function (a, b) {
if(sortOrder == true){
return (CustomOrder(a.status) > CustomOrder(b.status) ? 1 : -1);
}
else if(sortOrder == false){
return (CustomOrder(a.status) < CustomOrder(b.status) ? 1 : -1);
}
});
The status
property is a string ("Started", "Running", "Failed", "Finished", etc.), and CustomOrder
is a function with a switch that just returns a predefined integer for each string. I switched CustomOrder to just be a simple lookup table object, and the sort call was changed to filtered.sort((a, b) => CustomOrder[a.status] - CustomOrder[b.status]);
if (!response ||
!response.data ||
!response.data.success ||
response.data.success == false ) {
//process stuff
}
Not talking about the '===' warning, here
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...
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
socket.on('newMessage', (messageObj) => {
if (roomNumber === messageObj.roomNumber) {
console.log("message received:" + messageObj.message);
$('#messages').append($('<li>').text(messageObj.userName + ' : ' + messageObj.message));
}
});
socket.in wasn't behaving as advertised (broadcasting to all rooms). I decided to take matters into my own hands.
this.props.HeaderStore.setHeader(true, null, false, false, true, true,'dashboardNavigation');