Pages

Se afișează postările cu eticheta tutorial. Afișați toate postările
Se afișează postările cu eticheta tutorial. Afișați toate postările

sâmbătă, 29 martie 2025

News : Google Apps Script - add movies from website.

This source code with GAScript add few movies from cinemagia website:
This is the source code:
function scrapeProcessAndCleanUp() {
  const url = "https://www.cinemagia.ro/program-tv/filme-la-tv/filme-pro-tv,antena-1,tvr-1,prima-tv,diva,pro-cinema,film-cafe/azi/";
 
  let html;
  try {
    const response = UrlFetchApp.fetch(url);
    html = response.getContentText();
    Logger.log("Fetched HTML content length: ", html.length);
  } catch (error) {
    Logger.log("Error fetching HTML content: ", error.message);
    return;
  }

  let doc;
  try {
    doc = DocumentApp.create("Temporary HTML Content");
    doc.appendParagraph(html);
    doc.saveAndClose();
    Logger.log("Document created successfully with ID: ", doc.getId());
  } catch (error) {
    Logger.log("Error creating/saving document: ", error.message);
    return;
  }

  let text;
  try {
    const document = DocumentApp.openById(doc.getId());
    text = document.getBody().getText();
    Logger.log("Document text content length: ", text.length);
  } catch (error) {
    Logger.log("Error opening document or extracting text: ", error.message);
    return;
  }

  const titles = [...text.matchAll(/<li class="first">(.*?)<\/li>/g)];
  const images = [...text.matchAll(/<img src="(https:\/\/static\.cinemagia\.ro\/img\/resize\/db\/movie.*?)"/g)];
  const channels = [...text.matchAll(/<span class="r1">(.*?)<\/span>/g)];
  const times = [...text.matchAll(/<span class="r2">(.*?)<\/span>/g)];
  Logger.log("Titles found: ", titles.length);
  Logger.log("Images found: ", images.length);
  Logger.log("Channels found: ", channels.length);
  Logger.log("Times found: ", times.length);

  const extractedData = titles.map((title, index) => {
    const image = images[index] ? images[index][1] : "N/A";
    const channel = channels[index] ? channels[index][1].trim() : "N/A";
    const time = times[index] ? times[index][1].trim() : "N/A";
    return {
      title: title[1].trim(),
      image: image,
      channel: channel,
      time: time
    };
  });
  try {
    const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    const currentDate = new Date();
    extractedData.forEach((movie, rowIndex) => {
      if (movie.title !== "N/A" && movie.image !== "N/A") {
        const imageFormula = `=IMAGE("${movie.image}")`;
        const rowIndexAdjusted = sheet.getLastRow() + 1;
        sheet.appendRow([currentDate, movie.title, imageFormula, movie.channel, movie.time]);
        sheet.setRowHeight(rowIndexAdjusted, 76); // Set row height to 330px
      }
    });
    Logger.log("Processed movies count: ", extractedData.length);
  } catch (error) {
    Logger.log("Error adding data to spreadsheet: ", error.message);
  }
}
This is the result:

marți, 25 martie 2025

News : Google Apps Script - find duplicate files in google drive.

For today, a simple GAScript source code to add into spreadsheet the duplicate files from Google drive.
This Google Apps Script finds duplicate files in Google Drive by comparing file sizes and optionally file types. It then displays the results in a spreadsheet with detailed information about each duplicate file. The script collects information about all files in Drive. Files are grouped by their size and optionally file type. Any group with more than one file is considered a set of duplicates These duplicate sets are displayed in the spreadsheet
Functions
  • checkDuplicatesInDrive(): Main function that searches your entire Google Drive for duplicates
  • checkDuplicatesInFolder(): Alternative function that searches a specific folder and its subfolders
  • findDuplicateFiles(): Core function that identifies duplicate files based on size and type
  • addDuplicatesToSheet(): Adds the found duplicates to a spreadsheet
I used artificial inteligence and this help me much ...
/**
 * Main function to check files in the root folder and add duplicates to the active spreadsheet
 */
function checkDuplicatesInDrive() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  
  // Clear the sheet and set up headers
  sheet.clear();
  sheet.appendRow(["Group", "File Name", "Size", "Type", "File Path", "Date Created", "Last Updated", "URL"]);
  sheet.getRange(1, 1, 1, 8).setFontWeight("bold").setBackground("#f3f3f3");
  
  // Find all duplicates
  const duplicates = findDuplicateFiles(true);
  
  // Check if any duplicates were found
  if (Object.keys(duplicates).length === 0) {
    sheet.appendRow(["No duplicate files found"]);
    sheet.autoResizeColumns(1, 8);
    return;
  }
  
  // Add duplicates to the sheet
  addDuplicatesToSheet(duplicates, sheet);
  
  // Auto-resize columns
  sheet.autoResizeColumns(1, 8);
}

