Category Archives: IT

IT

Apple TV 3rd generation A1469 tech specifications and drive storage capacity

I had to check recently what is the storage capacity of an Apple TV 3rd generation device identified as model Apple TV A1469. Strangely NOWHERE in the About and Settings is shown the capacity. It seems that officially for this device there is no storage available and stated!!!

Apple TV (3rd Generation, Early 2013) Specs
Identifiers: 3rd Gen – MD199LL/A – AppleTV3,2 – A1469 – 2633

Apple TV (3rd Generation) has 512 MB of RAM and is capable of supporting 1080p video.

Processor Speed: 1 GHz* Processor Type: Apple A5

Apple does not specify the amount of RAM onboard. However, by third-parties it was confirmed that it has 512 MB of RAM.

Standard Storage: 8 GB SSD Storage. Officially, the third generation Apple TV models have no internal storage. However, third-parties have determined that they actually have 8 GB of flash memory to cache content, just like the second generation Apple TV.

Delete Mac OS local TimeMachine backup

To delete specific local Time Machine backups from the Terminal:

  1. List the available backups with:
    tmutil listlocalsnapshots /
  2. Delete backup with from the list:
    sudo tmutil deletelocalsnapshots 2024-xxxxxxx

    You should get confirmation of deletion like: “Delete local snapshot ‘2024-xxxxxx’

More info on how to clear space on Mac OS will be published later…

But generally you can first check this official document:
Free up storage space on Mac
https://support.apple.com/en-us/102624

How to set default date in ToolJet.com app

Target: Create a variable which has the default date as value. Then use this value as default for date picker component in ToolJet app.

Steps:

  1. Add new query of type “Run JavaScript code”
  2. In the code section paste the following code:
    const currentDate = new Date();

    const year = currentDate.getFullYear();
    const month = String(currentDate.getMonth() + 1).padStart(2,'0'); // Months are 0-indexed
    const day = String(currentDate.getDate()).padStart(2, '0');  

    today = `${year}-${month}-${day}`;

    actions.setVariable('dt', today);
    return actions.getVariable('dt');
  3. Below the code make sure to switch ON in Settings “Run this query on application load?”
  4. Now you can use the created value in the variable “dt” in any Date picker component by simply putting the following text in “Default value” property: “{{variables.dt}}

Permission denied while getting drive credentials from BigQuery table in Cloud Functions via SQL

If you have a BigQuery external table which uses for example a Google Sheets file as source, AND you try to read / join this table in BigQuery SQL you may get the error in BigQuery job failure log:

google.api_core.exceptions.Forbidden: 403 Access Denied: BigQuery BigQuery: Permission denied while getting Drive credentials.

Seems like no drive scope is the default, so BQ clients that need these scopes should be passing it in via the client_options.

So in this original solution post: https://github.com/googleapis/google-auth-library-python/issues/1204

This is the solution which worked for me too:

EricSeastrand commented on May 27, 2024• 
For anyone else facing this, here's the exact code that worked for me:

from google.cloud import bigquery
client = bigquery.Client(client_options={
    "scopes": ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/cloud-platform']
})
results = client.query_and_wait(sql)

During the bigquery.Client connection I had to pass the above scopes and there is no problem with authorizations in Sheets/Drive access anymore.

Some day I may post more on the topic …..

Google Cloud scheduler call to Cloud functions 401 error

I used to run some functions developed and deployed on Google Cloud Run Functions.

Some of them are scheduled to run via Cloud Scheduler.

Last time I decided to copy the definition of the Cloud Scheduler job from bot 2 to my new bot3 function. And I started to get 401 unauthenticated errors for bot3, but the same definition was working fine for bot2.

The error looks like below:

debugInfo: "URL_ERROR-ERROR_AUTHENTICATION. Original HTTP response code number = 401"
jobName: "projects/....../locations/europe-west6/jobs/......"
status: "UNAUTHENTICATED"
targetType: "HTTP"

