if(!Hardware::initialize()) {
    Serial.println("Hardware initialization failed!");
    for(;;){}
  }

  if(!UI.begin()) {
    Serial.println("SSD1306 allocation failed");
    for(;;){}
  }

For is best ever, why even bother with While, or even Return... Source of code: https://github.com/MausTec/nogasm-wifi/blob/master/ESP32_WiFi.ino

By Anonymous, 2020-11-22 20:05:34
this.onSubmit = this.onSubmit.bind(this)
this.onClose = this.onClose.bind(this)

somewhere in react-native app

By fluttershy, 2018-01-08 08:01:40
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;
});
By Anonymous, 2019-04-02 15:46:35
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iterator>

constexpr int N = 10;

int main() {
    std::vector<int> even;
    std::vector<int> odd;
    
    even.resize(N);
    
    // Fill up the 'even' vector with integers starting from from 1 through 'N'
    std::iota(even.begin(), even.end(), 1);

    // Segregate the odd and even integers from each other
    
    for (auto it = even.begin(); it != even.end(); ++it)
        if (*it % 2 != 0) {
            // If the number is odd, put it in the 'odd' vector
            odd.push_back(*it);
            // Remove the number from the even vector
            even.erase(it);
        }

    // Print the result
    
    std::cout << "Even numbers: ";
    std::copy(even.begin(), even.end(), std::ostream_iterator<int>(std::cout, " "));

    std::cout << "\nOdd numbers: ";
    std::copy(odd.begin(), odd.end(), std::ostream_iterator<int>(std::cout, " "));

    std::cout << '\n';
}

Seems fine to me... C++ couldn't possibly be THAT evil to introduce another nuanced and verbose complexity in there, right?

By cufbox, 2023-12-15 09:38:58
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);
  })
}
By a poor soul, 2018-04-11 17:07:13
 if (!String.IsNullOrEmpty(Client.CLADDR1))
            {
                if (Client.CLADDR1 == "NULL")
                {
By Anonymous, 2017-06-29 12:33:24
// this.collectPairs() returns data from the UI form 
// this.alert.alarmReasons contains empty array or alarmReason-Category pair objects

let newAlarmReasonsToAdd = []

this.collectPairs().forEach(categoryAndAlarmReasonPair => {
  !!!this.searchAmidExisting(categoryAndAlarmReasonPair, this.alert.alarmReasons) ? newAlarmReasonsToAdd.push(categoryAndAlarmReasonPair) : null
})

searchAmidExisting(alarmReasonToAdd, existingAlarmReasons){
    let res = existingAlarmReasons.find(existing => {
    if(alarmReasonToAdd.categoryDictEntryKey === existing.category && alarmReasonToAdd.reasonDictEntryKey === existing.reason){
      return true
    } else return false
  })
    return res
  }
By mallioppilas, 2023-11-03 14:13:41
return isDisabled == false ? false : true;
By Anonymous, 2018-03-23 22:02:31
(this.router.state['view']['data'] || {})['menuOpen'] && this.router.navigateBack();

That's how pros are javascripting

By Igor, 2017-07-06 04:00:05
def open(self, *filename):
	if len(filename) > 1:
		print(("Usage:\nopen() - opens with the initialized "
			"filename\nopen(filename) - opens with given filename"))
		return 1
	if len(filename) == 1:
		self.filename = filename[0]
	if self.filename is None:
		print("No filename given")
		return 1
	self.struct_p = open_struct(self.last_error, self.error_size, \
		self.filename)
	if self.struct_p is None:
		print("Cannot open file: " + self.filename)
		return 1
	self.load_data()
	return 0
By Anonymous, 2017-12-12 03:26:17
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?

By Anonymous, 2019-05-10 13:20:47
function clean(toClean, source){
	if (typeof(toClean) !== 'string') return true;
	if (typeof(source) !== 'string') return true;
	
	return source.replace(toClean, String('CLEANED')).toString();
}

Found this in a project at work and someone clearly doesn't trust JavaScripts typeof function

By Anonymous, 2018-06-02 22:09:57
public void sleep(long duration) {
    long start = System.currentTimeMillis();
    while(true) {
        if (System.currentTimeMillis() - start >= duration)
            break;
    }
}
By imaN NeO, 2018-10-28 09:35:15
    string sum_numbers(string a, string b) {
        char ca, cb, ci, out, co = '0';
        string result = "";
        while (a.size() > 0 || b.size() > 0 || co != '0') {
            ci = co; ca = '0'; cb = '0';
            if (a.size() > 0) {ca = a.back(); a.pop_back();}
            if (b.size() > 0) {cb = b.back(); b.pop_back();}
            result = ((((ca != cb) ? '1' : '0') != ci) ? '1' : '0') + result;
            co = ((((ca == '1' && cb == '1') ? '1' : '0') == '1' || 
                 ((((ca != cb) ? '1' : '0') == '1' && ci == '1') ? '1' : '0') == '1') ? '1' : '0');
        }
        return result;
    }

Scary stuff

By Anonymous, 2023-12-01 22:20:27
/*
 *                                                      _____________________________________________________ 
 *                                           ___________↓___↓____________________________________________   |  
 *                                          _↓_________↓|___|________________________________________   |   |
 *                                    ______↓|_________||___|↓___________________________________   |   |   |
 *                               _____↓__↓__||_________||___||_______________________________   |   |   |   |
 *                              _↓__↓_|__|__||_________||___||___________________________   |   |   |   |   |
 *                     _________↓|__|_|__|↓_||_________||___||_______________________   |   |   |   |   |   |
 *                     ↓   ↓    ||  | |  || ||         ||   ||                      |   |   |   |   |   |   |      */
opcId = child.replace(/([.])?(?:((.+)=(.+))|(([a-zA-Z]+)(\d*)))/g, function (match, m1, m2, m3, m4, m5, m6, m7) {
By Michal, 2024-01-18 13:18:02