tanaike - Google Apps Script, Gemini API, and Developer Tips

The Thinker

Statistics of gas Tag on Stackoverflow

Gists

This is the statistics for the tag gas on Stackoverflow. This statistics are retrieve from Stackoverflow using Stackexchange API. About 2020, the data is retrieved from 2020-01-01 to 2020-07-01.

This statistics data was obtained at 2020-07-15.

Measurement result

Fig. 1: Year vs. Total questions, Answered, Solved and Closed questions


Table 1: Tags which were used together with gas tag for each year.

Year Used Tag list
2008
2009 gas(12),assembly(11),x86(4),gcc(3),nasm(2),linux(2),relative-addressing(1),disassembly(1),avr(1),macos(1),segments(1),inline-assembly(1),tdm-mingw(1),c(1),directive(1),mips(1),compiler-construction(1),gnu(1),stack(1),multithreading(1)
2010 gas(31),assembly(28),x86(9),ld(6),gcc(4),linux(4),arm(4),gnu(3),c(3),inline-assembly(2),linker(2),elf(1),gdb(1),macos(1),ubuntu(1),mips(1),binutils(1),iphone(1),x86-64(1),64-bit(1),macros(1),intel-syntax(1),compiler-construction(1),python(1),embedded(1)
2011 gas(46),assembly(37),x86(16),gcc(11),c(9),linux(6),gnu(4),64-bit(3),arm(3),nasm(3),att(3),inline-assembly(3),binutils(2),x86-64(2),register-allocation(2),system-calls(1),32-bit(1),cortex-a8(1),fibonacci(1),recursion(1),xcode(1),string(1),mips(1),dwarf(1),callstack(1)
2012 gas(59),assembly(46),gcc(15),x86(10),x86-64(6),macos(6),gnu(6),linux(6),att(5),c(5),arm(4),ld(4),system-calls(3),binutils(3),nasm(3),struct(2),elf(2),syntax(2),interrupt(2),fpu(2),inline-assembly(1),clang(1),webrtc(1),compilation(1),iphone(1)
2013 gas(70),assembly(55),x86(18),x86-64(16),gcc(14),linux(14),att(7),nasm(6),c++(5),inline-assembly(4),c(4),syntax(3),intel-syntax(2),printf(2),arm(2),intel(2),segmentation-fault(2),arrays(2),linker(2),i386(2),ffmpeg(1),ios(1),yasm(1),tasm(1),elf(1)
2014 gas(61),assembly(53),x86(17),c(9),gcc(8),x86-64(7),nasm(5),linux(5),gdb(4),arm(4),stack(3),masm(3),disassembly(3),att(3),inline-assembly(3),arrays(2),32-bit(2),cpu-registers(2),shellcode(1),sockets(1),intel-syntax(1),opcode(1),gnu(1),c++(1),scanf(1)
2015 gas(89),assembly(76),x86(25),att(15),c(13),gcc(12),x86-64(12),gnu(6),nasm(4),linux(4),gdb(3),inline-assembly(3),mips(3),macos(2),clang(2),elf(2),disassembly(2),macros(2),yasm(2),xcode(2),calling-convention(2),makefile(2),ld(2),arm64(2),intel-syntax(1)
2016 gas(97),assembly(86),x86(32),x86-64(17),gcc(16),linux(16),att(14),c(5),nasm(5),osdev(4),ld(4),x86-16(4),linker(4),c++(3),gnu(3),gdb(2),forth(2),riscv(2),dwarf(2),intel(2),memory-alignment(2),intel-syntax(2),macos(2),system-calls(2),real-mode(2)
2017 gas(73),assembly(64),x86(26),gcc(22),att(15),c(11),x86-64(11),intel-syntax(4),gnu(4),linux(4),arm(4),bootloader(4),64-bit(4),nasm(3),x86-16(3),ubuntu(2),osdev(2),inline-assembly(2),gdb(2),macos(2),ld(2),string(2),go(1),if-statement(1),objdump(1)
2018 gas(69),assembly(55),x86(24),x86-64(14),gcc(13),att(6),linux(6),arm(4),macos(3),intel-syntax(3),position-independent-code(3),forth(2),ubuntu(2),x86-16(2),gdb(2),scanf(2),inline-assembly(2),gnu(2),blockchain(2),nasm(2),ld(2),osdev(2),bootloader(2),cygwin(1),debugging(1)
2019 gas(74),assembly(58),x86(21),x86-64(15),gcc(10),att(10),c(8),linux(8),gnu(5),gdb(5),ld(4),macros(3),intel-syntax(3),inline-assembly(2),shared-libraries(2),macos(2),dwarf(2),elf(2),arm(2),addressing-mode(2),machine-code(2),bootloader(2),c-preprocessor(1),pdp-11(1),thumb(1)
2020 gas(68),assembly(55),x86(25),gcc(17),x86-64(16),att(13),intel-syntax(7),c(4),bootloader(4),x86-16(4),osdev(3),arm(3),linux(3),c++(3),gnu(3),linker(3),arm64(2),string-literals(2),powerpc(2),riscv(2),calling-convention(2),ld(2),macos(2),clang(1),abi(1)

Summary

