Row down - Java script - row

I got this code: Right now the "item.movie" appear right after the "item.time" and "-" sign. I want the "item.movie" to show on a different row below the "item.time". I would love to get some help how can it be done. Thanks a lot.
var column = document.createElement('td');
column.appendChild(document.createTextNode(item.time + " - " + item.movie));
row.appendChild(column);

Replace
column.appendChild(document.createTextNode(item.time + " - " + item.movie));
with
column.appendChild(document.createTextNode(item.movie));
column.appendChild(document.createElement("br"));
var timeEl = document.createTextNode(item.time);
timeEl.className = "movieTime";
column.appendChild(timeEl);
And add the css
.movieTime {
font-weight: 700;
text-decoration: underline;
}

Related

Escape Character for aws CloudWatch Log Query Insights

I'm working with an api that excecutes an aws Insights query. I check some business layers and then add filters to the query.
Those filters are from a list of errors that I can't change.
The trouble is that I cant make an standard function to add the filters. Now I'm using
public CWL_InsightsQuery NotLike(string field, string value, int index = -1) {
if (index < 0) {
int Index = QSegments.FindIndex(x => x.StartsWith("filter"));
QSegments[Index] = QSegments[Index] + " and " + SetInternalField(field) + " not like /"" + value + "/" ";
} else {
QSegments[index] = QSegments[index] + " and " + SetInternalField(field) + " not like /"" + value + "/" ";
}
return this;
}
QSegments stands for the construction of the query.
In simple terms, I ended up with an string like
|filter Data not like "value here lol"
this IS working, and its fine. The trouble starts when value has quotation marks, or different special characters.
So, Value can be this "is a" very 'unique' value /and i hate it/
so, I cant use '', neither / or " to declare the filter string.
Is there any escape character, as # in C#?
Would need something in CloudWatch Log insights like
#"I love how ""this query"" works 'every' time /i/ need it"
Thank you very much!

Matching word pattern with character pattern

