Pages

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

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:

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

joi, 15 august 2024

Codapi an interactive code playground service.

Interactive code examples for all types of technical writing.
Embed executable code snippets directly into your product documentation, online course or blog post.
Supports 30 playgrounds out of the box, plus custom sandboxes if you need them.
You can run in-browser playgrounds without a server, use the Codapi cloud, or host a sandbox server yourself.
Read more on the official website.

duminică, 4 august 2024

Inkscape : Create an extension for inkscape.

You can create your own extensions in inkscape with all features you need to improve the working area.
One extension can have minimum two file: the basic Python source code and another file with the graphic user interface ...
The source code of Python file can be link with the G.U.I. source code type file INX.
The source code for python can be customized and this is the main reason is no need to add it here.
Let's see the source code for the INX file:
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
    <name>Default extension example</name>
    <id>default.extensions.example</id>
    <param name="tab" type="notebook">
        <page name="Options" gui-text="Options">
            <param name="value_int" type="int" min="0" max="9" gui-text="INT type value from 0 up to 9 : ">10</param>
            <param name="value_bool" type="bool" gui-text="BOOL value set to false : ">false</param>
            <param name="value_space" type="float" gui-text="FLOAT value set to 0.1 custom range min 0.0 up max=99.0 : " min="0.0" max="99.0">0.1</param>
                <param name="option_group selection" type="optiongroup" appearance="combo" gui-text="Options :">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
            </param>
		<param name="grouppick" type="bool" gui-text="selection pick ..." gui-description="This is gui-description">false</param>
            <param name="pickmode" type="optiongroup" appearance="combo" gui-text="pick values group:">
                <option value="first">first</option>
                <option value="second">second</option>
            </param> 
	</page>
        <page name="Help" gui-text="Help for default extension example">
            <label xml:space="preserve">This is example of default extension example
	You can use this INX file and PY files type named 'default_extension_example'</label>
        </page>
    </param>
    <effect>
        <object-type>all</object-type>
        <effects-menu>
            <submenu name="catafest"/>
        </effects-menu>
    </effect>
    <script>
        <command location="inx" interpreter="python">default_extension_example.py</command>
    </script>
</inkscape-extension>
Bellow you can see some screenshots with these result

marți, 6 februarie 2024

News : Shader Editor source code.

If you follow my blogger, you've seen some shaders I made for my background phone.
These shaders are created with this Android app called Shader Editor.
You can find the source code of this application on this GitHub project.

sâmbătă, 3 iunie 2023

Blender 3D : the working environment of the Blender 3D team .

... the building of the developers of the open-source program Blender 3D.

marți, 21 mai 2019

Show SVG with the anime javascript library.

First of all the anime javascript library can be found at the official webpage.
Start with the empty project on codepen.io website.
You need to add the javascript library into the editor by using the wheel icon of JS area:
https://cdnjs.cloudflare.com/ajax/libs/animejs/2.2.0/anime.min.js
You can add the SVG source code with the path and then this will be parsed by javascript script.
The CSS code is used to stylize the output.
For example, the size of the path can be used like this:
.anim path {
  stroke-width: 3;
}
Then use the source code from my example.
See the result of this source code:

sâmbătă, 25 august 2018

Meshroom 3D Reconstruction Software

The development team come with this infos about Meshroom 3D Reconstruction Software:
Meshroom is a free, open-source 3D Reconstruction Software based on the AliceVision framework.
The official website can be found here.

You can see a tutorial with Blender 3D - open-source software created by CG Geek:

duminică, 4 februarie 2018

The TreeIt 3D software.

This 3D free software allow you to create and export tree.
You can select easy to use and this powerfull real time 3d tree generator.
You can use for the simple creation of your very own 3d tree models or just open default examples.
Features:
  • easy to create high quality 3D trees;
  • create any tree, not limited to just one tree type;
  • edit joints as well as break joints;
  • render to image for leaf creation;
  • create adjustable LOD slider;
  • use exports to *.dbo *.fbx *.obj *.x ;

The program start with a default tree with trunk.
You need to select your settings fro the new tree.
The result can be fast and very good.
You can download it from here.

