Skip to content

Instantly share code, notes, and snippets.

View RenanGreca's full-sized avatar

Renan Greca RenanGreca

View GitHub Profile
@RenanGreca
RenanGreca / charm-dev.sh
Last active November 21, 2025 15:22
Multipass scripts for charm-dev
#!/bin/bash
multipass launch \
--cpus 8 \
--disk 50G \
--memory 16G \
--name charm-dev \
--mount ~/multipass-scripts \
--mount ~/repos \
24.04
@RenanGreca
RenanGreca / download.swift
Created February 25, 2024 20:05
Swift script for downloading separate audio/video files and combining them with ffmpeg
import Foundation
let args = CommandLine.arguments
print(args.joined(separator: " "))
if (args.count != 4) {
print("Usage: download.swift <video-url> <audio-url> <file-name>")
exit(1)
}
let videoURL = args[1]
@RenanGreca
RenanGreca / 1.go
Created February 24, 2024 08:20
Advent of Code 2023-01
package main
import (
"fmt"
"log"
"os"
"strconv"
"strings"
"sync"
// "runtime"
@RenanGreca
RenanGreca / Bing Searches.scpt
Created November 20, 2023 15:41
Apple Script for opening Microsoft Edge tabs
repeat 10 times
tell application "Microsoft Edge"
activate
set query to (random number from 1 to 9999) as text
set link to "https://www.bing.com/search?pglt=41&q=" & query & .......
open location link
end tell
end repeat
@RenanGreca
RenanGreca / CustomExpect.ts
Created October 24, 2023 09:45
Custom assertion extension for Playwright expect
import { expect } from "@playwright/test"
module.exports = {
toBeContainedIn(got: any, expected: any[]) {
const assertionName = 'toBeContainedIn'
let pass: boolean
let matcherResult: any
// We use the default expect as basis for our assertion
try {
@RenanGreca
RenanGreca / StringToNumber.js
Last active October 24, 2023 09:47
JS string to number conversion
/**
*
* @param {string} value a string containing a number
* @returns {Number} the converted number
* @warning This function cannot parse an ambiguous string such as '150.000'
*/
export function convertToNumber(value, decimalPositions = 2) {
function englishFormat(value) {
// English format number e.g. 1,234.56
@RenanGreca
RenanGreca / ZipExtract.js
Created September 3, 2023 08:24
Extract CSV file from ZIP archive in JavaScript
import path from "path";
const unzip = require("extract-zip")
const zipPath = path.resolve('path', 'to', `archive.zip`)
const unzipPath = path.resolve('directory', `to`, `extract`)
/** Create a directory to be used as target for the unzip */
if (process.platform == 'win32') {
await execShellCommand(`if not exist ${unzipPath} mkdir ${unzipPath}`)
} else {
@RenanGreca
RenanGreca / SimpleListReporter.ts
Last active March 6, 2024 08:27
Custom reporter for simplified test reports in Playwright
import fs from 'fs';
import path from 'path';
import { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult, TestStep, TestStatus } from '@playwright/test/reporter';
import { execSync as exec } from 'child_process';
function ms(ms: number): string {
if (!isFinite(ms))
return '-';
if (ms === 0)