So I have a very interesting question where I have a long string s such as:
eatsleepeatwalksleepwalk
and a smaller string p such as:
esetst
so on a quick look you can deduce that:
eat = e
sleep = s
walk = t
The problem statement is to tell whether the pattern of characters in smaller string p matches the words in the bigger string s
Size of s = 0 to 1000
Size of p = 0 to 1000
I'm aware of simple pattern matching using KMP, however this problem seems quite tricky and I'm unable to get to a starting point of solving this problem.
Any hints?
Edit 1: Look at #Neverever's answer below. Seems quite interesting, awaiting examination of space/time complexity.
Tried to solve it using JavaScript RegExp
$("button").click(function() {
let p = $("#p").val()
, s = $("#s").val()
, regMap = []
, regStr = "";
for (let c of p) {
let idx = regMap.indexOf(c);
if (idx === -1) {
regMap.push(c);
regStr += "(.+)";
} else {
regStr += "\\" + (idx + 1);
}
}
let reg = new RegExp("^" + regStr + "$");
console.log("RegExp used: " + regStr)
console.log("Result: " + reg.test(s));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label>String `s`: <input type="text" id="s" value="eatsleepeatwalksleepwalk" /></label><br>
<label>String `p`: <input type="text" id="p" value="esetst" /></label><br>
<button type="button">Run</button>

Google Script get a text from a cell(Spredsheet special characters like ç, à,é,è ) and search for it in a Google Doc document

I did a script (container-bound script) in my Spreadsheet in which I have 4 columns: (1) text before, (2) text after, (3) text to insert between, and (4) a URL of a Google Doc with the text in which I want to replace with the right value (between).
My method replace is not working when I have a french text (with characters like ç , à, è ) but with an english text it works fine How to solve this? Thank you very much for your help any idea is welcomed this is what I've done so far https://drive.google.com/drive/folders/1dOVNMrzEHvi3-vU3nbftK3Xoinxscrkn and my code :
/** It works for a text without accents :) but not for a french text :( **/
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Update the Google Doc") ;
var lastColumn = sheet.getLastColumn();
var numRows = sheet.getLastRow();
var COLUMN_URL = 3 ;
var data = sheet.getRange(1,1,numRows,lastColumn).getValues();
var start = 1;
var URL = data[start][COLUMN_URL];
Logger.log(' URL ' + URL);
var body = DocumentApp.openByUrl(URL).getBody();
var text_before = sheet.getRange(start + 1,1).getDisplayValue().replace(/[”|-’]/g,".");
Logger.log("text_before is " + text_before );
var text_after = sheet.getRange(start + 1,2).getDisplayValue().replace(/[”|-’]/g,".");
Logger.log("text_after is " + text_after );
var text_between = sheet.getRange(start + 1,3).getDisplayValue().replace(/[”|-’]/g,".");
Logger.log("text_between is " + text_between );
/** replace in the body of the Google Doc **/
// important to do this for the apostrophe and the " symbols that are different put the symbol in the cell
body.replaceText("\\Q’\\E","'");
// works
body.replaceText("\\Q”\\E",'"')
// ???? replace all unsupported characters from sheet means in my cell
/** symbols to test which works >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ok for the McDonald*?()\.,;%#(){!s . how about the " ***/
body.replaceText( "\\Q" + text_before + "\\E" + ".*?" + "\\Q" + text_after + "\\E", text_before + text_between + text_after );
/** another example **/
var start_bis = 2;
var text_before_bis = sheet.getRange(start_bis + 1,1).getDisplayValue().replace(/[”|-’]/g,".");
Logger.log("text_before is " + text_before_bis );
var text_after_bis = sheet.getRange(start_bis + 1,2).getDisplayValue().replace(/[”|-’]/g,".");
Logger.log("text_after is " + text_after_bis );
var text_between_bis = sheet.getRange(start_bis + 1,3).getDisplayValue().replace(/[”|-’]/g,".");
Logger.log("text_between is " + text_between_bis );
/** replace in the body of the Google Doc **/
body.replaceText( "\\Q" + text_before_bis + "\\E" + ".*?" + "\\Q" + text_after_bis + "\\E", text_before_bis + text_between_bis + text_after_bis );
}
You don't need to use replace. Just \\Q...\\E will work fine in this case. After replacing, . is considered a literal text due to (QE). Hence, it wasn't working.
Try
/** It works for a text without accents :) but not for a french text :( **/
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Update the Google Doc") ;
var lastColumn = sheet.getLastColumn();
var numRows = sheet.getLastRow();
var COLUMN_URL = 3 ;
var data = sheet.getRange(1,1,numRows,lastColumn).getValues();
var start = 1;
var URL = data[start][COLUMN_URL];
Logger.log(' URL ' + URL);
var body = DocumentApp.openByUrl(URL).getBody();
var text_before = sheet.getRange(start + 1,1).getDisplayValue();
Logger.log("text_before is " + text_before );
var text_after = sheet.getRange(start + 1,2).getDisplayValue();
Logger.log("text_after is " + text_after );
var text_between = sheet.getRange(start + 1,3).getDisplayValue();
Logger.log("text_between is " + text_between );
/** replace in the body of the Google Doc **/
// important to do this for the apostrophe and the " symbols that are different put the symbol in the cell
body.replaceText("\\Q’\\E","'");
// works
body.replaceText("\\Q”\\E",'"')
// ???? replace all unsupported characters from sheet means in my cell
/** symbols to test which works >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ok for the McDonald*?()\.,;%#(){!s . how about the " ***/
body.replaceText( "\\Q" + text_before + "\\E" + ".*?" + "\\Q" + text_after + "\\E", text_before + text_between + text_after );

sourceText value to be the layer index number according to current time indicator

Is there any way I could use a text layer and set it's source text value to be the layer index number of the visible layer or where AE's current time indicator is (CTI) during ram preview?
This will indicate the current time and the index of the first active layer:
var comp = app.project.activeItem;
var layer = comp.layers.addText("");
layer.text.sourceText.expression =
"""idx = "-";
N = thisComp.numLayers;
for (i=1; i<=N; i++){
if (i===index) continue;
if (thisComp.layer(i).active){idx = i; break;};
};
line2 = "Active Layer : " + idx;
line1 = "CTI : " + timeToCurrentFormat(time);
line1 + "\r" + line2;"""
(This is to be used from a script. To use directly inside After Effects, copy paste what's between triple quotes in the text expression box).

Regular Expression - Extract Tracking ID from Google Analytic script

I'm trying to extract UA-123456-7 from the following Google Analytic using regular expression. I think I'm too close, but I'm not sure it is even possible.
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-123456-7");
pageTracker._trackPageview();
</script>
Here is what I get when I run at www.regular-expressions.info
Regex: ^[<>%\w_\/.:;()\+-=?"]*(.*?)[<>\w_.;()]*$
Replacement text: $1
Result: gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));var pageTracker = _gat._getTracker("UA-140422-1"
Could someone please shed the light? Thanks in Advance!
Why don't you use a substring ?
Find the position of the string "_getTracker(" -> Pos A
same for string ")" -> Pos B
And substring between Pos A and Pos B.
Is that helpfull ?