sâmbătă, 14 octombrie 2017

News: The new released Krita version 3.3.1 .

The Krita development team tell us:

Published    10/11/2017

Today we are releasing Krita 3.3.1, a bugfix release for Krita 3.3.0. This release fixes two important regressions:

Krita would crash if you would restart Krita after closing Krita with the reference images docker set to floating
Krita 3.3.0 could not read .kra backup files or .kra files that were unzipped, then zipped up manually.
Additionally, there are the following fixes and improvements:

Fix a crash when creating a swap file on OSX (Bernhard Liebl).
Merge down does not remove locked layers anymore (Nikita Smirnov)
Various performance improvements, especially for macOS (Bernhard Liebl)
Improve the look and feel of dragging and dropping layers (Bernhard Liebl)
Improve the tooltips in the brush preset selector (Bernhard Liebl)
Fix a memory leak in the color selectors (Boudewijn Rempt)
Fix rotation and tilt when using the Windows Ink api (Alvin Wong)
Don’t allow the fill tool to be used on group layers (Boudewijn Rempt)
Add brightness and contrast sliders for textured brushes (Rad)
Add paste-at-cursor (Dmitry Kazakov)
Improve performance of the cpu canvas (Alvin Wong)
Fix a crash on closing Krita when there is something on the clipboard (Dmitry Kazakov)
Add a button to open a file layer’s image in Krita (Wolthera van Hövell tot Westerflier)

You can read more about this new version of Krita software and download it from here.

miercuri, 4 octombrie 2017

Blender 3D - Open Shading Language tutorial - part 001 .

Using this tutorial about Open Shading Language, you can try a glass shader. The source code show a simple use for Fresnel equations. The backfacing() and raytype() are two functions that provide the shader some information about the state of the renderer and the scene at the time of evaluation. I used just backfacing(), because is a raw example of this Fresnel equations. As you can see the I, N, eta inputs from Fresnel_Dielectric() is used to get a result variable fr. The all result of this shader is bsdf like a equation. See the next code:
#define IOR_THRESHOLD 1.000000001

float Fresnel_Dielectric(vector i, normal n, float eta)
{
//see https://en.wikipedia.org/wiki/Fresnel_equations
    float c = fabs(dot(i, n));
    float g = eta * eta - 1 + c * c;
    float result = 1.0;
    
    if (g > 0) {
        g = sqrt(g);
        float a = (g - c) / (g + c);
        float b = (c * (g + c) - 1) / (c * (g + c) + 1);
        result = 0.5 * a * a * (1 + b * b);
    }
    
    return result;
}

shader glass(
    color diffuse_col = 1.8, 
    float ior = 1.45, 
    output closure color bsdf = 0)
{
    float real_ior = max(ior, IOR_THRESHOLD);
    float eta = backfacing()? 1.0 / real_ior : real_ior;
    float fr = Fresnel_Dielectric(I, N, eta);
    
    bsdf = diffuse_col * (fr * reflection(N) + (1.0 - fr) * refraction(N, eta));
}

duminică, 1 octombrie 2017

The Storyboarder free tool.

The development team tell us about this free tool named Storyboarder:
Storyboarder makes it easy to visualize a story as fast you can draw stick figures. Quickly draw to test if a story idea works. Create and show animatics to others. Express your story idea without making a movie.
...
Wonder Unit is a studio that makes movies. We spend a lot of time in creative development, building tools, and being smarter about creating the best stories.
This tool come with six simple drawing tools , boards (add a board, draw, duplicate, copy, paste) and metadata for a board (duration, dialogue, action and note).

How can be used this tool? 
You can start with your script or an empty board.
Then just draw each board and add all settings like: duration, dialogue, action and note.
You can export your work to Premiere, Final Cut, Avid, PDF, or Animated GIF.
You can edit your board with Photoshop.
You can improve this software with your source code using github.com - storyboarder.
You can download it from official website.

miercuri, 27 septembrie 2017

Blender 3D - Open Shading Language tutorial.

