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;
});
this.onSubmit = this.onSubmit.bind(this)
this.onClose = this.onClose.bind(this)
somewhere in react-native app
<?php
$k =1;
for($v = 0; $v < $nt; $v++) {
$bgClass= 'blueBg';
if($k > 1 && $k%2 == 0){
$bgClass= 'whiteBg';
}
?>
<tr class="row_tr <?php echo $bgClass;?>">
<td class="row_td td_column_0"> </td>
<td class="row_td column_1"><?php echo $rows[$v]['nothing'];?></td>
...
<td class="row_td td_column_0"> </td>
</tr>
<?php
$k++;
}
?>
set_locations(locations){
return new Promise((resolve, reject) => {
this.locations = locations;
resolve();
});
}
public void sleep(long duration) {
long start = System.currentTimeMillis();
while(true) {
if (System.currentTimeMillis() - start >= duration)
break;
}
}
if (!String.IsNullOrEmpty(Client.CLADDR1))
{
if (Client.CLADDR1 == "NULL")
{
function generateArrayFrom1To10()
{
let a = 0;
let b = 1;
let c = 3;
let d = 4;
let e = 5;
let f = 6;
let g = 7;
let h = 8;
let i = 9;
let array = [a,b,c,d,e,f,g,h,i];
return array;
}
def MergeThings(config_file, list_of_things, output_dir):
# read configparser config
config = read_config(config_file)
thing_string = ' --option '.join(list_of_things)
cmd = ''
cleaner_cmd = ''
cleaner_cmd = """&& a=%s ; s=`python -c "b=[line.split() for line in open('$a') if line.startswith('#COMMENT')][0][7:]; print '-ab ' + ' -ab '.join([b[0]] + b[-len(b)/2:])"`; java -Xmx1g -XX:ParallelGCThreads=1 -jar /path/to/a/java/command.jar -Z SelectThings -Y %s -W $a -U %s $s""" % (
os.path.join(output_dir, config.get('PARAMETERS', 'NAME') + '.file.extension'), config.get('FILES' + config.get('PARAMETERS', 'REFERENCE'), 'REF'), os.path.join(output_dir, config.get('PARAMETERS', 'NAME') + '.cleaned.file.extention'))
cmd = '%s -Xmx1g -XX:ParallelGCThreads=1 -Djava.io.tmpdir=/path/to/temp -jar %s -A doThings -B %s --option %s -otherOptions UNIQUE -C %s %s -D' % (config.get('SCRIPTS', 'JAVA'), config.get(
'SCRIPTS', 'OTHER_SCRIPT'), config.get('FILES' + config.get('PARAMETERS', 'REFERENCE'), 'REF'), thing_string, os.path.join(output_dir, config.get('PARAMETERS', 'NAME') + '.file.extention.gz'), cleaner_cmd)
return cmd
When scientists write code, sometimes it's not pretty. It's rather redacted ("thing" was not "thing" in the original). I especially love that the Bash part uses `` rather than $().
return isDisabled == false ? false : true;
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
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
// Check if marked for deletion and run finalizers
if k8sutil.IsMarkedForDeletion(instance.ObjectMeta) {
return r.checkFinalizers(ctx, log, instance)
}
// var array = retrieveArrayValue();
var filteredArray = array.filter(function (element, index, array) {
return array.indexOf(element) == index;
});
// processArray(filteredArray);
request.get_something = (something_id) => {
return new Promise((resolve, reject) => {
database.find_all('something', { where: {something_id: something_id, is_deleted:0} }).then(function(res){
let result = {};
res = JSON.stringify(res);
res = JSON.parse(res);
res.forEach(function(element){
if(typeof element.is_deleted != "undefined"){
delete element.is_deleted;
}
let key = 'something_' + element.id;
result[key] = element;
});
resolve(result);
}, reject);
});
}
I LOVE MY JOB!
private void EnableGPSAutoMatically() {
GoogleApiClient googleApiClient = null;
if (googleApiClient == null) {
oogleApiClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API).addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).build();
/* about 50 lines of code were here ...
* all depends on this if statement ... !
* Actually the whole method depends on this if statement ! */
}
}
});
}
}
what if that mysterious power change it to be not null !! It gonna be a holly object and You should not "new" it anymore ?! damn ... :)))