Handlebars.registerHelper("compare", function(a, operator, b) {
var result = false;
try {
switch (operator) {
case "==":
// eslint-disable-next-line eqeqeq
result = a == b;
break;
case "===":
result = a === b;
break;
case "!=":
// eslint-disable-next-line eqeqeq
result = a != b;
break;
case "!==":
result = a !== b;
break;
case "<":
result = a < b;
break;
case ">":
result = a > b;
break;
case "<=":
result = a <= b;
break;
case ">=":
result = a >= b;
break;
case "typeof":
// eslint-disable-next-line valid-typeof
result = typeof a === b;
break;
default: {
throw new Error(
"helper {{compare}}: invalid operator: ' + ".concat(operator, " + '")
);
}
}
} catch (err) {
console.error("\n********** ".concat(err, "."));
}
return result;
});
try {
$order->addItem($item);
} catch (Exception $ex) {
throw $ex;
}
@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.
public function getProfilePicture(Company $company, $id, $url = null) {
// @TODO: Figure out how to do this.
return null;
}
func runAnsible(c *cli.Context) {
runAnsibleCmd1(c.String("command"), c.StringSlice("var-file"), c.StringSlice("var"))
}
func runAnsibleCmd1(cmd string, varfiles []string, varstrs []string) {
runAnsibleCmd2(cmd, util.ToVars(varfiles, varstrs))
}
func runAnsibleCmd2(cmd string, vars map[string]interface{}) {
err := exec.SyscallExecute(cmd, vars)
log.Error("Error running ansible command.", "err", err.Error())
}
$('#userCheck').not(this).prop('checked', false);
function formatUpToANumberOfZeroesAfterFloatingPoint(number, numberOfZeroes, floatingPointSymbol) {
numberOfZeroes = (numberOfZeroes === undefined || numberOfZeroes < 0) ? 2 : numberOfZeroes;
floatingPointSymbol = floatingPointSymbol === undefined ? '.' : floatingPointSymbol;
let numberSplitByFloatingPoint = number.toString().split(floatingPointSymbol);
if (numberSplitByFloatingPoint.length !== 2)
return `${number}${floatingPointSymbol}${'0'.repeat(+numberOfZeroes)}`;
let numberAfterFloatingPoint = numberSplitByFloatingPoint[1].toString();
let formattedNumber = `${numberSplitByFloatingPoint[0]}`;
let numberAfterFloatingPointLength = numberAfterFloatingPoint.toString().length;
if (+numberOfZeroes > +numberAfterFloatingPointLength)
return `${formattedNumber}${floatingPointSymbol}${numberAfterFloatingPoint}${'0'.repeat(+numberOfZeroes - numberAfterFloatingPointLength)}`;
let countOfNumbersAfterFloatingPoint = numberAfterFloatingPointLength;
for (var i = numberAfterFloatingPointLength - 1; i >= 0; i--) {
if (+(numberAfterFloatingPoint[i]) !== 0 || +countOfNumbersAfterFloatingPoint === +numberOfZeroes) {
formattedNumber += `${floatingPointSymbol}${numberAfterFloatingPoint.substring(0, countOfNumbersAfterFloatingPoint)}`;
break;
}
countOfNumbersAfterFloatingPoint--;
}
return formattedNumber;
}
Well, a junior dev here. A cute female QA came to me with a request - "the field for the price already has precision up to 4 decimal places, but we don't like the 4 ugly zeroes, so if the number ends in zeroes, let it have only 2" - she said in the most innocent-like tone ever known to mankind. How easy I mumbled and accepted the task. As she was leaving she added - "oo almost forgot, we also would like it if all the data fields for the price that are shown in the tables also are formatted that way". As I was watching her better side, while she was getting reunited with her QA tribe, I got shivers down the spine. I had a bad feeling about that one, but I wasn't sure why yet. Suddenly as I was getting up to get a cup of coffe, it dawned on me - "this poor excuse for a project is using jqGrid for displaying the data". To wrap things up - I got a quadruple espresso with a shot of Jacky, developers best friend in a time of need, and came up with this piece of art. Enjoy :)
boolean isUserAuthorized = user.isSuperAdmin();
if (!isUserAuthorized) {
isUserAuthorized = isUserAdminOfEntity1();
}
if (!isUserAuthorized) {
isUserAuthorized = isUserAdminOfEntity2();
}
if (!isUserAuthorized) {
throw new AccessDeniedException("Authenticated user is not admin ");
}
"check cassandra config" in {
val config: Configuration = pureconfig.loadConfigOrThrow[Configuration]
config.cassandra.hosts shouldBe List("192.168.26.207")
config.cassandra.keyspace shouldBe "releases"
}
Why not to check works cassandra or not? What is the difference between this and hardcoding data right in source?
function renderGroupSelectedSuccessors() {
var index = 0;
if (tempSuccessorsGroupsList != null && tempSuccessorsGroupsList.length > 0) {
var groups = tempSuccessorsGroupsList.splice(0, PageSettings.lazyRenderItemsPerPage);
var groupSuccessors = '';
for (var i = 0; i < groups.length; i++) {
if (index % 10 == 0) {
groupSuccessors += '<div style="float: left;"><ul>';
}
groupSuccessors += '<li><a data-groupid="'+groups[i].GroupID+'">' + groups[i].GroupName + '</a></li>';
index++;
if (index % 10 == 0 || i == groups.length - 1) {
groupSuccessors += '</ul></div>';
}
}
$('#divGroupSuccessorsList').append(groupSuccessors);
SetCheckBoxState();
setTimeout(renderGroupSelectedSuccessors, 50);
}
}
Where does the data come from? Where does it go? Why isn't this an endless recursive loop? Why has this worked for three years?
if (CATEGORY_NORMAL.equalsIgnoreCase(categorie)) {
return assignGroupStartWithPrefix(assignmentGroups);
} else if (CATEGORY_EXTERNAL.equalsIgnoreCase(categorie)) {
return assignGroupStartWithPrefix(assignmentGroups);
}
def get_schema(self, schema: object) -> object:
"""Get the Schema class
"""
if isinstance(schema, str):
Schema = getattr(self.request["operation"], schema, None)
else:
Schema = schema
if Schema is None:
Schema = getattr(self, schema, None)
if Schema is None:
raise web.HTTPNotImplemented
return Schema
I don't even know what to say
var move=0;
var kier=0;
var pic=0;
var rol=0;
var rol2=171;
var rol3=343;
var rol4=514;
var rol2_cel=171;
var rol3_cel=343;
var rol4_cel=514;
function onpic(p) {
pic=p;
}
function offpic(p) {
if( pic==p ) pic=0;
}
function next() { if(move<40) move = 40; kier=0; }
function prev() { if(move<40) move = 60; kier=1; }
function set() {
document.getElementById('ba1').style.left=0;
document.getElementById('ba2').style.left=rol2;
document.getElementById('ba3').style.left=rol3;
document.getElementById('ba4').style.left=rol4;
}
function SetOpacity(object,opacityPct)
{
// IE.
object.style.filter = 'alpha(opacity=' + opacityPct + ')';
// Old mozilla and firefox
object.style.MozOpacity = opacityPct/100;
// Everything else.
object.style.opacity = opacityPct/100;
}
var randtim=new Array(110,103,130,125,108,118,112,122,101,100);
var showtimer=0;
var showpic=1;
function Animuj() {
if( pic==0 ) {
rol2_cel=171;
rol3_cel=343;
rol4_cel=514;
} else if( pic==1 ) {
rol2_cel=342;
rol3_cel=457;
rol4_cel=571;
} else if( pic==2 ) {
rol2_cel=115;
rol3_cel=457;
rol4_cel=571;
} else if( pic==3 ) {
rol2_cel=114;
rol3_cel=229;
rol4_cel=571;
} else if( pic==4 ) {
rol2_cel=114;
rol3_cel=228;
rol4_cel=344;
}
var a = (rol2-rol2_cel)/10; if(( a< -0.1 )&&( a> -1 )) a = -1; if(( a>0.1 )&&( a<1 )) a = 1;
if( rol2!=rol2_cel ) rol2-= a;
var a = (rol3-rol3_cel)/10; if(( a< -0.1 )&&( a> -1 )) a = -1; if(( a>0.1 )&&( a<1 )) a = 1;
if( rol3!=rol3_cel ) rol3-= a;
var a = (rol4-rol4_cel)/10; if(( a< -0.1 )&&( a> -1 )) a = -1; if(( a>0.1 )&&( a<1 )) a = 1;
if( rol4!=rol4_cel ) rol4-= a;
set();
document.getElementById('ba2').style.left=rol2;
showtimer+=1;
if(showtimer>100) {
for( st=0; st<9; ++st ) {
if(showtimer==randtim[st]) { SetOpacity(document.getElementById("ps"+st), 0); document.getElementById("ps"+st).style.backgroundImage="url('cs/log"+showpic+".jpg')"; }
if(showtimer==(randtim[st]+1)) SetOpacity(document.getElementById("ps"+st),20);
if(showtimer==(randtim[st]+2)) SetOpacity(document.getElementById("ps"+st),40);
if(showtimer==(randtim[st]+3)) SetOpacity(document.getElementById("ps"+st),60);
if(showtimer==(randtim[st]+4)) SetOpacity(document.getElementById("ps"+st),80);
if(showtimer==(randtim[st]+5)) { document.getElementById("pn"+st).style.backgroundImage="url('cs/log"+showpic+".jpg')"; SetOpacity(document.getElementById("ps"+st),0); }
}
if(showtimer>150) {
showtimer=0;
for( st=0; st<9; ++st ) randtim[st]=Math.floor(Math.random()*26)+100;
showpic+=1; if(showpic>2) showpic=0;
}
}
}
window.setInterval("Animuj()", 50);
This is how public money is spent in poland
void destroy_phone(T9obj* ptr_T9Obj){
free(ptr_T9Obj);
}
Such thoughtful name!
auto settingsFileSize = static_cast<int>(sizeof(_settings));
This was in release branch for a month. Casting wasn't even necessary.