Today, I will show you how to use the Open Shading Language with Blender 3D version 2.79.
Use the Scripting area from Screen layout and Cycles for rendering.
Select from Render tab and check the option:Open Shading Language.
Add your object to test this tool.
For example you can use the default Cube.
Add a material to this object.
The Scripting area from Screen layout come with editor text.
Use Templates - > Open Shading Language -> Empty Shader and add this OSL script:
shader marble (color Col = .5, float freq = 1.0,  
           output color result = 0)  
{  
float sum = 0;  
float freq_value = freq;  

point pixel_shader = transform ("object", P);  
for (int i = 0; i < 6; i++)   
{  
    sum = sum + 1/freq_value * abs(.5 - noise( 4 * freq_value * pixel_shader)) ;  
    freq_value = 2 * freq_value;  
}  
result = Col * sum;  
}  
Save this script into your folder . Add a OSL script interface into Node Editor using : Add -> Script -> Script.
This will come with a open dialog icon to add your OSL script.
Link result to Color from your material Diffuse BSDF. All this steps I tell you is on the next image:

luni, 25 septembrie 2017

News: Blender 3D - version 2.79

The Blender 3D is an open source software with a great team.
They tell us about this new released version of Blender 3D:
These are the release notes for Blender 2.79, released September 12th, 2017.
  • Denoiser
  • PBR Shader
  • Shadow Catcher
  • Filmic Color Management
  • Faster AMD OpenCL
  • over 700 bugs fixed
  • so much more!
Some features can be found here.
You can also download this 3D software from here.

After you download it, you need to run the install executable for Windows.
If you use a Linux OS then you just run it with: ./blender.
You can the windows of this 3D software tool into the next image:
The next step is to set the Blender 3D from menu: File -> User Preferences ( or use keys Ctr - Alt - U ).
First step:
 - set your CPU or graphic card - GPU into System tab;
 - set your addons to see if works with this version;
 - test all this with a simple example but using all renders: ( Blender, Cycles and Blender Game); 

Some addons I used: ANT Landscape, animation-nodes, blam, blender-light-studio, mira-tools, uvsquares. 
You can find more about this addons blenderartists website.

miercuri, 30 august 2017

News: Blender 3D version 2.79 - the new Blender 2.8 Branch.

Today I tested the new Blender 2.8 Branch from version 2.79 of Blender 3D software and is working well.
The new branch come with the new render Eevee and many of old 2.79 features:
  • Cycles: Built-in Denoising, Shadow catcher, Principled shader, AMD OpenCL optimizations.
  • Grease Pencil: New frame interpolation tools, per-layer onion skinning.
  • Alembic: Improvements to compatibility, stability and support.
  • User Interface: Initial support for reusable custom configurations, automatic DPI scaling.
  • Twenty Three new and several updated add-ons.
  • And: 100s of bug fixes and other improvements!
Next is a screenshot of this release:

duminică, 6 august 2017

The great Rainmeter tool for Windows .

Developers tell us about this open source software:
Rainmeter displays customizable skins, like memory and battery power, RSS feeds and weather forecasts, right on your desktop. Many skins are even functional: they can record your notes and to-do lists, launch your favorite applications, and control your media player - all in a clean, unobtrusive interface that you can rearrange and customize to your liking. Rainmeter is at once an application and a toolkit. You are only limited by your imagination and creativity. 
The last revision was on July 28, 2017.
This software can be found on the official website.
Here's a good example of a 99villages user on his deviantart web page:

vineri, 28 iulie 2017

News: 0 A.D. Alpha 22 Venustas.

The game named 0 A.D. is free for Windows, Linux and Mac OS X.
If you area a developer then you can redistribute the game and modify it freely as long as you abide by the GPL or you can even use parts of the art and sound for your own projects as long as you abide by CC BY-SA.

 The new features from development team :
  • Remake of many models, animations and textures, two new music tracks 
  • Configuration-free Multiplayer Hosting 
  • Capture the Relic Gamemode 
  • Aura and Heal Range Visualization 
  • Twelve new maps, including scripted enemies, rising water and a tutorial 
  • Espionage Technology, Team Bonuses and Hero Auras 
  • Petra AI Diplomacy and Attack Strategies 
  • Summary Screen Graphs 
  • Cinema Path Editing 
  • Buddy System