From Fig. 1, it shows that the tag gas is used a lot at 2016. At that time, this tag is used for 97 questions. After 2016, this frequency of gas is a bit low. The average frequency of use is 71.

GAS Library - OwnershipTransfer

Overview

This is a Google Apps Script library for achieving the ownership-transfer of the specific folder including the files and sub-folders using Drive API.

IMPORTANT: PLEASE BE CAREFUL THIS.

At first, please read this section

I cannot take responsibility for the problems occurred by this library. So when you use this library, please use it by according to your own decision and at your own responsibility.

This GAS library transfers the ownership of files and folders. For example, when the ownership of a file is transferred to other account, the file cannot be managed by the original user. And also, when the ownership of the specific folder is transferred to other account, all files ans sub-folders in the specific folder cannot be managed by the original user. PLEASE BE CAREFUL THIS. So when you use this library, at first, please test this library using a sample file and folder. PLEASE BE CAREFUL THIS.

And also, the specification of ownership transfer might be updated by Google side in the future update. Because when I had tested this library, I could notice that the specification had been changed. Ref By this, I noticed that the transferred files had no parent folders, and also, the script was required to be modified. From this situation, when you use this script for your important files and folders, please be careful this. At first, PLEASE TEST THIS LIBRARY USING A SIMPLE FILE AND FOLDER.

Description

Recently, I had the situation that it is required to transfer the ownership of a folder including the files and sub-folders. When I manually transferred the ownership of the top folder from my account to other user’s account, although the ownership of top folder could be transferred, my account is left as the writer. And also, the ownership of the files and sub-folders in the top folder was not changed, while the user is the writer. Although I do the same situation using the method of create.permissions in Drive API, the same result was obtained. In the current stage, unfortunately, by the simple method, the complete ownership-transfer of the file including the files and sub-folders cannot be achieved. From this situation, I created the script for achieving the complete ownership-transfer of the files and folders as a Google Apps Script library.

Specification of Files: copy in Drive API was changed

I noticed that the specification of Files: copy in Drive API was changed. About the method of Files: copy in Drive API v3, this method could be used with the scope of https://www.googleapis.com/auth/drive.readonly until July 5, 2020. But I confirmed that in the current stage, the scope is required to be changed to the following scopes.

  • https://www.googleapis.com/auth/drive
  • https://www.googleapis.com/auth/drive.file
  • https://www.googleapis.com/auth/drive.appdata
  • https://www.googleapis.com/auth/drive.photos.readonly

Please be careful this.

Transfer of owner of files got not to be able to be used with batch requests of Drive API

At 15, June 2020, I have reported the transfer of owner of files got to be able to be achieved with batch requests of Drive API. Ref And also, yesterday (06, July 2020), I could have confirmed that this could be worked. But, now (07, July 2020), the following response is returned.

{
  "error": {
    "errors": [
      {
        "domain": "global",
        "reason": "invalidSharingRequest",
        "message": "Bad Request. User message: \"You can't yet change the owner of this item. (We're working on it.)\""
      }
    ],
    "code": 400,
    "message": "Bad Request. User message: \"You can't yet change the owner of this item. (We're working on it.)\""
  }
}

I hope this situation is resolved in the near future.

Statistics of appscript Tag on Stackoverflow

Gists

This is the statistics for the tag appscript on Stackoverflow. This statistics are retrieve from Stackoverflow using Stackexchange API. About 2020, the data is retrieved from 2020-01-01 to 2020-07-01.

Recently, this tag is modified by editing the tags. So I think that it has to be said that this statistics data is obtained at 2020-07-06.

Measurement result

Fig. 1: Year vs. Total questions, Answered, Solved and Closed questions


Table 1: Tags which were used together with appscript tag for each year.

Adjusting Text Length to Fit in Cell Width on Google Spreadsheet using Google Apps Script

Gists

This is a sample script for adjusting the text length to fit in the cell width on Google Spreadsheet using Google Apps Script. In this case, in order to fit to the cell width, the font size is changed.

Issue and workaround:

Unfortunately, in the current stage, there are no methods for automatically resize the font size for fitting in the cell width in the Spreadsheet service. So in this case, it is required to think of the workaround. But the direction for calculating the length of texts in the unit of pixel cannot be directly used. Because as a test case, when I compared the text length (pixel) calculated from the font size and the cell width (pixel), those were different. By this, here, I would like to introduce a workaround using other direction. The base flow of this workaround is as follows.

Updated: Taking advantage of Web Apps with Google Apps Script

New section CORS in Web Apps was added to Taking advantage of Web Apps with Google Apps Script

In this section, I would like to introduce CORS in Web Apps. As the result, in order to prevent the error related to CORS, it was found the following important points.

  1. It is required to return ContentService.createTextOutput() and ContentService.createTextOutput("done") from doGet and doPost.

  2. For POST method, the data is required to be converted to the string and sent to Web Apps.

Report: Processing to Create New File to Specific Folder using Drive API

Gists

In this report, I would like to report for processing to create new file to the specific folder using Drive API. When the new file is created to the specific folder using Drive API, the property of parents with the value of folder ID is included in the request body of the method “Files: create”. About this process, I had thought that the file is directly created to the specific folder. But, I could confirm that the new file is created by the following process.