/**
 * Adds duplicate files to the specified sheet
 */
function addDuplicatesToSheet(duplicates, sheet) {
  let groupNumber = 1;
  let rowIndex = 2;
  let totalDuplicateFiles = 0;
  
  for (const key in duplicates) {
    const files = duplicates[key];
    totalDuplicateFiles += files.length;
    
    files.forEach((file, index) => {
      // Get file path
      const filePath = getFilePath(file.id);
      
      sheet.appendRow([
        groupNumber,
        file.name,
        formatFileSize(file.size),
        file.mimeType,
        filePath,
        file.dateCreated.toLocaleString(),
        file.lastUpdated.toLocaleString(),
        file.url
      ]);
      
      // Add hyperlink to the file URL
      sheet.getRange(rowIndex, 8).setFormula(`=HYPERLINK("${file.url}","Open File")`);
      
      rowIndex++;
    });
    
    groupNumber++;
  }
  
  // Add summary at the bottom - only if we have duplicates
  if (totalDuplicateFiles > 0) {
    sheet.appendRow(["SUMMARY"]);
    sheet.appendRow([`Found ${totalDuplicateFiles} duplicate files in ${groupNumber - 1} groups.`]);
  }
  
  return totalDuplicateFiles;
}

/**
 * Gets the file path for a given file ID
 */
function getFilePath(fileId) {
  try {
    const file = DriveApp.getFileById(fileId);
    const parents = file.getParents();
    
    if (parents.hasNext()) {
      const parent = parents.next();
      return getFolderPath(parent) + "/" + file.getName();
    } else {
      return "/" + file.getName();
    }
  } catch (e) {
    return "Path not available";
  }
}

/**
 * Gets the folder path for a given folder
 */
function getFolderPath(folder) {
  try {
    const parents = folder.getParents();
    
    if (!parents.hasNext()) {
      return "/" + folder.getName();
    }
    
    const parent = parents.next();
    return getFolderPath(parent) + "/" + folder.getName();
  } catch (e) {
    return "/Unknown";
  }
}

/**
 * Finds duplicate files in Google Drive based on file size and optionally file type.
 * @param {boolean} considerFileType Whether to consider file type when finding duplicates (default: true)
 * @param {string} folderId Optional folder ID to search in. If not provided, searches in the entire Drive.
 * @return {Object} An object containing groups of duplicate files
 */
function findDuplicateFiles(considerFileType = true, folderId = null) {
  // Create a map to store files by their size (and optionally type)
  const fileMap = {};
  
  // Get files to check
  let files;
  if (folderId) {
    const folder = DriveApp.getFolderById(folderId);
    files = folder.getFiles();
  } else {
    files = DriveApp.getFiles();
  }
  
  // Process each file
  while (files.hasNext()) {
    const file = files.next();
    // Skip Google Docs, Sheets, etc. as they don't have a fixed size
    if (file.getSize() === 0) continue;
    
    const fileSize = file.getSize();
    const mimeType = file.getMimeType();
    
    // Create a key based on file size and optionally type
    let key = fileSize.toString();
    if (considerFileType) {
      key += '_' + mimeType;
    }
    
    // Add file to the map
    if (!fileMap[key]) {
      fileMap[key] = [];
    }
    
    fileMap[key].push({
      id: file.getId(),
      name: file.getName(),
      size: fileSize,
      mimeType: mimeType,
      url: file.getUrl(),
      dateCreated: file.getDateCreated(),
      lastUpdated: file.getLastUpdated()
    });
  }
  
  // Filter out unique files (groups with only one file)
  const duplicates = {};
  for (const key in fileMap) {
    if (fileMap[key].length > 1) {
      duplicates[key] = fileMap[key];
    }
  }
  
  return duplicates;
}

/**
 * Alternative function to check files in a specific folder and its subfolders
 */
function checkDuplicatesInFolder() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  
  // Clear the sheet and set up headers
  sheet.clear();
  sheet.appendRow(["Group", "File Name", "Size", "Type", "File Path", "Date Created", "Last Updated", "URL"]);
  sheet.getRange(1, 1, 1, 8).setFontWeight("bold").setBackground("#f3f3f3");
  
  // Collect all files from the folder and subfolders
  var fileMap = {};
  var rootFolder = DriveApp.getRootFolder(); // Change this to your specific folder if needed
  collectFilesFromFolder(rootFolder, fileMap);
  
  // Filter out unique files
  const duplicates = {};
  for (const key in fileMap) {
    if (fileMap[key].length > 1) {
      duplicates[key] = fileMap[key];
    }
  }
  
  // Check if any duplicates were found
  if (Object.keys(duplicates).length === 0) {
    sheet.appendRow(["No duplicate files found"]);
    sheet.autoResizeColumns(1, 8);
    return;
  }
  
  // Add duplicates to the sheet
  addDuplicatesToSheet(duplicates, sheet);
  
  // Auto-resize columns
  sheet.autoResizeColumns(1, 8);
}

