Skip to content

Instantly share code, notes, and snippets.

View mark05e's full-sized avatar

mark05E mark05e

View GitHub Profile
@mark05e
mark05e / ConvertTextFilesToCSV.ps1
Created September 23, 2023 22:09
Scans text files in a directory, creates a CSV file with customizable file extensions, and formats the contents in <filename>.<extension>,"<content>" format.
View ConvertTextFilesToCSV.ps1
function ConvertTextFilesToCSV {
param (
[string]$outputDirectory = ".",
[string]$customFileExtension = ".wav"
)
# Get the current directory name
$currentDirectory = (Get-Item -Path $outputDirectory).Name
# Define the CSV file name
View FL2000_Updates.txt
;aiu;
[FL2000-2.1.34054.0]
Name = Fresco Logic USB Display Driver 2.1.34054.0
ProductVersion = 2.1.34054.0
URL = http://updates.frescologic.com/FL2000/FL2000-2.1.34054.0.exe
Size = 8058744
ReleaseDate = 23/11/2017
MD5 = 18b0139ca76e7447bc64f9a812f4a9f2
CommandLine = /qn
View urlExtractPathAndQuery.js
function urlExtractPathAndQuery(urlObject) {
try {
// Process the path
let pathString = '';
if (urlObject.path && urlObject.path.length > 0) {
// Use JSON.parse and JSON.stringify to ensure proper stringification
const parsedPath = JSON.parse(JSON.stringify(urlObject.path));
pathString = '/' + parsedPath.join('/');
}
@mark05e
mark05e / extract-json-from-html-sample.js
Created July 13, 2023 13:38
The goal is to extract the header text, item text, item color, and header icon name from the given HTML structure and organize them into a JSON object
View extract-json-from-html-sample.js
const html = `
<div class="ui floating dropdown labeled icon button">
<i class="cloud upload icon"></i>
<span class="text">API Action</span>
<div class="menu">
<div class="ui icon search input">
<i class="search icon"></i>
<input type="text" placeholder="Search menu...">
</div>
<div class="scrolling menu">
@mark05e
mark05e / appscript-page.html
Created June 16, 2023 02:41
Example to show local and appscript file references
View appscript-page.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style><?!= HtmlService.createHtmlOutputFromFile('styles').getContent(); ?></style>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Welcome to the Sidebar</h1>
<p>This is some content inside the sidebar.</p>
@mark05e
mark05e / build.ps1
Created June 10, 2023 19:23
Powershell script to insert js and css contents into an html
View build.ps1
# Define the HTML file path
$htmlFilePath = "main-template.html"
# Define the CSS file path
$cssFilePath = "style.css"
# Define the JS file path
$jsFilePath = "functions.js"
# Define the output file path
View python-docopts-install-error.md

Situation

While installing docopts on embedded python 3.10.x, I get the error below.

C:\python-test>python -m pip install docopt
Collecting docopt
  Using cached docopt-0.6.2.tar.gz (25 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
View writeToFile.js
/**
* Writes fileContents to a file with the given fileName in the specified folder. If a file with the
* same name already exists, it will either overwrite it or append to it, based on the value of the append parameter.
*
* @param {string} fileName - The name of the file to write to.
* @param {string} fileContents - The contents to write to the file.
* @param {string} folderIdOrUrl - The ID or URL of the folder to write the file to.
* @param {boolean} [append=false] - Whether to append the fileContents to an existing file with the same name.
* @returns {string} The ID of the created or modified file.
*/
View getFilenamesAndIds.js
/**
* Retrieves the filenames and corresponding file IDs of all files within a given Google Drive folder.
*
* @param {string} folderId - The ID of the folder.
* @returns {Object[]} - An array of objects containing the file ID and name.
*/
function getFilenamesAndIds(folderId) {
// Get the folder using the provided folderId
let folder = DriveApp.getFolderById(folderId);
View logToSpreadsheet.js
/**
* Logs information to a Google Spreadsheet for tracking and debugging purposes.
*
* @param {string} functionName - The name of the function being logged.
* @param {string} functionState - The state or status of the function being logged.
* @param {string|object} message - The log message to be recorded, which can be a string or an object.
* @param {string} spreadsheetUrl - The URL of the logging spreadsheet.
*/
function logToSpreadsheet(functionName, functionState, message, spreadsheetUrl) {
// Get the active sheet of the Google Spreadsheet