Skip to content

Instantly share code, notes, and snippets.

View brunomarks7's full-sized avatar
🏠
Working from home

Bruno Saraiva brunomarks7

🏠
Working from home
View GitHub Profile
@brunomarks7
brunomarks7 / gist:2d5b0366c75a3aef4fbc37a211e97c2b
Created September 25, 2022 21:21
Remove webp recursively
#!/bin/bash
CDIR=$(pwd)
for i in $(ls -R | grep :); do
DIR=${i%:}
cd $DIR
rm *.webp
cd $CDIR
done
@brunomarks7
brunomarks7 / delay.js
Created October 4, 2023 19:18
delayed function js
export function delay(min, max) {
const delayTime = Math.floor(Math.random() * (max - min + 1) + min) * 1000;
return new Promise((resolve) => {
setTimeout(resolve, delayTime);
});
}
@brunomarks7
brunomarks7 / app.js
Last active December 13, 2023 03:38
Newsletter - Unzip, optimize images, replace in files and upload to domain
const fs = require('fs');
const path = require('path');
const AdmZip = require('adm-zip');
const readline = require('readline');
const sharp = require('sharp');
const { exec } = require('child_process');
// Cria uma interface readline
const rl = readline.createInterface({
input: process.stdin,
@brunomarks7
brunomarks7 / select.sql
Last active August 7, 2024 01:20
Select customer emails from WooCommerce
SELECT DISTINCT pm.meta_value AS email
FROM wp_posts AS p
INNER JOIN wp_postmeta AS pm ON p.ID = pm.post_id
INNER JOIN wp_woocommerce_order_items AS oi ON p.ID = oi.order_id
INNER JOIN wp_woocommerce_order_itemmeta AS oim ON oi.order_item_id = oim.order_item_id
WHERE p.post_type = 'shop_order'
AND p.post_status IN ('wc-completed', 'wc-processing')
AND pm.meta_key = '_billing_email'
AND oim.meta_key = '_product_id'
AND p.post_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
@brunomarks7
brunomarks7 / clone-all.bash
Created January 30, 2025 23:36
Clone all repositories using gh-cli
gh repo list <org-name> | awk '{print $1}' > repository_urls.txt
while IFS= read -r url; do
repo_name=$(basename "$url" .git)
gh repo clone "$url" "$repo_name"
done < repository_urls.txt
@brunomarks7
brunomarks7 / gist:97d613feb4d04fd69abf19bc9f22f485
Created February 13, 2025 19:52
Create file with repository list by org, using gh-cli
gh repo list [org-name] | awk '{print $1}' > repositories.txt