This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import the required modules | |
const fs = require('fs'); | |
const path = require('path'); | |
const handlebars = require('handlebars'); | |
// Get the template and data file names from the command line arguments | |
const templateFile = process.argv[2]; | |
const dataFile = process.argv[3]; | |
// Check if the files exist and are valid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$help = $false | |
if ($args -contains "-h" -or $args -contains "--help") { | |
$help = $true | |
} | |
if ($help) { | |
write-host "Usage" | |
write-host " zipnsync [options] <source> <target>" | |
write-host "" | |
write-host "Arguments" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashMap; | |
use regex::Regex; | |
// Define a function that returns a tuple of a hashmap of flags and values and an array of non-flag arguments | |
fn parse_args() -> (HashMap<String, String>, Vec<String>) { | |
// Create a hashmap to store the flags and values | |
let mut flags = HashMap::new(); | |
// Create an array to store the non-flag arguments | |
let mut args = Vec::new(); | |
// Create regular expressions to match different kinds of flags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import the file system module | |
const fs = require('fs'); | |
// Import the process module | |
const process = require('process'); | |
// Define a function to convert snake_case to camelCase | |
function snakeToCamel(str) { | |
// Split the string by underscore | |
let words = str.split('_'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal | |
set wasi_bin_path=%WASI_SDK_PATH%\bin | |
set wasi_self=%~n0 | |
set wasi_cmd=%1 | |
if "%wasi_cmd%" == "" ( | |
echo Usage: %wasi_self% executable [arguments] | |
exit /b 1 | |
) | |
if not exist "%wasi_bin_path%\%wasi_cmd%.exe" ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs").promises; | |
const path = require("path"); | |
// A class to remove all comments from a js file | |
class CommentRemover { | |
// A constructor that takes a file name as an argument | |
constructor(filePath) { | |
// A property to store the file name | |
this.filePath = filePath; | |
// A property to store the file content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
@title Sample minimal static server | |
@file static-server.js | |
@setup npm install connect serve-static | |
@usage node static-server.js | |
*/ | |
const os = require('os'); | |
const path = require('path'); | |
const connect = require('connect'); | |
const serveStatic = require('serve-static'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertArrayToCSV(arr) { | |
const arrayCopy = [...arr]; | |
const header = arrayCopy.shift(); | |
const csv = [ | |
header.join(','), | |
...arrayCopy.map((row) => row.join(',')), | |
].join('\n'); | |
return csv; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertArrayOfObjectsToCSV(data) { | |
const arrayCopy = [...data]; | |
const header = Object.keys(arrayCopy[0]); | |
const csv = [ | |
header.join(','), | |
...arrayCopy.map((row) => { | |
return header.map((fieldName) => { | |
let cellValue = row[fieldName] !== undefined ? row[fieldName] : ''; | |
if (typeof cellValue === 'string') { | |
cellValue = cellValue.replace(/"/g, '""'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const APP_NAME = 'CliApp'; | |
const APP_VER = '1.0.0'; | |
class CliArgParser { | |
constructor() { | |
this.argv = process.argv.slice(2); | |
this.args = this.map(); | |
} |