/**
 * Recursively collects files from a folder and its subfolders
 */
function collectFilesFromFolder(folder, fileMap, considerFileType = true) {
  // Process files in this folder
  var files = folder.getFiles();
  while (files.hasNext()) {
    const file = files.next();
    // Skip Google Docs, Sheets, etc. as they don't have a fixed size
    if (file.getSize() === 0) continue;
    
    const fileSize = file.getSize();
    const mimeType = file.getMimeType();
    
    // Create a key based on file size and optionally type
    let key = fileSize.toString();
    if (considerFileType) {
      key += '_' + mimeType;
    }
    
    // Add file to the map
    if (!fileMap[key]) {
      fileMap[key] = [];
    }
    
    fileMap[key].push({
      id: file.getId(),
      name: file.getName(),
      size: fileSize,
      mimeType: mimeType,
      url: file.getUrl(),
      dateCreated: file.getDateCreated(),
      lastUpdated: file.getLastUpdated()
    });
  }
  
  // Process subfolders
  var subfolders = folder.getFolders();
  while (subfolders.hasNext()) {
    var subfolder = subfolders.next();
    collectFilesFromFolder(subfolder, fileMap, considerFileType);
  }
}

/**
 * Helper function to format file size in a human-readable format
 */
function formatFileSize(bytes) {
  if (bytes < 1024) return bytes + " bytes";
  else if (bytes < 1048576) return (bytes / 1024).toFixed(2) + " KB";
  else if (bytes < 1073741824) return (bytes / 1048576).toFixed(2) + " MB";
  else return (bytes / 1073741824).toFixed(2) + " GB";
}

/**
 * Creates a new Google Spreadsheet with the duplicate files report
 */
function createDuplicateFilesSpreadsheet() {
  const duplicates = findDuplicateFiles(true);
  
  // Create a new spreadsheet
  const ss = SpreadsheetApp.create("Duplicate Files Report - " + new Date().toLocaleString());
  const sheet = ss.getActiveSheet();
  
  // Set up headers
  sheet.appendRow(["Group", "File Name", "Size", "Type", "File Path", "Date Created", "Last Updated", "URL"]);
  
  // Format header row
  sheet.getRange(1, 1, 1, 8).setFontWeight("bold").setBackground("#f3f3f3");
  
  // Check if any duplicates were found
  if (Object.keys(duplicates).length === 0) {
    sheet.appendRow(["No duplicate files found"]);
    sheet.autoResizeColumns(1, 8);
    return ss.getUrl();
  }
  
  // Add duplicates to the sheet
  addDuplicatesToSheet(duplicates, sheet);
  
  // Auto-resize columns
  sheet.autoResizeColumns(1, 8);
  
  Logger.log(`Spreadsheet created: ${ss.getUrl()}`);
  return ss.getUrl();
}
See the result into the spreadsheet:

luni, 17 martie 2025

News : New changes in pluralsight website.

I leran from this website and I tested my skills and is a great tool with certification and training.
Is a little bit expensive for me because I learn a lot of programming, design, game engines and API.
If I had gotten certificates for everything, for how much the exams cost, I would have to be very rich.
The only way to make a correct statement without enormous cost is online tests and the results obtained and the webiste comes with tested area.
The area of learning is:
  • IT Ops
  • Cloud
  • Security
  • Project Management
  • Data
  • Software Development
  • Popular Certifications
  • Newest
The newest now has Iris witch is a: Jumpstart a new conversation with one of our quick prompts.
See some my tested and learning skills on this website:

marți, 4 februarie 2025

Blender 3D : fix deformation Array of Curve modifier.

Possible bug ...
I noticed after creating an Array with an object and a NurbsPath object in Blender 3D version 4.3.2 and after the classic basic operations aligned, scaled and applied all transformations of these two objects, distortions appear when applying the Curve modifier to the Array object. I do not know the cause; it is possible a bug. It can be solved if you convert the NurbsPath to a new type of Curve object from the main menu Object - Convert - Curve, then applying the Deform Curve modifier will not deform the Array object.

sâmbătă, 11 ianuarie 2025

Blender 3D : How to Extract Marvel Rivals 3D Model and Use in Blender.

