Skip to content

Instantly share code, notes, and snippets.

View joao-pedrozo's full-sized avatar

João Pedro joao-pedrozo

View GitHub Profile
@joao-pedrozo
joao-pedrozo / gist:b0baf28aba5bba802bf54862e2bc8984
Created December 21, 2023 20:30
make all github repositories private using with powershell
# Set your GitHub username and access token
$githubUsername = "abc"
$githubToken = "YOUR_TOKEN"
# Get repositories
$repos = Invoke-RestMethod -Uri "https://api.github.com/users/$githubUsername/repos" -Method Get
# Loop through each repository and update it
foreach ($repo in $repos) {
$repoName = $repo.name
@joao-pedrozo
joao-pedrozo / format.json
Created December 8, 2022 21:38
format 2
{
"orders": [
{
"store_name": "Loja 4",
"store_directory_name": "loja-4",
"store_logo": "http://loja.dev.local:3002/store/logos/4_aaa229139880f95b20e60452929230606163d178.png?1666966575",
"store_informations": [],
"store_address": "Italino Peruffo, 81650-330 - Boqueirão - Curitiba/PR",
"state": "complete",
"payment_state": "paid",
{
"orders": [
{
"store_name": "Loja 2",
"store_directory_name": "loja-2",
"store_logo": "http://loja.dev.local:3002/store/logos/2_8503ab1cf9ac0e20367cc664f94028c0ecd746ea.png?1666966575",
"store_informations": [],
"store_address": "Italino Peruffo, 81650-330 - Boqueirão - Curitiba/PR",
"state": "complete",
"payment_state": "balance_due",
@joao-pedrozo
joao-pedrozo / upload.js
Created June 27, 2022 14:01
Upload image to strapi
try {
const formData = new FormData();
const { data: stream } = await axios.get(
"https://images.unsplash.com/photo-1611095785020-1ba3dd228ea7?ixid=MXwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=900&q=60",
{ responseType: "stream" }
);
formData.append("files", stream);
formData.append("ref", "api::article.article"); // Collection name
@joao-pedrozo
joao-pedrozo / promises.js
Last active June 22, 2022 13:59
Test promises
await Promise.all([
new Promise((resolve) => setTimeout(() => {resolve('A (slow)'); console.log('A (slow)')}, 1000)),
new Promise((resolve) => setTimeout(() => {resolve('B (slower)'); console.log('B (slower)')}, 2000)),
new Promise((resolve) => setTimeout(() => {resolve('C (fast)'); console.log('C (fast)')}, 10))
])
const promises = Array.from({ length: 1000 }, (_, i) => i).map(item => new Promise((resolve) => setTimeout(() => {
resolve('A');
console.log('resolved')
}, 3000)))
@joao-pedrozo
joao-pedrozo / Component.jsx
Created March 23, 2021 22:02
Draft.js with toolbar and ERROR when toolbar's button
import React, { useEffect } from 'react';
import { Editor, EditorState } from 'draft-js';
import { useState } from 'react';
import 'draft-js/dist/Draft.css';
import createToolbarPlugin from '@draft-js-plugins/static-toolbar';
const staticToolbarPlugin = createToolbarPlugin();
const { Toolbar } = staticToolbarPlugin;
@joao-pedrozo
joao-pedrozo / .js
Created January 26, 2021 19:08
Testes
import LeafletSearch from './leaflet-search';
const { $ } = window;
window.requestAnimationFrame.mockRestore();
const waitRAF = () => new Promise((resolve) => requestAnimationFrame(resolve));
const simulateKeyboardInput = async (text, inputElement) => {
/*
import Base from '@/components/base';
const { $ } = window;
export default class extends Base {
constructor($element) {
super($element);
this.content = document.querySelectorAll('.leaflet-content__text');
this.$nextBtn = $("button[data-search='next']");