and in the Cloud Function log is the misleading:

The request was not authorized to invoke this service. Read more at https://cloud.google.com/run/docs/securing/authenticating Additional troubleshooting documentation can be found at: https://cloud.google.com/run/docs/troubleshooting#401

BUT – actually the problem is that during the copy of the scheduler job definition, the “Audience” value IS NOT updated with the new function URL (in my case bot3), but the old function URL is kept. It seems like it was autofilled in bot2 definition though and I didn’t noticed it. So be sure that URL and Audience are properly set!

If you fix this the 401 error is solved and gone!!!

I hope I saved you some time. Post one thanks in comments if so …

Gmail.com – more info on how ids work and two tricks

1st: You can append a plus “+” sign after your name

So adding any text after “+” sign still get the emails to your inbox, but you can filter based on this additional email id. E.g.:

your.email@gmail.com and your.email+subscription1@gmail.com and your.email+bank1@gmail.com

will both deliver the emails to your.email@gmail.com !

2nd: Gmail DOES NOT recognize the dots “.” in the email ID.

So your.email@gmail.com is the same as youremail@gmail.com or y.o.u.r.e.m.a.i.l@gmail.com

Original article is here: 2 hidden ways to get more from your Gmail address

https://gmail.googleblog.com/2008/03/2-hidden-ways-to-get-more-from-your.html

Fix VirtualBox (copy/move/restore) VM

If you have moved a VM or have an old copy of working VM, you can land in situation where the VirtualBox software is reinstalled or moved and you get errors when you restore old VMs or move some.

Could not find an open hard disk with UUID {2219b9d1-8931-418c-a7d5-d5ce00c81b7c}.
Result Code:
VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)
Component:
VirtualBoxWrap

or

Virtual Box UUID {17c3.........} does not match the value {3c1b...} 
stored in the media registry ('/home/user/.VirtualBox/VirtualBox.xml')
Machine UUID {899a89219ax-7d55-8381-01ac-288288101} doesn't match its UUID {0388cb75-f076-4992-ab96-ed8d2ff99623} in the registry file
Result code: NS_ERROR_FAILURE (0x80004005}

The solution I found is based on the answers here:

https://stackoverflow.com/questions/15074878/virtual-box-uuid-07c3-does-not-match-the-value-2c1b-stored-in-th and my experience.

First – check if you have running the VirtualBox with the right user! Sometimes errors can occur if you have installed the VirtualBox with different user and the current one is not admin or does not have enough rights!!!

Second – fix the UUID like below.

Copy existing VM (duplicate) via VirtualBox to create a new folder and working VM.

Rename the VirtualBox.vdi file to VirtualBox0.vdi of the new VM.

Get the UUID of the working VM with the following command:

The result should look like:

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands dumphdinfo VirtualBox0.vdi
--- Dumping VD Disk, Images=1
Dumping VD image "polikont_feb2016-disk1.vdi" (Backend=VDI)
Dumping VDI image "polikont_feb2016-disk1.vdi" mode=r/o uOpenFlags=9 File=0x0002586d731290
Header: Version=00010001 Type=1 Flags=0 Size=85888373760
Header: cbBlock=1048576 cbBlockExtra=0 cBlocks=81910 cBlocksAllocated=13687
Header: offBlocks=512 offData=328192
Header: Geometry: C/H/S=1024/255/63 cbSector=512
Header: uuidCreation={0388cb75-f076-4992-ab96-ed8d2ff99623}
Header: uuidModification={24bde4bc-e7cf-4d60-8f40-a257b3460228}

Set UUID to the restored/copied VM which was giving error (I have renamed it to VirtualBox.vdi in the directory of the working copy, after I have renamed the working VDI to VirtualBox0.vdi and taken its UUID as shown above). So set its UUID as follow:

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands sethduuid  VirtualBox.vdi 0388cb75-f076-4992-ab96-ed8d2ff99623

