class PythonClass {
protected boolean True = true;
protected boolean False = false;
protected Object None = null;
}
class MyClass extends PythonClass {
String do_something(Object foo) {
if (foo == False)
return "" ;
else if (foo == None)
return "!" ;
else if (foo == True)
return "Yay!" ;
}
}
Yikes
foreach($bookings as $booking) {
$status = $apiController->getBookingStatus($booking);
if($status->error == 1) {
switch($status->message) {
case "FIND_PRV_KO": continue; //Wrong parameters
case "ERR_PREN_NOTFOUND": continue; //Request booking cannot be found
case "ERR_PRV_NOTFOUND": continue; //Check-in not carried out
default: continue;
};
continue;
}
//DO SOME STUFF...
}
Found this on a production website
if (argv[1][0]=='D'){
demo=1;
argv[1]++;
}
if (argv[1][0]=='P'){
if (sscanf(argv[1], "P%ux%ux%ux%ux%lfx%ux%u"
,&temporal_resample
,&input_w, &input_h, &rate, &input_gamma
,&output_w
,&output_h)!=7){
fprintf(stderr,"%s: Invalid argument format\n", progname);
print_usage();
exit(3);
}
ppm=1;
}else{
if (sscanf(argv[1], "%ux%ux%ux%ux%lfx%ux%u"
,&temporal_resample
,&input_w
,&input_h
,&rate
,&input_gamma
,&output_w
,&output_h)!=7){
fprintf(stderr,"%s: Invalid argument format\n", progname);
print_usage();
exit(3);
}
Found in a chroma subsampling algorithm.
let foo = {} // object no. 1
let bar = {} // object no. 2
foo > bar // return false
foo < bar // return false, so maybe foo equals bar?
foo == bar // oh well, return false
// but
foo >= bar // return true, 'cause !(foo < bar) == true
return value is expected, but JS is funny
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
Never, ever define developer environment and debug as default thing! #pdk
int w = 100;
for (nil; w!=0; nil) {
w -= 1;
//so some shit
}
this code was found in chinese contract work
public enum DataSize {
BYTE,
DOUBLE_BYTE,
INT,
LONG;
public boolean isEqualTo(Object value) {
if(value instanceof Byte && this.equals(BYTE)) {
return true;
} else if ((value instanceof Character || value instanceof Short) && this.equals(DOUBLE_BYTE)) {
return true;
} else if ((value instanceof Integer) && this.equals(INT)) {
return true;
} else if ((value instanceof Long) && this.equals(LONG)) {
return true;
}
return false;
}
}
String s = "string";
String.valueOf(s).toString();
// just to make sure it's a damn string
while(!s instanceof String) {
String.valueOf(s).toString();
}
if (isset($data['phone_id']) && !empty($data['phone_id'])) {
$userPhone = $this->getDoctrine()->getRepository('STODBBundle:Phones')->find($data['phone_id']);
if ($userPhone->getPhoneNumber() != $data['phone'] || $userPhone->getMobileProviderCode()->getId() != $data['phone_code']) {
if ($data['smsCode'] ?? false) {
if ($sessionSmsCode !== $data['smsCode']) {
$aData['smsCodeShow'] = false;
$aData['isWrongCode'] = true;
} else {
$aData['isWrongCode'] = false;
$checkCode = $data['smsCode'];
}
} else {
$aData['smsCodeShow'] = true;
$aData['isWrongCode'] = true;
}
} elseif (!$userPhone->getCodeCheck()) {
if ($data['smsCode'] ?? false) {
if ($sessionSmsCode !== $data['smsCode']) {
$aData['smsCodeShow'] = false;
$aData['isWrongCode'] = true;
} else {
$aData['isWrongCode'] = false;
$checkCode = $data['smsCode'];
}
} else {
$aData['smsCodeShow'] = true;
}
} else {
$aData['isWrongCode'] = false;
}
} else {
if ($data['smsCode'] ?? false) {
if ($sessionSmsCode !== $data['smsCode']) {
$aData['smsCodeShow'] = false;
$aData['isWrongCode'] = true;
} else {
$aData['isWrongCode'] = false;
$checkCode = $data['smsCode'];
}
} else {
$aData['smsCodeShow'] = true;
}
}
shit ... this junior
self.isOptionsVisible = ko.computed(function() {
if((self.type() == 'select') || (self.type() == 'multiselect') || (self.type() == 'radio') || (self.type() == 'checkbox') || (self.type() == 'upload')) {
return true;
}
return false;
}, this);
self.isNameVisible = ko.computed(function() {
if((self.type() == 'text') || (self.type() == 'textarea') || (self.type() == 'select') || (self.type() == 'multiselect') || (self.type() == 'radio') || (self.type() == 'checkbox') || (self.type() == 'upload')) {
return true;
}
return false;
}, this);
self.isBeforeAfterImagesVisible = ko.computed(function() {
if((self.type() == 'text') || (self.type() == 'textarea') || (self.type() == 'select') || (self.type() == 'multiselect') || (self.type() == 'radio') || (self.type() == 'checkbox') || (self.type() == 'upload')) {
return true;
}
return false;
}, this);
self.isTooltipVisible = ko.computed(function() {
if((self.type() == 'text') || (self.type() == 'textarea') || (self.type() == 'select') || (self.type() == 'multiselect') || (self.type() == 'radio') || (self.type() == 'checkbox') || (self.type() == 'upload')) {
return true;
}
return false;
}, this);
self.isLabelVisible = ko.computed(function() {
if((self.type() == 'text') || (self.type() == 'textarea') || (self.type() == 'select') || (self.type() == 'multiselect') || (self.type() == 'radio') || (self.type() == 'checkbox') || (self.type() == 'upload') || (self.type() == 'info')) {
return true;
}
return false;
}, this);
self.isClassVisible = ko.computed(function() {
if((self.type() == 'text') || (self.type() == 'textarea') || (self.type() == 'select') || (self.type() == 'multiselect') || (self.type() == 'radio') || (self.type() == 'checkbox') || (self.type() == 'upload')) {
return true;
}
return false;
}, this);
self.isStyleVisible = ko.computed(function() {
if((self.type() == 'text') || (self.type() == 'textarea') || (self.type() == 'select') || (self.type() == 'multiselect') || (self.type() == 'radio') || (self.type() == 'checkbox') || (self.type() == 'upload')) {
return true;
}
return false;
}, this);
object orientation overrated. let's check the fields in several places ...
// check if user is valid or not
ValidUserValidationResult userValidationResult = validUserValidator.validateUser(validationRequest);
if (!response ||
!response.data ||
!response.data.success ||
response.data.success == false ) {
//process stuff
}
Not talking about the '===' warning, here
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
<?php
if(!defined('WPINC')) // MUST have WordPress.
exit ('Do not access this file directly.');
if(!class_exists('pluginName_options_page_class'))
{
/**
* Menu page blah
*
* @package blah
* @since 140617
*/
class pluginName_options_page_class
{
public function __construct()
{
echo '<div class="wrap menu-page">'."\n";
echo '<div class="wp-header-end"></div>'."\n";
echo '<div class="menu-page-toolbox">'."\n";
pluginName_some_other_class::display();
echo '</div>'."\n";
echo '<h2>Options</h2>'."\n";
echo '<table class="menu-page-table">'."\n";
echo '<tbody class="menu-page-table-tbody">'."\n";
echo '<tr class="menu-page-table-tr">'."\n";
echo '<td class="menu-page-table-l">'."\n";
echo '<form method="post" name="plugin_options_form" id="plugin--options-form" autocomplete="off">'."\n";
echo '<input type="hidden" name="plugin_options_save" id="plugin--options-save" value="'.esc_attr(wp_create_nonce('plugin--options-save')).'" />'."\n";
echo '<div class="menu-page-group" title="Account Details">'."\n";
/* includes things like this gem */
echo (!is_multisite() || !pluginName_utils_conds::is_multisite_farm() || is_main_site()) ? '<p>[ Really Long message about something ]</p>'."\n" : '';
/* ... continues until end ... */
echo '</div>'."\n";
}
}
}
new pluginName_options_page_class ();
The entire file is a single class with a constructor. The constructor is ~ 1150 lines of echo statements with a few PHP conditionals thrown in. There are no other methods. The class is instantiated as soon as it is defined. Clever...
def get_verified_infos(request):
try:
# request logic here
return data
except Exception:
logger.error(
'Request to XXX was unsuccessful, '
'Will retry till max recursion! Retrying...'
)
return get_verified_infos(request)
Used for OpenID authentication