For those who are Marvel Rivals fans or study gaming files, here is a useful video tutorial.

joi, 2 ianuarie 2025

News : Roblox Studio changes and access places

Roblox comes with new features into Roblox Editor.
One is the the palaces area witch is Private - security reason by team developmen, and you not see this type of scene into default Roblox Studio Editor.
If you want to edit one of this you need to use this way, see this screenshot from the official webpage.

duminică, 29 decembrie 2024

Blender 3D : ... all available nodes !

An old surce code in python for Blender 3D to see available nodes :
import bpy

node_tree = bpy.context.object.active_material.node_tree

location_x = 0
location_y = 0

for type in dir(bpy.types):
    real_type = getattr(bpy.types, type)
    if issubclass(real_type, bpy.types.ShaderNode):
        try:
            node = node_tree.nodes.new(type)
            node.width = 250
            node.location = (location_x, location_y)
            location_x += 300
            if location_x > 3000:
                location_x = 0
                location_y -= 600
        except:
            pass

duminică, 1 decembrie 2024

Inkscape : watercolor effect on inkscape version 1.4 .

... the watercolor effect in inkscape can be found in the main menu : Filters - Textures - Watercolor.
Just draw a shape an then select the filter.
Use Filters - Filter Editor ... to edit the filter, see this image:

joi, 21 noiembrie 2024

News : ... test with the Tascade agent using custom data.

Today I tried to build an agent in taskade using my data.
I wanted to see if I could create SVG files using the data I entered.
I used a link and this PDF file as agent training data.
After training, I asked them to create an SVG file for me.
Here is the result:

miercuri, 20 noiembrie 2024

FASM : simple bootloader source code with menu .

This is the source code with a boot menu and can be tested with qemu emulator.
I need to use the Sonet 3.5 artificial inteligence to search infos and make this source code better, but I learn assembly in the past.
The compile commands of the source code:
mythcat@localhost:~/fasm$ ./fasm.x64
flat assembler  version 1.73.32
...
mythcat@localhost:~/fasm$ ./fasm.x64 bootloader.asm bootloader.bin
flat assembler  version 1.73.32  (16384 kilobytes memory, x64)
2 passes, 512 bytes.
The test with qemu tool:
mythcat@localhost:~/fasm$ qemu-system-x86_64 -drive format=raw,file=bootloader.bin
Let's see the source code:
; Simple Bootloader with Menu for QEMU
; Written in FASM

org 0x7C00

format binary

start:
    ; Clear the screen
    xor ax, ax
    mov ds, ax
    mov es, ax
    mov ah, 0x0
    int 0x10

    ; Display the menu
    call display_menu

main_loop:
    ; Wait for key press
    call wait_for_input

    ; Check key pressed
    cmp al, '1'
    je handle_option1
    cmp al, '2'
    je handle_option2

    ; Invalid option, restart
    jmp main_loop

handle_option1:
    ; Option 1 selected
    mov si, option1_msg
    call display_message
    call wait_for_input  ; Wait for any key
    jmp start           ; Return to menu

handle_option2:
    ; Option 2 selected
    mov si, option2_msg
    call display_message
    call wait_for_input  ; Wait for any key
    jmp start           ; Return to menu

display_menu:
    ; Display the menu
    mov si, menu
    call print_string
    ret

wait_for_input:
    ; Wait for a key press
    xor ax, ax
    int 0x16
    ret

print_string:
    ; Print string at DS:SI
    mov ah, 0x0E
@@:
    lodsb
    test al, al
    jz @f
    int 0x10
    jmp @b
@@:
    ret

display_message:
    ; Print message at DS:SI
    call print_string
    ret

menu db 'Simple Bootloader Menu', 13, 10
     db '1. Option 1', 13, 10
     db '2. Option 2', 13, 10
     db 'Select an option: ', 0

option1_msg db 13, 10, 'You selected Option 1!', 13, 10
           db 'Press any key to return to menu...', 13, 10, 0

option2_msg db 13, 10, 'You selected Option 2!', 13, 10
           db 'Press any key to return to menu...', 13, 10, 0

rb 510-($-$$)
db 0x55, 0xAA
This is the result:

joi, 3 octombrie 2024

Pydroid 3 android application for python ...

The Pydroid3 android application is the best way to test and run python scripts.
I install python packages with the install option, the pip command on terminal comes with errors for same python package.
I used the free version but if you pay for monthly or lifetime then you can have more features.
Same team come with android applications to have add more features, see these IIEC team appplicatons.

duminică, 1 septembrie 2024

News : FreeBSD in 100 Seconds.

... I tested a long time ago..., an old Live FreeBSD from an IT Romanian magazine. It is very fast and comes with a great graphic user interface.