I am quite new to NodeJs and need some help regarding flow.
So, I need to change some lib as it does not work for me. I have asny call and then right a way i have sync code. The thing is that sync code starts executing before asny part return data.
asny:
xmlenc.encrypt(message, options509, function(err, result) {
console.log("error:", err)
message = result
return message;
})
sync right after asyn:
xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<" + envelopeKey + ":Envelope " +
xmlnsSoap + " " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
encoding +
this.wsdl.xmlnsInEnvelope + '>' +
((self.soapHeaders || self.security) ?
(
"<" + envelopeKey + ":Header>" +
(self.soapHeaders ? self.soapHeaders.join("\n") : "") +
(self.security && !self.security.postProcess ? self.security.toXML() : "") +
"</" + envelopeKey + ":Header>"
)
:
''
) +
"<" + envelopeKey + ":Body" +
(self.bodyAttributes ? self.bodyAttributes.join(' ') : '') +
(self.security && self.security.postProcess ? ' Id="_0"' : '') +
">" +
genXML() +
"</" + envelopeKey + ":Body>" +
"</" + envelopeKey + ":Envelope>";
How to solve this that the progrem with wait for asyn part to return before moving to sync part.
thank you
I have just upgraded from Xcode 8.3 to Xcode 9.4 and it kept indexing until it crashed, then it output an error.
Swift - Expression was too complex to be solved in reasonable time;
consider breaking up the expression into distinct sub-expressions
Is this a bug in Xcode 9 and Swift 4.1?
let fromString = convenience.getTimeAsString(timeStamp: timeStampDateAndTime, timeFormat: "HH:mm")
let toString = convenience.getTimeAsString(timeStamp: toTimeStamp, timeFormat: "HH:mm")
var cellData = "Booking: " + booking.BookingNumber + "\n" + "Area: " + booking.Locality + "\n" + "Postcode: " + booking.PostCode + "\n" + "Time: " + fromString + " - " + toString
How I fixed it?
var cellData = " \("Booking: ") \(booking.BookingNumber) \("\n") \("Area: ") \(booking.Locality) \("\n") \("Postcode: ") \(booking.PostCode) \("\n") \("Time: ") \(fromString) \(" - ") \(toString) "
How can I format this String with double x,y,total to two decimal places. String output = (x + " + " + y + " = " + total);
String ouput = String.format("%.2f + %.2f = %.2f",x,y,total);
System.out.println(output);
will give you the output with 2 decimal places or you can use DecimalFormat as well.
I encounter an annoying issue with Android studio. I have nicely and easy readable formatted piece of code:
But if I press Code - reformat code, my string declaration turns in complete mess:
It would not be a problem if only new line characters were removed, but Code - reformat code also split my strings and make empty line insertions (WTF)
Compare string before reformat:
private static final String
DATABASE_CREATE =
"create table "
+ TABLE_NAME + "("
+ COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_ITEM_ID + " integer default '0', "
+ COLUMN_SLUG + " text default '',"
+ COLUMN_TITLE + " text default '',"
+ COLUMN_TYPE + " integer default '0', "
+ COLUMN_YOUTUBE_ID + " text default '',"
+ COLUMN_ARTISTS + " text default '',"
+ COLUMN_ARTISTS_SLUG + " text default '',"
+ COLUMN_DESCRIPTION + " text default '',"
+ COLUMN_PICTURE + " text default '',"
+ COLUMN_SOURCE + " text default '',"
+ COLUMN_VIEW_COUNT + " integer '0',"
+ COLUMN_GOOGLE_LINK + " text default '',"
+ COLUMN_OFFLINE_SOURCE + " text default '',"
+ COLUMN_IS_SAVED_OFFLINE + " integer '0', "
+ COLUMN_OFFLINE_PLAYS + " integer default '0',"
+ COLUMN_DOWNLOADING_ID + " integer default '-1',"
+ COLUMN_IS_LIKE + " integer default '0' " +
");";
and string after reformat:
private static final String
DATABASE_CREATE =
"create table " + TABLE_NAME + "(" + COLUMN_ID + " integer primary key autoincrement, " +
"" + COLUMN_ITEM_ID + " integer default '0', " + COLUMN_SLUG + " text " +
"default ''," + COLUMN_TITLE + " text default ''," + COLUMN_TYPE + " integer " +
"default '0', " + COLUMN_YOUTUBE_ID + " text default ''," +
"" + COLUMN_ARTISTS + " text default ''," + COLUMN_ARTISTS_SLUG + " text " +
"default ''," + COLUMN_DESCRIPTION + " text default ''," +
"" + COLUMN_PICTURE + " text default ''," + COLUMN_SOURCE + " text default " +
"''," + COLUMN_VIEW_COUNT + " integer '0'," + COLUMN_GOOGLE_LINK + " text " +
"default ''," + COLUMN_OFFLINE_SOURCE + " text default ''," +
"" + COLUMN_IS_SAVED_OFFLINE + " integer '0', " + COLUMN_OFFLINE_PLAYS + " " +
"integer default '0'," + COLUMN_DOWNLOADING_ID + " integer default '-1'," +
"" + COLUMN_IS_LIKE + " integer default '0' " +
");";
You clearly can see lots of "" which were not present before.
How to fix such strange behaviour?
So I have this javascript function:
function show_courseline (course_index, repeats) {
var s = "";
var count = 0;
while (count < repeats) {
s = s + 'Number: ' + document.getElementById(course_index + count + 'a').innerHTML + '\n' +
'Semester: ' + document.getElementById(course_index + count + 'b').innerHTML + '\n' +
'Year: ' + document.getElementById(course_index + count + 'c').innerHTML + '\n' +
'Title: ' + document.getElementById(course_index + count + 'd').innerHTML + '\n' +
'Units: ' + document.getElementById(course_index + count + 'e').innerHTML + '\n' +
'Description: ' + document.getElementById(course_index + count + 'f').innerHTML + '\n';
++count;
}
alert(s);
}
But I get an error when I run it through an "onclick" input box. It has nothing to do with the document ids not being there, because they are.
Is course_index integer? If it is course_index + count is an integer and I know that ids cannot start with a digit