if ( x == true)
{
// do something
}
Fucking amateurs :| lol
String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1);};
String.prototype.followCase=function(b){
if(b==b.toUpperCase()){return this.toUpperCase();}
if(b==b.toLowerCase()){return this.toLowerCase();}
if(b==b.capitalize()){return this.capitalize();}
return this;
};
String.prototype.atRemoveAdd=function(index,n,string){
return this.substring(0,index)+string+this.substring(index+n,this.length);
};
String.prototype.matchIndex=function(re){
var a=[];
while((match=re.exec(this))!==null){
a.push({chars:match[0].length,index:match.index});
}
return a;
};
String.prototype.caseReplace=function(o,n){
for(var s=this,a=this.matchIndex(o),shift=0,i=0;i<a.length;i++){
var c=n.followCase(this.substring(a[i].index,a[i].index+a[i].chars));
s=s.atRemoveAdd(a[i].index+shift,a[i].chars,c);
shift+=c.length-a[i].chars;
}
return s;
};
My code from 2016 for the hall of shame where I realized today that caseReplace could just return this.replace(o,m=>n.followCase(m))
instead.
public IsTrueWithNewTokenResponse isVoice(String token){
IsTrueWithNewTokenResponse isTrue = isWhatever(token, 0)
resultStatus.success = isTrue.generalResultResponse.success;
resultStatus.statusCode = isTrue.generalResultResponse.statusCode;
resultStatus.statusDescription = isTrue.generalResultResponse.statusDescription;
if(isTrue != null && isTrue.generalResultResponse != null && isTrue.generalResultResponse.success){
isTrue.isTrue = !isTrue.isTrue
return isTrue
} else {
return isTrue
}
}
//read country intformation and assign to variables
cName = InpList.get(0).replace(",", ".");
cCode = InpList.get(1).replace(",", ".");
cAlpha2 = InpList.get(2).replace(",", ".");
cAbreviation = InpList.get(3).replace(",", ".");
dYear = InpList.get(4).replace(",", ".");
dPoliticalCompatibility = InpList.get(5).replace(",", ".");
dRankPoliticalCompatibility = InpList.get(6).replace(",", ".");
dEconomicCompatibility = InpList.get(7).replace(",", ".");
dRankEconomicCompatibility = InpList.get(8).replace(",", ".");
dMilitaryCompatibility = InpList.get(9).replace(",", ".");
dRankMilitaryCompatibility = InpList.get(10).replace(",", ".");
dDemoScore = InpList.get(11).replace(",", ".");
dRankDemoScore = InpList.get(12).replace(",", ".");
dEnvironmentalCompatibility = InpList.get(13).replace(",", ".");
dRankEnvironmentalCompatibility = InpList.get(14).replace(",", ".");
dSumCompatibility = InpList.get(15).replace(",", ".");
dRankCompatibility = InpList.get(16).replace(",", ".");
dPoliticalUtility = InpList.get(17).replace(",", ".");
dRankPoliticalUtility = InpList.get(18).replace(",", ".");
dEconomicUtility = InpList.get(19).replace(",", ".");
dRankEconomicUtility = InpList.get(20).replace(",", ".");
dMilitaryUtility = InpList.get(21).replace(",", ".");
dRankMilitaryUtility = InpList.get(22).replace(",", ".");
dEnvironmentalUtility = InpList.get(23).replace(",", ".");
dRankEnvironmentalUtility = InpList.get(24).replace(",", ".");
dSumUtility = InpList.get(25).replace(",", ".");
dRankUtility = InpList.get(26).replace(",", ".");
dPoliticalScore = InpList.get(27).replace(",", ".");
dRankPoliticalScore = InpList.get(28).replace(",", ".");
dEconomicScore = InpList.get(29).replace(",", ".");
dRankEconomicScore = InpList.get(30).replace(",", ".");
dMilitaryScore = InpList.get(31).replace(",", ".");
dRankMilitaryScore = InpList.get(32).replace(",", ".");
dEnvironmentalScore = InpList.get(33).replace(",", ".");
dRankEnvironmentalScore = InpList.get(34).replace(",", ".");
dAggregate = InpList.get(35).replace(",", ".");
dRankAggregate = InpList.get(36).replace(",", ".");
maybeSomething match {
case Some(x) => true
case None => false
}
maybeSomething.getOrElse(false) Short code and readable
if (logger.isDebugEnabled()) {
logger.debug("process (FollettPojo) - start");
}
String dnum = StringUtil.toCapitalizedString(pojo.getDnum().toString());
pojo.setDnum(new String(dnum));
if (logger.isDebugEnabled()) {
logger.debug("process (FollettPojo) - middle ");
}
String rawI = StringUtil.toCapitalizedString(pojo.getRawInput().trim().toString());
pojo.setRawInput(new String(rawI));
if (logger.isDebugEnabled()) {
logger.debug("process (FollettPojo) - end ");
}
/* And you may ask what is this toCapitalizedString? Well here you go a separate class to boot */
public static String toCapitalizedString(String string){
StringBuilder strb = new StringBuilder();
if(string != null && string.trim().length() > 0
&& Character.isLetter(string.charAt(0))
&& Character.isLowerCase(string.charAt(0))){
strb.append(string.substring(0,1).toUpperCase()).append(string.substring(1));
return strb.toString();
}
return string;
}
SpringBatch this is the processor for each record...dnum example D00000000
function prepareKeyword($keyword) {
$keyword = html_entity_decode($keyword);
$keyword = html_entity_decode($keyword);
$keyword = html_entity_decode($keyword);
$keyword = iconv("ISO-8859-1", "UTF-8", $keyword);
$keyword = cleanString($keyword);
$keyword = html_entity_decode($keyword);
if ($keyword != "") {
$keyword = mb_strtolower($keyword, "UTF-8");
$keyword = htmlentities($keyword, ENT_HTML5);
}
return $keyword;
}
SELECT CAST(CASE a8900.AllowCloserChanges
WHEN 0
THEN 0
ELSE 1 END AS BIT) AllowCloserChanges
FROM Vision.sub8900.tApplication8900 a8900
WHERE a8900.ApplicationNum = @ApplicationNum
Inheriting others' code in the fun world of corporate development.
def divide(a, b):
try:
return a / b
except:
x = 17
My smart exception handling before meeting "pass" :))
void printNumber(int Number){
while(Number>0){
int i=Number%10;
switch(i) {
case 1 : cout << '1'; // prints "1",
case 2 : cout << '2'; // then prints "2"
case 3 : cout << '3'; // then prints "3"
case 4 : cout << '4'; // then prints "4"
case 5 : cout << '5'; // then prints "5"
case 6 : cout << '6'; // then prints "6"
case 7 : cout << '7'; // then prints "7"
case 8 : cout << '8'; // then prints "8"
case 9 : cout << '9'; // then prints "9"
case 0 : cout << '0'; // then prints "0"
default : cout<<'5'; // :|
}
Number=Number/10;
}
}
int true = 0;
while (true)
{
//do something
}
true = false
public static int[] xxx(String filename) throws IOException{
int[] f = new int[26];
BufferedReader in = new BufferedReader(new FileReader(filename));
String line;
while((line = in.readLine()) != null){
line = line.toUpperCase();
for(char ch:line.toCharArray()){
if(Character.isLetter(ch)){
f[ch - 'A']++;
}
}
}
in.close();
return f;
}
function getJSType(cppType: string) {
let typeMap = new Map<string, string>([
["Bool", "boolean"],
["Int32", "number"],
["UInt32", "number"],
["Int64", "number"],
["UInt64", "number"],
["Double", "number"],
["String", "string"],
["Object", "any"]
]);
if (typeMap.get(cppType) === undefined) {
console.error("Invalid type in getJavascriptType: " + cppType);
process.exit(1);
}
return typeMap.get(cppType);
}
function changePassword() {
if (isInputEmpty()) {
$.ajax({
type: 'POST',
data: '...'
url: '...',
success: function (result) {
if (result.substring(0, 3) != "!!!") {
//success
} else {
//faliure
}
},
error: function () {
}
});
}
}
And of course,in production, it always reported success and never changed the password, because of equally bad server code.
if( %rightBtnCmd $= "noButtons" )
{
//do nothing, as there are no buttons
}
proprietary script language.