Google Apps Script doesn’t find file

Uncategorized
Question: I just want to check, if a file already exists on my Google Drive:var Filename = 'xyz'; var Files = DriveApp.getFilesByName(Filename); if (Files.hasNext()) { ... } This did work very good for some month. But suddenly it stopped working a few weeks ago. Now the result of hasNext() is always false - although the filename definitely does exist. Did anything change at Google Apps Script? Is anything wrong with my code? Can I fix it? Answer: Filename is not used at DriveApp.getFilesByName(). Because xyz is used as a string variable. If you want to use 'xyz' as Filename, please change as follows. From :var Files = DriveApp.getFilesByName(xyz); To :var Files = DriveApp.getFilesByName(Filename); If I misunderstand your question, I'm sorry. Read more
Read More

Why does the presence of `n` in the input sentence before `n` give wrong output?

c#
Question: I want to input a sentence (containing any possible characters) and print it. But there is a catch. If there is a n in the sentence then only the part of the sentence before n should be printed out (i.e. n should signify the end of the inputted sentence). I wrote a code for this situation : #include main() { char ch[100]; printf("Enter a sentence"); scanf("%99[^\n]",&ch); printf("%s",ch); } This code seems to work fine but it fails in a certain situation. If there is the character n anywhere in the sentence before n then it prints only the first word of the sentence! Why does this happen? How can I fix this bug? This case works fine: But in this case it fails: Detail from comments: Q: Do you…
Read More

Unix Renaming Files

Uncategorized
Question: I want to rename files in a folder on UNIX using a script. The format of the original file is abc.txt.temp and I want to rename it to abc.txt There are many files with the same format and I want to just remove .temp from the original file name. Answer: The answer Ciprian gave is certainly an option but I feel it's limiting. The solution below is much more flexible as you don't have to actually count anything and you can remove text from any position rather than just the end. The following command (1 line) will remove any mention of .temp in all the files:for filename in *; do mv "$filename" "${filename//.temp/}"; done Note The "*" means all files in current folder. You can use *.temp to achieve…
Read More

Working with remote host via git GUI in WebStorm

Uncategorized
Question: I have a project on remote host (instead virtual machine) and working with it by adding it as remote host and WebStorm and synchronize needed files. But I can't use git GUI for creating branch, committing etc - only SSH command line. I tried to add remote host as remote folder in Windows and work with it via SourceTree. But it's too slow. How can I work with remote host's git in WebStorm GUI? Or in SourceTree? Or in other GUI? Answer: Read more
Read More

Multiple Lightbox (Modal Image Gallery) on 1 page

Uncategorized
Question: I would like to create a lightbox effect without downloading anything. I found a nice solution using Modal/Slideshow as a lightbox and it works well. I would like to have more than 1 on a page and can't get it to work. Here is a link to the example and all the code is below. https://www.w3schools.com/howto/howto_js_lightbox.asp Lightbox × 1 / 4 2 / 4 3 / 4 4 / 4 ❮ ❯ Answer: Try if u are using bootstrap HTML × 1 / 4 2 / 4 3 / 4 4 / 4 ❮ ❯ CSS .row > .column { padding: 0 8px; } .row:after { content: ""; display: table; clear: both; } .column { float: left; width: 25%; } /* The Modal (background) */ .modal { display: none;…
Read More

List of lists changes reflected across sublists unexpectedly

Uncategorized
Question: I needed to create a list of lists in Python, so I typed the following: myList = [[1] * 4] * 3 The list looked like this: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]] Then I changed one of the innermost values: myList[0][0] = 5 Now my list looks like this: [[5, 1, 1, 1], [5, 1, 1, 1], [5, 1, 1, 1]] which is not what I wanted or expected. Can someone please explain what's going on, and how to get around it? Answer: When you write [x]*3 you get, essentially, the list [x, x, x]. That is, a list with 3 references to the same x. When you then modify this single x it is visible via all three references to it.…
Read More

I have a TemplateDoesNotExist error. I can update my models but not delete them?

django
Question: I'm making my first Django site that has one app so far named clients and i keep my templates in project_name/clients/templates/clients. Like the title says i'm able to update an instance of my model Client using UpdateView in my views file and I thought I would be able to delete an instance in the same way using DeleteView but I get the error stated previously. Any help would be appreciated. I've seen other similar posts but nothing that helped me solve this problem Here's my url file:from django.conf.urls import url from . import views app_name = 'clients' url(r'^$', views.IndexView.as_view(), name='index'), # /clients/11/... could be any number url(r'^(?P[0-9]+)/$', views.DetailView.as_view(), name='detail'), # /clients/viewed/ url(r'^viewed/', views.viewed, name='viewed'), # /clients/add/ url(r'^add/$', views.ClientCreate.as_view(), name='client-add'), # /clients/3/update/ url(r'^(?P[0-9]+)/update$', views.ClientUpdate.as_view(), name='client-update'), # /clients/8/delete/ url(r'^(?P[0-9]+)/delete/$', views.ClientDelete.as_view(), name='client-delete'),…
Read More