Replace the UUID (0388cb75-f076-4992-ab96-ed8d2ff99623) with your result from dumphdinfo command!

*** This was experienced and tested in VirtualBox 7.0 under Windows 10 at May 2024.

Google Drive API v3 (googleapiclient.errors.HttpError 404 File not found)

If you try to upload a file in a shared drive (in Google Drive) you may get the above error.

This is my experience and solution as of February 2024 using Python 3.10.

from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload
from google.oauth2 import service_account

from io import BytesIO
from googleapiclient.http import MediaIoBaseUpload
from google.cloud import translate_v2 as translate

## Credentials of service account
credentials = service_account.Credentials.from_service_account_info(service_account_info, scopes=['https://www.googleapis.com/auth/drive'])

## API Client Service
service = build("drive", "v3", credentials=credentials)

# buffer_memory=BytesIO(b"some initial binary data: \x00\x01") # BytesIO() new_body
buffer_memory=BytesIO() # BytesIO() new_body
buffer_memory.write(new_body.encode('utf-8'))

## Prepare the file in memory (you can upload local file too with MediaBase Upload)
media_body = MediaIoBaseUpload(buffer_memory, mimetype='text/html', 
        chunksize=1024*1024, resumable=False)
                body = {
                        'title': file_name,
                        "name": file_name,
                        "mimeType": "application/vnd.google-apps.document",
                        "driveId": "0APee............PVA",
                        "parents": ['0APe.............PVA'],
                    }

## Upload file
returned_fields="id, name, mimeType, size, webViewLink, exportLinks"
upload_response=service.files().create( body=body,                                                            
   media_body=media_body,
   supportsAllDrives=True,
   fields=returned_fields).execute()

## Share the created file with user
user_permission = {
                    "type": "user",
                    "role": "writer",
                    "emailAddress": share_user,
                }
                perm_response = service.permissions().create(
                    fileId=uploaded_file_id,
                    body=user_permission,
                    fields="id"
                ).execute()
   

The important difference between uploading in private Google drive is that you have to use the following parameters for Shared Drives:

supportsAllDrives=True
driveId -> Id of Shared Drive
parents -> Folder or Shared Drive

Mime Types: List of the supported Mime type here

Tip:

If you want to convert the uploaded file to Google Drive native format use the following parameter:

"mimeType": "application/vnd.google-apps.document",

Google documentation: https://developers.google.com/drive/api/guides/manage-uploads

And this article on StackOverflow as well helped to find the solution although some parameters are wrong or deprecated already: https://stackoverflow.com/questions/67622131/google-drive-api-v3-googleapiclient-errors-httperror-404-file-not-found

Python snippets 2024 Q1

How to convert StringIO object to BytesIO object vice versa.

I want to read a string with the io.StringIO and then convert it to an io.BytesIO object and vice versa, how can I do this?

Below is the example source code which can implement python StringIO and BytesIO object converts.

import io
# Convert a StringIO object to BytesIO object.
def stringio_to_bytesio(str):
    
    str_io_object = io.StringIO(str)
    
    str_data = str_io_object.read().encode('utf8')
    
    bytes_io_object = io.BytesIO(str_data)
    
    print(bytes_io_object)  
    print(bytes_io_object.read())
    
# Use io.TextIOWrapper to convert BytesIO object to a string. Then we can build a StringIO object on the string.     
def bytesio_to_stringio(bytes_str):
    
    data = io.BytesIO(bytes_str)
    
    # Create an instance of io.TextIOWrapper class.
    text_wrapper = io.TextIOWrapper(data, encoding='utf-8')
    
    str = text_wrapper.read()
    
    str_io_object = io.StringIO(str)
    print(str_io_object)  
    
    print(str)  
if __name__ == '__main__':
    
    bytes_str = stringio_to_bytesio('I love python')
    
    bytesio_to_stringio(b'hello python')

Source (with more details): https://www.code-learner.com/python-stringio-and-bytesio-example/